Add a map with tiles that can block player movement
This commit is contained in:
parent
4419eb360d
commit
367b284d31
4 changed files with 62 additions and 9 deletions
|
@ -4,11 +4,9 @@
|
|||
import tcod
|
||||
|
||||
class Object:
|
||||
'''
|
||||
A drawable object with a symbol and (x, y) position.
|
||||
'''
|
||||
'''A drawable object with a symbol and (x, y) position.'''
|
||||
|
||||
def __init__(self, symbol, color=(255, 255, 255), x=0, y=0):
|
||||
def __init__(self, symbol: str, color: tcod.Color = (255, 255, 255), x: int = 0, y: int = 0):
|
||||
self.__x = int(x)
|
||||
self.__y = int(y)
|
||||
self.__color = color
|
||||
|
@ -30,5 +28,15 @@ class Object:
|
|||
def y(self, value):
|
||||
self.__y = int(value)
|
||||
|
||||
def move(self, dx: int, dy: int):
|
||||
'''Move this object by (dx, dy).'''
|
||||
self.__x += dx
|
||||
self.__y += dy
|
||||
|
||||
def move_to(self, x: int, y: int) -> None:
|
||||
'''Move this object directly to the given position.'''
|
||||
self.__x = x
|
||||
self.__y = y
|
||||
|
||||
def print(self, console: tcod.Console) -> None:
|
||||
console.print(x=self.__x, y=self.__y, string=self.__symbol, fg=self.__color)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue