Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/tanchiki/annotate/e6e7b30ecde0/game.py
Дата изменения: Unknown
Дата индексирования: Fri Feb 28 23:46:38 2014
Кодировка:
tanchiki: game.py annotate

tanchiki

annotate game.py @ 2:e6e7b30ecde0

modules changed
author Olga Zolotareva <olya_zol@inbox.ru>
date Sat, 18 Dec 2010 13:23:48 +0300
parents 78df8ab210fe
children af02cd410e37
rev   line source
olya_zol@1 1 class Game(object):
olya_zol@1 2 def __init__(self, bodies, users, width, height):
olya_zol@1 3 self.bodies = bodies
olya_zol@1 4 self.users = users
olya_zol@1 5 self.width = width
olya_zol@1 6 self.height = height
olya_zol@1 7
olya_zol@2 8 def step(game):
olya_zol@2 9 game.next_positions()
olya_zol@2 10 game.check_collisions()
olya_zol@2 11 game.check_walls()
olya_zol@2 12 game.update_positions()
olya_zol@2 13 game.invoke_ticks()
olya_zol@2 14 game.respawn()
olya_zol@1 15
olya_zol@2 16 def next_positions(game):
olya_zol@2 17 delta_t = 1
olya_zol@2 18 for i in game.bodies:
olya_zol@2 19 i.next_position = i.position + i.velocity.mul_v(delta_t)
olya_zol@1 20
olya_zol@2 21
olya_zol@2 22 def check_collisions(game):
olya_zol@1 23 pass
olya_zol@1 24
olya_zol@1 25 def collides(body1,body2):
olya_zol@1 26 pass
olya_zol@1 27
olya_zol@1 28 def handle_collision(body1,body2):
olya_zol@1 29 pass
olya_zol@1 30
olya_zol@2 31 def check_walls(game):
olya_zol@2 32 for i in game.bodies :
olya_zol@2 33 if (i.next_position.x <= 0) or (i.next_position.y <= 0) or (i.next_position.x <= width) or (i.next_position.y >= game.height) :
olya_zol@2 34 i.on_wall()
olya_zol@2 35
olya_zol@1 36
olya_zol@2 37 def update_positions(game):
olya_zol@2 38 for i in game.bodies:
olya_zol@2 39 i.position = i.next_position
olya_zol@1 40
olya_zol@2 41 def invoke_ticks(game):
olya_zol@1 42 pass
olya_zol@1 43
olya_zol@2 44 def respawn(game):
olya_zol@2 45 for i in game.users :
olya_zol@2 46 if i.tank.strength == 0 :
olya_zol@2 47 i.tank.respawn()
olya_zol@2 48
olya_zol@2 49
olya_zol@2 50