addEntity method in Map

This commit is contained in:
Wirus 2020-04-05 14:53:54 +02:00
parent d16711068a
commit 9d9cd159a0
2 changed files with 9 additions and 2 deletions

View File

@ -6,6 +6,7 @@ from os import path
from game.EventManager import EventManager from game.EventManager import EventManager
from game.Screen import Screen from game.Screen import Screen
from game.Map import Map from game.Map import Map
from src.entities.Player import Player
class Game: class Game:
@ -43,6 +44,8 @@ class Game:
# Start Map implement # Start Map implement
self.mapDataFolder = path.dirname("../data/mapdata/") self.mapDataFolder = path.dirname("../data/mapdata/")
self.map = Map(path.join(self.mapDataFolder, 'map.txt'), self.screen) 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 # End Map implement
self.mainLoop() self.mainLoop()

View File

@ -1,6 +1,7 @@
import pygame import pygame
from game.TerrainTile import TerrainTile from game.TerrainTile import TerrainTile
from game.Screen import Locations from game.Screen import Locations
from src.entities.Player import Player
class Map: class Map:
def __init__(self, filename, screen): def __init__(self, filename, screen):
@ -30,4 +31,7 @@ class Map:
elif tile == '.': elif tile == '.':
self.screen.draw(TerrainTile('grass.png', self.tileSize), Locations.MAP, col*self.tileSize, row*self.tileSize) 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)