-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.py
More file actions
26 lines (22 loc) · 767 Bytes
/
Player.py
File metadata and controls
26 lines (22 loc) · 767 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
from GameObject import GameObject
from object_componenets import Fighter
import libtcodpy as libtcod
class Player(GameObject):
"""docstring for Player"""
def __init__(self, state, (x, y)):
super(Player, self).__init__(state, (x, y), 'player', '@', libtcod.white, fighter=Fighter())
def move_or_attack(self, (dx, dy)):
state = self.state
x = self.x + dx
y = self.y + dy
position = (x, y)
target = state.find_object(position)
if target and target.fighter:
self.fighter.attack(target)
return False
else:
return self.move((dx, dy), state)
def death(self):
print 'You died!'
self.character = '.'
self.color = libtcod.darker_red