Changeset 28:06f6a43de54a
Legend:
- Unmodified
- Added
- Removed
-
engine.py
r17 r28 ˆà 11 11 self.canvas = canvasˆà 12 12 self.snake = Noneˆà 13 ˆà self.type = emptyˆàˆà 13 self.type = 'empty'ˆà 14 14 returnˆà 15 15 def redraw(self):ˆà òÀæ òÀæ ˆà 47 47 def __init__(self, canvas):ˆà 48 48 self.canvas = canvasˆà 49 ˆà self.w = min(canvas.height, canvas.width)ˆà50 ˆà self.h = min(canvas.height, canvas.width)ˆàˆà 49 #self.w = min(canvas.height, canvas.width)ˆà ˆà 50 #self.h = min(canvas.height, canvas.width)ˆà 51 51 self.snakes = [None, None, None, None]ˆà 52 52 self.init_field()ˆà -
main.py
r27 r28 ˆà 14 14 buttons.pack(side ="bottom", fill="both", expand="yes")ˆà 15 15 self.buttons_pack(buttons)ˆà 16 ˆà self. id = 0ˆàˆà 16 self.step_id = 0ˆà 17 17 self.engine = engine.Engine(self.canvas)ˆà 18 18 returnˆà 19 19 def buttons_pack(self, frame):ˆà 20 ˆà load_1 = tk.Button(frame, text="Load", command= self.load(1))ˆàˆà 20 load_1 = tk.Button(frame, text="Load", command=lambda: self.load(1))ˆà 21 21 load_1.pack(side="top", fill="both", expand = "yes")ˆà 22 ˆà load_2 = tk.Button(frame, text="Load", command= self.load(2))ˆàˆà 22 load_2 = tk.Button(frame, text="Load", command=lambda: self.load(2))ˆà 23 23 load_2.pack(side="top", fill="both", expand = "yes")ˆà 24 ˆà run_b = tk.Button(frame, text="Run", command= self.run())ˆàˆà 24 run_b = tk.Button(frame, text="Run", command=lambda: self.run())ˆà 25 25 run_b.pack(side="top", fill="both", expand = "yes")ˆà 26 ˆà load_3 = tk.Button(frame, text="Load", command= self.load(3))ˆàˆà 26 load_3 = tk.Button(frame, text="Load", command=lambda: self.load(3))ˆà 27 27 load_3.pack(side="bottom", fill="both", expand = "yes")ˆà 28 ˆà load_4 = tk.Button(frame, text="Load", command= self.load(4))ˆàˆà 28 load_4 = tk.Button(frame, text="Load", command=lambda: self.load(4))ˆà 29 29 load_4.pack(side="bottom", fill="both", expand = "yes")ˆà 30 ˆà step_b = tk.Button(frame, text="Step", command= self.step())ˆàˆà 30 step_b = tk.Button(frame, text="Step", command=lambda: self.step())ˆà 31 31 step_b.pack(side="bottom", fill="both", expand = "yes")ˆà 32 32 returnˆà òÀæ òÀæ ˆà 38 38 ˆà 39 39 def run (self):ˆà ˆà 40 self.step_id = self.id+1ˆà ˆà 41 self.engine.step()ˆà ˆà 42 self.after_id = self.canvas.after(300, self.run())ˆà ˆà 43 if self.step_id == 200:ˆà ˆà 44 self.canvas.after_cancel(self.after_id)ˆà ˆà 45 self.end()ˆà ˆà 46 passˆà ˆà 47 returnˆà ˆà 48 def step (self):ˆà ˆà 49 self.canvas.after_cancel(self.after_id)ˆà ˆà 50 self.id = self.id+1ˆà ˆà 51 self.engine.step()ˆà ˆà 52 passˆà 40 53 ˆà 41 ˆà passˆà 42 ˆà def step (self):ˆà 43 ˆà ˆà ˆà 54 def end (self):ˆà 44 55 passˆà 45 56 ˆà
Note: See TracChangeset
for help on using the changeset viewer.