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

Changeset 167:36756bd7e7ed


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

added oftions for UI.restart()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main.py

    r166 r167 ˆà
    4343        run_b = tk.Button(buttons, text="Run", command=lambda: self.start())ˆà
    4444        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"))ˆà
    4646        restart_b.grid(row=1, column=5, stick="news")ˆà
    4747        load_3 = tk.Button(buttons, text="Load 3", command=lambda: self.load(2))ˆà
    òÀæ òÀæ ˆà
    7979        """Init running of the game."""ˆà
    8080        if self.step_id == self.game_length + 666:ˆà
    81ˆà            self.next_round()ˆà
    ˆà81            self.restart(survived="yes")ˆà
    8282        if self.dead_snake_check() == False:ˆà
    8383            returnˆà
    òÀæ òÀæ ˆà
    125125            return Falseˆà
    126126        ˆà
    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          ˆà
    129137        self.step_id = 0ˆà
    130ˆà        for i, snake in enumerate(self.engine.psnakes):ˆà
    131ˆà            if self.engine.psnakes[i] != None:ˆà
    ˆà138        for i, snake in enumerate(snake_set):ˆà
    ˆà139            if snake_set[i] != None:ˆà
    132140                self.engine.snakes[i] = snakeˆà
    133141                self.engine.create_snake(i, snake)ˆà
    134142        self.engine.refill()ˆà
    135143        self.engine.redraw()ˆà
    136ˆàˆà
    137ˆà    def next_round(self):ˆà
    138ˆà        passˆà
    139144ˆà
    140145    def end (self):ˆà
Note: See TracChangeset for help on using the changeset viewer.