diff options
Diffstat (limited to 'dev/pacmath.activity/gameMain.py')
-rw-r--r-- | dev/pacmath.activity/gameMain.py | 14 |
1 files changed, 7 insertions, 7 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(): |