e3ec741dfd928f4cd387be8e60eab8ef500e5beb
[supertux.git] / data / levels / world2 / default.nut
1 function add_key(key)
2 {
3   local keys = state.world2_keys;
4   keys[key] = true;
5   update_keys();
6   end_level();
7 }
8
9 function level2_init()
10 {
11   add_key("air");
12   add_key("earth");
13   add_key("wood");
14   add_key("fire");
15   add_key("water");
16   Tux.deactivate();
17   Effect.sixteen_to_nine(2);
18   Text.set_text(translate("---Insert Cutscene Here---"));
19   Tux.walk(100);
20   Text.fade_in(2);
21   wait(4);
22   Text.fade_out(1);
23   wait(1);
24   Effect.four_to_three();
25   Tux.activate();
26 }
27
28 /***************************************
29  * Handling of the "keys" in the world *
30  ***************************************/
31 if(! ("world2_keys" in state))
32         state.world2_keys <- {}
33         
34 local keys = state.world2_keys;
35 if(! ("air" in keys))
36         keys.air <- false;
37 if(! ("earth" in keys))
38         keys.earth <- false;
39 if(! ("wood" in keys))
40         keys.wood <- false;
41 if(! ("fire" in keys))
42         keys.fire <- false;
43 if(! ("water" in keys))
44         keys.water <- false;
45
46 /// this function updates the key images (call this if tux has collected a key)
47 function update_keys()
48 {
49         local keys = state.world2_keys;
50         key_air.set_action(keys.air ? "display" : "outline");
51         key_earth.set_action(keys.earth ? "display" : "outline");
52         key_wood.set_action(keys.wood ? "display" : "outline");
53         key_fire.set_action(keys.fire ? "display" : "outline");
54         key_water.set_action(keys.water ? "display" : "outline");
55 }
56
57 local x = 10;
58 local y = 10;
59
60
61 key_air <- FloatingImage("images/objects/keys/key_air.sprite");
62 key_air.set_anchor_point(ANCHOR_TOP_LEFT);
63 key_air.set_pos(x, y);
64 key_air.set_visible(true);
65 x += 30;
66
67 key_earth <- FloatingImage("images/objects/keys/key_earth.sprite");
68 key_earth.set_anchor_point(ANCHOR_TOP_LEFT);
69 key_earth.set_pos(x, y);
70 key_earth.set_visible(true);
71 x += 30;
72
73 key_wood <- FloatingImage("images/objects/keys/key_wood.sprite");
74 key_wood.set_anchor_point(ANCHOR_TOP_LEFT);
75 key_wood.set_pos(x, y);
76 key_wood.set_visible(true);
77 x += 30;
78
79 key_fire <- FloatingImage("images/objects/keys/key_fire.sprite");
80 key_fire.set_anchor_point(ANCHOR_TOP_LEFT);
81 key_fire.set_pos(x, y);
82 key_fire.set_visible(true);
83 x += 30;
84
85 key_water <- FloatingImage("images/objects/keys/key_water.sprite");
86 key_water.set_anchor_point(ANCHOR_TOP_LEFT);
87 key_water.set_pos(x, y);
88 key_water.set_visible(true);
89 x += 30;
90
91 update_keys();