Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/dev/pacmath.activity/question.py
diff options
context:
space:
mode:
Diffstat (limited to 'dev/pacmath.activity/question.py')
-rw-r--r--dev/pacmath.activity/question.py42
1 files changed, 32 insertions, 10 deletions
diff --git a/dev/pacmath.activity/question.py b/dev/pacmath.activity/question.py
index 67eed88..caf20b9 100644
--- a/dev/pacmath.activity/question.py
+++ b/dev/pacmath.activity/question.py
@@ -21,6 +21,7 @@ class question:
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
SIZE = (275, 75)
@@ -47,10 +48,8 @@ class question:
Draws all answers in their color coded boxes
@param screen: The screen on which to draw
"""
- self.drawAnswer(screen, self.questions[0][1], 1)
- self.drawAnswer(screen, self.questions[1][1], 2)
- self.drawAnswer(screen, self.questions[2][1], 3)
- self.drawAnswer(screen, self.questions[3][1], 4)
+ for i in range(4):
+ self.drawAnswer(screen, self.questions[i][1], i+1)
# Draws the answer in a ghost colored rectangle
def drawAnswer(self, screen, answer, choice):
@@ -87,11 +86,25 @@ class question:
# Create and draw rectangle, answer and ghost right of maze
ans = font.render(answer, 1, color)
- rect = (pos, self.SIZE)
+ rect = pygame.rect.Rect(pos, self.SIZE)
+ total = rect
+ rect.inflate_ip(-3,-3)
pygame.draw.rect(screen, color, rect, 3)
g = pygame.image.load(ghost).convert_alpha()
screen.blit(ans, center)
- screen.blit(g, (pos[0] + 4, pos[1] + 4))
+ screen.blit(g, (pos[0] + 7, pos[1] + 7))
+ pygame.display.update(total)
+
+ def clearAnswers(self, screen):
+ for i in range(3):
+ self.clearAnswer( screen, i )
+
+ def clearAnswer(self, screen, number):
+ pos = (625, number*B[1][1])
+ dim = SIZE
+ rect = pygame.rect.Rect(pos, dim)
+ screen.fill((0,0,0), rect)
+ pygame.display.update(rect)
# Draws the question
def drawQuestion(self, screen):
@@ -105,8 +118,12 @@ class question:
# Draws the question under maze
q = font.render(self.question, 1, self.QUESTION_COLOR)
self.clearBottom(screen)
- screen.blit(q, (0, 640))
- pygame.display.flip()
+ pos = (0,640)
+ screen.blit(q, pos)
+ rect = q.get_rect()
+ rect.x = pos[0]
+ rect.y = pos[1]
+ pygame.display.update(rect)
def drawPaused(self, screen):
"""
Writes 'Paused' over where the question is usually printed
@@ -117,8 +134,12 @@ class question:
q = font.render("Paused", 1, self.QUESTION_COLOR)
self.clearBottom(screen)
- screen.blit(q, (0, 640))
- pygame.display.flip()
+ pos = (0,640)
+ screen.blit(q, pos)
+ rect = q.get_rect()
+ rect.x = pos[0]
+ rect.y = pos[1]
+ pygame.display.update(rect)
def clearBottom(self, screen):
"""
Draws a black box over the question-holding part of the screen
@@ -126,6 +147,7 @@ class question:
blackBox = pygame.Surface((600,60))
blackBox.fill((0,0,0))
screen.blit(blackBox, (0,640))
+ pygame.display.update(0,640, 600,60)
def getAnswerIndex(self):
"""