Skip to content
Download

Old API

Before the easy API, the code reached the scene and the input through longer paths. All of that still works: the easy API adds to the old one.

Before Now (easy API)
scene().spawn<Bullet>(x, y) spawn<Bullet>(x, y, "Instancias")
scene().all<Enemy>() with a for each<Enemy>([](Enemy& e) { ... })
scene().count<Enemy>() count<Enemy>()
Input::held(Key::Left) held(Key::Left)
Input::pressed(Key::Space) pressed(Key::Space)
Input::mouseX() mouseX()
touching<Enemy>() findAt<Enemy>(x, y)
touching<Wall>(x + 2, y) != nullptr collidesAt<Wall>(x + 2, y)
brasa::goToScene("Level2") goTo("Level2")
a counter decremented in onUpdate after(steps, ...)
a random function of your own (such as randomRange) random(a, b)
  • scene() gives access to the current scene: the camera (scene().camera), the size (scene().width, scene().height), the background color and scene().alive(), the list of all the instances.
  • Input::mouseGuiX() and Input::mouseGuiY(): the mouse in screen coordinates, for menus.
  • Free functions, outside objects, use the prefix: brasa::goToScene, brasa::quit.