intro.nut 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. function initialize()
  2. {
  3. Tux.deactivate();
  4. Tux.set_visible(false);
  5. Tux.add_bonus("grow");
  6. RADIO.set_action("quiet");
  7. PENNY.set_action("stand-left");
  8. NOLOK.set_visible(false);
  9. Effect.sixteen_to_nine(0);
  10. Effect.fade_in(2);
  11. Camera.scroll_to(0, 913, 15);
  12. Tux.walk(200);
  13. wait(2);
  14. Tux.set_visible(true);
  15. wait(4);
  16. Tux.walk(0);
  17. wait(11);
  18. Tux.walk(200);
  19. Camera.scroll_to(2808, 913, 18);
  20. wait(7.3);
  21. logo.fade_in(0.2);
  22. wait(5.5);
  23. logo.fade_out(1.2);
  24. wait(5);
  25. }
  26. function logo_in()
  27. {
  28. }
  29. function intro_text()
  30. {
  31. }
  32. function rap_scene()
  33. {
  34. Tux.walk(0);
  35. Tux.set_visible(true);
  36. wait(7);
  37. Text.set_text(_("Somewhere at the shores of Antarctica..."));
  38. Text.fade_in(1);
  39. wait(3);
  40. Text.fade_out(1);
  41. wait(2);
  42. Text.set_text(_("Tux and Penny had a nice picnic\non the ice fields."));
  43. Text.fade_in(1);
  44. wait(3);
  45. Text.fade_out(1);
  46. wait(1.5);
  47. //begin conversation and Tux rap
  48. play_sound("speech/tux_hello.ogg"); // 3.1 seconds
  49. wait(3.5);
  50. play_sound("speech/penny_runt_01.ogg"); // 1.2 seconds
  51. wait(1.5);
  52. play_sound("speech/tux_murp_01.ogg"); // 1.5 seconds
  53. wait(1.5);
  54. RADIO.set_action("loud");
  55. play_sound("speech/tux_rap.ogg"); // 24.6 seconds
  56. local t = ::newthread(shake_bush_thread);
  57. t.call(this); // Nolok's waiting...
  58. // meanwhile... Tux dances!
  59. // TODO: add some more dance moves besides jumps, ducks, & flips
  60. // and fill in the parts where he just stands still
  61. wait(6); // music intro - 6 seconds
  62. Tux.do_duck();
  63. Tux.set_dir(false);
  64. wait(0.40625); // all times rounded to nearest 1/64 of a second
  65. Tux.do_standup();
  66. Tux.kick(); // 0.3 seconds
  67. wait(0.40625);
  68. Tux.set_dir(true);
  69. wait(0.203125);
  70. Tux.set_dir(false);
  71. wait(0.203125);
  72. Tux.set_dir(true);
  73. wait(0.09375);
  74. Tux.do_duck(); // t=7.3
  75. wait(0.5);
  76. Tux.set_dir(false);
  77. wait(0.203125);
  78. Tux.set_dir(true);
  79. wait(0.203125);
  80. Tux.set_dir(false);
  81. wait(0.203125);
  82. Tux.set_dir(true);
  83. wait(0.203125);
  84. Tux.set_dir(false);
  85. wait(0.203125);
  86. Tux.set_dir(true);
  87. Tux.do_standup(); // t=8.8
  88. wait(0.203125);
  89. Tux.set_dir(false);
  90. wait(0.203125);
  91. Tux.kick();
  92. wait(0.40625);
  93. Tux.set_dir(true);
  94. Tux.do_jump(-300);
  95. wait(0.703125);
  96. Tux.do_duck(); // t=10.7
  97. wait(0.296875);
  98. Tux.set_dir(false);
  99. wait(0.59375);
  100. Tux.set_dir(true);
  101. wait(0.703125);
  102. Tux.do_standup(); // t=12.3
  103. Tux.kick();
  104. wait(0.5);
  105. Tux.do_duck();
  106. wait(0.5);
  107. Tux.do_backflip(); // t=13.3
  108. wait(79.0/64);
  109. Tux.walk(200);
  110. wait(38.0/64);
  111. Tux.walk(0);
  112. wait(184.0/64);
  113. Tux.set_dir(false); //t=18.0
  114. wait(0.3)
  115. Tux.kick();
  116. wait(0.40625);
  117. Tux.do_duck();
  118. Tux.set_dir(true);
  119. wait(0.296875);
  120. Tux.set_dir(false); // t=19.0
  121. wait(0.5);
  122. Tux.do_standup();
  123. Tux.do_jump(-800);
  124. wait(1.5);
  125. Tux.kick(); // t=21
  126. wait(0.5);
  127. Tux.do_duck();
  128. wait(0.5);
  129. Tux.do_jump(-400);
  130. wait(1.0);
  131. Tux.do_standup();
  132. wait(0.796875);
  133. Tux.set_dir(true); //t=23.8 - Tux sees Nolok!
  134. Tux.do_jump(-520);
  135. wait(1.5);
  136. // we have to activate Tux to hurt him
  137. Tux.activate();
  138. Tux.kill(false);
  139. Tux.deactivate();
  140. wait(3);
  141. // song is done
  142. // darkness
  143. NOLOK.set_visible(false);
  144. NOLOK.set_solid(false);
  145. PENNY.set_visible(false);
  146. PENNY.set_solid(false);
  147. RADIO.set_action("quiet");
  148. RADIO.set_solid(false);
  149. //wake up, Tux...
  150. Effect.fade_in(3);
  151. play_sound("speech/tux_upset.ogg"); // 11 seconds
  152. wait(2.4);
  153. Tux.do_jump(-150);
  154. wait(1.5); // t=2.4
  155. Tux.set_dir(false);
  156. Tux.walk(-200);
  157. Text.set_text(_("Oh no! Nolok has kidnapped Penny!")); // t=3.9
  158. Text.fade_in(1);
  159. wait(0.1);
  160. Tux.walk(0);
  161. wait(1.4);
  162. Tux.set_dir(true);
  163. Tux.walk(200);
  164. wait(0.1);
  165. Tux.walk(0);
  166. wait(1.4); // t=4.4
  167. Text.fade_out(1);
  168. wait(1.7);
  169. Tux.do_jump(-150);
  170. wait(1.5); // t=6.9
  171. Tux.walk(50);
  172. Tux.walk(100);
  173. Tux.walk(150);
  174. Tux.walk(250);
  175. Tux.walk(300);
  176. Text.set_text(_("And now it is up to Tux to save her!")); // t=8.4
  177. Text.fade_in(1);
  178. wait(3);
  179. Text.fade_out(1);
  180. wait(5);
  181. }
  182. function shake_bush()
  183. {
  184. //play_sound("sounds/rustle.wav");
  185. local bushx = BUSH.get_pos_x();
  186. local bushy = BUSH.get_pos_y();
  187. for(local i = 0; i < 21; ++i) {
  188. BUSH.set_pos(bushx + ( rand() % 6 ) - 3, bushy);
  189. wait(0.046875);
  190. }
  191. wait(0.015625);
  192. }
  193. function shake_bush_thread(table)
  194. {
  195. table.wait(8);
  196. table.shake_bush(); // each bush shake lasts 1 second
  197. table.wait(5);
  198. table.shake_bush();
  199. table.wait(3);
  200. table.shake_bush();
  201. Text.set_text(_("Suddenly, Nolok jumped out from behind\nan ice bush!"));
  202. Text.fade_in(0.5);
  203. table.wait(2);
  204. Text.fade_out(0.5);
  205. table.shake_bush();
  206. table.shake_bush(); // total 23 seconds
  207. //enter Nolok
  208. table.NOLOK.set_velocity(-220, 600);
  209. table.NOLOK.set_visible(true);
  210. table.Effect.fade_out(0.5);
  211. }
  212. function end_level()
  213. {
  214. //end intro sequence
  215. Effect.fade_out(2);
  216. wait(2.1);
  217. Level.finish(true);
  218. }
  219. state_idx <- 0;
  220. states <- { init=0, start=1, logo_in=2, intro_text=3, rap_scene=4, end_level=5};
  221. function trigger_state(state) {
  222. local idx = states[state];
  223. if(!idx || idx <= state_idx)
  224. return;
  225. state_idx = idx;
  226. switch(state) {
  227. case "start":
  228. initialize();
  229. break;
  230. case "logo_in":
  231. logo_in();
  232. break;
  233. case "intro_text":
  234. intro_text();
  235. break;
  236. case "rap_scene":
  237. rap_scene();
  238. break;
  239. case "end_level":
  240. end_level();
  241. break;
  242. }
  243. }