27 lines
730 B
Python
27 lines
730 B
Python
from gameobject import *
|
|
from world import *
|
|
|
|
class Game:
|
|
def __init__(self, world: World, hero: GameObject, home: GameObject):
|
|
self.__world = world
|
|
self.__hero = hero
|
|
self.__home = home
|
|
|
|
def run(self) -> bool:
|
|
gui = Gui(self.__world.width, self.__world.height)
|
|
|
|
while True:
|
|
gui.clear()
|
|
self.__world.draw(gui)
|
|
self.__home.draw(gui)
|
|
self.__hero.draw(gui)
|
|
gui.show()
|
|
|
|
if self.__hero.position == self.__home.position:
|
|
return True
|
|
|
|
if not self.__world.is_empty(self.__hero.position):
|
|
return False
|
|
|
|
self.__hero.move(gui.input_direction())
|