Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # for code details: bsdgames.sourcearchive.com
- import math
- class Ship:
- def __init__(self, pos):
- self.pos = [float(i) for i in pos]
- class Klingon(Ship):
- def __init__(self, pos, hp):
- Ship.__init__(self, pos)
- self.hp = hp
- def isalive(self):
- return self.hp > 0
- def hit(self, damage):
- self.hp -= damage
- class Enterprise(Ship):
- max_energy = 5000
- def __init__(self, pos):
- self.energy = self.max_energy
- Ship.__init__(self, pos)
- def move(self, angle, distance):
- rad = math.radians(angle)
- delta = [math.sin(rad), -math.cos(rad)]
- delta = [round(i*distance, 1) for i in delta]
- self.pos = [self.pos[i] + delta[i] for i in xrange(len(self.pos))]
- def refill_energy(self):
- self.energy = self.max_energy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement