diff options
Diffstat (limited to 'dev/pacmath.activity/question.py')
-rw-r--r-- | dev/pacmath.activity/question.py | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/dev/pacmath.activity/question.py b/dev/pacmath.activity/question.py index 5dd01c9..68c90df 100644 --- a/dev/pacmath.activity/question.py +++ b/dev/pacmath.activity/question.py @@ -8,18 +8,18 @@ import random class question: """ - @var A: Properties of answer box [color, (left, top), center, ghost location] - @var B: Properties of answer box [color, (left, top), center, ghost location] - @var C: Properties of answer box [color, (left, top), center, ghost location] - @var D: Properties of answer box [color, (left, top), center, ghost location] - @var SIZE: Size of answer box - @var QUESTION_COLOR: the rgb color in which question text is written + @cvar A: Properties of answer box [color, (left, top), center, ghost location] + @cvar B: Properties of answer box [color, (left, top), center, ghost location] + @cvar C: Properties of answer box [color, (left, top), center, ghost location] + @cvar D: Properties of answer box [color, (left, top), center, ghost location] + @cvar SIZE: Size of answer box + @cvar QUESTION_COLOR: the rgb color in which question text is written """ # Properties of rectangles: [color, (left, top), center, ghost location] - A = [(0, 180, 255), (625, 0), (735, 15), "./images/ghost.png"] - B = [(253, 0, 1), (625, 79), (735, 94), "./images/ghost2.png"] - C = [(255, 124, 0), (625, 158), (735, 173), "./images/ghost3.png"] - D = [(255, 0, 192), (625, 237), (735, 250), "./images/ghost4.png"] + A = [( 0, 180, 255), (625, 0), (735, 15), "./images/ghost.png"] + B = [(253, 0, 1), (625, 79), (735, 94), "./images/ghost2.png"] + C = [(255, 124, 0), (625, 158), (735, 173), "./images/ghost3.png"] + D = [(255, 0, 192), (625, 237), (735, 250), "./images/ghost4.png"] # Size of rectangles @@ -31,8 +31,9 @@ class question: def __init__ (self, screen, quests): """ Randomly selects which questions are going to be used and draws the answer + @type screen: pygame.display @param screen: the screen in which we will draw - @param quests: array a questions with answers + @param quests: list of questions with answers """ # Draw the answers and questions self.questions = quests @@ -47,6 +48,11 @@ class question: self.screen = screen def nextQuestion(self): + """ + Moves on to a new question to answer from this question set. If the set has been exhausted, false is returned + @rtype: boolean + @return: True if the question set had enough questions, false if a new one needs to be generated + """ if(len(self.answered) > 3): return False else: @@ -60,6 +66,7 @@ class question: def drawAnswers(self, screen): """ Draws all answers in their color coded boxes + @type screen: pygame.display @param screen: The screen on which to draw """ for i in range(4): @@ -69,7 +76,9 @@ class question: def drawAnswer(self, screen, answer, choice): """ Draws answers in a color coded box + @type screen: pygame.display @param screen: the screen in which we will draw + @type answer: string @param answer: answer to be drawn @param choice: which choice from 1-4 """ @@ -110,10 +119,21 @@ class question: pygame.display.update(total) def clearAnswers(self, screen): + """ + Clears the answers off the screen + @type screen: pygame.display + @param screen: the screen in which we will draw + """ for i in range(3): self.clearAnswer( screen, i ) def clearAnswer(self, screen, number): + """ + Clears a specified answer off the screen + @type screen: pygame.display + @param screen: the screen in which we will draw + @param number: which answer to clear + """ pos = (625, number*B[1][1]) dim = SIZE rect = pygame.rect.Rect(pos, dim) @@ -124,6 +144,7 @@ class question: def drawQuestion(self, screen): """ Draws the question to the screen + @type screen: pygame.display @param screen: the screen in which we will draw """ # Font used @@ -141,6 +162,7 @@ class question: def drawPaused(self, screen): """ Writes 'Paused' over where the question is usually printed + @type screen: pygame.display @param screen: the screen on which we will draw """ # Font used @@ -157,6 +179,7 @@ class question: def clearBottom(self, screen): """ Draws a black box over the question-holding part of the screen + @type screen: pygame.display """ blackBox = pygame.Surface((600,60)) blackBox.fill((0,0,0)) @@ -166,7 +189,8 @@ class question: def getAnswerIndex(self): """ Returns the integer index of the correct answer - @return the index + @rtype: number + @return: the index """ return self.answerIndex @@ -174,7 +198,9 @@ class question: def updateLives(self, screen, count): """ Redraws the lives display onto the screen + @type screen: pygame.display @param screen: the screen on which to draw + @type count: number @param count: the number of lives we have """ self.clearLives(screen) @@ -196,6 +222,7 @@ class question: def clearLives(self, screen): """ Draws a black box over the lives display so we may redraw them + @type screen: pygame.display @param screen: the screen on which to draw """ blackBox = pygame.Surface((300,30)) @@ -206,6 +233,7 @@ class question: def updateScore(self, screen, score): """ Redraws the score onto the screen + @type screen: pygame.display @param screen: the screen on which we will draw @param score: the score to be drawn """ @@ -218,6 +246,7 @@ class question: def clearScore(self, screen): """ Draws a black box over the score display so that we may redraw it + @type screen: pygame.display @param screen: the screen on which to draw """ blackBox = pygame.Surface((300,30)) @@ -228,8 +257,10 @@ class question: def updateLevel(self, screen, level): """ Redraws the score onto the screen + @type screen: pygame.display @param screen: the screen on which we will draw - @param score: the score to be drawn + @type level: number + @param level: the level to be drawn """ self.clearLevel(screen) @@ -240,6 +271,7 @@ class question: def clearLevel(self, screen): """ Draws a black box over the score display so that we may redraw it + @type screen: pygame.display @param screen: the screen on which to draw """ blackBox = pygame.Surface((275,30)) |