/+junk/c_sdl_joypad_ducktape

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/c_sdl_joypad_ducktape
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil
 * vi: set shiftwidth=2 tabstop=2 expandtab:
 * :indentSize=2:tabSize=2:noTabs=true:
 */

#include "GameObject.h"

/**
 * This file, as the rest of the project is under MIT license.
 * see http://opensource.org/licenses/MIT
 *
 * Author Gustav Hartvigsson <gustav.hartvigsson _at_ gmail.com> 2014
 */

void game_object_free (GameObject * self) {
  GameObjectFreeFunc free_func = self->klass->free_func;
  free_func (self);
}

GameObjectClass * game_object_get_class (GameObject * self) {
  return self->klass;
}

void game_object_set_class (GameObject * self, GameObjectClass * klass) {
  self->klass = klass;
}

void game_object_draw (GameObject * self, SDL_Renderer * renderer) {
  GameObjectDrawFunc draw_func = self->klass->draw_func;
  draw_func (self, renderer);
}

void game_object_set_movment_delta (GameObject * self, int delta_x,
                                    int delta_y, uint32_t delta_time) {
  GameObjectSetMovementDeltaFunc set_movement_delta_func
                                         = self->klass->set_movement_delta_func;
  set_movement_delta_func (self, delta_x, delta_y, delta_time);
}

bool game_object_get_is_alive (GameObject * self) {
  GameObjectGetIsAliveFunc is_alive = self->klass->get_is_alive_func;
  bool ret = is_alive (self);
  return ret;
}

void game_object_set_callback (GameObject * self, char * name,
                               GameObjectCallbackFunc callback_func,
                               void * data) {
  GameObjectSetCallbackFunc set_callback_func = self->klass->set_callback_func;
  set_callback_func (self, name, callback_func, data);
}

void game_object_do_callback (GameObject * self, char * name) {
  GameObjectCallbackHandlerFunc do_callback_func
                                           = self->klass->callback_handler_func;
  do_callback_func (self, name);
}

bool game_object_get_is_collide (GameObject * self, GameObject * other) {
  GameObjectGetIsCollideFunc s_is_collide = self->klass->get_is_collide_func;
  bool ret = s_is_collide (self, other);
  return ret;
}


/******************************************************************************/

void game_object_set_free_func (GameObject * self,
                                GameObjectFreeFunc free_func) {
  self->klass->free_func = free_func;
}


void game_object_set_draw_func (GameObject * self,
                                GameObjectDrawFunc draw_func) {
  self->klass->draw_func = draw_func;
}

void game_object_set_callback_handler_func (GameObject * self,
                          GameObjectCallbackHandlerFunc callback_handler_func) {
  self->klass->callback_handler_func = callback_handler_func;
}

void game_object_set_set_callback_func (GameObject * self,
                                  GameObjectSetCallbackFunc set_callback_func) {
  self->klass->set_callback_func = set_callback_func;
}

void game_object_set_move_func (GameObject * self,
                                GameObjectMoveFunc move_func) {
  self->klass->move_func = move_func;
}

void game_object_set_set_move_delta_func (GameObject * self,
                       GameObjectSetMovementDeltaFunc set_movement_delta_func) {
  self->klass->set_movement_delta_func = set_movement_delta_func;
}

void game_object_set_get_bounding_box_func (GameObject * self,
                           GameObjectGetBoundingBoxFunc get_bounding_box_func) {
  self->klass->get_bounding_box_func = get_bounding_box_func;
}

void game_object_set_get_is_alive_func (GameObject * self,
                                   GameObjectGetIsAliveFunc get_is_alive_func) {
  self->klass->get_is_alive_func = get_is_alive_func;
}

void game_object_set_is_collide_func (GameObject * self,
                               GameObjectGetIsCollideFunc get_is_collide_func) {
  self->klass->get_is_collide_func = get_is_collide_func;
}

/**  MOOOOO!  **/