-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtorpedo.py
More file actions
31 lines (24 loc) · 935 Bytes
/
Copy pathtorpedo.py
File metadata and controls
31 lines (24 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from flying_object import FlyingObject
TORPEDO_RADIUS = 4
TORPEDO_STARTING_LIFESPAN = 200
class Torpedo(FlyingObject):
def __init__(self, location, speed, heading):
"""Creates a new Torpedo object."""
super().__init__(location, speed)
self._heading = heading
self._radius = TORPEDO_RADIUS
self._lifespan_left = TORPEDO_STARTING_LIFESPAN
def drop_lifespan(self):
"""Lowers the torpedo's lifespan by one. Returns true if the lifespan
is now 0."""
self._lifespan_left -= 1
return self._lifespan_left == 0
def get_lifespan(self):
"""Returns the current lifetime left for the torpedo."""
return self._lifespan_left
def get_heading(self):
"""Returns the torpedo's current heading (in degrees)"""
return self._heading
def get_radius(self):
"""Returns the torpedo's radius"""
return self._radius