vanity-convert: add Makefile
[hackover2013-badge-firmware.git] / badge / jumpnrun / items.c
1 #include "items.h"
2 #include "jumpnrun.h"
3 #include "game_state.h"
4
5 static void on_collect_win(jumpnrun_item *self,
6 jumpnrun_game_state *state,
7 jumpnrun_level *lv) {
8 (void) lv;
9 self->flags |= JUMPNRUN_ITEM_COLLECTED;
10 state->flags |= JUMPNRUN_STATE_WON;
11 }
12
13 static void on_collect_checkpoint(jumpnrun_item *self,
14 jumpnrun_game_state *state,
15 jumpnrun_level *lv) {
16 (void) state;
17 self->flags |= JUMPNRUN_ITEM_COLLECTED;
18 lv->start_pos = (vec2d) { self->pos.x,
19 fixed_point_sub(fixed_point_add(self->pos.y, FIXED_INT(self->type->sprite.height)), jumpnrun_player_extents().y)
20 };
21 }
22
23 static void on_collect_key(jumpnrun_item *self,
24 jumpnrun_game_state *state,
25 jumpnrun_level *lv) {
26 (void) lv;
27 self->flags |= JUMPNRUN_ITEM_COLLECTED;
28 ++state->player.keys;
29 }
30
31 static void on_collect_encrypted(jumpnrun_item *self,
32 jumpnrun_game_state *state,
33 jumpnrun_level *lv) {
34 if(state->player.keys != 0) {
35 on_collect_win(self, state, lv);
36 }
37 }
38
39 jumpnrun_item_type const jumpnrun_item_type_data[JUMPNRUN_ITEM_TYPE_COUNT] = {
40 { { 6, 7, (uint8_t const *) "\x7c\x61\xb5\x1a\xfc\x03" }, on_collect_win },
41 { { 9, 12, (uint8_t const *) "\xff\x1f\x04\x49\x10\x05\x49\x50\x04\x51\x10\x04\x7f" }, on_collect_checkpoint },
42 { { 3, 7, (uint8_t const *) "\xa7\xfe\x01" }, on_collect_key },
43 { { 9, 10, (uint8_t const *) "\xfc\x0b\x98\x65\xbd\x1d\x06\x98\x6a\x80\xff\x03" }, on_collect_encrypted }
44 };
This page took 0.047851 seconds and 5 git commands to generate.