/+junk/c_sdl_joypad_ducktape

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/c_sdl_joypad_ducktape

« back to all changes in this revision

Viewing changes to src/GameObject.h

  • Committer: Gustav Hartvigsson
  • Date: 2014-08-31 20:00:04 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20140831200004-yxmcbn8ilq7tl34m
* Starded working on making GameObject compile with the new "base class".

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * :indentSize=2:tabSize=2:noTabs=true:
4
4
 */
5
5
 
6
 
#ifndef __H_GAME_OBJECT__
7
 
#define __H_GAME_OBJECT__
8
6
 
9
7
/*
10
8
 * This file, as the rest of the project is under MIT license.
13
11
 * Author Gustav Hartvigsson <gustav.hartvigsson _at_ gmail.com> 2014
14
12
 */
15
13
 
 
14
#ifndef __H_GAME_OBJECT__
 
15
#define __H_GAME_OBJECT__
 
16
 
16
17
#include <SDL2/SDL.h>
17
18
#include <stdbool.h>
18
19
 
 
20
#include "defs.h"
19
21
#include "Object.h"
20
22
 
 
23
/** @file
 
24
 * GameObject is the base class for game objects, it provides a set
 
25
 * of methods that make it easy to handle drawing and moving of objects in
 
26
 * the game.
 
27
 *
 
28
 * All game objects that require drawing to the screen should be a "subclass"
 
29
 * of this.
 
30
 *
 
31
 * @warning A GameObject contains no data, only the primaries for handling
 
32
 *          game objects.
 
33
 */
 
34
 
 
35
BEGIN_DECLS
 
36
 
 
37
#ifndef DOXYGEN_SHOULD_SKIP_THIS
21
38
typedef struct GameObject GameObject;
 
39
typedef struct GameObjectClass GameObjectClass;
 
40
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
22
41
 
23
42
/******************************************************************************
24
43
 * Function pointer declarations.
50
69
 * Object declaration.
51
70
 *****************************************************************************/
52
71
 
 
72
/**
 
73
 * The class for the GameObject.
 
74
 */
53
75
typedef struct GameObjectClass {
 
76
  /** The Parent Class */
54
77
  ObjectClass                            parent;
 
78
  /** The callback handler */
55
79
  GameObjectCallbackHandlerFunc          callback_handler_func;
 
80
  /** Method used to set a callback on a GameObject */
56
81
  GameObjectSetCallbackFunc              set_callback_func;
 
82
  /** The method to be run when <tt>game_object_move ()</tt> is run. */
57
83
  GameObjectMoveFunc                     move_func;
 
84
  /** The method that handles how objects move over time */
58
85
  GameObjectSetMovementDeltaFunc         set_movement_delta_func;
 
86
  /** The method that returns the bounding box of an object, if available. */
59
87
  GameObjectGetBoundingBoxFunc           get_bounding_box_func;
 
88
  /** Gets weather a game object is "alive" or "dead" */
60
89
  GameObjectGetIsAliveFunc               get_is_alive_func;
 
90
  /** The method that determines if a Game Object is colliding with an other
 
91
   * game object or not.
 
92
   */
61
93
  GameObjectGetIsCollideFunc             get_is_collide_func;
62
94
} GameObjectClass;
63
95
 
64
 
 
 
96
/**
 
97
 * Instance of a GameObject.
 
98
 */
65
99
typedef struct GameObject {
66
100
  Object parent;
67
 
  
68
 
  void * priv; /**< The private data. */
69
101
} GameObject;
70
102
 
71
103
 
73
105
/******************************************************************************
74
106
 * Game Object base functions.
75
107
 *****************************************************************************/
76
 
void game_object_free (GameObject * self);
77
108
 
78
 
GameObjectClass * game_object_get_class (GameObject * self);
 
109
/**
 
110
 * Initialises a GameObject.
 
111
 *
 
112
 * This should be run on every "sub instance" of a GameObject before the
 
113
 * sub instance has its own methods and data set.
 
114
 */
 
115
void game_object_initialize (GameObject *               self,
 
116
                             FreeFunc                   free_func,
 
117
                             ToStringFunc               to_string_func,
 
118
                             GameObjectCallbackFunc     callback_handler_func,
 
119
                             GameObjectSetCallbackFunc  set_callback_func,
 
120
                             GameObjectMoveFunc         move_func,
 
121
                             GameObjectSetMovementDeltaFunc
 
122
                                                        set_movement_delta_func,
 
123
                             GameObjectGetBoundingBoxFunc
 
124
                                                        get_bounding_box_func,
 
125
                             GameObjectGetIsAliveFunc   get_is_alive_func,
 
126
                             GameObjectGetIsCollideFunc get_is_collide_func
 
127
                             );
79
128
 
80
129
void game_object_set_class (GameObject * self, GameObjectClass * klass);
81
130
 
122
171
 
123
172
void game_object_set_is_collide_func (GameObject * self,
124
173
                                   GameObjectGetIsCollideFunc is_collide_func);
 
174
 
 
175
END_DECLS
 
176
 
125
177
#endif /* __H_GAME_OBJECT__ */