2021-05-21 20:14:00 +02:00
|
|
|
from survival.components.OnCollisionComponent import OnCollisionComponent
|
2021-03-28 18:56:32 +02:00
|
|
|
from survival.components.camera_target_component import CameraTargetComponent
|
|
|
|
from survival.components.input_component import InputComponent
|
2021-05-24 13:10:10 +02:00
|
|
|
from survival.components.inventory_component import InventoryComponent
|
2021-03-28 18:56:32 +02:00
|
|
|
from survival.components.movement_component import MovementComponent
|
|
|
|
from survival.components.position_component import PositionComponent
|
|
|
|
from survival.components.sprite_component import SpriteComponent
|
2021-04-18 19:53:51 +02:00
|
|
|
from survival.components.time_component import TimeComponent
|
2021-05-24 17:20:08 +02:00
|
|
|
from survival.systems.automation_system import AutomationComponent
|
2021-03-28 18:56:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
class PlayerGenerator:
|
|
|
|
|
|
|
|
def create_player(self, world, game_map):
|
|
|
|
player = world.create_entity()
|
|
|
|
pos = PositionComponent([0, 0], [0, 0])
|
|
|
|
world.add_component(player, pos)
|
|
|
|
world.add_component(player, MovementComponent())
|
|
|
|
world.add_component(player, InputComponent())
|
2021-05-21 20:14:00 +02:00
|
|
|
world.add_component(player, OnCollisionComponent())
|
2021-05-24 13:10:10 +02:00
|
|
|
world.add_component(player, InventoryComponent())
|
2021-03-28 18:56:32 +02:00
|
|
|
camera_target = CameraTargetComponent(pos)
|
|
|
|
world.add_component(player, camera_target)
|
2021-05-24 17:20:08 +02:00
|
|
|
# world.add_component(player, AutomationComponent())
|
2021-03-28 18:56:32 +02:00
|
|
|
game_map.add_entity(player, pos)
|
|
|
|
sprite = SpriteComponent('stevenson.png')
|
|
|
|
sprite.set_scale(1)
|
|
|
|
world.add_component(player, sprite)
|
2021-04-18 19:53:51 +02:00
|
|
|
world.add_component(player, TimeComponent(0, 0, 0, 0))
|
2021-03-28 18:56:32 +02:00
|
|
|
|
|
|
|
return player
|