SDLGameEngine

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

Defines | Functions

# SgeControl

Low level control functions. More...

## Defines
#define | SGEREDRAW 0xf00
#define | SGETIMER SDL_TimerID
#define | sgeRemoveTimer(timer) SDL_RemoveTimer(timer)
| Remove a timer from the event system.
#define | sgeGameLoop(event, quitvar) while ((SDL_WaitEvent(&event)&&(!quit)))
| The actual game loop.
#define | sgeStartGame(function, fps)
| A shortcut to start a game.
## Functions
SGETIMER | sgeAddTimer (int ms, void *function)
| Add a function which is called in a regular time interval.
SGETIMER | sgeStartRedrawTimer (int fps)
| Start the timer system.
void | sgeStopRedrawTimer (SGETIMER sgetimer)
| Stop the timer.
Uint32 | sgeGetFPS (void)
| Check the frames per second the game is currently running.

## Detailed Description

Low level control functions.

Functions for managing timing and gameloops. These are mostly for internal tasks or for complex requirements. In most cases you should use the gamestate system.

See also:
  sgeGameStateNew

## Define Documentation

#define sgeGameLoop | ( |  | event,
|  |  | quitvar
| ) |  | while ((SDL_WaitEvent(&event)&&(!quit)))

The actual game loop.

Parameters:

  event | A SGEEVENT variable to handle the events
  quitvar | A integer variable which ends the gameloop when set to 1

Definition at line 55 of file sgecontrol.h.

#define SGEREDRAW 0xf00

The redraw event ID

Definition at line 36 of file sgecontrol.h.

#define sgeRemoveTimer | ( |  | timer | ) | SDL_RemoveTimer(timer)

Remove a timer from the event system.

Parameters:

  timer | The timer ID returned by sgeAddTimer

Definition at line 48 of file sgecontrol.h.

#define sgeStartGame | ( |  | function,
|  |  | fps
| ) |  |

Value:

    SGETIMER t=sgeStartRedrawTimer(fps);\
            function();\
            sgeStopRedrawTimer(t);

A shortcut to start a game.

Parameters:

  function | A function pointer to your main game loop
  fps | The frames per second the game should run

Definition at line 62 of file sgecontrol.h.

#define SGETIMER SDL_TimerID

The timer ID, currently only a alias to SDL_TimerID, but may change

Definition at line 42 of file sgecontrol.h.

## Function Documentation

SGETIMER sgeAddTimer | ( | int | ms,
|  | void * | function
| ) |  |

Add a function which is called in a regular time interval.

Parameters:

  ms | Miliseconds the function is called
  function | A function pointer to call

Returns:
  A SGETIMER handle

Definition at line 13 of file sgecontrol.c.

SGETIMER sgeStartRedrawTimer | ( | int | fps | ) |

Start the timer system.

Parameters:

  fps | The frames per second to call the SGEREDRAW event

Returns:
  A SGETIMER handle

Definition at line 35 of file sgecontrol.c.

void sgeStopRedrawTimer | ( | SGETIMER | sgetimer | ) |

Stop the timer.

Parameters:

  sgetimer | The SGETIMER handle

Definition at line 40 of file sgecontrol.c.

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines