From 9e7c4f1ae01bf3290132132df3134ec34a6b7b95 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Mon, 6 Apr 2020 10:35:58 +0200 Subject: [PATCH] Map can now load interactable entities --- src/game/Map.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/game/Map.py b/src/game/Map.py index 7ed08bf..33ce59a 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -1,6 +1,8 @@ import json import pygame + +from src.entities.Interactable import Interactable from src.game.TerrainTile import TerrainTile from src.game.Screen import Locations @@ -41,6 +43,7 @@ class Map: entityListJson = json.loads(file.read()) for entity in entityListJson: try: + # Creates a pickupable object if entity["isPickupable"]: actualEntities.append(Pickupable(entity["name"] + ".png", self.tileSize, @@ -49,6 +52,17 @@ class Map: entity["effect"]["hunger"], entity["effect"]["thirst"], entity["effect"]["stamina"]))) + # Creates an interactable object + elif "effect" in entity: + actualEntities.append(Interactable(entity["name"] + ".png", + self.tileSize, + (entity["position"]["x"] * self.tileSize, + entity["position"]["y"] * self.tileSize), + Statistics(entity["effect"]["hp"], + entity["effect"]["hunger"], + entity["effect"]["thirst"], + entity["effect"]["stamina"]))) + # Creates plain entity else: actualEntities.append(Entity(entity["name"] + ".png", self.tileSize,