Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.su/trac/tanchiki/browser/game.py?rev=2
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Sun Apr 10 20:35:42 2016
Êîäèðîâêà: IBM-866
game.py òÀÓ Tanchiki

source: game.py @ 2:e6e7b30ecde0

Revision 2:e6e7b30ecde0, 1.0 KB checked in by Olga Zolotareva <olya_zol@òÀæ>, 5 years ago (diff)

modules changed

Lineˆà
1classˆàGame(object):
2ˆà ˆà ˆà ˆà defˆà__init__(self,ˆàbodies,ˆàusers,ˆàwidth,ˆàheight):
3ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.bodies =ˆàbodies
4ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.users =ˆàusers
5ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.width =ˆàwidth
6ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.height =ˆàheight
7
8ˆà ˆà ˆà ˆà defˆàstep(game):
9ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà game.next_positions()
10ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà game.check_collisions()
11ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà game.check_walls()
12ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà game.update_positions()
13ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà game.invoke_ticks()
14ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà game.respawn()
15
16ˆà ˆà ˆà ˆà defˆànext_positions(game):
17ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà delta_t =ˆà1
18ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà forˆài inˆàgame.bodies:
19ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà i.next_position =ˆài.position +ˆài.velocity.mul_v(delta_t)
20ˆà ˆà ˆà ˆà
21
22ˆà ˆà ˆà ˆà defˆàcheck_collisions(game):
23ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà pass
24
25ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà defˆàcollides(body1,body2):
26ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà pass
27
28ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà defˆàhandle_collision(body1,body2):
29ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà pass
30
31ˆà ˆà ˆà ˆà defˆàcheck_walls(game):
32ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà forˆài inˆàgame.bodies :
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)ˆà:
34ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà i.on_wall()
35ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà
36
37ˆà ˆà ˆà ˆà defˆàupdate_positions(game):
38ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà forˆài inˆàgame.bodies:
39ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà i.position =ˆài.next_position
40
41ˆà ˆà ˆà ˆà defˆàinvoke_ticks(game):
42ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà pass
43ˆà ˆà ˆà ˆà
44ˆà ˆà ˆà ˆà defˆàrespawn(game):ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà
45ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà forˆài inˆàgame.users :
46ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ifˆài.tank.strength ==ˆà0ˆà:
47ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà i.tank.respawn()
48
49
50ˆà
Note: See TracBrowser for help on using the repository browser.