Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.su/trac/tanchiki/browser/tanchiki/game.py?rev=19
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Tue Apr 12 00:28:48 2016
Êîäèðîâêà: IBM-866
game.py in tanchiki òÀÓ Tanchiki

source: tanchiki/game.py @ 19:31ea2608cc39

Revision 19:31ea2608cc39, 1.1 KB checked in by Peter Zotov <whitequark@òÀæ>, 5 years ago (diff)

Changed repository structure.

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