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