Changeset 165:af59540d48a9
Legend:
- Unmodified
- Added
- Removed
-
engine.py
r164 r165 ˆà 201 201 else:ˆà 202 202 old_snake.cells = cellsˆà 203 ˆà self.psnakes = self.snakes[:]ˆà204 203 return self.snakes[snake_number]ˆà 205 204 ˆà -
main.py
r164 r165 ˆà 25 25 self.canvas.pack(side ="top", fill="both", expand="yes")ˆà 26 26 self.buttons_pack(self.root).pack(side ="bottom", fill="both", expand="no")ˆà 27 ˆà self.step_id = 666ˆàˆà 27 self.step_id = 0ˆà 28 28 self.engine = engine.Engine(self.canvas)ˆà 29 29 self.after_id = Noneˆà òÀæ òÀæ ˆà 39 39 load_2 = tk.Button(buttons, text="Load 2", command=lambda: self.load(1))ˆà 40 40 load_2.grid(row=2, column=3, stick="news")ˆà 41 ˆà run_b = tk.Button(buttons, text="Run", command=lambda: self. run())ˆàˆà 41 run_b = tk.Button(buttons, text="Run", command=lambda: self.start())ˆà 42 42 run_b.grid(row=2, column=2, stick="news")ˆà 43 43 restart_b = tk.Button(buttons, text="Restart", command=lambda: self.restart())ˆà òÀæ òÀæ ˆà 74 74 returnˆà 75 75 ˆà 76 ˆà def run (self):ˆà 77 ˆà """Run the game with 'step_length' ms stepˆà 78 ˆà After the end of the game - restarts it with snakes survived inˆà 79 ˆà previous game"""ˆà 80 ˆà self.engine.psnakes = self.engine.snakes[:]ˆà ˆà 76 def start (self):ˆà ˆà 77 """Init running of the game."""ˆà 81 78 if self.step_id == 666:ˆà 82 ˆà self. restart()ˆàˆà 79 self.next_round()ˆà 83 80 if self.dead_snake_check() == False:ˆà 84 81 returnˆà òÀæ òÀæ ˆà 86 83 self.end()ˆà 87 84 returnˆà ˆà 85 self.engine.psnakes = self.engine.snakes[:]ˆà ˆà 86 self.run()ˆà ˆà 87 ˆà ˆà 88 def run (self):ˆà ˆà 89 """Run the game with 'step_length' ms stepˆà ˆà 90 After the end of the game - restarts it with snakes survived inˆà ˆà 91 previous game"""ˆà 88 92 self.step_id = self.step_id+1ˆà 89 93 self.engine.step()ˆà òÀæ òÀæ ˆà 129 133 self.engine.redraw()ˆà 130 134 ˆà ˆà 135 def next_round(self):ˆà ˆà 136 passˆà ˆà 137 ˆà 131 138 def end (self):ˆà 132 139 """End the game and raise the window that tels about it."""ˆà
Note: See TracChangeset
for help on using the changeset viewer.