These steps are all that is needed to get a simple game up and running.
Extend Launcher
and provide your own implementation for window creation and
rendering using your preferred libraries.
Listen for input using your preferred library, and pass events to the launcher's
input
field. This will make the latest input available to the current state
each frame.
The launcher has one active State
at any time, which is updated and rendered
each frame. This may be a loading screen, a menu, or the game itself.
A basic game state should instantiate the Logic
and a Camera
(if
required), and override the following methods:
-
processInput()
: Process the user input from the last frame. -
update()
: Update theLogic
andCamera
. -
render()
Tell some renderer to render the game.
In your main
method, instantiate your launcher, load your initial state, and
call launcher.start()
.
To add an Entity to the world, subclass Entity and use the following:
MyEntity entity = new MyEntity(x, y);
logic.addEntity(entity);
Components can be added to Entities to add new properties and behaviour. For example, you might add a graphical component to an Entity to allow it to be rendered.
To make the camera track a particular Entity, use the following code:
camera.trackEntity(entity);
camera.teleportToDestination();