Skip to content
Snippets Groups Projects
Commit 6b912982 authored by Annika Österdiekhoff's avatar Annika Österdiekhoff
Browse files

add root file for easier file loading

parent f74fee07
No related branches found
No related tags found
1 merge request!4Resolve "ROOT for easy file loading"
Pipeline #41425 passed
......@@ -8,10 +8,13 @@ from overcooked_simulator.game_items import Tomato
from overcooked_simulator.player import Player
from overcooked_simulator.pygame_gui.pygame_gui import PyGameGUI
from overcooked_simulator.simulation_runner import Simulator
from root_definition import ROOT_DIR
def main():
simulator = Simulator(Path("overcooked_simulator/layouts/basic.layout"), 600)
simulator = Simulator(
Path(ROOT_DIR + "/overcooked_simulator/layouts/basic.layout"), 600
)
player_one_name = "p1"
player_two_name = "p2"
simulator.register_player(Player(player_one_name, np.array([100, 200])))
......
......@@ -6,6 +6,7 @@ from overcooked_simulator.game_items import ProgressibleItem
from overcooked_simulator.game_items import Tomato
from overcooked_simulator.overcooked_environment import Action
from overcooked_simulator.simulation_runner import Simulator
from root_definition import ROOT_DIR
WHITE = (255, 255, 255)
GREY = (190, 190, 190)
......@@ -51,10 +52,10 @@ class PyGameGUI:
"""Visualisation of the overcooked environmnent and reading keyboard inputs using pygame."""
def __init__(
self,
simulator: Simulator,
player_names: list[str],
player_keys: list[pygame.key],
self,
simulator: Simulator,
player_names: list[str],
player_keys: list[pygame.key],
):
self.FPS = 60
self.simulator = simulator
......@@ -167,11 +168,11 @@ class PyGameGUI:
if isinstance(item, Tomato):
if item.finished:
image = pygame.image.load(
"overcooked_simulator/pygame_gui/images/tomato_cut.png"
ROOT_DIR + "/overcooked_simulator/pygame_gui/images/tomato_cut.png"
).convert_alpha() # or .convert_alpha()
else:
image = pygame.image.load(
"overcooked_simulator/pygame_gui/images/tomato.png"
ROOT_DIR + "/overcooked_simulator/pygame_gui/images/tomato.png"
).convert_alpha() # or .convert_alpha()
rect = image.get_rect()
rect.center = pos
......
import os
ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) # This is your Project Root
......@@ -8,13 +8,14 @@ from overcooked_simulator.game_items import Tomato
from overcooked_simulator.overcooked_environment import Action
from overcooked_simulator.player import Player
from overcooked_simulator.simulation_runner import Simulator
from root_definition import ROOT_DIR
try:
with open("../overcooked_simulator/layouts/basic.layout", "r") as textfile:
with open(ROOT_DIR + "/overcooked_simulator/layouts/basic.layout", "r") as textfile:
pass
layouts_folder = Path("../overcooked_simulator/layouts")
layouts_folder = Path(ROOT_DIR + "/overcooked_simulator/layouts")
except FileNotFoundError as e:
layouts_folder = Path("overcooked_simulator/layouts")
layouts_folder = Path(ROOT_DIR + "/overcooked_simulator/layouts")
def test_player_registration():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment