2021-05-08 22:15:20 +02:00
|
|
|
from survival.components.collision_component import CollisionComponent
|
|
|
|
from survival.components.inventory_component import InventoryComponent
|
|
|
|
from survival.components.position_component import PositionComponent
|
|
|
|
from survival.components.sprite_component import SpriteComponent
|
|
|
|
|
|
|
|
|
|
|
|
class BuildingGenerator:
|
2021-05-22 18:32:36 +02:00
|
|
|
def create_home(self, world, game_map, position = [10,10]):
|
2021-05-08 22:15:20 +02:00
|
|
|
home = world.create_entity()
|
2021-05-22 18:32:36 +02:00
|
|
|
home_pos = PositionComponent([position[0]*32, position[1]*32], position)
|
|
|
|
world.add_component(home, home_pos)
|
|
|
|
game_map.add_entity(home, home_pos)
|
2021-05-08 22:15:20 +02:00
|
|
|
world.add_component(home, InventoryComponent())
|
2021-05-22 18:32:36 +02:00
|
|
|
sprite = SpriteComponent('home.png')
|
2021-05-08 22:15:20 +02:00
|
|
|
world.add_component(home, sprite)
|
|
|
|
world.add_component(home, CollisionComponent())
|
2021-05-22 18:32:36 +02:00
|
|
|
|
|
|
|
for x_pos in [-1, 1]:
|
|
|
|
chest = world.create_entity()
|
|
|
|
chest_pos = PositionComponent(
|
|
|
|
[(position[0]+x_pos)*32, position[1]*32],
|
|
|
|
[position[0]+x_pos, position[1]]
|
|
|
|
)
|
|
|
|
world.add_component(chest, chest_pos)
|
|
|
|
game_map.add_entity(chest, chest_pos)
|
|
|
|
world.add_component(chest, InventoryComponent())
|
|
|
|
sprite = SpriteComponent('chest.png')
|
|
|
|
world.add_component(chest, sprite)
|
|
|
|
world.add_component(chest, CollisionComponent())
|