intro.nut 6.0 KB

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