diff --git a/data/images/entities/berry.jpg b/data/images/entities/berry.jpg deleted file mode 100644 index 375d44f..0000000 Binary files a/data/images/entities/berry.jpg and /dev/null differ diff --git a/data/images/entities/berry.png b/data/images/entities/berry.png new file mode 100644 index 0000000..253530f Binary files /dev/null and b/data/images/entities/berry.png differ diff --git a/data/images/entities/bush.jpg b/data/images/entities/bush.jpg deleted file mode 100644 index e894c0f..0000000 Binary files a/data/images/entities/bush.jpg and /dev/null differ diff --git a/data/images/entities/bush.png b/data/images/entities/bush.png new file mode 100644 index 0000000..f5a37c0 Binary files /dev/null and b/data/images/entities/bush.png differ diff --git a/data/images/entities/cranberry.jpg b/data/images/entities/cranberry.jpg deleted file mode 100644 index 07d9fc8..0000000 Binary files a/data/images/entities/cranberry.jpg and /dev/null differ diff --git a/data/images/entities/cranberry.png b/data/images/entities/cranberry.png new file mode 100644 index 0000000..f8bb9fa Binary files /dev/null and b/data/images/entities/cranberry.png differ diff --git a/data/images/entities/mushroom.png b/data/images/entities/mushroom.png new file mode 100644 index 0000000..45a65b7 Binary files /dev/null and b/data/images/entities/mushroom.png differ diff --git a/data/images/entities/player.jpg b/data/images/entities/player.jpg deleted file mode 100644 index 1845ca8..0000000 Binary files a/data/images/entities/player.jpg and /dev/null differ diff --git a/data/images/entities/player.png b/data/images/entities/player.png new file mode 100644 index 0000000..f9da2de Binary files /dev/null and b/data/images/entities/player.png differ diff --git a/data/images/entities/rabbit.jpg b/data/images/entities/rabbit.jpg deleted file mode 100644 index d9510d6..0000000 Binary files a/data/images/entities/rabbit.jpg and /dev/null differ diff --git a/data/images/entities/rabbit.png b/data/images/entities/rabbit.png new file mode 100644 index 0000000..d16d594 Binary files /dev/null and b/data/images/entities/rabbit.png differ diff --git a/data/images/entities/rock.jpg b/data/images/entities/rock.jpg deleted file mode 100644 index 01a4d5a..0000000 Binary files a/data/images/entities/rock.jpg and /dev/null differ diff --git a/data/images/entities/rock.png b/data/images/entities/rock.png new file mode 100644 index 0000000..cf9822e Binary files /dev/null and b/data/images/entities/rock.png differ diff --git a/data/images/terrain/water.jpg b/data/images/terrain/water.jpg deleted file mode 100644 index a7ecffe..0000000 Binary files a/data/images/terrain/water.jpg and /dev/null differ diff --git a/data/images/terrain/water.png b/data/images/terrain/water.png new file mode 100644 index 0000000..341c543 Binary files /dev/null and b/data/images/terrain/water.png differ diff --git a/data/mapdata/mapEntities.json b/data/mapdata/mapEntities.json index a0c8a32..a590e65 100644 --- a/data/mapdata/mapEntities.json +++ b/data/mapdata/mapEntities.json @@ -18,7 +18,7 @@ "name" : "cranberry", "position" : { "x": 7, - "y": 1 + "y": 3 }, "isPickupable" : true, "effect" : { @@ -56,8 +56,23 @@ "name" : "rock", "position" : { "x": 13, - "y": 1 + "y": 2 }, "isPickupable" : false + }, + + { + "name" : "mushroom", + "position" : { + "x": 14, + "y": 3 + }, + "isPickupable": true, + "effect" : { + "hp": -50, + "stamina": 0, + "thirst": 0, + "hunger": 25 + } } ] \ No newline at end of file diff --git a/src/entities/Player.py b/src/entities/Player.py index f3cbd4e..f1f90fe 100644 --- a/src/entities/Player.py +++ b/src/entities/Player.py @@ -9,7 +9,7 @@ class Player(Entity): statistics: Statistics def __init__(self, spawnpoint, size): - super().__init__("player.jpg", size, (spawnpoint[0] * size, spawnpoint[1] * size)) + super().__init__("player.png", size, (spawnpoint[0] * size, spawnpoint[1] * size)) # Where the player is facing, 0 - north, 1 self.rotation = Rotations.NORTH self.statistics = Statistics(100, 0, 0, 100) @@ -28,9 +28,14 @@ class Player(Entity): def getFacingCoord(self): if self.rotation == Rotations.NORTH: - return (0, -1) + return self.rect.x, self.rect.y - (self.rect.h) elif self.rotation == Rotations.SOUTH: - pass + return self.rect.x, self.rect.y + (self.rect.h) + elif self.rotation == Rotations.EAST: + return self.rect.x + (self.rect.h), self.rect.y + elif self.rotation == Rotations.WEST: + return self.rect.x - (self.rect.h), self.rect.y + # Returns given statistic def getStatistic(self, stat): if stat.value == StatisticNames.HP: diff --git a/src/game/EventManager.py b/src/game/EventManager.py index 3960521..d8a3bca 100644 --- a/src/game/EventManager.py +++ b/src/game/EventManager.py @@ -1,5 +1,6 @@ import pygame +from src.entities.Pickupable import Pickupable from src.entities.Player import Rotations # Player can move every given milliseconds @@ -38,7 +39,11 @@ class EventManager: def handlePlayerControls(self, keys): # Key names are temporary # TODO: Load key bindings from JSON - + if keys[pygame.K_SPACE]: + object = self.game.map.getEntityOnCoord(self.player.getFacingCoord()) + if type(object) is Pickupable: + object.on_pickup(self.player) + self.game.map.removeSpriteFromMap(object) if keys[pygame.K_w]: self.player.rotate(Rotations.NORTH) if not self.game.map.collision(self.player.rect.x, self.player.rect.y - self.player.rect.w): diff --git a/src/game/Map.py b/src/game/Map.py index f0fa06c..7ed08bf 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -42,7 +42,7 @@ class Map: for entity in entityListJson: try: if entity["isPickupable"]: - actualEntities.append(Pickupable(entity["name"] + ".jpg", + actualEntities.append(Pickupable(entity["name"] + ".png", self.tileSize, (entity["position"]["x"] * self.tileSize, entity["position"]["y"] * self.tileSize), Statistics(entity["effect"]["hp"], @@ -50,7 +50,7 @@ class Map: entity["effect"]["thirst"], entity["effect"]["stamina"]))) else: - actualEntities.append(Entity(entity["name"] + ".jpg", + actualEntities.append(Entity(entity["name"] + ".png", self.tileSize, (entity["position"]["x"] * self.tileSize, entity["position"]["y"] * self.tileSize))) except KeyError: @@ -67,7 +67,7 @@ class Map: elif tile == '.': self.screen.draw(TerrainTile(col, row, 'grass.png', self.tileSize), Locations.MAP, 0, 0) elif tile == 'x': - object = TerrainTile(col, row, 'water.jpg', self.tileSize) + object = TerrainTile(col, row, 'water.png', self.tileSize) self.screen.draw(object, Locations.MAP, 0, 0) self.collidables.add(object) elif tile == 'w':