Deleted unwanted code in Player
It isn't the player's role to check whether they can move to a tile, check it beforehands and use the move method from its Entity superclass.
This commit is contained in:
parent
230a7ec432
commit
7c1c427892
|
@ -1,27 +1,5 @@
|
||||||
from .interfaces import FightingEntity
|
from ..interfaces import FightingEntity
|
||||||
|
|
||||||
class Player(FightingEntity):
|
class Player(FightingEntity):
|
||||||
maxhealth = 20
|
maxhealth = 20
|
||||||
strength = 5
|
strength = 5
|
||||||
|
|
||||||
|
|
||||||
def move_up(self, p : Player, m : Map) :
|
|
||||||
if p.y > 0 :
|
|
||||||
cell = Tile(Map.tiles[p.y-1][p.x])
|
|
||||||
if can_walk(cell) :
|
|
||||||
p.y = p.y-1
|
|
||||||
def move_down(self, p : Player, m : Map) :
|
|
||||||
if p.y < Map.height :
|
|
||||||
cell = Tile(Map.tiles[p.y+1][p.x])
|
|
||||||
if can_walk(cell) :
|
|
||||||
p.y = p.y+1
|
|
||||||
def move_left(self, p : Player, m : Map) :
|
|
||||||
if p.x > 0 :
|
|
||||||
cell = Tile(Map.tiles[p.y][p.x-1])
|
|
||||||
if can_walk(cell) :
|
|
||||||
p.x = p.x-1
|
|
||||||
def move_right(self, p : Player, m : Map) :
|
|
||||||
if p.x < Map.width :
|
|
||||||
cell = Tile(Map.tiles[p.y][p.x+1])
|
|
||||||
if can_walk(cell) :
|
|
||||||
p.x = p.x+1
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Map:
|
||||||
height: int
|
height: int
|
||||||
tiles: list
|
tiles: list
|
||||||
|
|
||||||
def __init__(self, width: int, height: int, tiles: list, entities = []: list):
|
def __init__(self, width: int, height: int, tiles: list, entities = []):
|
||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
self.tiles = tiles
|
self.tiles = tiles
|
||||||
|
|
Loading…
Reference in New Issue