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

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

Revision 19:31ea2608cc39, 1.3 KB checked in by Peter Zotov <whitequark@?>, 5 years ago (diff)

Changed repository structure.

Lineš
1importšvector
2importšmath
3delta_phi =šmath.piš š# deltha phi = math.pi
4speed_delta =š1
5delta_t =š1
6max_velocity =š2
7initial_strength =š1
8
9classšBody(object):
10š š š š defš__init__(self,šposition,švelocity =švector.null):
11š š š š š š š š self.position =šposition
12š š š š š š š š self.velocity =švelocity
13š š š š š š š š self.radius =šradius
14
15classšTank(Body):
16š š š š radius =š1
17š š š š defš__init__(self,šposition,šuser):
18š š š š š š š š Body.__init__(self,šposition)
19š š š š š š š š self.strength =š0
20š š š š š š š š self.turret =švector.i
21š š š š š š š š self.base_orientation =š1š š š š# 1 or -1
22š š š š š š š š self.user =šuser
23š š š š š š š š user.tank =šselfš# äîáàâëÿåò ñåáÿ â User
24
25š š š š defšrotate_base(tank,šangle):š
26š š š š š š š š self.velocity.phi +=šangle
27
28š š š š defšrotate_turret(self,šangle):
29š š š š š š š š self.turret.phi +=šangle
30
31š š š š defšaccelerate(self,šspeed_delta):
32š š š š š š š š self.velocity.rho +=šspeed_delta *šdelta_t
33š š š š š š š š ifšself.velocity.rho >šmax_velocity :
34š š š š š š š š š š š š self.velocity.rho =šmax_velocity
35
36š š š š defšfire(self):
37š š š š š š š š pass
38
39š š š š defšon_tick(self,other_tanks,šbullets):
40š š š š š š š š ifšself.user.base_left ==šTrueš:
41š š š š š š š š š š š š self.rotate_base(delta_phi)
42š š š š š š š š ifšself.user.base_right ==šTrueš:
43š š š š š š š š š š š š self.rotate_base(-1*delta_phi)
44š š š š š š š š ifšself.user.accelerate ==šTrueš:
45š š š š š š š š š š š š self.accelerate(speed_delta)
46
47š š š š defšon_spawn(self):
48š š š š š š š š pass
49
50š š š š defšon_death(self):
51š š š š š š š š pass
52
53š š š š defšon_hit(self,bullet):
54š š š š š š š š pass
55
56š š š š defšon_collision(self):
57š š š š š š š š pass
58
59š š š š defšon_wall(self):
60š š š š š š š š pass
61
62classšBullet(Body):
63š š š š radius =š0.1
64š š š š pass
Note: See TracBrowser for help on using the repository browser.