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 |
*/
|
|
5 |
||
4
by Gustav Hartvigsson
What I have done: |
6 |
#include "GameObject.h" |
7 |
||
7
by Gustav Hartvigsson
* Added licensing information to the files. |
8 |
/**
|
9 |
* This file, as the rest of the project is under MIT license.
|
|
10 |
* see http://opensource.org/licenses/MIT
|
|
11 |
*
|
|
8
by Gustav Hartvigsson
* added and changed little in the files Lincening information. |
12 |
* Author Gustav Hartvigsson <gustav.hartvigsson _at_ gmail.com> 2014
|
7
by Gustav Hartvigsson
* Added licensing information to the files. |
13 |
*/
|
14 |
||
4
by Gustav Hartvigsson
What I have done: |
15 |
void game_object_free (GameObject * self) { |
16 |
GameObjectFreeFunc free_func = self->klass->free_func; |
|
17 |
free_func (self); |
|
18 |
}
|
|
19 |
||
20 |
GameObjectClass * game_object_get_class (GameObject * self) { |
|
21 |
return self->klass; |
|
22 |
}
|
|
23 |
||
24 |
void game_object_set_class (GameObject * self, GameObjectClass * klass) { |
|
25 |
self->klass = klass; |
|
26 |
}
|
|
27 |
||
28 |
void game_object_draw (GameObject * self, SDL_Renderer * renderer) { |
|
29 |
GameObjectDrawFunc draw_func = self->klass->draw_func; |
|
30 |
draw_func (self, renderer); |
|
31 |
}
|
|
32 |
||
33 |
void game_object_set_movment_delta (GameObject * self, int delta_x, |
|
34 |
int delta_y, uint32_t delta_time) { |
|
35 |
GameObjectSetMovementDeltaFunc set_movement_delta_func |
|
36 |
= self->klass->set_movement_delta_func; |
|
37 |
set_movement_delta_func (self, delta_x, delta_y, delta_time); |
|
38 |
}
|
|
39 |
||
40 |
bool game_object_get_is_alive (GameObject * self) { |
|
41 |
GameObjectGetIsAliveFunc is_alive = self->klass->get_is_alive_func; |
|
42 |
bool ret = is_alive (self); |
|
43 |
return ret; |
|
44 |
}
|
|
45 |
||
46 |
void game_object_set_callback (GameObject * self, char * name, |
|
5
by Gustav Hartvigsson
fixed the callback stuff.. |
47 |
GameObjectCallbackFunc callback_func, |
4
by Gustav Hartvigsson
What I have done: |
48 |
void * data) { |
49 |
GameObjectSetCallbackFunc set_callback_func = self->klass->set_callback_func; |
|
5
by Gustav Hartvigsson
fixed the callback stuff.. |
50 |
set_callback_func (self, name, callback_func, data); |
4
by Gustav Hartvigsson
What I have done: |
51 |
}
|
52 |
||
53 |
void game_object_do_callback (GameObject * self, char * name) { |
|
6
by Gustav Hartvigsson
reverted a mistake and fixed the code in the .c file to match this |
54 |
GameObjectCallbackHandlerFunc do_callback_func |
55 |
= self->klass->callback_handler_func; |
|
4
by Gustav Hartvigsson
What I have done: |
56 |
do_callback_func (self, name); |
57 |
}
|
|
58 |
||
59 |
bool game_object_get_is_collide (GameObject * self, GameObject * other) { |
|
60 |
GameObjectGetIsCollideFunc s_is_collide = self->klass->get_is_collide_func; |
|
61 |
bool ret = s_is_collide (self, other); |
|
62 |
return ret; |
|
63 |
}
|
|
64 |
||
65 |
||
66 |
/******************************************************************************/
|
|
67 |
||
68 |
void game_object_set_free_func (GameObject * self, |
|
69 |
GameObjectFreeFunc free_func) { |
|
70 |
self->klass->free_func = free_func; |
|
71 |
}
|
|
72 |
||
73 |
||
74 |
void game_object_set_draw_func (GameObject * self, |
|
75 |
GameObjectDrawFunc draw_func) { |
|
76 |
self->klass->draw_func = draw_func; |
|
77 |
}
|
|
78 |
||
79 |
void game_object_set_callback_handler_func (GameObject * self, |
|
6
by Gustav Hartvigsson
reverted a mistake and fixed the code in the .c file to match this |
80 |
GameObjectCallbackHandlerFunc callback_handler_func) { |
81 |
self->klass->callback_handler_func = callback_handler_func; |
|
82 |
}
|
|
4
by Gustav Hartvigsson
What I have done: |
83 |
|
84 |
void game_object_set_set_callback_func (GameObject * self, |
|
85 |
GameObjectSetCallbackFunc set_callback_func) { |
|
86 |
self->klass->set_callback_func = set_callback_func; |
|
87 |
}
|
|
88 |
||
89 |
void game_object_set_move_func (GameObject * self, |
|
90 |
GameObjectMoveFunc move_func) { |
|
91 |
self->klass->move_func = move_func; |
|
92 |
}
|
|
93 |
||
94 |
void game_object_set_set_move_delta_func (GameObject * self, |
|
6
by Gustav Hartvigsson
reverted a mistake and fixed the code in the .c file to match this |
95 |
GameObjectSetMovementDeltaFunc set_movement_delta_func) { |
4
by Gustav Hartvigsson
What I have done: |
96 |
self->klass->set_movement_delta_func = set_movement_delta_func; |
97 |
}
|
|
98 |
||
99 |
void game_object_set_get_bounding_box_func (GameObject * self, |
|
100 |
GameObjectGetBoundingBoxFunc get_bounding_box_func) { |
|
101 |
self->klass->get_bounding_box_func = get_bounding_box_func; |
|
102 |
}
|
|
103 |
||
104 |
void game_object_set_get_is_alive_func (GameObject * self, |
|
105 |
GameObjectGetIsAliveFunc get_is_alive_func) { |
|
106 |
self->klass->get_is_alive_func = get_is_alive_func; |
|
107 |
}
|
|
108 |
||
109 |
void game_object_set_is_collide_func (GameObject * self, |
|
110 |
GameObjectGetIsCollideFunc get_is_collide_func) { |
|
111 |
self->klass->get_is_collide_func = get_is_collide_func; |
|
112 |
}
|
|
113 |
||
114 |
/** MOOOOO! **/
|