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

source: tanchiki/body.py @ 28:4ef6336d1707

Revision 28:4ef6336d1707, 1.3 KB checked in by Peter Zotov <whitequark@òÀæ>, 5 years ago (diff)

Merge changes.

Lineˆà
1#coding:utf-8
2
3importˆàvector
4importˆàmath
5
6classˆàBody(object):
7ˆà ˆà ˆà ˆà defˆà__init__(self,ˆàgame,ˆàposition,ˆàvelocity =ˆàvector.Vector.null):
8ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.game =ˆàgame
9ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.position =ˆàposition
10ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.velocity =ˆàvelocity
11
12classˆàTank(Body):
13ˆà ˆà ˆà ˆà radius =ˆà1
14ˆà ˆà ˆà ˆà model =ˆà"tank"
15
16ˆà ˆà ˆà ˆà defˆà__init__(self,ˆàgame,ˆàposition,ˆàcontroller):
17ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà Body.__init__(self,ˆàgame,ˆàposition)
18ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.controller =ˆàcontroller
19ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.turret =ˆàvector.Vector()
20ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.strength =ˆà0
21
22ˆà ˆà ˆà ˆà defˆàrotate_base(tank,ˆàangle):ˆà
23ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ifˆàabs(angle)ˆà<ˆàself.game.max_base_delta :
24ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.velocity.phi +=ˆàangle
25ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà elseˆà:
26ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.velocity.phi +=ˆàself.game.max_base_delta
27
28ˆà ˆà ˆà ˆà defˆàrotate_turret(self,ˆàangle):
29ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ifˆàabs(angle)ˆà<ˆàself.game.max_base_delta :
30ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.turret.phi +=ˆàangle
31ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà elseˆà:
32ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.turret.phi +=ˆàself.game.max_turret_delta
33
34ˆà ˆà ˆà ˆà defˆàaccelerate(self,ˆàspeed_delta):
35ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.velocity +=ˆàself.velocity.normalize()ˆà*ˆàspeed_delta
36ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ifˆàself.velocity.rho >ˆàmax_velocity :
37ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.velocity.rho =ˆàmax_velocity
38
39ˆà ˆà ˆà ˆà defˆàfire(self):
40ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà bullet_position =ˆàself.position +ˆàself.turret *ˆà(self.radius +ˆà0.1)
41ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà bullet_velocity =ˆàself.turret.normalize()ˆà*ˆàself.game.bullet_speed
42ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà bullet =ˆàBullet(bullet_position,ˆàbullet_velocity,ˆàself)
43ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.game.bodies.append(bullet)
44
45classˆàBullet(Body):
46ˆà ˆà ˆà ˆà radius =ˆà0.1
47ˆà ˆà ˆà ˆà model =ˆà"bullet"
48
49ˆà ˆà ˆà ˆà defˆà__init__(self,ˆàposition,ˆàvelocity,ˆàtank):
50ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà Body.__init__(self,ˆàposition,ˆàvelocity)
51ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.origin =ˆàorigin
Note: See TracBrowser for help on using the repository browser.