-
Notifications
You must be signed in to change notification settings - Fork 19
Getting Started
Once you have compiled the library with the compiler of your choice, simply link it to your new project, along with the SFML libraries. xygine requires all only four components of SFML - system, windows, graphics, and audio, although networking can optionally be used if it is required.
To use the library create a new class which inherits xy::App
and implement the virtual functions:
void handleEvent(const sf::Event&);
void handleMessage(const xy::Message&);
void registerStates();
void updateApp(float dt);
void draw();
and, optionally, override initialise()
and finalise()
. These are executed on startup and exit respectively, and should be used for any potentially non-exception safe code not suitable for the constructor or destructor. When using the state stack you'd want to clear it in finalise()
for example.
handleEvent()
and
handleMessage()
pass on any window event and system messages respectively. See messages for more detail.
registerStates()
is needed when using the state stack implementation of xygine. When creating new game states (deriving from xy::State
) they need to be registered with the StateStack
instance of your game. See the Example directory for a demo project which shows how to create a basic state which using a xy::Scene
to create a menu.
updateApp()
passes on the current elapsed game time, fixed at 1/60 second. This is used to update logic when xygine is running.
draw()
is the top level draw function, from which all drawing code should be called.
Once you have created your app class, instantiate it in your main()
function and call run()
int main()
{
MyApp game;
game.run();
return 0;
}