Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kitson <msk5293@rit.edu>2010-11-11 21:34:30 (GMT)
committer Michael Kitson <msk5293@rit.edu>2010-11-11 21:34:30 (GMT)
commit31386d9f76eb28441abf64d646d6808f13a24f2d (patch)
tree6c11bde980dc0764cec6aeb322fbbcfe81ca5bd5
parent73c4c041fdf562378b7e2265c13e0d90312c647f (diff)
Score no longer hurt from wrong answer, only lives. Level display now works and lives display will change to a number when there is no more room for pacman images
-rw-r--r--dev/pacmath.activity/gameMain.py14
-rw-r--r--dev/pacmath.activity/question.py28
2 files changed, 26 insertions, 16 deletions
diff --git a/dev/pacmath.activity/gameMain.py b/dev/pacmath.activity/gameMain.py
index c1b3db2..d1b034f 100644
--- a/dev/pacmath.activity/gameMain.py
+++ b/dev/pacmath.activity/gameMain.py
@@ -38,7 +38,7 @@ class gameMain:
self.screen.fill((0,0,0))
self.operation = random.sample('x+-/', 1)
self.questGen = questionGenerator( self.operation, 2, 12 )
- self.lives = BASE_LIVES
+ self.lives = BASE_LIVES
self.score = 0
self.level = 1
@@ -55,18 +55,20 @@ class gameMain:
self.ghosts = [ self.ghost1, self.ghost2, self.ghost3, self.ghost4 ]
self.nextQuestion()
-
+
def nextQuestion(self):
if self.QandA.nextQuestion():
self.wrongGhosts = pygame.sprite.Group()
self.correctGhosts = pygame.sprite.Group()
+
for i in range(len(self.ghosts)):
if not (i == self.QandA.getAnswerIndex() ):
self.wrongGhosts.add( self.ghosts[i] )
else:
self.correctGhosts.add( self.ghosts[i] )
else:
+ self.level += 1
self.resetQuestion()
def update(self, event):
@@ -104,15 +106,12 @@ class gameMain:
def checkCollisions(self):
for ghost in pygame.sprite.spritecollide(self.pacman, self.correctGhosts,False):
- if self.nextQuestion() == False:
- self.resetQuestion()
- self.level +=1
- self.QandA.updateLevel(level)
+ self.nextQuestion()
+ self.QandA.updateLevel(self.screen, self.level)
ghost.eaten()
return True
for ghost in pygame.sprite.spritecollide(self.pacman, self.wrongGhosts, False):
- self.score -= 50
self.lives -= 1
if self.lives < 0:
print "GAME OVER"
@@ -139,6 +138,7 @@ class gameMain:
self.resetQuestion()
self.QandA.updateScore(self.screen, self.score)
self.QandA.updateLives(self.screen, self.lives)
+ self.QandA.updateLevel(self.screen, self.level)
while done == False:
for event in pygame.event.get():
diff --git a/dev/pacmath.activity/question.py b/dev/pacmath.activity/question.py
index c492541..5dd01c9 100644
--- a/dev/pacmath.activity/question.py
+++ b/dev/pacmath.activity/question.py
@@ -45,6 +45,7 @@ class question:
self.drawQuestion(screen)
self.pacman = pygame.image.load("./images/pacmanr.png").convert_alpha()
self.screen = screen
+
def nextQuestion(self):
if(len(self.answered) > 3):
return False
@@ -177,11 +178,20 @@ class question:
@param count: the number of lives we have
"""
self.clearLives(screen)
- offset = 0
- for i in range(count):
- offset += 30
+ if count < 10:
+ offset = 0
+ for i in range(count):
+ offset += 30
+ screen.blit(self.pacman, (900-offset, 640))
+ pygame.display.update(pygame.Rect(900-offset, 640, offset, 30))
+ else:
+ offset = 30
screen.blit(self.pacman, (900-offset, 640))
- pygame.display.update(pygame.Rect(900-offset, 640, offset, 30))
+ offset += 5
+ text = pygame.font.Font(None, 36).render( str(count), 1, self.QUESTION_COLOR )
+ screen.blit( text, (900 - text.get_width() - offset, 640))
+ offset += text.get_width()
+ pygame.display.update(pygame.Rect(900-offset, 640, offset, 30))
def clearLives(self, screen):
"""
@@ -224,16 +234,16 @@ class question:
self.clearLevel(screen)
text = pygame.font.Font(None, 36).render( 'Level: ' + str(level), 1, self.QUESTION_COLOR )
- screen.blit(text, (900-text.get_width(), 625))
- pygame.display.update(pygame.Rect(900-text.get_width(), 625, text.get_width(), 30))
+ screen.blit(text, (900-text.get_width(), 605))
+ pygame.display.update(pygame.Rect(900-text.get_width(), 605, text.get_width(), 30))
def clearLevel(self, screen):
"""
Draws a black box over the score display so that we may redraw it
@param screen: the screen on which to draw
"""
- blackBox = pygame.Surface((300,30))
+ blackBox = pygame.Surface((275,30))
blackBox.fill((0,0,0))
- screen.blit(blackBox, (600,635))
- pygame.display.update(pygame.Rect(600, 670, 300, 30))
+ screen.blit(blackBox, (625,605))
+ pygame.display.update(pygame.Rect(625, 605, 275, 30))