Changeset 167:36756bd7e7ed
Legend:
- Unmodified
- Added
- Removed
-
main.py
r166 r167 ˆà 43 43 run_b = tk.Button(buttons, text="Run", command=lambda: self.start())ˆà 44 44 run_b.grid(row=2, column=2, stick="news")ˆà 45 ˆà restart_b = tk.Button(buttons, text="Restart", command=lambda: self.restart( ))ˆàˆà 45 restart_b = tk.Button(buttons, text="Restart", command=lambda: self.restart(survived="no"))ˆà 46 46 restart_b.grid(row=1, column=5, stick="news")ˆà 47 47 load_3 = tk.Button(buttons, text="Load 3", command=lambda: self.load(2))ˆà òÀæ òÀæ ˆà 79 79 """Init running of the game."""ˆà 80 80 if self.step_id == self.game_length + 666:ˆà 81 ˆà self. next_round()ˆàˆà 81 self.restart(survived="yes")ˆà 82 82 if self.dead_snake_check() == False:ˆà 83 83 returnˆà òÀæ òÀæ ˆà 125 125 return Falseˆà 126 126 ˆà 127 ˆà def restart(self):ˆà 128 ˆà """"Restarts the game after the end of the game with snakes survived"""ˆà ˆà 127 def restart(self, survived):ˆà ˆà 128 """"Restarts snakes positions after the end of the gameˆà ˆà 129 ˆà ˆà 130 Options:ˆà ˆà 131 survived = "yes" - restarts next round only with snakes survived in previous roundˆà ˆà 132 survived = "no" - restart next roun with all snakes played in previous round"""ˆà ˆà 133 if survived == "yes":ˆà ˆà 134 snake_set = self.engine.snakesˆà ˆà 135 else:ˆà ˆà 136 snake_set = self.engine.psnakes ˆà 129 137 self.step_id = 0ˆà 130 ˆà for i, snake in enumerate(s elf.engine.psnakes):ˆà131 ˆà if s elf.engine.psnakes[i] != None:ˆàˆà 138 for i, snake in enumerate(snake_set):ˆà ˆà 139 if snake_set[i] != None:ˆà 132 140 self.engine.snakes[i] = snakeˆà 133 141 self.engine.create_snake(i, snake)ˆà 134 142 self.engine.refill()ˆà 135 143 self.engine.redraw()ˆà 136 ˆà ˆà137 ˆà def next_round(self):ˆà138 ˆà passˆà139 144 ˆà 140 145 def end (self):ˆà
Note: See TracChangeset
for help on using the changeset viewer.