-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectile.py
53 lines (41 loc) · 1.17 KB
/
Projectile.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import util
from RoguePy.UI import Colors
from RoguePy.libtcod import libtcod
from RoguePy.Map import Entity
import config
class Projectile(Entity):
def __init__(self, parent, type, x, y, tx, ty, heading, range, dmg):
super(Projectile, self).__init__('projectile')
self.ch = '*'
self.heading = heading
self.speed = config.projectile['speed']
self.damage = dmg
self.type = type
if type == "cannon":
clr = Colors.black
else:
clr = Colors.silver
self.color = clr
self.range = range
self.distanceTravelled = 0
self.distanceToTarget = int(util.dist(x, y, tx, ty))
self.canSee = False
self.parent = parent
self.x = x
self.y = y
def __str__(self):
return "Projectile[{},{}] spd [{}] hdg[{}]".format(self.x, self.y, self.speed, self.heading)
@property
def x(self):
return self.__x
@x.setter
def x(self, x):
self.__x = x
self.mapX = int(round(x))
@property
def y(self):
return self.__y
@y.setter
def y(self, y):
self.__y = y
self.mapY = int(round(y))