|
SDLGameEngine
|
Game states and event handlers. More...
Data Structures | |
| struct | SGEGAMESTATEMANAGER |
| struct | SGEGAMESTATE |
Functions | |
| SGEGAMESTATEMANAGER * | sgeGameStateManagerNew (void) |
| Create a new state manager. | |
| int | sgeGameStateManagerChange (SGEGAMESTATEMANAGER *manager, SGEGAMESTATE *next_state) |
| Change to a new state. | |
| void | sgeGameStateManagerRun (SGEGAMESTATEMANAGER *manager, int fps) |
| Run the game with the current states, redrawing at certain frames per second. | |
| void | sgeGameStateManagerQuit (SGEGAMESTATEMANAGER *manager) |
| Quit the game state manager. | |
| SGEGAMESTATE * | sgeGameStateNew (void) |
| Create new game state. | |
Variables | |
| void * | SGEGAMESTATE::data |
| A pointer to your data. | |
| void(* | SGEGAMESTATE::onRedraw )(struct _SGEGAMESTATE *state) |
| A function pointer to the states redraw function. | |
| int(* | SGEGAMESTATE::onKeyDown )(struct _SGEGAMESTATE *state, SGEEVENT *event) |
| (optional) A function pointer to the states key down handler | |
| int(* | SGEGAMESTATE::onKeyUp )(struct _SGEGAMESTATE *state, SGEEVENT *event) |
| (optional) A function pointer to the states key up handler | |
| int(* | SGEGAMESTATE::onJoystickButtonDown )(struct _SGEGAMESTATE *state, SGEEVENT *event) |
| (optional) A function pointer to the states joystick button down handler | |
| int(* | SGEGAMESTATE::onJoystickButtonUp )(struct _SGEGAMESTATE *state, SGEEVENT *event) |
| (optional) A function pointer to the states joystick button up handler | |
| void(* | SGEGAMESTATE::onJoystickMove )(struct _SGEGAMESTATE *state, SGEEVENT *event) |
| (optional) A function pointer to the states joystick move handler | |
| void(* | SGEGAMESTATE::onMouseDown )(struct _SGEGAMESTATE *state, SGEEVENT *event) |
| (optional) A function pointer to the states mouse button down handler | |
| void(* | SGEGAMESTATE::onMouseUp )(struct _SGEGAMESTATE *state, SGEEVENT *event) |
| (optional) A function pointer to the states mouse button up handler | |
| void(* | SGEGAMESTATE::onMouseMove )(struct _SGEGAMESTATE *state, SGEEVENT *event) |
| (optional) A function pointer to the states mouse move handler | |
| int(* | SGEGAMESTATE::onStateChange )(struct _SGEGAMESTATE *state, struct _SGEGAMESTATE *previous) |
| (optional) A function pointer to a state change handler | |
Game states and event handlers.
Split your game into single states to switch between.
Also provides event callbacks for handling user input.
| int sgeGameStateManagerChange | ( | SGEGAMESTATEMANAGER * | manager, |
| SGEGAMESTATE * | next_state | ||
| ) |
Change to a new state.
| manager | The game state manager |
| next_state | The SGEGAMESTATE to switch to |
Definition at line 31 of file sgegamestate.c.
| void sgeGameStateManagerRun | ( | SGEGAMESTATEMANAGER * | manager, |
| int | fps | ||
| ) |
Run the game with the current states, redrawing at certain frames per second.
| manager | The game state manager |
| fps | The frames per seconds the game should run |
Definition at line 43 of file sgegamestate.c.
| SGEGAMESTATE* sgeGameStateNew | ( | void | ) |
Create new game state.
The sge game state struct is given to all function callbacks to enable them to call the manager and get its data.
It needs at least a onRedraw function, the rest of the callbacks are optional.
Definition at line 19 of file sgegamestate.c.
int(* SGEGAMESTATE::onJoystickButtonDown)(struct _SGEGAMESTATE *state, SGEEVENT *event) [inherited] |
(optional) A function pointer to the states joystick button down handler
| state | The current state |
| event | The current event object |
If the handler did not handle the event, the event is passed on to the gamepad event system.
Definition at line 96 of file sgegamestate.h.
int(* SGEGAMESTATE::onJoystickButtonUp)(struct _SGEGAMESTATE *state, SGEEVENT *event) [inherited] |
(optional) A function pointer to the states joystick button up handler
| state | The current state |
| event | The current event object |
If the handler did not handle the event, the event is passed on to the gamepad event system.
Definition at line 106 of file sgegamestate.h.
void(* SGEGAMESTATE::onJoystickMove)(struct _SGEGAMESTATE *state, SGEEVENT *event) [inherited] |
(optional) A function pointer to the states joystick move handler
| state | The current state |
| event | The current event object |
Definition at line 113 of file sgegamestate.h.
int(* SGEGAMESTATE::onKeyDown)(struct _SGEGAMESTATE *state, SGEEVENT *event) [inherited] |
(optional) A function pointer to the states key down handler
| state | The current state |
| event | The current event object |
If the handler did not handle the event, the event is passed on to the gamepad event system.
Definition at line 76 of file sgegamestate.h.
int(* SGEGAMESTATE::onKeyUp)(struct _SGEGAMESTATE *state, SGEEVENT *event) [inherited] |
(optional) A function pointer to the states key up handler
| state | The current state |
| event | The current event object |
If the handler did not handle the event, the event is passed on to the gamepad event system.
Definition at line 86 of file sgegamestate.h.
void(* SGEGAMESTATE::onMouseDown)(struct _SGEGAMESTATE *state, SGEEVENT *event) [inherited] |
(optional) A function pointer to the states mouse button down handler
| state | The current state |
| event | The current event object |
Definition at line 120 of file sgegamestate.h.
void(* SGEGAMESTATE::onMouseMove)(struct _SGEGAMESTATE *state, SGEEVENT *event) [inherited] |
(optional) A function pointer to the states mouse move handler
| state | The current state |
| event | The current event object |
Definition at line 134 of file sgegamestate.h.
void(* SGEGAMESTATE::onMouseUp)(struct _SGEGAMESTATE *state, SGEEVENT *event) [inherited] |
(optional) A function pointer to the states mouse button up handler
| state | The current state |
| event | The current event object |
Definition at line 127 of file sgegamestate.h.
void(* SGEGAMESTATE::onRedraw)(struct _SGEGAMESTATE *state) [inherited] |
A function pointer to the states redraw function.
| state | The current state |
Definition at line 66 of file sgegamestate.h.
int(* SGEGAMESTATE::onStateChange)(struct _SGEGAMESTATE *state, struct _SGEGAMESTATE *previous) [inherited] |
(optional) A function pointer to a state change handler
| state | The current state |
| event | The current event object |
Definition at line 142 of file sgegamestate.h.