Templates
The templates package ships ready-made controllers and characters.
Controllers
| Class | Purpose |
|---|---|
PlatformController | Platformer movement (accel, friction, jump) |
TopDownController | 8-direction movement |
CameraController | Pan / zoom / rotate a layer camera |
Controllers expect actions on self.control (left/right/jump or left/right/up/down).
player = bf.PlatformController(size=(32, 48))
player.control.add_actions(
bf.Action("left").add_key_control(pygame.K_a).set_holding(),
bf.Action("right").add_key_control(pygame.K_d).set_holding(),
bf.Action("jump").add_key_control(pygame.K_SPACE),
)
scene.add("world", player)
PlatformCharacter
PlatformCharacter combines PlatformController and AnimatedSprite, and owns an AnimatedStateMachine.
hero = bf.PlatformCharacter(size=(32, 48))
idle = bf.AnimatedState("idle")
hero.state_machine.add_state(idle)
hero.state_machine.set_state("idle")
scene.add("world", hero)