};
}
+static void on_collect_key(jumpnrun_item *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv) {
+ (void) lv;
+ self->flags |= JUMPNRUN_ITEM_COLLECTED;
+ ++state->keys;
+}
+
+static void on_collect_encrypted(jumpnrun_item *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv) {
+ if(state->keys != 0) {
+ on_collect_win(self, state, lv);
+ }
+}
+
jumpnrun_item_type const jumpnrun_item_type_data[JUMPNRUN_ITEM_TYPE_COUNT] = {
{ { 6, 7, (uint8_t const *) "\x7c\x61\xb5\x1a\xfc\x03" }, on_collect_win },
- { { 9, 12, (uint8_t const *) "\xff\x1f\x04\x49\x10\x05\x49\x50\x04\x51\x10\x04\x7f" }, on_collect_checkpoint }
+ { { 9, 12, (uint8_t const *) "\xff\x1f\x04\x49\x10\x05\x49\x50\x04\x51\x10\x04\x7f" }, on_collect_checkpoint },
+ { { 3, 7, (uint8_t const *) "\xa7\xfe\x01" }, on_collect_key },
+ { { 9, 10, (uint8_t const *) "\xfc\x0b\x98\x65\xbd\x1d\x06\x98\x6a\x80\xff\x03" }, on_collect_encrypted }
};
enum {
JUMPNRUN_ITEM_TYPE_DOCUMENT,
JUMPNRUN_ITEM_TYPE_CHECKPOINT,
+ JUMPNRUN_ITEM_TYPE_KEY,
+ JUMPNRUN_ITEM_TYPE_ENCRYPTED_DOCUMENT,
JUMPNRUN_ITEM_TYPE_COUNT
};
uint8_t status;
int left;
uint8_t lives;
+ uint8_t keys;
jumpnrun_shot shots[JUMPNRUN_MAX_SHOTS];
} jumpnrun_game_state;
memset(dest, 0, sizeof(*dest));
dest->type = &jumpnrun_item_type_data[thing.type];
- dest->pos.x = FIXED_POINT( thing.x * JUMPNRUN_TILE_PIXEL_WIDTH , 0);
- dest->pos.y = FIXED_POINT((thing.y + 1) * JUMPNRUN_TILE_PIXEL_WIDTH - dest->type->sprite.height, 0);
+
+ uint8_t xoff = (JUMPNRUN_TILE_PIXEL_WIDTH - (dest->type->sprite.width % JUMPNRUN_TILE_PIXEL_WIDTH)) / 2;
+ uint8_t yoff = thing.type != JUMPNRUN_ITEM_TYPE_CHECKPOINT ? 1 : 0; // HACK: spezielle Ausnahme
+
+ dest->pos.x = FIXED_POINT( thing.x * JUMPNRUN_TILE_PIXEL_WIDTH + xoff, 0);
+ dest->pos.y = FIXED_POINT((thing.y + 1) * JUMPNRUN_TILE_PIXEL_WIDTH - dest->type->sprite.height - yoff, 0);
}
static void jumpnrun_level_make_enemy(jumpnrun_enemy *dest, level_thing thing) {
c ##### # ###
? #?#?# 01 01 #?# # ## ? ? ? # ## # # ## # ##?# ###### V # ###
01 23 23 @ R R ## ## ### ## ####### # #####
- 01 23 23 23 G M ### ### #### ### 01 01 ######## d # #####
- P S 23 23B 23 H H 23 C C S S C C H H #### #### ##### #### 23 H H 23######### # #####
-#################################################################### ############### ################################################################ ############################################^^^######
+ 01 23 23 23 G M ### ### #### ### 01 01 ######## # #####
+ P S 23 23B 23 H H 23 C C S S C C H H #### #### ##### #### 23 H H 23######### d # #####k e
+#################################################################### ############### ################################################################ ############################################^^^###### ###
[tiles]
0 tube_top_left
[items]
d doc
c checkpoint
+k key
+e doc_encrypted
[enemies]
C cat
;
items.add
- ("doc" , JUMPNRUN_ITEM_TYPE_DOCUMENT )
- ("checkpoint", JUMPNRUN_ITEM_TYPE_CHECKPOINT)
+ ("doc" , JUMPNRUN_ITEM_TYPE_DOCUMENT )
+ ("checkpoint" , JUMPNRUN_ITEM_TYPE_CHECKPOINT )
+ ("key" , JUMPNRUN_ITEM_TYPE_KEY )
+ ("doc_encrypted", JUMPNRUN_ITEM_TYPE_ENCRYPTED_DOCUMENT)
;
enemies.add