From 9d9cd159a04aa7c563e289d78f5df5fdd4d41efc Mon Sep 17 00:00:00 2001 From: Wirus Date: Sun, 5 Apr 2020 14:53:54 +0200 Subject: [PATCH] addEntity method in Map --- src/game/Game.py | 3 +++ src/game/Map.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/game/Game.py b/src/game/Game.py index 6e6e8e4..8e5b7b5 100644 --- a/src/game/Game.py +++ b/src/game/Game.py @@ -6,6 +6,7 @@ from os import path from game.EventManager import EventManager from game.Screen import Screen from game.Map import Map +from src.entities.Player import Player class Game: @@ -43,6 +44,8 @@ class Game: # Start Map implement self.mapDataFolder = path.dirname("../data/mapdata/") self.map = Map(path.join(self.mapDataFolder, 'map.txt'), self.screen) + self.player = Player((0, 0), self.map.tileSize) + self.map.addEntity(self.player) # End Map implement self.mainLoop() diff --git a/src/game/Map.py b/src/game/Map.py index 7daa356..17f19d3 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -1,6 +1,7 @@ import pygame from game.TerrainTile import TerrainTile from game.Screen import Locations +from src.entities.Player import Player class Map: def __init__(self, filename, screen): @@ -19,7 +20,7 @@ class Map: self.height = self.tileHeight * self.tileSize self.terrainDraw() - + def terrainDraw(self): for row, tiles in enumerate(self.terrain): for col, tile in enumerate(tiles): @@ -29,5 +30,8 @@ class Map: self.screen.draw(TerrainTile('floor.png', self.tileSize), Locations.MAP, col*self.tileSize, row*self.tileSize) elif tile == '.': self.screen.draw(TerrainTile('grass.png', self.tileSize), Locations.MAP, col*self.tileSize, row*self.tileSize) - + + def addEntity(self, entity): + self.entities.append(entity) + self.screen.draw(entity, Locations.MAP, 0, 0)