Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/snake/diff/f99b094a3d5d/main.py
Дата изменения: Unknown
Дата индексирования: Sun Feb 3 06:59:43 2013
Кодировка:
snake: main.py diff

snake

diff main.py @ 166:f99b094a3d5d

Added UI.game_length as atribute
author Alex Martynov
date Thu, 23 Dec 2010 20:09:48 +0300
parents af59540d48a9
children 36756bd7e7ed
line diff
     1.1 --- a/main.py	Thu Dec 23 20:00:59 2010 +0300
     1.2 +++ b/main.py	Thu Dec 23 20:09:48 2010 +0300
     1.3 @@ -15,7 +15,8 @@
     1.4      - 'canvas' - Widget field is pictured at
     1.5      - 'step_id' - current step of the game
     1.6      - 'after_id' - identificator of runing game process
     1.7 -    - 'step_legth' - fime of the step"""
     1.8 +    - 'step_legth' - length of the step (in ms)
     1.9 +    - 'game_length' - number of the steps in one round of the game"""
    1.10      def __init__ (self):
    1.11          """Create Python Battle game window.
    1.12          Initialyze engige of the game."""
    1.13 @@ -28,6 +29,7 @@
    1.14          self.engine = engine.Engine(self.canvas)
    1.15          self.after_id = None
    1.16          self.step_length = 150
    1.17 +        self.game_length = 200
    1.18          return
    1.19      
    1.20      def buttons_pack(self, root):
    1.21 @@ -75,11 +77,11 @@
    1.22  
    1.23      def start (self):
    1.24          """Init running of the game."""
    1.25 -        if self.step_id == 666:
    1.26 +        if self.step_id == self.game_length + 666:
    1.27              self.next_round()
    1.28          if self.dead_snake_check() == False:
    1.29              return
    1.30 -        if self.step_id > 200:
    1.31 +        if self.step_id > self.game_length:
    1.32              self.end()
    1.33              return
    1.34          self.engine.psnakes = self.engine.snakes[:]
    1.35 @@ -98,7 +100,7 @@
    1.36          """Do the next game step"""
    1.37          if self.dead_snake_check() == False:
    1.38              return
    1.39 -        if self.step_id <= 200:
    1.40 +        if self.step_id <= self.game_length:
    1.41              if self.after_id != None:
    1.42                  self.canvas.after_cancel(self.after_id)
    1.43                  pass
    1.44 @@ -140,7 +142,7 @@
    1.45          if self.after_id != None:
    1.46              self.canvas.after_cancel(self.after_id)
    1.47              pass
    1.48 -        self.step_id = 666
    1.49 +        self.step_id = self.game_length + 666
    1.50          root = tk.Tk()
    1.51          end_label = tk.Label(root, text="End")
    1.52          end_label.pack()