65536 is too big
[supertux.git] / data / levels / world2 / default.nut
index 091e665..de5ef1b 100644 (file)
@@ -1,15 +1,17 @@
-
-
-function get_gold_key()
+function add_key(key)
 {
-  add_key(KEY_GOLD);
-  end_level();
+  local keys = state.world2_keys;
+  keys[key] = true;
+  update_keys();
 }
 
 function level2_init()
 {
-  add_key(KEY_BRASS);
-  add_key(KEY_IRON);
+  add_key("air");
+  add_key("earth");
+  add_key("wood");
+  add_key("fire");
+  add_key("water");
   Tux.deactivate();
   Effect.sixteen_to_nine(2);
   Text.set_text(translate("---Insert Cutscene Here---"));
@@ -22,30 +24,67 @@ function level2_init()
   Tux.activate();
 }
 
-// Initialize keys
+/***************************************
+ * Handling of the "keys" in the world *
+ ***************************************/
 if(! ("world2_keys" in state))
        state.world2_keys <- {}
        
 local keys = state.world2_keys;
-if(! ("brass" in keys))
-       keys.brass <- false;
-if(! ("gold" in keys))
-       keys.gold <- false;
+if(! ("air" in keys))
+       keys.air <- false;
+if(! ("earth" in keys))
+       keys.earth <- false;
+if(! ("wood" in keys))
+       keys.wood <- false;
+if(! ("fire" in keys))
+       keys.fire <- false;
+if(! ("water" in keys))
+       keys.water <- false;
+
+/// this function updates the key images (call this if tux has collected a key)
+function update_keys()
+{
+       local keys = state.world2_keys;
+       key_air.set_action(keys.air ? "display" : "outline");
+       key_earth.set_action(keys.earth ? "display" : "outline");
+       key_wood.set_action(keys.wood ? "display" : "outline");
+       key_fire.set_action(keys.fire ? "display" : "outline");
+       key_water.set_action(keys.water ? "display" : "outline");
+}
 
 local x = 10;
 local y = 10;
 
-key_brass <- FloatingImage("images/objects/keys/key_brass.sprite");
-key_brass.set_anchor_point(ANCHOR_TOPLEFT);
-key_brass.set_pos(x, y);
-key_brass.set_visible(true);
-key_brass.set_action(keys.brass ? "display" : "outline");
+
+key_air <- FloatingImage("images/objects/keys/key_air.sprite");
+key_air.set_anchor_point(ANCHOR_TOP_LEFT);
+key_air.set_pos(x, y);
+key_air.set_visible(true);
+x += 30;
+
+key_earth <- FloatingImage("images/objects/keys/key_earth.sprite");
+key_earth.set_anchor_point(ANCHOR_TOP_LEFT);
+key_earth.set_pos(x, y);
+key_earth.set_visible(true);
+x += 30;
+
+key_wood <- FloatingImage("images/objects/keys/key_wood.sprite");
+key_wood.set_anchor_point(ANCHOR_TOP_LEFT);
+key_wood.set_pos(x, y);
+key_wood.set_visible(true);
+x += 30;
+
+key_fire <- FloatingImage("images/objects/keys/key_fire.sprite");
+key_fire.set_anchor_point(ANCHOR_TOP_LEFT);
+key_fire.set_pos(x, y);
+key_fire.set_visible(true);
 x += 30;
 
-key_gold <- FloatingImage("images/objects/keys/key_gold.sprite");
-key_gold.set_anchor_point(ANCHOR_TOPLEFT);
-key_gold.set_pos(x, y);
-key_gold.set_visible(true);
-key_gold.set_action(keys.gold ? "display" : "outline");
+key_water <- FloatingImage("images/objects/keys/key_water.sprite");
+key_water.set_anchor_point(ANCHOR_TOP_LEFT);
+key_water.set_pos(x, y);
+key_water.set_visible(true);
 x += 30;
 
+update_keys();