view body.py @ 32:803f8353f38f
Created branch new
author |
Peter Zotov <whitequark@whitequark.org> |
date |
Mon, 20 Dec 2010 16:05:49 +0300 |
parents |
0f8f077a682d |
children |
dfdc1def5d24 |
line source
3 delta_phi = math.pi # deltha phi = math.pi
10 def __init__(self, position, velocity = vector.null):
11 self.position = position
12 self.velocity = velocity
17 def __init__(self, position, user):
18 Body.__init__(self, position)
20 self.turret = vector.i
21 self.base_orientation = 1 # 1 or -1
23 user.tank = self # ?????????????????? ???????? ?? User
25 def rotate_base(tank, angle):
26 self.velocity.phi += angle
28 def rotate_turret(self, angle):
29 self.turret.phi += angle
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
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)
53 def on_hit(self,bullet):
56 def on_collision(self):