Changeset 16:c71c27b09bc7
- Timestamp:
-
12/20/10 04:35:08
(5 years ago)
- Author:
- Peter Zotov <whitequark@>
- Branch:
- default
- Children:
- 17:ce43bb4acf82, 32:803f8353f38f
- Message:
-
Fixed and updated overall repository format.
Removed CR's. Changed encoding to UTF-8.
Removed trailing whitespace and unified the rest.
Removed test code from vector.py.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
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 |
-
|
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 : |
-
|
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 |
-