Changeset 16:c71c27b09bc7
- Timestamp:
- 12/20/10 04:35:08 (5 years ago)
- Branch:
- default
- Children:
- 17:ce43bb4acf82, 32:803f8353f38f
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
body.py
- Property exe deleted
r13 r16 12 12 self.velocity = velocity 13 13 self.radius = radius 14 15 14 16 15 class Tank(Body): 22 21 self.base_orientation = 1 # 1 or -1 23 22 self.user = user 24 user.tank = self # 놃冒 ᆃ User 25 23 user.tank = self # Ϻ User 26 24 27 25 def rotate_base(tank, angle): 33 31 def accelerate(self, speed_delta): 34 32 self.velocity.rho += speed_delta * delta_t 35 if self.velocity.rho > max_velocity :33 if self.velocity.rho > max_velocity : 36 34 self.velocity.rho = max_velocity 37 35 40 38 41 39 def on_tick(self,other_tanks, bullets): 42 if self.user.base_left == True :40 if self.user.base_left == True : 43 41 self.rotate_base(delta_phi) 44 if self.user.base_right == True :42 if self.user.base_right == True : 45 43 self.rotate_base(-1*delta_phi) 46 if self.user.accelerate == True :44 if self.user.accelerate == True : 47 45 self.accelerate(speed_delta) 48 46 50 48 pass 51 49 52 def on_death(self) 50 def on_death(self): 53 51 pass 54 52 55 53 def on_hit(self,bullet): 56 54 pass -
game.py
- Property exe deleted
r8 r16 19 19 def next_positions(game): 20 20 delta_t = 1 21 for i in game.bodies :21 for i in game.bodies : 22 22 i.next_position = i.position + i.velocity*(delta_t) 23 24 23 25 24 def check_collisions(game): 36 35 if ((i.next_position.x - i.radius) <= 0) or ((i.next_position.y - i.radius) <= 0) or ((i.next_position.x + i.radius) >= game.width) or ((i.next_position.y + i.radius) >= game.height) : 37 36 i.on_wall() 38 39 37 40 38 def update_positions(game): 41 for i in game.bodies :39 for i in game.bodies : 42 40 i.position = i.next_position 43 41 44 42 def invoke_ticks(game): 45 for i in game.users :43 for i in game.users : 46 44 i.tank.on_tick(other_tanks,bullets) 47 45 48 def respawn(game): 46 def respawn(game): 49 47 for i in game.users : 50 48 if i.tank.strength == 0 : -
user.py
- Property exe deleted
r2 r16 1 1 class User(object): 2 2 3 def __init__(self, base_left = False , base_right = False, turret_left = False, turret_right = False, accelerate = False, decelerate = False, fire = False, tank = 0): 3 def __init__(self, base_left = False, base_right = False, 4 turret_left = False, turret_right = False, 5 accelerate = False, decelerate = False, 6 fire = False, tank = 0): 4 7 self.base_left = base_left 5 8 self.base_right = base_right -
vector.py
- Property exe deleted
r14 r16 1 1 import math 2 2 3 class Vector(object): 3 class Vector(object): 4 4 5 def __init__(self, x=0 , y=0): 5 def __init__(self, x=0 , y=0): 6 6 self.x = x 7 7 self.y = y 8 8 9 9 def __add__(self, other): 10 10 result = Vector(0,0) 20 20 21 21 def dot_product(self, other): 22 return self.x*other.x + self.y*other.y22 return self.x*other.x + self.y*other.y 23 23 24 24 def __abs__(self): 38 38 39 39 def set_rho(self, new_rho): 40 if self.is_null() == 1 :40 if self.is_null() == 1 : 41 41 self.x , self.y = new_rho*math.cos(self.phi) , new_rho*math.sin(self.phi) 42 42 else : 49 49 if self.is_null == 1: 50 50 phi = 0 51 return 51 return phi 52 52 53 53 def set_phi(self, new_phi): 54 54 rho = abs(self) 55 self.x 55 self.x, self.y = rho*math.cos(new_phi) , rho*math.sin(new_phi) 56 56 57 57 phi = property(get_phi, set_phi) 58 59 i = Vector(1,0)60 j = Vector(0,1)61 null = Vector(0,0)
Note: See TracChangeset
for help on using the changeset viewer.