Bugfix: Möglicher segfault beim Sterben.
[hackover2013-badge-firmware.git] / badge / jumpnrun / items.h
1 #ifndef INCLUDED_JUMPNRUN_ITEMS_H
2 #define INCLUDED_JUMPNRUN_ITEMS_H
3
4 #include "../ui/sprite.h"
5 #include "../util/rectangle.h"
6
7 struct jumpnrun_game_state;
8 struct jumpnrun_level;
9 struct jumpnrun_item;
10
11 enum {
12 JUMPNRUN_ITEM_COLLECTED = 1
13 };
14
15 typedef struct jumpnrun_item_type {
16 badge_sprite sprite;
17 void (*on_collect)(struct jumpnrun_item *item,
18 struct jumpnrun_game_state *state,
19 struct jumpnrun_level *lv);
20 } jumpnrun_item_type;
21
22 typedef struct jumpnrun_item {
23 vec2d pos;
24 uint8_t flags;
25 jumpnrun_item_type const *type;
26 } jumpnrun_item;
27
28 static inline rectangle rect_from_item(jumpnrun_item const *item) {
29 rectangle r = { item->pos, { FIXED_POINT(item->type->sprite.width, 0), FIXED_POINT(item->type->sprite.height, 0) } };
30 return r;
31 }
32
33 /************************************/
34
35 enum {
36 JUMPNRUN_ITEM_TYPE_DOCUMENT,
37 JUMPNRUN_ITEM_TYPE_CHECKPOINT,
38 JUMPNRUN_ITEM_TYPE_KEY,
39 JUMPNRUN_ITEM_TYPE_ENCRYPTED_DOCUMENT,
40
41 JUMPNRUN_ITEM_TYPE_COUNT
42 };
43
44 extern jumpnrun_item_type const jumpnrun_item_type_data[JUMPNRUN_ITEM_TYPE_COUNT];
45
46 #endif
This page took 0.050326 seconds and 5 git commands to generate.