default.nut 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. function add_key(key)
  2. {
  3. local keys = state.world2_keys;
  4. keys[key] = true;
  5. update_keys();
  6. }
  7. function level2_init()
  8. {
  9. foreach(name in ["air", "earth", "wood", "fire", "water"])
  10. {
  11. add_key(name);
  12. }
  13. Tux.deactivate();
  14. Effect.sixteen_to_nine(2);
  15. Text.set_text(translate("---Insert Cutscene Here---"));
  16. Tux.walk(100);
  17. Text.fade_in(2);
  18. wait(4);
  19. Text.fade_out(1);
  20. wait(1);
  21. Effect.four_to_three();
  22. Tux.activate();
  23. }
  24. /***************************************
  25. * Handling of the "keys" in the world *
  26. ***************************************/
  27. if(! ("world2_keys" in state))
  28. state.world2_keys <- {}
  29. local keys = state.world2_keys;
  30. foreach(name in ["air", "earth", "wood", "fire", "water"])
  31. {
  32. if(! (name in keys))
  33. keys[name] <- false;
  34. }
  35. /// this function updates the key images (call this if tux has collected a key)
  36. function update_keys()
  37. {
  38. local keys = state.world2_keys;
  39. foreach(name in ["air", "earth", "wood", "fire", "water"])
  40. {
  41. key[name].set_action(keys[name] ? "display" : "outline");
  42. }
  43. }
  44. if(! ("key" in this))
  45. key <- {};
  46. local x = 10;
  47. local y = 10;
  48. foreach(name in ["air", "earth", "wood", "fire", "water"])
  49. {
  50. if(! (name in key) ) {
  51. key[name] <- FloatingImage("images/objects/keys/key_" + name + ".sprite");
  52. key[name].set_anchor_point(ANCHOR_TOP_LEFT);
  53. key[name].set_pos(x, y);
  54. key[name].set_visible(true);
  55. }
  56. x += 30;
  57. }
  58. update_keys();