def menu(self): self.purge() self.img.append(display.object(self.menu_back)) self.option.append(display.font_wid(['pySnake'],'self.pysnake()',['center'],off=(-200,0))) self.option.append(display.font_wid(['pySnake Retro'],'self.game_classic()',['center'],off=(-200,0))) self.option.append(display.font_wid(['Options'],'self.settings()',['center'],off=(-200,0))) self.option.append(display.font_wid(['Highscores'],'self.show_high()',['center'],off=(-200,0))) self.option.append(display.font_wid(['Exit'],'sys.exit()',['center'],off=(-200,0)))
def get_high(self): self.text.append( display.font_wid(['Your Score was: ' + str(self.snake.count - 1)], do=['centerh', 'centerv'], off=(0, -70))) self.option.append( display.font_wid( ['Please Enter your Name'], 'self.submit_high(self.get_str(),self.snake.count)', ['center'], )) self.option.append( display.font_wid(['Back to Menu'], 'self.menu()', ['center'])) self.loop()
def show_high(self): self.purge() self.img.append(display.object(self.menu_back)) self.option.append(display.font_wid(['Back'],'self.menu()',['center'],off=(0,300))) conn=sqlite3.connect('highdat') try: c=conn.cursor();c.execute('select * from stocks order by score DESC') for high in enumerate(c): text=str(high[0]+1)+'.'+str(high[1][0])+' '+str(high[1][1]) self.text.append(display.font_wid([text],do=['center'],off=(-50,0))) if high[0]>=15:break except: pass # no highdat file present... c.close() self.loop()
def settings(self): self.purge() self.img.append(display.object(self.menu_back)) self.option.append(display.font_wid(['Absolute Movement','Relative Movement'],'self.relcontrol=not self.relcontrol;self.option[self.sel].index=self.relcontrol',['center'],off=(-50,0))) if self.relcontrol==True:self.option[len(self.option)-1].cycle() self.text.append(display.font_wid(['Speed'],do=['center'],off=(-100,0))) self.text.append(display.font_wid(['Difficulty'],do=['center'],off=(-100,0))) self.text.append(display.font_wid(['FPS-Limit'],do=['center'],off=(-100,0))) self.option.append(display.font_wid(['Back'],'self.menu()',['center'],off=(-50,0))) self.option.insert(1,display.font_wid([str(self.fpslimit)],'self.fpslimit=self.setvar(3,self.fpslimit)',['alignv','centerh'],targetv=3,off=(0,0))) self.option.insert(1,display.font_wid([str(self.diff)],'self.diff=self.setvar(2,self.diff)',['alignv','centerh'],targetv=5,off=(0,0),stackv=True)) self.option.insert(1,display.font_wid([str(self.speed)],'self.speed=self.setvar(1,self.speed)',['alignv','centerh'],targetv=7,off=(0,0)))
def get_high(self): self.text.append(display.font_wid(['Your Score was: '+str(self.snake.count-1)],do=['centerh','centerv'],off=(0,-70))) self.option.append(display.font_wid(['Please Enter your Name'],'self.submit_high(self.get_str(),self.snake.count)',['center'],)) self.option.append(display.font_wid(['Back to Menu'],'self.menu()',['center'])) self.loop()