# main.c

## Defines
#define | _PHYSFS
#define | _INITS_
#define | _KEYBOARD_
#define | _MOUSE_
#define | _BUTTONS_
#define | _EVENTHANDLER_
#define | _SPRITES_
#define | _MAINGAME_
#define | _RENDER_
#define | _PHYSCOL_
#define | _OPTIONS_
#define | _MAIN_
## Functions
int | main (int argc, char **argv)
| The entry point of the game.
_Bool | data_init (void)
| Initializes the gdata structure.
_Bool | main_loop (void)
| Everything happens here!
GDATAPTR | get_game_data (void)
| Grabs the main GDATA structure.
void | loader (void)
void | cleanup (GDATAPTR game)

## Detailed Description

The entry point of the program and contains the main_loop function

## Define Documentation

#define _BUTTONS_

Definition at line 100 of file main.c.

#define _EVENTHANDLER_

Definition at line 105 of file main.c.

#define _INITS_

Definition at line 85 of file main.c.

#define _KEYBOARD_

Definition at line 90 of file main.c.

#define _MAIN_

Definition at line 135 of file main.c.

#define _MAINGAME_

Definition at line 115 of file main.c.

#define _MOUSE_

Definition at line 95 of file main.c.

#define _OPTIONS_

Definition at line 130 of file main.c.

#define _PHYSCOL_

Definition at line 125 of file main.c.

#define _PHYSFS

Definition at line 55 of file main.c.

#define _RENDER_

Definition at line 120 of file main.c.

#define _SPRITES_

Definition at line 110 of file main.c.

## Function Documentation

void cleanup | ( | GDATAPTR | game | ) |

Definition at line 464 of file main.c.

_Bool data_init | ( | void |  | ) |

Initializes the gdata structure.

Initializes all members of the gdata structure, *data. Specifically, the screen is set, timer started, keyboard and mouse installed, allegro events registered and other important routines are executed.

Returns:
  Returns true if all initializes were executed correctly, otherwise false is returned and program will then exit

Definition at line 188 of file main.c.

GDATAPTR get_game_data | ( | void |  | ) |

Grabs the main GDATA structure.

Returns a pointer to 'data', a pointer to a structure of type GDATA

Returns:
  returns GDATAPTR

Definition at line 431 of file main.c.

void loader | ( | void |  | ) |

Definition at line 438 of file main.c.

int main | ( | int | argc,
|  | char ** | argv |
| ) |  |  |

The entry point of the game.

Initializes all needed assets and transfer control to the main_loop.

Parameters:

  `[in]` | argc | The number of command line arguments passed to the program for processing
  `[in]` | *argv[] | The commands passed to the program, contained in an array of char*'s

Returns:
  Returns 1 and exits if any of the initialization functions fail, otherwise it returns 0 at the end of program execution.

See also:
  gdata
  data_init
  init_core_sprites
  init_buttons
  main_loop

Todo:
  remove init_core_sprites, put instead ini_base_images, instead of initializing sprites at startup, initialize them before the game starts. This way the sprites can be reset to their default x and y coordinates without the need of additional functions. Also, empty sprite list when the game is exited back to the menu.

Definition at line 147 of file main.c.

_Bool main_loop | ( | void |  | ) |

Everything happens here!

The main game loop, all other function are directly or indirectly called from this function. The fucntion does not return until the game quits, i.e. when the user hits the escape key or closes the Allegro window.

Returns:
  Returns true when the game exits.

Note:
  A good place to start when tracing errors!

Definition at line 302 of file main.c.