BuildingGenerator creates house with 2 chests.
This commit is contained in:
parent
ee25509975
commit
f449cec090
BIN
assets/atlas.png
BIN
assets/atlas.png
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 21 KiB |
BIN
assets/chest.png
Normal file
BIN
assets/chest.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 885 B |
BIN
assets/home.png
Normal file
BIN
assets/home.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -5,14 +5,25 @@ from survival.components.sprite_component import SpriteComponent
|
|||||||
|
|
||||||
|
|
||||||
class BuildingGenerator:
|
class BuildingGenerator:
|
||||||
def create_home(self, world, game_map):
|
def create_home(self, world, game_map, position = [10,10]):
|
||||||
home = world.create_entity()
|
home = world.create_entity()
|
||||||
pos = PositionComponent([32, 32], [32, 32])
|
home_pos = PositionComponent([position[0]*32, position[1]*32], position)
|
||||||
world.add_component(home, pos)
|
world.add_component(home, home_pos)
|
||||||
|
game_map.add_entity(home, home_pos)
|
||||||
world.add_component(home, InventoryComponent())
|
world.add_component(home, InventoryComponent())
|
||||||
|
sprite = SpriteComponent('home.png')
|
||||||
game_map.add_entity(home, pos)
|
|
||||||
sprite = SpriteComponent('tree.png')
|
|
||||||
sprite.set_scale(2)
|
|
||||||
world.add_component(home, sprite)
|
world.add_component(home, sprite)
|
||||||
world.add_component(home, CollisionComponent())
|
world.add_component(home, CollisionComponent())
|
||||||
|
|
||||||
|
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())
|
||||||
|
Loading…
Reference in New Issue
Block a user