Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.su/trac/snake/changeset/165
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Sun Apr 10 01:36:01 2016
Êîäèðîâêà: IBM-866
Changeset 165:af59540d48a9 òÀÓ Python Battle

Changeset 165:af59540d48a9


Ignore:
Timestamp:
12/23/10 20:00:59 (5 years ago)
Author:
Alex Martynov
Branch:
default
Message:

UI.start() function added (still need to check for bags)
UI.next_round() function added - passes

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • engine.py

    r164 r165 ˆà
    201201        else:ˆà
    202202            old_snake.cells = cellsˆà
    203ˆà        self.psnakes = self.snakes[:]ˆà
    204203        return self.snakes[snake_number]ˆà
    205204    ˆà
  • main.py

    r164 r165 ˆà
    2525        self.canvas.pack(side ="top", fill="both", expand="yes")ˆà
    2626        self.buttons_pack(self.root).pack(side ="bottom", fill="both", expand="no")ˆà
    27ˆà        self.step_id = 666ˆà
    ˆà27        self.step_id = 0ˆà
    2828        self.engine = engine.Engine(self.canvas)ˆà
    2929        self.after_id = Noneˆà
    òÀæ òÀæ ˆà
    3939        load_2 = tk.Button(buttons, text="Load 2", command=lambda: self.load(1))ˆà
    4040        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())ˆà
    4242        run_b.grid(row=2, column=2, stick="news")ˆà
    4343        restart_b = tk.Button(buttons, text="Restart", command=lambda: self.restart())ˆà
    òÀæ òÀæ ˆà
    7474        returnˆà
    7575ˆà
    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."""ˆà
    8178        if self.step_id == 666:ˆà
    82ˆà            self.restart()ˆà
    ˆà79            self.next_round()ˆà
    8380        if self.dead_snake_check() == False:ˆà
    8481            returnˆà
    òÀæ òÀæ ˆà
    8683            self.end()ˆà
    8784            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"""ˆà
    8892        self.step_id = self.step_id+1ˆà
    8993        self.engine.step()ˆà
    òÀæ òÀæ ˆà
    129133        self.engine.redraw()ˆà
    130134ˆà
    ˆà135    def next_round(self):ˆà
    ˆà136        passˆà
    ˆà137ˆà
    131138    def end (self):ˆà
    132139        """End the game and raise the window that tels about it."""ˆà
Note: See TracChangeset for help on using the changeset viewer.