/+junk/c_sdl_joypad_ducktape

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