?login_element?

Subversion Repositories NedoOS

Rev

Rev 957 | Blame | Compare with Previous | Last modification | View Log | Download

  1. #ifndef LEVEL2_C
  2. #define LEVEL2_C
  3. #include "gameloop.c"
  4. #include "level_fragments.h"
  5. #include "engine.c"
  6. #include "resources.h"
  7. #include "dialogs.c"
  8. #include "gameloop.c"
  9. #include "level3.c"
  10.  
  11. //static void init_level(u8 image);
  12. //static void start_level(u8 image, u8 *name);
  13. static void init_level(u8 pal, char *fn);
  14. static void start_level(u8 pal, char *fn, u8 *name);
  15.  
  16. static void process_level2();
  17. u8 l2s=0;
  18.  
  19. const u8 l2intro[] = {
  20.     PushNpc(160, -10, 0, 2, FROG, 1, 300, 0),
  21.     Nop(10),
  22.     End
  23. };
  24.  
  25. const u8 level2_bc[] = {
  26.     DoubleCaravan(FROG, 1, 20, 0),
  27.     Nop(10),
  28.     Triangle(FAIRY, 30, BONUS_CARD),
  29.     Nop(10),
  30.     MakeCorridor(FIARY2, 1, 20, 0),
  31.     Nop(10),
  32.     MakeRightFlyers(32, GHOST, 10, BONUS_CARD),
  33.     MakeLeftFlyers(120, GHOST, 10, BONUS_CARD),
  34.     Nop(20),
  35.     MakeBoomFairy(160, 30, HEALTH_CARD),
  36.     Nop(10),
  37.     MakeShootingStar(160, 90, ICEBALL, 20, 30),
  38.     Nop(10),
  39.     TriangleHalf(1, FAIRY, 30, HEALTH_CARD),
  40.     Nop(20),
  41.     DroppedEnemy(32, SHARP_ICE, 5),
  42.     DroppedEnemy(64, SHARP_ICE, 5),
  43.     DroppedEnemy(16, SHARP_ICE, 5),
  44.     DroppedEnemy(160, SHARP_ICE, 5),
  45.     JustStar(160, 120, 3),
  46.     Nop(5),
  47.     DroppedEnemy(15, SHARP_ICE, 5),
  48.     DroppedEnemy(32, SHARP_ICE, 5),
  49.     DroppedEnemy(96, SHARP_ICE, 5),
  50.     DroppedEnemy(150, SHARP_ICE, 5),
  51.     DroppedEnemy(200, SHARP_ICE, 5),
  52.     DroppedEnemy(96, SHARP_ICE, 5),
  53.     Nop(3),
  54.     JustStar(160, 120, 3),
  55.     Nop(10),
  56.     MakeShootingStar(160, 90, ICEBALL, 20, 30),
  57.     Nop(20),
  58.     FiringTrap(SHARP_ICE),
  59.     Nop(10),
  60.     DroppedEnemy(16, GHOST, 4),
  61.     DroppedEnemy(160, GHOST, 4),
  62.     DroppedEnemy(300, GHOST, 4),
  63.     DroppedEnemy(50, GHOST, 4),
  64.     DroppedEnemy(250, GHOST, 4),
  65.     Nop(13),
  66.     DroppedEnemy(16, GHOST, 4),
  67.     DroppedEnemy(160, GHOST, 4),
  68.     DroppedEnemy(300, GHOST, 4),
  69.     DroppedEnemy(50, GHOST, 4),
  70.     DroppedEnemy(250, GHOST, 4),
  71.     Nop(20),
  72.     MidBoss2(FAIRY_MB, 100),
  73.     Nop(10),
  74.     MakeShootingStar(160, 90, ICEBALL, 20, 30),
  75.     Nop(20),
  76.     DroppedEnemy(16, GHOST, 4),
  77.     DroppedEnemy(160, GHOST, 4),
  78.     DroppedEnemy(300, GHOST, 4),
  79.     DroppedEnemy(50, GHOST, 4),
  80.     DroppedEnemy(250, GHOST, 4),
  81.     Nop(10),
  82.     DroppedEnemy(16, GHOST, 4),
  83.     DroppedEnemy(160, GHOST, 4),
  84.     DroppedEnemy(300, GHOST, 4),
  85.     DroppedEnemy(50, GHOST, 4),
  86.     DroppedEnemy(250, GHOST, 4),
  87.     Nop(10),
  88.     DroppedEnemy(16, GHOST, 4),
  89.     DroppedEnemy(160, GHOST, 4),
  90.     DroppedEnemy(300, GHOST, 4),
  91.     DroppedEnemy(50, GHOST, 4),
  92.     DroppedEnemy(250, GHOST, 4),
  93.     Nop(10),
  94.     MakeLeftFlyers(120, GHOST, 10, BONUS_CARD),
  95.     Nop(20),
  96.     PushNpc(160, -10, 0, 1, CIRNO, 66, 1024, 0),
  97.     Nop(15),
  98.     End
  99. };
  100.  
  101. static void init_level2()
  102. {
  103.     level_loop = 0;
  104.     scroll_speed = 1;
  105.     process_level = process_level2;
  106.     init_vm(l2intro);
  107.     flush_sprites();
  108.     //start_level(IMG256_BG3, "Fairies Lake");
  109. music_stop();
  110. start_level(PAL256_BG3, "bg3-16.bmp", "Fairies Lake");
  111.     music_play(MUS_GLASSED);
  112.     bullet_sprite = DEFAULT_BULLET;
  113.     state = STATE_PLAY;
  114.     l2s = 0;
  115. }
  116.  
  117. static void l2b_dialog()
  118. {
  119.     init_dialog();
  120.     swap_screen();
  121.     put_dialog_string(REIMU_FACE, "CIIIIRRRNOO!\nWhat a heck you doing?!", 1);
  122. //swap_screen();
  123.     wait_for_space();
  124.     flush_sprites();
  125.     //init_level(IMG256_BG3);
  126. init_level(0/*PAL256_BG3*/, "bg3-16.bmp");
  127. unpack_pal256(PAL256_BG3, 0);
  128.     init_vm(level2_bc);
  129. }
  130.  
  131. static void l2f_dialog()
  132. {
  133.     init_dialog();
  134.     swap_screen();
  135.     put_dialog_string(CIRNO_FACE, "Okay, okay...\nYou've beaten the\nstrongest boss!", 0);
  136.     put_dialog_string(REIMU_FACE, "Hey, insect!\nHave you seen my donation\nbox?", 1);
  137.     put_dialog_string(CIRNO_FACE, "Why do I need empty box?No. I don't need it.", 0);
  138.     put_dialog_string(REIMU_FACE, "We'll talk again!\nI have no time for bugs now!", 1);
  139. //swap_screen();
  140.     wait_for_space();
  141.     init_level3();
  142. }
  143.  
  144. static void process_boss2()
  145. {
  146.     u8 c;
  147.     Npc *boss;
  148.  
  149.     if (scroll_pos < 2)
  150.         scroll_speed = 0;
  151.  
  152.     boss = find_npc_by_type(BOSS_TYPE);
  153.  
  154.     if (boss)
  155.     {
  156.         if (boss->sprite.x <= 20 || boss->sprite.x >= 280)
  157.         {
  158.             boss->sprite.dx = -boss->sprite.dx;
  159.             boss->sprite.x += boss->sprite.dx;
  160.         }
  161.         if (boss->sprite.y <= 20 || boss->sprite.y >= 120)
  162.         {
  163.             boss->sprite.dy = -boss->sprite.dy;
  164.             boss->sprite.y += boss->sprite.dy;
  165.         }
  166.     }
  167.     else
  168.     {
  169.         l2f_dialog();
  170.         return;
  171.     }
  172.    
  173.     switch (level_loop)
  174.     {
  175.         boss_shoot1(1, boss->sprite.x + 16, boss->sprite.y + 16);
  176.         boss_attack_drop_npc(20, ICE);
  177.     case 26:
  178.         boss->sprite.dx = 1;
  179.         boss->sprite.dy = 1;
  180.         break;
  181.         boss_shoot1(30, boss->sprite.x + 16, boss->sprite.y + 16);
  182.         boss_attack_drop_npc(50, FROG);
  183.  
  184.         just_star(60, boss->sprite.x + 16, boss->sprite.y + 16);
  185.         just_star(61, boss->sprite.x + 16, boss->sprite.y + 16);
  186.         just_star(62, boss->sprite.x + 16, boss->sprite.y + 16);
  187.  
  188.         just_star(80, boss->sprite.x + 16, boss->sprite.y + 16);
  189.         just_star(82, boss->sprite.x + 16, boss->sprite.y + 16);
  190.         just_star(84, boss->sprite.x + 16, boss->sprite.y + 16);
  191.  
  192.     case 100:
  193.         for (c = 0; c < 5; c++)
  194.             push_bonus(BONUS_CARD, boss->sprite.x + 16, boss->sprite.y + 16, 3 - (c * 2), 2);
  195.         level_loop = 1;
  196.     }
  197. }
  198.  
  199. static void l2m_dialog()
  200. {
  201. music_stop();
  202. init_level(PAL256_BG4, "bg4-16.bmp");
  203.     music_play(MUS_CIRNO); //TODO почему где-то здесь приостанавливается музыка?
  204.     init_dialog();
  205.     swap_screen();
  206.     put_dialog_string(REIMU_FACE, "Hey, BUG!\nSTOP! I SAID STOP!", 1);
  207.     put_dialog_string(CIRNO_FACE, "Whaat?\nYou are talking with\nthe final boss!", 0);
  208.     put_dialog_string(REIMU_FACE, "You are the second...\nIf Marisa was the first.", 1);
  209.     put_dialog_string(CIRNO_FACE, "It's your final!", 0);
  210. //swap_screen();
  211.     wait_for_space();
  212.     flush_sprites();
  213.     //init_level(IMG256_BG4);
  214. unpack_pal256(PAL256_BG4, 0);
  215.  
  216.     level_loop = 0;
  217.     bullet_sprite = CIRNO_BULLET;
  218.     process_level = process_boss2;
  219.     scroll_pos = 192;
  220.     push_npc(144, 20, 0, 0, CIRNO, 255, 1500, 0);
  221. }
  222.  
  223.  
  224. static void process_level2()
  225. {
  226.     if (executing) {
  227.         vm_step();
  228.     } else {
  229.         switch (l2s) {
  230.             case 0:
  231.                 l2s ++;
  232.                 l2b_dialog();
  233.                 break;
  234.             case 1:
  235.                 l2m_dialog();
  236.                 break;
  237.         }
  238.     }
  239. }
  240.  
  241. #endif