Start f new pathfinding, not working
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
|
||||
from squirrelbattle.interfaces import Map
|
||||
from .display import Display
|
||||
from squirrelbattle.entities.player import Player
|
||||
|
||||
|
||||
class MapDisplay(Display):
|
||||
@ -22,6 +23,24 @@ class MapDisplay(Display):
|
||||
for e in self.map.entities:
|
||||
self.addstr(self.pad, e.y, self.pack.tile_width * e.x,
|
||||
self.pack[e.name.upper()], self.color_pair(2))
|
||||
players = [ p for p in self.map.entities if isinstance(p,Player) ]
|
||||
player = players[0] if len(players) > 0 else None
|
||||
if player:
|
||||
for x in range(self.map.width):
|
||||
for y in range(self.map.height):
|
||||
if (y,x) in player.paths:
|
||||
deltay, deltax = (y - player.path[(y, x)][0],
|
||||
x - player.path[(y, x)][1])
|
||||
if (deltay, deltax) == (-1, 0):
|
||||
character = '╹'
|
||||
elif (deltay, deltax) == (1, 0):
|
||||
character = '╻'
|
||||
elif (deltay, deltax) == (0, -1):
|
||||
character = '╺'
|
||||
else:
|
||||
character = '╸'
|
||||
self.addstr(self.pad, y, self.pack.tile_width * x,
|
||||
character, self.color_pair(1))
|
||||
|
||||
def display(self) -> None:
|
||||
y, x = self.map.currenty, self.pack.tile_width * self.map.currentx
|
||||
|
Reference in New Issue
Block a user