addEntity method in Map
This commit is contained in:
parent
d16711068a
commit
9d9cd159a0
@ -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()
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user