From f2e13f1df02ac66bd73163697d5e8cea9a2be5fa Mon Sep 17 00:00:00 2001 From: drako Date: Wed, 08 Sep 2010 20:42:51 +0000 Subject: a new class has been created name newhigscores and its implementation is in almost all the so i have to put it newhigscore uses things of pares impares etc so some things have been added --- diff --git a/highScores.py b/highScores.py index 97bfecc..09989a6 100755 --- a/highScores.py +++ b/highScores.py @@ -16,7 +16,6 @@ class HighScore(): temp = line.split('\t') items.append((int(temp[1].strip()), (temp[0]))) file.close() - return items def numeric_compare(self, x, y): diff --git a/impares.py b/impares.py index 6e65e63..f60ace4 100755 --- a/impares.py +++ b/impares.py @@ -12,7 +12,7 @@ from score import * from constants import * LOG_FILENAME='Esquiador.log' - +skier = None log = logging.getLogger( 'EsquiadorRun' ) #log.setLevel( logging.DEBUG ) @@ -26,6 +26,7 @@ def mainImpares(): if olpcgames.ACTIVITY: size = olpcgames.ACTIVITY.game_size screen = pygame.display.set_mode(size) + global skier skier = Skier('impares') track = Track() score = Score(skier) diff --git a/newhighscore.py b/newhighscore.py new file mode 100644 index 0000000..25eeeca --- /dev/null +++ b/newhighscore.py @@ -0,0 +1,36 @@ +import pygame, highScores,pares,impares,logging,os +from highScores import * +from pygame.locals import * +h = HighScore() + +class newhighscore(): + + + def __init__(self): + newScore = 0 + global item + item = h.loadscores() + global scorew + scorew = [] + i=0 + for i in range(len(item)): + scorew.append(item[i][0]) + print scorew + def main(self,newscore): + newenter = False + for score in scorew[:len(item)]: + if score < newscore : + newenter = True + if newenter == True: + item.append((newscore,os.getlogin())) + h.savescores(item) + else: + print "nooooo" + + LOG_FILENAME='Esquiador.log' + + log = logging.getLogger( 'EsquiadorRun' ) + #log.setLevel( logging.DEBUG ) + if __name__=="__main__": + logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) + main() diff --git a/pares.py b/pares.py index 58b9c2a..c4beb1d 100755 --- a/pares.py +++ b/pares.py @@ -12,7 +12,7 @@ from score import * from constants import * LOG_FILENAME='Esquiador.log' - +skier = None log = logging.getLogger( 'EsquiadorRun' ) #log.setLevel( logging.DEBUG ) @@ -26,6 +26,7 @@ def mainPares(): if olpcgames.ACTIVITY: size = olpcgames.ACTIVITY.game_size screen = pygame.display.set_mode(size) + global skier skier = Skier('pares') track = Track() score = Score(skier) diff --git a/runEsquiadorFunc.py b/runEsquiadorFunc.py index b40ec43..e89682b 100755 --- a/runEsquiadorFunc.py +++ b/runEsquiadorFunc.py @@ -1,74 +1,83 @@ -import pygame, jmenu, impares, pares, olpcgames, logging, finishGame, sys, about, help, highScores +import pygame, jmenu, impares, pares, olpcgames, logging, finishGame, sys, about, help, highScores, newhighscore from impares import * from pares import * from constants import * from finishGame import * from about import * from help import * +from newhighscore import * from highScores import * from constants import * highScore = HighScore() +nh = newhighscore() def estadoJugador(self, estado): self.jugador=estado +def main(): + LOG_FILENAME='Esquiador.log' + log = logging.getLogger( 'EsquiadorRun' ) + #log.setLevel( logging.DEBUG ) -LOG_FILENAME='Esquiador.log' -log = logging.getLogger( 'EsquiadorRun' ) -#log.setLevel( logging.DEBUG ) + screen = pygame.display.set_mode(screen_size) + bg = imagenFondo; -screen = pygame.display.set_mode(screen_size) -bg = imagenFondo; - -pygame.display.flip() -color = (0,0,0) -font = './fonts/ice_sticks.ttf' -just = True -pos = ('center','center') - -while pygame.event.poll().type != pygame.QUIT: - screen.blit(bg, (0,0) ) - selection = jmenu.run(['Numeros pares','Numeros impares','Puntajes mas altos' ,'Ayuda','Acerca de','Salir'],color,42,font=font,light=10,justify=just,pos=pos) - if selection == 'Numeros pares': - just = True - pos = ('center','center') + pygame.display.flip() color = (0,0,0) - font = font - try: - pares.mainPares() - except IndexError: - print 'Termino el juego de pares!!!' - finishGame.finishing() - elif selection == 'Numeros impares': + font = './fonts/ice_sticks.ttf' just = True pos = ('center','center') - color = (0,0,0) - font = font - try: - impares.mainImpares() - except IndexError: - print 'Termino el juego de impares!!!' - finishGame.finishing() - elif selection == 'Puntajes mas altos': - just = True - pos = ('center','center') - color = (0,0,0) - font = font - highScore.mainHighScores() - elif selection == 'Ayuda': - just = True - pos = ('center','center') - color = (0,0,0) - font = font - help.mainHelp() - elif selection == 'Acerca de': - just = True - pos = ('center','center') - color = (0,0,0) - font = font - about.mainAbout() - elif selection == 'Salir' : - sys.exit(0) - #break + + while pygame.event.poll().type != pygame.QUIT: + screen.blit(bg, (0,0) ) + selection = jmenu.run(['Numeros pares','Numeros impares','Puntajes mas altos' ,'Ayuda','Acerca de','Salir'],color,42,font=font,light=10,justify=just,pos=pos) + if selection == 'Numeros pares': + just = True + pos = ('center','center') + color = (0,0,0) + font = font + try: + pares.mainPares() + except IndexError: + print 'Termino el juego de pares!!!' + global skier + nh.main(pares.skier.score) + finishGame.finishing(pares.skier.score,"pares") + elif selection == 'Numeros impares': + just = True + pos = ('center','center') + color = (0,0,0) + font = font + try: + impares.mainImpares() + except IndexError: + print 'Termino el juego de impares!!!' + global skier + nh.main(impares.skier.score) + finishGame.finishing(impares.skier.score,"impares") + elif selection == 'Puntajes mas altos': + just = True + pos = ('center','center') + color = (0,0,0) + font = font + highScore.mainHighScores() + elif selection == 'Ayuda': + just = True + pos = ('center','center') + color = (0,0,0) + font = font + help.mainHelp() + elif selection == 'Acerca de': + just = True + pos = ('center','center') + color = (0,0,0) + font = font + about.mainAbout() + elif selection == 'Salir' : + sys.exit(0) + #break +if __name__=="__main__": + logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) + main() diff --git a/score.dat b/score.dat index c95de5c..9693c42 100755 --- a/score.dat +++ b/score.dat @@ -1,4 +1,5 @@ +drako 27955 +drako 26520 +drako 25919 EDUARDO 20000 MATEU 10000 -RICARDO 9000 -ALDO 3000 -- cgit v0.9.1