Пример #1
0
def register_afv(afv_surface: pygame.Surface, entities_manager: ecs.EntitiesManager, afv: ecs.Entity) -> None:
    afv["GraphicComponent"] = ecs.GraphicComponent(afv_surface, AFV_INITIAL_POSITION[0], AFV_INITIAL_POSITION[1])
    afv["HorizontalOrientationComponent"] = ecs.HorizontalOrientationComponent(afv_surface,
                                                                               pygame.transform.flip(afv_surface, True,
                                                                                                     False))
    afv["VelocityComponent"] = ecs.VelocityComponent(AFV_VELOCITY[0], AFV_VELOCITY[1])
    entities_manager.register_entity(afv)
Пример #2
0
 def alien_factory(initial_x: int, initial_y: int) -> ecs.Entity:
     alien = dict()
     alien["GraphicComponent"] = ecs.GraphicComponent(alien_surface, initial_x, initial_y)
     alien["AnimationCycleComponent"] = ecs.AnimationCycleComponent(cyc_surfaces, ALIEN_ANIMATION_INTERVAL_LENGTH)
     alien["VelocityComponent"] = ecs.VelocityComponent(ALIEN_VELOCITY[0], ALIEN_VELOCITY[1])
     entities_manager.register_and_enlist_entity(alien, "aliens")
     return alien
Пример #3
0
 def shot_factory(initial_x: int, initial_y: int) -> ecs.Entity:
     shot = dict()
     shot["GraphicComponent"] = ecs.GraphicComponent(shot_surface, initial_x, initial_y)
     shot["VelocityComponent"] = ecs.VelocityComponent(SHOT_VELOCITY[0], SHOT_VELOCITY[1])
     shot["AudioComponent"] = ecs.AudioComponent(shot_sound)
     shot["AudioComponent"].sound.play()
     entities_manager.register_and_enlist_entity(shot, "shots")
     return shot
Пример #4
0
def register_and_enlist_alien(images: List[pygame.Surface],
                              entities_manager: ecs.EntitiesManager) -> None:
    alien = dict()
    alien["GraphicComponent"] = ecs.GraphicComponent(images[ImgsIndices.alien1], ALIEN_INITIAL_POSITION[0],
                                                     ALIEN_INITIAL_POSITION[1])
    alien["AnimationCycleComponent"] = ecs.AnimationCycleComponent((images[ImgsIndices.alien1],
                                                                    images[ImgsIndices.alien2],
                                                                    images[ImgsIndices.alien3]),
                                                                   ALIEN_ANIMATION_INTERVAL_LENGTH)
    alien["VelocityComponent"] = ecs.VelocityComponent(ALIEN_VELOCITY[0], ALIEN_VELOCITY[1])
    entities_manager.register_and_enlist_entity(alien, "aliens")
Пример #5
0
 def bomb_factory(initial_x: int, initial_y: int) -> ecs.Entity:
     bomb = dict()
     bomb["GraphicComponent"] = ecs.GraphicComponent(bomb_surface, initial_x, initial_y)
     bomb["VelocityComponent"] = ecs.VelocityComponent(BOMB_VELOCITY[0], BOMB_VELOCITY[1])
     entities_manager.register_and_enlist_entity(bomb, "bombs")
     return bomb