bzr branch
http://gegoxaren.bato24.eu/bzr/%2Bjunk/c_sdl_joypad
21
by Gustav Hatvigsson
* added Modeline to (almost) all files. |
1 |
/* c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil
|
2 |
* vi: set shiftwidth=2 tabstop=2 expandtab:
|
|
3 |
* :indentSize=2:tabSize=2:noTabs=true:
|
|
4 |
*/
|
|
3
by Gustav Hartvigsson
Added the skeliton for game objects that. They can be used as a basis for a |
5 |
|
6 |
#ifndef __H_GAME_OBJECT__
|
|
7 |
#define __H_GAME_OBJECT__
|
|
8 |
||
17
by Gustav Hartvigsson
* fixed a few Doxygen problems. |
9 |
/*
|
7
by Gustav Hartvigsson
* Added licensing information to the files. |
10 |
* This file, as the rest of the project is under MIT license.
|
11 |
* see http://opensource.org/licenses/MIT
|
|
12 |
*
|
|
8
by Gustav Hartvigsson
* added and changed little in the files Lincening information. |
13 |
* Author Gustav Hartvigsson <gustav.hartvigsson _at_ gmail.com> 2014
|
7
by Gustav Hartvigsson
* Added licensing information to the files. |
14 |
*/
|
15 |
||
3
by Gustav Hartvigsson
Added the skeliton for game objects that. They can be used as a basis for a |
16 |
#include <SDL2/SDL.h> |
17 |
#include <stdbool.h> |
|
18 |
||
15
by Gustav Hartvigsson
* moved the files to ./src/ |
19 |
typedef struct GameObject GameObject; |
20 |
||
21 |
/******************************************************************************
|
|
22 |
* Function pointer declarations.
|
|
23 |
*****************************************************************************/
|
|
24 |
|
|
25 |
typedef void (* GameObjectCallbackFunc)(GameObject * self, void * data); |
|
26 |
||
27 |
typedef void (* GameObjectFreeFunc)(GameObject * self); |
|
28 |
||
29 |
typedef void (* GameObjectDrawFunc)(GameObject * self, SDL_Renderer * renderer); |
|
30 |
||
31 |
typedef void (* GameObjectCallbackHandlerFunc)(GameObject * self, char * name); |
|
32 |
||
33 |
typedef void (* GameObjectSetCallbackFunc)(GameObject * self, char * name,\ |
|
34 |
GameObjectCallbackFunc callback_func, |
|
35 |
void * data); |
|
36 |
||
37 |
typedef void (* GameObjectMoveFunc)(GameObject * self); |
|
38 |
||
39 |
typedef void (* GameObjectSetMovementDeltaFunc)(GameObject * self, int delta_x,\ |
|
40 |
int delta_y, Uint32 time_delta); |
|
41 |
||
42 |
typedef SDL_Rect (* GameObjectGetBoundingBoxFunc)(GameObject * self); |
|
43 |
||
44 |
typedef bool (* GameObjectGetIsAliveFunc)(GameObject * self); |
|
45 |
||
46 |
typedef bool (* GameObjectGetIsCollideFunc)(GameObject * self, |
|
47 |
GameObject * other); |
|
48 |
||
12
by Gustav Hartvigsson
* reorganising code to be remove extra typedefs. |
49 |
/******************************************************************************
|
50 |
* Object declaration.
|
|
51 |
*****************************************************************************/
|
|
52 |
||
53 |
typedef struct GameObjectClass { |
|
54 |
GameObjectFreeFunc free_func; |
|
55 |
GameObjectDrawFunc draw_func; |
|
56 |
GameObjectCallbackHandlerFunc callback_handler_func; |
|
57 |
GameObjectSetCallbackFunc set_callback_func; |
|
58 |
GameObjectMoveFunc move_func; |
|
59 |
GameObjectSetMovementDeltaFunc set_movement_delta_func; |
|
60 |
GameObjectGetBoundingBoxFunc get_bounding_box_func; |
|
61 |
GameObjectGetIsAliveFunc get_is_alive_func; |
|
62 |
GameObjectGetIsCollideFunc get_is_collide_func; |
|
63 |
} GameObjectClass; |
|
64 |
||
65 |
||
66 |
typedef struct GameObject { |
|
67 |
GameObjectClass * klass; /**< the class that holds all the virtual |
|
68 |
* functions. */
|
|
69 |
void * priv; /**< The private data. */ |
|
70 |
} GameObject; |
|
3
by Gustav Hartvigsson
Added the skeliton for game objects that. They can be used as a basis for a |
71 |
|
4
by Gustav Hartvigsson
What I have done: |
72 |
|
3
by Gustav Hartvigsson
Added the skeliton for game objects that. They can be used as a basis for a |
73 |
|
74 |
/******************************************************************************
|
|
75 |
* Game Object base functions.
|
|
76 |
*****************************************************************************/
|
|
77 |
void game_object_free (GameObject * self); |
|
78 |
||
79 |
GameObjectClass * game_object_get_class (GameObject * self); |
|
80 |
||
81 |
void game_object_set_class (GameObject * self, GameObjectClass * klass); |
|
82 |
||
83 |
void game_object_draw (GameObject * self, SDL_Renderer * renderer); |
|
84 |
||
85 |
void game_object_move (GameObject * self); |
|
86 |
||
4
by Gustav Hartvigsson
What I have done: |
87 |
void game_object_set_movement_delta (GameObject * self, int delta_x, |
88 |
int delta_y, uint32_t d_t); |
|
89 |
||
3
by Gustav Hartvigsson
Added the skeliton for game objects that. They can be used as a basis for a |
90 |
bool game_object_get_is_alive (GameObject * self); |
91 |
||
4
by Gustav Hartvigsson
What I have done: |
92 |
void game_object_set_callback (GameObject * self, char * name, |
5
by Gustav Hartvigsson
fixed the callback stuff.. |
93 |
GameObjectCallbackFunc callback_func, |
3
by Gustav Hartvigsson
Added the skeliton for game objects that. They can be used as a basis for a |
94 |
void * data); |
95 |
||
4
by Gustav Hartvigsson
What I have done: |
96 |
void game_object_do_callback (GameObject * self, char * name); |
3
by Gustav Hartvigsson
Added the skeliton for game objects that. They can be used as a basis for a |
97 |
|
98 |
||
99 |
/******************************************************************************
|
|
100 |
* Game Object set virtual function functions.
|
|
101 |
*****************************************************************************/
|
|
102 |
||
103 |
void game_object_set_free_func (GameObject * self, |
|
104 |
GameObjectFreeFunc free_func); |
|
105 |
||
106 |
void game_object_set_draw_func (GameObject * self, |
|
107 |
GameObjectDrawFunc draw_func); |
|
108 |
||
109 |
void game_object_set_callback_handler_func (GameObject * self, |
|
110 |
GameObjectCallbackHandlerFunc callback_handler_func); |
|
111 |
||
112 |
void game_object_set_add_callback_func (GameObject * self, |
|
4
by Gustav Hartvigsson
What I have done: |
113 |
GameObjectSetCallbackFunc add_callback_func); |
3
by Gustav Hartvigsson
Added the skeliton for game objects that. They can be used as a basis for a |
114 |
|
115 |
void game_object_set_move_func (GameObject * self, |
|
116 |
GameObjectMoveFunc move_func); |
|
117 |
||
118 |
void game_object_set_set_move_delta_func (GameObject * self, |
|
119 |
GameObjectSetMovementDeltaFunc set_movent_delta_func); |
|
120 |
||
121 |
void game_object_set_get_bounding_box_func (GameObject * self, |
|
122 |
GameObjectGetBoundingBoxFunc get_bounding_box_func); |
|
123 |
||
124 |
void game_object_set_movment_delta (GameObject * self, int delta_x, |
|
4
by Gustav Hartvigsson
What I have done: |
125 |
int delta_y, uint32_t delta_time); |
3
by Gustav Hartvigsson
Added the skeliton for game objects that. They can be used as a basis for a |
126 |
|
127 |
void game_object_set_get_is_alive_func (GameObject * self, |
|
128 |
GameObjectGetIsAliveFunc get_is_alive_func); |
|
129 |
||
4
by Gustav Hartvigsson
What I have done: |
130 |
void game_object_set_is_collide_func (GameObject * self, |
131 |
GameObjectGetIsCollideFunc is_collide_func); |
|
3
by Gustav Hartvigsson
Added the skeliton for game objects that. They can be used as a basis for a |
132 |
#endif /* __H_GAME_OBJECT__ */ |