Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.su/trac/snake/changeset/28%3A06f6a43de54a
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Sun Apr 10 04:29:18 2016
Êîäèðîâêà: IBM-866
Changeset 28:06f6a43de54a òÀÓ Python Battle

Changeset 28:06f6a43de54a


Ignore:
Timestamp:
12/19/10 09:19:10 (5 years ago)
Author:
Alex Martynov <martiran@òÀæ>
Branch:
default
Message:

main.UI.run() main.UI.step() #engine.canvas.w #engine.canvas.h

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • engine.py

    r17 r28 ˆà
    1111        self.canvas = canvasˆà
    1212        self.snake = Noneˆà
    13ˆà        self.type = emptyˆà
    ˆà13        self.type = 'empty'ˆà
    1414        returnˆà
    1515    def redraw(self):ˆà
    òÀæ òÀæ ˆà
    4747    def __init__(self, canvas):ˆà
    4848        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)ˆà
    5151        self.snakes = [None, None, None, None]ˆà
    5252        self.init_field()ˆà
  • main.py

    r27 r28 ˆà
    1414        buttons.pack(side ="bottom", fill="both", expand="yes")ˆà
    1515        self.buttons_pack(buttons)ˆà
    16ˆà        self.id = 0ˆà
    ˆà16        self.step_id = 0ˆà
    1717        self.engine = engine.Engine(self.canvas)ˆà
    1818        returnˆà
    1919    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))ˆà
    2121        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))ˆà
    2323        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())ˆà
    2525        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))ˆà
    2727        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))ˆà
    2929        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())ˆà
    3131        step_b.pack(side="bottom", fill="both", expand = "yes")ˆà
    3232        returnˆà
    òÀæ òÀæ ˆà
    3838ˆà
    3939    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ˆà
    4053ˆà
    41ˆà        passˆà
    42ˆà    def step (self):ˆà
    43ˆàˆà
    ˆà54    def end (self):ˆà
    4455        passˆà
    4556        ˆà
Note: See TracChangeset for help on using the changeset viewer.