diff options
author | Mateu Batle <mateu.batle@collabora.co.uk> | 2010-11-15 03:31:27 (GMT) |
---|---|---|
committer | Mateu Batle <mateu.batle@collabora.co.uk> | 2010-11-15 03:31:27 (GMT) |
commit | 8f6895f91e54534b585edc4ad76fbd9c29d0688a (patch) | |
tree | f095684aabb85e070a5f6a13508c4657eaf1a59f /game2 | |
parent | 3396aade01aa9c9d22e923728f1341deb4fe7f3b (diff) |
fixed timelimit and score not reset on every new game
fixed crash in game 2
fixed strings for spanish as default
Diffstat (limited to 'game2')
-rwxr-xr-x | game2/game2.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/game2/game2.py b/game2/game2.py index dd0d6e1..18fbc6b 100755 --- a/game2/game2.py +++ b/game2/game2.py @@ -139,6 +139,11 @@ class Game2(usmpgames.ApplicationState): global GAMEMODE n = 0 GAMEMODE = self.game_mode + #Get initial time + global TIMESTART + TIMESTART= round(time.time(),0) + global score + score = 0 def exiting_state(self, fromStack): global score @@ -208,7 +213,7 @@ class Game2(usmpgames.ApplicationState): number2 = random.randint(max(n-15,0),n) z=min(number1,number2) number1=max(number1,number2) - number2=zImages() + number2=z result=number1-number2 result=number1-number2 elif(GAMEMODE==3): @@ -233,7 +238,7 @@ class Game2(usmpgames.ApplicationState): #print ('number1: '+str(number1)+' number2: '+str(number2)+' result: '+str(result)) - while True: # Score loop + while self.running(): # Score loop #score += 1 # increase score for event in pygame.event.get(): @@ -350,24 +355,24 @@ class Game2(usmpgames.ApplicationState): # Show score and maximum score global maxScore global score - drawText(_('SCORE: %s') % (score), font, surface, 700, 0, TEXTCOLOR) - drawText(_('MAX SCORE: %s') % (maxScore), font, surface, 700, 60, TEXTCOLOR) + drawText(_('PUNTAJE: %s') % (score), font, surface, 700, 0, TEXTCOLOR) + drawText(_('PUNTAJE MAX: %s') % (maxScore), font, surface, 700, 60, TEXTCOLOR) if(GAMEMODE==1): #This draw the operation - drawText(_('ADD: %d + %d') % (number1,number2), font, surface, 10, 0, TEXTCOLOR) + drawText(_('SUMAR: %d + %d') % (number1,number2), font, surface, 10, 0, TEXTCOLOR) elif(GAMEMODE==2): #This draw the operation - drawText(_('SUBSTRACT: %d - %d') % (number1,number2), font, surface, 10, 0, TEXTCOLOR) + drawText(_('RESTAR: %d - %d') % (number1,number2), font, surface, 10, 0, TEXTCOLOR) elif(GAMEMODE==3): #This draw the operation - drawText(_('MULTIPLY: %d * %d') % (number1,number2), font, surface, 10, 0, TEXTCOLOR) + drawText(_('MULTIPLICAR: %d x %d') % (number1,number2), font, surface, 10, 0, TEXTCOLOR) elif(GAMEMODE==4): #This draw the operation - drawText(_('COUNT: '), font, surface, 10, 0, TEXTCOLOR) + drawText(_('CONTAR '), font, surface, 10, 0, TEXTCOLOR) medC=0 i=0 while(i<number1): @@ -388,14 +393,14 @@ class Game2(usmpgames.ApplicationState): rectBunny.move_ip(-35, 0) #surface.blit(happy, rectBunny) surface.blit(happy, rectBunny) - drawText(_('CORRECT ANSWER!'), font, surface, (WINDOWWIDTH / 3.5), (WINDOWHEIGHT / 2.25), TEXTCOLOR) + drawText(_('RESPUESTA CORRECTA!'), font, surface, (WINDOWWIDTH / 3.5), (WINDOWHEIGHT / 2.25), TEXTCOLOR) if(GAMEMODE==3): n=n+1 else: n=n+5 #print ('n cambio a :'+str(n)) - drawText(_('PRESS ANY KEY'), font, surface, (WINDOWWIDTH / 3), (WINDOWHEIGHT / 2.25) + 50,TEXTCOLOR) + drawText(_('PULSA UNA TECLA'), font, surface, (WINDOWWIDTH / 3), (WINDOWHEIGHT / 2.25) + 50,TEXTCOLOR) musicSound.stop() correctAnswerSound.play() score=returnScore() @@ -406,10 +411,10 @@ class Game2(usmpgames.ApplicationState): surface.blit(sad, rectBunny) #surface.blit(sad, rectBunny) score=returnScore() - drawText(_('BAD ANSWER! '), font, surface, (WINDOWWIDTH / 2.85), (WINDOWHEIGHT / 2.25), TEXTCOLOR) - drawText(_('CORRECT ANSWER: '+str(result)), font, surface, (WINDOWWIDTH / 3.8), (WINDOWHEIGHT / 2.25)+50, TEXTCOLOR) + drawText(_('RESPUESTA INCORRECTA!'), font, surface, (WINDOWWIDTH / 2.85), (WINDOWHEIGHT / 2.25), TEXTCOLOR) + drawText(_('RESPUESTA CORRECTA: '+str(result)), font, surface, (WINDOWWIDTH / 3.8), (WINDOWHEIGHT / 2.25)+50, TEXTCOLOR) - drawText(_('PRESS ANY KEY'), font, surface, (WINDOWWIDTH / 3), (WINDOWHEIGHT / 2.25) + 100, TEXTCOLOR) + drawText(_('PULSA UNA TECLA'), font, surface, (WINDOWWIDTH / 3), (WINDOWHEIGHT / 2.25) + 100, TEXTCOLOR) musicSound.stop() gameOverSound.play() #print ('bunnyEatsCarrot(after): MaxScore'+str(maxScore)+' score: '+str(maxScore)) @@ -433,8 +438,6 @@ class Game2(usmpgames.ApplicationState): ######################################## methods -#Get initial time -TIMESTART= round(time.time(),0) #Time Limit TIMELIMIT=240.0 #print ('time: '+str(TIMESTART)) |