From 4d6de52e8c47aa923384d1424a0c1bf9c79f39ca Mon Sep 17 00:00:00 2001 From: Mateusz Date: Sat, 25 Apr 2020 23:33:55 +0200 Subject: [PATCH 1/3] add cost attribute --- src/game/TerrainTile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/TerrainTile.py b/src/game/TerrainTile.py index e5b7db7..9af1c78 100644 --- a/src/game/TerrainTile.py +++ b/src/game/TerrainTile.py @@ -4,7 +4,7 @@ import pygame class TerrainTile(pygame.sprite.Sprite): - def __init__(self, x, y, texture, tileSize): + def __init__(self, x, y, texture, tileSize, cost): super().__init__() terrainTexturesPath = Path("./data/images/terrain").resolve() self.image = pygame.image.load(str(terrainTexturesPath / texture)).convert() @@ -14,5 +14,5 @@ class TerrainTile(pygame.sprite.Sprite): self.y = y self.rect.x = x * tileSize self.rect.y = y * tileSize + self.cost = cost - # TODO : rozne koszty map tilesów From 91efd32d875cac0caa788415fe91278e1d298904 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Sat, 25 Apr 2020 23:34:18 +0200 Subject: [PATCH 2/3] add clay sprite --- data/mapdata/map.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/data/mapdata/map.txt b/data/mapdata/map.txt index 9989e2e..cba96bb 100644 --- a/data/mapdata/map.txt +++ b/data/mapdata/map.txt @@ -1,20 +1,20 @@ xxxxxxxxxxxxxxxxxxxx xssssssssssssssssssx -xs................sx -xs................sx -xs................sx -xs................sx -xs.....wwwwww.....sx +xsccc...c......cccsx +xscccc..........ccsx +xscc..............sx +xscc........cc....sx +xs.....wwwwwwc....sx xs.....w,,,,w.....sx xs.....w,,,,w.....sx -xs.....ww,,ww.....sx -xs................sx -xs................sx -xs................sx -xs................sx -xs................sx -xs................sx +xs.....ww,,ww...ccsx +xs...............csx +xs...c............sx +xs...........c....sx xs................sx xs................sx +xs.....c......c...sx +xs....cc.........csx +xs.............cccsx xssssssssssssssssssx xxxxxxxxxxxxxxxxxxxx \ No newline at end of file From d44274397db563aa288c1f595cbf4acd3c7fc117 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Sat, 25 Apr 2020 23:34:49 +0200 Subject: [PATCH 3/3] describe sprites costs --- src/game/Map.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/game/Map.py b/src/game/Map.py index 84881a5..aba1272 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -75,17 +75,19 @@ class Map: for row, tiles in enumerate(self.terrain): for col, tile in enumerate(tiles): if tile == 's': - self.screen.draw(TerrainTile(col, row, 'sand.png', self.tileSize), Locations.MAP, 0, 0) + self.screen.draw(TerrainTile(col, row, 'sand.png', self.tileSize, 15), Locations.MAP, 0, 0) elif tile == ',': - self.screen.draw(TerrainTile(col, row, 'floor.png', self.tileSize), Locations.MAP, 0, 0) + self.screen.draw(TerrainTile(col, row, 'floor.png', self.tileSize, 0), Locations.MAP, 0, 0) elif tile == '.': - self.screen.draw(TerrainTile(col, row, 'grass.png', self.tileSize), Locations.MAP, 0, 0) + self.screen.draw(TerrainTile(col, row, 'grass.png', self.tileSize, 10), Locations.MAP, 0, 0) + elif tile == 'c': + self.screen.draw(TerrainTile(col, row, 'clay.png', self.tileSize, 20), Locations.MAP, 0, 0) elif tile == 'x': - object = TerrainTile(col, row, 'water.png', self.tileSize) + object = TerrainTile(col, row, 'water.png', self.tileSize, 0) self.screen.draw(object, Locations.MAP, 0, 0) self.collidables.add(object) elif tile == 'w': - object = TerrainTile(col, row, 'wall.png', self.tileSize) + object = TerrainTile(col, row, 'wall.png', self.tileSize, 0) self.screen.draw(object, Locations.MAP, 0, 0) self.collidables.add(object)