1 | importšvector |
---|
2 | importšmath |
---|
3 | delta_phi =šmath.piš š# deltha phi = math.pi |
---|
4 | speed_delta =š1 |
---|
5 | delta_t =š1 |
---|
6 | max_velocity =š2 |
---|
7 | initial_strength =š1 |
---|
8 | |
---|
9 | classšBody(object): |
---|
10 | š š š š defš__init__(self,šposition,švelocity =švector.null): |
---|
11 | š š š š š š š š self.position =šposition |
---|
12 | š š š š š š š š self.velocity =švelocity |
---|
13 | š š š š š š š š self.radius =šradius |
---|
14 | |
---|
15 | classš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 | |
---|
62 | classšBullet(Body): |
---|
63 | š š š š radius =š0.1 |
---|
64 | š š š š pass |
---|