view body.py @ 50:21d63c918715
Fixed bug: was unable to display bullets.
author |
Daniil Alexeyevsky <me.dendik@gmail.com> |
date |
Mon, 20 Dec 2010 21:10:48 +0300 |
parents |
cf05c46d014c |
children |
d740eff76e7e |
line source
5 base_angle = math.pi/32 # deltha phi = math.pi/32
6 turret_angle = math.pi/32
18 def __init__(self, position, velocity = vector.null):
19 self.position = position
20 self.velocity = velocity
24 def __init__(self, position, user, game):
25 Body.__init__(self, position)
27 self.turret = vector.i
29 self.base_orientation = 1 # 1 or -1
34 def rotate_base(tank, angle):
35 if abs(angle) < max_base_angle:
36 self.velocity.phi += angle
38 self.velocity.phi += max_base_angle
40 def rotate_turret(self, angle):
41 if abs(angle) < max_base_angle:
42 self.turret.phi += angle
44 self.turret.phi += max_turret_angle
47 def accelerate(self, speed_delta):
48 self.velocity += self.velocity.normalize() * speed_delta * delta_t
49 print self.velocity.rho
50 if self.velocity.rho > max_velocity:
51 self.velocity.rho = max_velocity
54 bullet_position = self.position + self.turret * (self.radius + 0.1)
55 bullet_velocity = self.turret.normalize() * self.game.bullet_speed
56 bullet = Bullet(bullet_position, bullet_velocity, self)
57 self.game.bodies.append(bullet)
59 def on_tick(self,other_tanks, bullets):
68 def on_hit(self, bullet):
71 def on_collision(self, other):
79 def __init__(self, position, velocity, tank):
80 Body.__init__(self, position, velocity = bullet_velocity)