Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/tanchiki/file/803f8353f38f/body.py
Дата изменения: Unknown
Дата индексирования: Fri Feb 28 18:12:12 2014
Кодировка:
tanchiki: 803f8353f38f body.py

tanchiki

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
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
9 class Body(object):
10 def __init__(self, position, velocity = vector.null):
11 self.position = position
12 self.velocity = velocity
13 self.radius = radius
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
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
36 def fire(self):
37 pass
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)
47 def on_spawn(self):
48 pass
50 def on_death(self):
51 pass
53 def on_hit(self,bullet):
54 pass
56 def on_collision(self):
57 pass
59 def on_wall(self):
60 pass
62 class Bullet(Body):
63 radius = 0.1
64 pass