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