2021-03-28 18:05:52 +02:00
|
|
|
from survival.components.position_component import PositionComponent
|
|
|
|
from survival.entity_layer import EntityLayer
|
2021-03-04 15:02:42 +01:00
|
|
|
from survival.player import Player
|
2021-03-14 17:12:11 +01:00
|
|
|
from survival.tile_layer import TileLayer
|
2021-03-04 14:07:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
class GameMap:
|
|
|
|
def __init__(self, width, height):
|
|
|
|
self.width = width
|
|
|
|
self.height = height
|
2021-03-28 18:05:52 +02:00
|
|
|
self.tile_layer = TileLayer(width, height)
|
|
|
|
self.entity_layer = EntityLayer(width, height)
|
2021-03-04 14:07:44 +01:00
|
|
|
|
2021-03-15 13:31:25 +01:00
|
|
|
def draw(self, camera):
|
2021-03-15 14:10:19 +01:00
|
|
|
visible_area = camera.get_visible_area()
|
2021-03-28 18:05:52 +02:00
|
|
|
self.tile_layer.draw(camera, visible_area)
|
2021-03-04 14:07:44 +01:00
|
|
|
|
2021-03-28 18:05:52 +02:00
|
|
|
def add_entity(self, entity, pos):
|
|
|
|
self.entity_layer.add_entity(entity, pos.grid_position)
|
|
|
|
|
|
|
|
def move_entity(self, from_pos, to_pos):
|
|
|
|
self.entity_layer.move_entity(from_pos, to_pos)
|
|
|
|
|
|
|
|
def remove_entity(self, pos):
|
|
|
|
self.entity_layer.remove_entity(pos)
|
|
|
|
|
|
|
|
def is_colliding(self, pos):
|
|
|
|
return self.entity_layer.is_colliding(pos)
|