Schlüssel, verschlüsselte Dokumente.
authorWintermute <wintermute@hannover.ccc.de>
Sat, 19 Oct 2013 14:12:53 +0000 (16:12 +0200)
committerWintermute <wintermute@hannover.ccc.de>
Sat, 19 Oct 2013 14:12:53 +0000 (16:12 +0200)
badge/jumpnrun/items.c
badge/jumpnrun/items.h
badge/jumpnrun/jumpnrun.h
badge/jumpnrun/level_load.c
badge/jumpnrun/smb.lv
mock/tools/level-converter.cc

index cc296c3..d4fb281 100644 (file)
@@ -19,7 +19,25 @@ static void on_collect_checkpoint(jumpnrun_item       *self,
   };
 }
 
+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 }
 };
index 2ee7a94..e939e68 100644 (file)
@@ -35,6 +35,8 @@ static inline rectangle rect_from_item(jumpnrun_item const *item) {
 enum {
   JUMPNRUN_ITEM_TYPE_DOCUMENT,
   JUMPNRUN_ITEM_TYPE_CHECKPOINT,
+  JUMPNRUN_ITEM_TYPE_KEY,
+  JUMPNRUN_ITEM_TYPE_ENCRYPTED_DOCUMENT,
 
   JUMPNRUN_ITEM_TYPE_COUNT
 };
index c6613f5..899eebc 100644 (file)
@@ -44,6 +44,7 @@ typedef struct jumpnrun_game_state {
   uint8_t status;
   int     left;
   uint8_t lives;
+  uint8_t keys;
 
   jumpnrun_shot shots[JUMPNRUN_MAX_SHOTS];
 } jumpnrun_game_state;
index dc009b9..21e2541 100644 (file)
@@ -38,8 +38,12 @@ static void jumpnrun_level_make_item(jumpnrun_item *dest, level_thing thing) {
   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) {
index 59c765b..b686851 100644 (file)
@@ -8,9 +8,9 @@
                                                                                                    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
@@ -27,6 +27,8 @@ v spike_down
 [items]
 d doc
 c checkpoint
+k key
+e doc_encrypted
 
 [enemies]
 C cat
index cdd4662..54be8f7 100644 (file)
@@ -40,8 +40,10 @@ namespace jnrcpp {
         ;
 
       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
This page took 0.038959 seconds and 4 git commands to generate.