1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/* c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil
* vi: set shiftwidth=2 tabstop=2 expandtab:
* :indentSize=2:tabSize=2:noTabs=true:
*/
#ifndef __H_GAME__
#define __H_GAME__
#include "defs.h"
#include <SDL2/SDL.h>
#include <stdbool.h>
BEGIN_DECLS
#include "MousePointer.h"
#include "GameButton.h"
//#include "JSParser.h"
#include "game_utils.h"
/*
* This file, as the rest of the project is under MIT license.
* see http://opensource.org/licenses/MIT
*
* Author Gustav Hartvigsson <gustav.hartvigsson _at_ gmail.com> 2014
*/
#define J_SCALE_FACTOR 5000 //TODO: change the movement to time-based
/** @file
* A Game represents the game itself. This is going to be re-implementation in
* the future.
*/
/**
* Quits the program in an unsafe way.
*/
void quit (int rc);
typedef struct Game {
SDL_Event event;
SDL_Point mouse_delta;
bool mouse_pressed;
bool bg_color_toggle;
int done;
SDL_Color background_color;
SDL_Window * window;
SDL_Renderer * renderer;
SDL_GameController * game_controller;
MousePointer * mouse;
GameButton * button;
} Game;
/**
* Creates a new Game.
*/
Game * game_new ();
/**
* The function that possesses the events of the game.
* Should generally not be called from outside the Game.
*/
void game_process_events (Game * self);
/**
* The function that has to be run for the game to run. executes the main loop
* of the game.
*/
void game_main_loop (Game * self);
/**
* Frees the Game and the resources associated with it.
*/
void game_free (Game * self);
/**
* a function that internally is called to draw all the objects on the screen.
*/
void game_draw (Game * self);
END_DECLS
#endif
|