ZoriaRPG

Arkanoid (backup, alpha 0.9)

Aug 15th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 18.04 KB | None | 0 0
  1. import "std.zh"
  2.  
  3. //Arkanoid script
  4. //v0.9
  5. //14th August, 2018
  6.  
  7. const int FFC_VAUS = 1;
  8. const int CMB_VAUS_EXTENDED = 1528;
  9. const int CMB_VAUS = 1524;
  10. const int CMB_VAUS_DEAD = 1520;
  11.  
  12. const int MID_STAGE_START = 4;
  13.  
  14. int quit;
  15. int caught;
  16. int frame;
  17. bool newstage = true;
  18.  
  19. int ball_x;
  20. int ball_y;
  21. int ball_dir;
  22. int ball_angle;
  23. int ball_speed;
  24. int ball_vx;
  25. int ball_vy;
  26. int paddle_x;
  27. int paddle_y;
  28. int paddle_width = 16;
  29. int paddle_speed = 2;
  30. int extended;
  31.  
  32. //animation
  33. int death_frame;
  34.  
  35. int templayer[4];
  36.  
  37. int input_accel; //pressing left and right for multiple frames increases this
  38. int frames_pressed[18];
  39.  
  40. //ffc paddle;
  41.  
  42. int hit_zones[5]; //angle offsets for where the ball strikes the paddle
  43.  
  44. const int WALL_LEFT = 24;
  45. const int WALL_TOP = 8; //Mix Ball Y
  46. const int WALL_RIGHT = 232;
  47.  
  48. const int BALL_MIN_Y = 9; //ceiling +1
  49. const int BALL_MAX_Y = 145; //one pixel under paddle top
  50. const int BALL_MIN_X = 25; //left wall +1
  51. const int BALL_MAX_X = 229; //right wall -1
  52.  
  53.  
  54.  
  55. const int START_PADDLE_X = 62;
  56. const int START_PADDLE_Y = 160;
  57. const int START_PADDLE_WIDTH = 32;
  58. const int START_PADDLE_HEIGHT = 8;
  59. const int BALL_WIDTH = 4;
  60. const int BALL_HEIGHT = 4;
  61. const int START_BALL_X = 98; //(START_PADDLE_X + 36);
  62. const int START_BALL_Y = 156; //START_PADDLE_Y - 4;
  63. const int START_BALL_DIR = 5; //DIR_UPRIGHT;
  64. const int START_BALL_RADS = 220; //angle in radians
  65. const int START_BALL_SPEED = 45;
  66. const int START_BALL_VX = 0;
  67. const int START_BALL_VY = 0;
  68.  
  69. const int PADDLE_MIN_X = 25;
  70. const int PADDLE_MAX_X = 200; //WALL_RIGHT -32; //This one varies as the paddle width may change.
  71. const int PADDLE_MAX_X_EXTENDED = 184; //WALL_RIGHT - 48; //This one varies as the paddle width may change.
  72. const int PADDLE_MIN_X_EXTENDED = 25;
  73.  
  74. const int _MOUSE_X = 0;
  75. const int _MOUSE_Y = 1;
  76. const int _MOUSE_LCLICK = 2;
  77.  
  78. //const float ACCEL_FACTOR = 0.25;
  79.  
  80. const int FRAMES_PER_MOVEMENT = 10;
  81. int USE_ACCEL = 0; //Do we accelerate KB/JP input?
  82. int USE_MOUSE = 0; //Are we using the mouse?
  83.  
  84.  
  85. /*
  86. const int CB_UP     = 0;
  87. const int CB_DOWN   = 1;
  88. const int CB_LEFT   = 2;
  89. const int CB_RIGHT  = 3;
  90. const int CB_A      = 4;
  91. const int CB_B      = 5;
  92. const int CB_L      = 7;
  93. const int CB_R      = 8;
  94. const int CB_START  = 6;
  95. const int CB_MAP    = 9;
  96. const int CB_EX1    = 10;
  97. const int CB_EX2    = 11;
  98. const int CB_EX3    = 12;
  99. const int CB_EX4    = 13;
  100. const int CB_AXIS_UP    = 14;
  101. const int CB_AXIS_DOWN  = 15;
  102. const int CB_AXIS_LEFT  = 16;
  103. const int CB_AXIS_RIGHT = 17;
  104.  
  105. */
  106.  
  107. ffc script paddle
  108. {
  109.     void run(){}
  110.    
  111.     bool move(bool mouse, bool accel, ffc p)
  112.     {
  113.         int dir; int dist;
  114.         if ( mouse )
  115.         {
  116.             //get the mouse movement this frame and apply a relative amount to the paddle
  117.             //set the dir here
  118.             //set the dist here
  119.             //if moving left
  120.             //if ( p->X > PADDLE_MIN_X )
  121.             //{
  122.             //  p->X = Input->Mouse[_MOUSE_X];
  123.                 //apply change -- ZC has no special mouse tracking.
  124.             //}
  125.             //if moving right
  126.             if ( !extended )
  127.             {
  128.                 if ( Input->Mouse[_MOUSE_X] <= PADDLE_MAX_X )
  129.                 {
  130.                     if ( Input->Mouse[_MOUSE_X] >= PADDLE_MIN_X )
  131.                     {
  132.                         //apply change
  133.                         p->X = Input->Mouse[_MOUSE_X];
  134.                     }
  135.                 }
  136.             }
  137.             else
  138.             {
  139.                 if ( Input->Mouse[_MOUSE_X] <= PADDLE_MAX_X_EXTENDED )
  140.                 {
  141.                     if ( Input->Mouse[_MOUSE_X] >= PADDLE_MIN_X_EXTENDED )
  142.                     {
  143.                         //apply change
  144.                         p->X = Input->Mouse[_MOUSE_X];
  145.                     }
  146.                 }
  147.             }
  148.         }
  149.         else //using a KB or joypad
  150.         {
  151.             //check how long the dir button is held
  152.             if ( accel ) //if we allow acceleratiopn, move N pixeld * accel factor * frames held
  153.             {
  154.                
  155.                 if ( !extended )
  156.                 {
  157.                     if (  Input->Button[CB_LEFT] )
  158.                     {
  159.                         for ( int q = frames_pressed[CB_LEFT]; q > 0 ; --q )
  160.                         {
  161.                             if ( p->X > PADDLE_MIN_X )
  162.                             {
  163.                                 --p->X;
  164.                                 --p->X;
  165.                             }
  166.                         }
  167.                     }
  168.                     if (  Input->Button[CB_RIGHT] )
  169.                     {
  170.                         for ( int q = frames_pressed[CB_RIGHT]; q > 0; --q )
  171.                         {
  172.                             if ( p->X < PADDLE_MAX_X )
  173.                             {
  174.                                 ++p->X;
  175.                             }
  176.                         }
  177.                     }
  178.                 }
  179.                
  180.             }
  181.                 /*
  182.                 if ( !(frame%FRAMES_PER_MOVEMENT) )
  183.                 {
  184.                     if (  Input->Button[CB_LEFT] )
  185.                     {                      
  186.                         if ( !extended )
  187.                         {
  188.                             if ( p->X > (PADDLE_MIN_X_EXTENDED+frames_pressed[CB_LEFT]+1) ) p->X -= frames_pressed[CB_LEFT]+1;
  189.                         }
  190.                         else
  191.                         {
  192.                             if ( p->X > (PADDLE_MIN_X+frames_pressed[CB_LEFT]+1) ) p->X -= frames_pressed[CB_LEFT]+1;
  193.                         }
  194.                     }
  195.                     if (  Input->Button[CB_RIGHT] )
  196.                     {
  197.                         if ( !extended )
  198.                         {
  199.                             if ( p->X < (PADDLE_MAX_X_EXTENDED-frames_pressed[CB_RIGHT]-1) ) p->X += frames_pressed[CB_RIGHT]+1;
  200.                         }
  201.                         else
  202.                         {
  203.                             if ( p->X < (PADDLE_MAX_X-frames_pressed[CB_RIGHT]-1) ) p->X += frames_pressed[CB_RIGHT]+1;
  204.                         }
  205.                     }
  206.                 }
  207.                 */
  208.            
  209.             else //no accel offered, move a static number of pixels
  210.             {
  211.                 //if ( !(frame%FRAMES_PER_MOVEMENT) )
  212.                 //{
  213.                     if ( !extended )
  214.                     {
  215.                         if (  Input->Button[CB_LEFT] )
  216.                         {
  217.                             for ( int q = 0; q < paddle_speed; ++q )
  218.                             {
  219.                                 if ( p->X > PADDLE_MIN_X )
  220.                                 {
  221.                                     --p->X;
  222.                                 }
  223.                             }
  224.                         }
  225.                         if (  Input->Button[CB_RIGHT] )
  226.                         {
  227.                             for ( int q = 0; q < paddle_speed; ++q )
  228.                             {
  229.                                 if ( p->X < PADDLE_MAX_X )
  230.                                 {
  231.                                     ++p->X;
  232.                                 }
  233.                             }
  234.                         }
  235.                     }
  236.                     else
  237.                     {
  238.                         if (  Input->Button[CB_LEFT] )
  239.                         {
  240.                             if ( p->X > PADDLE_MIN_X_EXTENDED )
  241.                             {
  242.                                 --p->X;
  243.                             }
  244.                         }
  245.                         if (  Input->Button[CB_RIGHT] ) {
  246.                             if ( p->X < PADDLE_MAX_X_EXTENDED )
  247.                             {
  248.                                 ++p->X;
  249.                             }
  250.                         }
  251.                        
  252.                     }
  253.                 //}
  254.             }
  255.         }
  256.        
  257.     }
  258.  
  259.     void check_input()
  260.     {
  261.         if ( Input->Button[CB_LEFT] ) ++frames_pressed[CB_LEFT];
  262.         else frames_pressed[CB_LEFT] = 0;
  263.         if ( Input->Button[CB_RIGHT] ) ++frames_pressed[CB_RIGHT];
  264.         else frames_pressed[CB_RIGHT] = 0;
  265.        
  266.     }
  267.    
  268.     void extend(ffc p)
  269.     {
  270.         if ( extended )
  271.         {
  272.             if ( p->TileWidth < 3 )
  273.             {
  274.                 p->Data = CMB_VAUS_EXTENDED;
  275.                 p->TileWidth = 3;
  276.             }
  277.         }
  278.         else
  279.         {
  280.             if ( p->TileWidth > 2 )
  281.             {
  282.                 p->Data = CMB_VAUS;
  283.                 p->TileWidth = 2;
  284.             }
  285.         }
  286.     }
  287.     void setup(ffc p)
  288.     {
  289.         p->Y = START_PADDLE_Y;
  290.         p->X = START_PADDLE_X;
  291.         p->Data = CMB_VAUS;
  292.         p->TileWidth = 2;
  293.        
  294.     }
  295.     void dead(ffc p)
  296.     {
  297.         p->Data = CMB_VAUS_DEAD;
  298.         p->TileWidth = 2;
  299.         death_frame = frame;
  300.     }
  301.    
  302.  
  303. }
  304.  
  305. const int MISC_BALLID = 0; //Misc index of Vaud->Misc[]
  306. const int MISC_DEAD = 1; //Misc index of Vaud->Misc[]
  307. const int MISC_LAUNCHED = 0; //Misc index of ball->Misc[]
  308.  
  309. const int BALL_MINIMUM_Y = 24; //Invisible line at which point, ball is lost.
  310. global script arkanoid
  311. {
  312.    
  313.     void run()
  314.     {
  315.         quit = -1;
  316.         frame = -1;
  317.         ffc vaus = Screen->LoadFFC(FFC_VAUS);
  318.         lweapon movingball;
  319.         bool ext;
  320.         Link->CollDetection = false;
  321.         Link->DrawYOffset = -32768;
  322.         Trace(quit);
  323.         ball.setup_sprite(SPR_BALL);
  324.         while(true)
  325.         {
  326.             //TraceS("Starting Arkanoid");
  327.             ++frame;
  328.             hold_Link();
  329.             if ( newstage )
  330.             {
  331.                 Game->PlayMIDI(MID_STAGE_START);
  332.                 brick.setup();
  333.                 Waitframes(6);
  334.                
  335.                 brick.clear_combos();
  336.                
  337.                 newstage = false;
  338.                 paddle.setup(vaus);
  339.                 ball.create(vaus);
  340.                 movingball = vaus->Misc[MISC_BALLID];
  341.             }
  342.            
  343.             if ( !vaus->Misc[MISC_DEAD] )
  344.             {
  345.                 change_setting(); //check for a setting change_setting
  346.                 paddle.extend(vaus);
  347.                 paddle.check_input();
  348.                 paddle.move(USE_MOUSE, USE_ACCEL, vaus);
  349.                
  350.                 ball.launch(movingball);
  351.                 if ( !ball.launched(movingball) )
  352.                 {
  353.                     ball.move_with_vaus(movingball, vaus);
  354.                 }
  355.                
  356.                 ball.check_ceiling(movingball);
  357.                 ball.check_leftwall(movingball);
  358.                 ball.check_rightwall(movingball);
  359.                 ball.check_hitvaus(movingball, vaus);
  360.             }
  361.             else
  362.             {
  363.                 paddle.dead(vaus);
  364.                 if ( death_frame < frame - 36 )
  365.                 {
  366.                     //we should hide the vaus, and restart the stage here.
  367.                 }
  368.             }
  369.            
  370.             Waitdraw();
  371.             Waitframe();
  372.         }
  373.     }
  374.     void change_setting()
  375.     {
  376.         if ( Input->Key[KEY_M] ) USE_MOUSE = 1;
  377.         if ( Input->Key[KEY_N] ) USE_MOUSE = 0;
  378.         if ( Input->Key[KEY_F] ) USE_ACCEL = 1;
  379.         if ( Input->Key[KEY_G] ) USE_ACCEL = 0;
  380.         if ( Input->Key[KEY_T] ) --paddle_speed; // paddle_speed = vbound(paddle_speed
  381.         if ( Input->Key[KEY_Y] ) ++paddle_speed; // paddle_speed = vbound(paddle_speed
  382.     }
  383.     void hold_Link()
  384.     {
  385.         Link->X = 60; Link->Y = 60;
  386.     }
  387.    
  388. }
  389.  
  390. const int TILE_BALL = 50512;
  391. const int SPR_BALL = 100;
  392.  
  393.  
  394.  
  395. //preliminary ball
  396. ffc script ball
  397. {
  398.     void run(){}
  399.     void setup_sprite(int sprite_id)
  400.     {
  401.         spritedata sd = Game->LoadSpriteData(sprite_id);
  402.         sd->Tile = TILE_BALL;
  403.     }
  404.     void create(ffc vaus_id) //send the ball lweapon pointer back to the vaus
  405.     {
  406.         lweapon ball = Screen->CreateLWeapon(LW_SCRIPT1);
  407.         ball->HitWidth = 4;
  408.         ball->HitHeight = 4;
  409.         ball->UseSprite(SPR_BALL);
  410.         ball->X = vaus_id->X+18;
  411.         ball->Y = vaus_id->Y-2;
  412.         ball->Damage = 1;
  413.         vaus_id->Misc[MISC_BALLID] = ball;
  414.     }
  415.     void launch(lweapon b)
  416.     {
  417.         if ( b->Misc[MISC_LAUNCHED] ) return;
  418.         bool launched;
  419.         for ( int q = CB_A; q < CB_R; ++q )
  420.         {
  421.             if ( Input->Press[q] ) { launched = true; break; }
  422.         }
  423.         if ( launched )
  424.         {
  425.             //b->Angular = true;
  426.             Game->PlaySound(6);
  427.             b->Dir = DIR_RIGHTUP;  
  428.             b->Step = 90;
  429.             b->Misc[MISC_LAUNCHED] = 1;
  430.         }
  431.     }
  432.     bool launched(lweapon b)
  433.     {
  434.         return (b->Misc[MISC_LAUNCHED]);
  435.     }
  436.     void move(lweapon b)
  437.     {
  438.        
  439.     }
  440.     //Not launched yet.
  441.     void move_with_vaus(lweapon b, ffc v)
  442.     {
  443.         b->X = v->X+18;
  444.     }
  445.     void check_ceiling(lweapon b)
  446.     {
  447.         if ( b->Y <= BALL_MIN_Y )          
  448.         {
  449.             Game->PlaySound(7);
  450.             switch(b->Dir)
  451.             {
  452.                 case DIR_RIGHTUP: { b->Dir = DIR_RIGHTDOWN; break; }
  453.                 case DIR_LEFTUP: { b->Dir = DIR_LEFTDOWN; break; }
  454.                 default: { b->Dir = DIR_DOWN; break; }
  455.             }
  456.         }
  457.     }
  458.     void check_leftwall(lweapon b)
  459.     {
  460.         if ( caught ) return; //don't do anything while the vaus is holding the ball
  461.         if ( b->X == BALL_MIN_X )
  462.         {
  463.             Game->PlaySound(7);
  464.             switch(b->Dir)
  465.             {
  466.                 case DIR_LEFTDOWN: { b->Dir = DIR_RIGHTDOWN; break; }
  467.                 case DIR_LEFTUP: { b->Dir = DIR_RIGHTUP; break; }
  468.                 default: { b->Dir = DIR_DOWN; break; }
  469.             }
  470.         }
  471.     }
  472.     void check_rightwall(lweapon b)
  473.     {
  474.         if ( caught ) return; //don't do anything while the vaus is holding the ball
  475.         if ( b->X == BALL_MAX_X )
  476.         {
  477.             Game->PlaySound(7);
  478.             switch(b->Dir)
  479.             {
  480.                 case DIR_RIGHTDOWN: { b->Dir = DIR_LEFTDOWN; break; }
  481.                 case DIR_RIGHTUP: { b->Dir = DIR_LEFTUP; break; }
  482.                 default: { b->Dir = DIR_DOWN; break; }
  483.             }
  484.         }
  485.     }
  486.     void check_hitvaus(lweapon b, ffc v)
  487.     {
  488.         if ( launched(b) )
  489.         {
  490.             if ( b->Dir == DIR_RIGHTUP ) return;
  491.             if ( b->Dir == DIR_LEFTUP ) return;
  492.             //if ( Collision(b,v) ) //We'll refine this, later.
  493.            
  494.             if ( b->Y+4 == v->Y )
  495.                 //we need to check here, if the paddle is under the ball
  496.             {
  497.                 if ( b->X >= v->X )
  498.                 {
  499.                     if ( b->X <= v->X+(v->TileWidth*16) )
  500.                     {
  501.                         Game->PlaySound(6);
  502.                         b->Y = v->Y-1;
  503.                         switch(b->Dir)
  504.                         {
  505.                             case DIR_LEFTDOWN: { b->Dir = DIR_LEFTUP; break; }
  506.                             case DIR_RIGHTDOWN: { b->Dir = DIR_RIGHTUP; break; }
  507.                             default: { b->Dir = DIR_DOWN; break; }
  508.                         }
  509.                     }
  510.                     else
  511.                     {
  512.                         dead(b,v);
  513.                     }
  514.                 }
  515.                 else
  516.                 {
  517.                     dead(b,v);
  518.                 }
  519.             }
  520.            
  521.         }
  522.     }
  523.     void dead(lweapon b, ffc v)
  524.     {
  525.        
  526.         Game->PlayMIDI(5);
  527.         //remove the ball
  528.         b->Y = -32768; b->Step = 0;
  529.         v->Misc[MISC_DEAD] = 1;
  530.         //if there are more balls in play, switch movingball to one of those
  531.         //otherwise,
  532.         //check next life
  533.         //if more lives, reset playfield
  534.         //otherwise game over
  535.        
  536.     }
  537.    
  538.    
  539.    
  540. }
  541.  
  542. ffc script ball_controller
  543. {
  544.     void run()
  545.     {
  546.         lweapon ball;
  547.         lweapon active_ball; //will be used for when we have multiple balls.
  548.         lweapon balls[3]; //for divide
  549.         ball = Screen->CreateLWeapon(LW_SCRIPT1);
  550.         ball->X = START_BALL_X;
  551.         ball->Y = START_BALL_Y;
  552.         this->Vx = START_BALL_VX;
  553.         this->Vy = START_BALL_VY;
  554.         bool alive = true;
  555.         int num_balls = 1;
  556.         while(alive)
  557.         {
  558.             if ( ball->Y <= BALL_MIN_Y )
  559.             {
  560.                 bounce();
  561.             }
  562.             if ( ball->X <= BALL_MIN_X )
  563.             {
  564.                 bounce();
  565.             }
  566.             if ( ball->X >= BALL_MAX_X )
  567.             {
  568.                 bounce();
  569.             }
  570.                
  571.             if ( ball->Y >= BALL_MAX_Y )
  572.             {
  573.                 if ( num_balls < 2 )
  574.                 {
  575.                     alive = false;
  576.                 }
  577.                 else
  578.                 {
  579.                     kill_ball(ball); //removes this ball, and sets another ball to be the active one
  580.                     --num_balls;
  581.                 }
  582.             }
  583.             Waitframe();
  584.         }
  585.     }
  586.     void bounce(){}
  587.     void kill_ball(lweapon b){}
  588.    
  589. }
  590.  
  591. const int BRICK_MAX = 14;
  592.  
  593. //Layer 1
  594. const int CMB_BRICK_RED     = 1488;
  595. const int CMB_BRICK_WHITE   = 1490;
  596. const int CMB_BRICK_BLUE    = 1492;
  597. const int CMB_BRICK_ORANGE  = 1494;
  598. const int CMB_BRICK_TEAL    = 1496;
  599. const int CMB_BRICK_VIOLET  = 1498;
  600. const int CMB_BRICK_GREEN   = 1500;
  601. const int CMB_BRICK_YELLOW  = 1502;
  602. const int CMB_BRICK_SILVER1 = 1504;
  603. const int CMB_BRICK_SILVER2 = 1506;
  604. const int CMB_BRICK_SILVER3 = 1508;
  605. const int CMB_BRICK_SILVER4 = 1510;
  606. const int CMB_BRICK_GOLD    = 1516;
  607.  
  608.  
  609. //layer 2
  610. const int CMB_BRICK_RED_LOW     = 1489;
  611. const int CMB_BRICK_WHITE_LOW   = 1491;
  612. const int CMB_BRICK_BLUE_LOW    = 1493;
  613. const int CMB_BRICK_ORANGE_LOW  = 1495;
  614. const int CMB_BRICK_TEAL_LOW    = 1497;
  615. const int CMB_BRICK_VIOLET_LOW  = 1499;
  616. const int CMB_BRICK_GREEN_LOW   = 1501;
  617. const int CMB_BRICK_YELLOW_LOW  = 1503;
  618. const int CMB_BRICK_SILVER1_LOW = 1505;
  619. const int CMB_BRICK_SILVER2_LOW = 1507;
  620. const int CMB_BRICK_SILVER3_LOW = 1509;
  621. const int CMB_BRICK_SILVER4_LOW = 1511;
  622. const int CMB_BRICK_GOLD_LOW    = 1517;
  623.  
  624. //enemies
  625. const int NPC_BRICK_RED     = 181;
  626. const int NPC_BRICK_WHITE   = 182;
  627. const int NPC_BRICK_BLUE    = 183;
  628. const int NPC_BRICK_ORANGE  = 184;
  629. const int NPC_BRICK_TEAL    = 185;
  630. const int NPC_BRICK_VIOLET  = 186;
  631. const int NPC_BRICK_GREEN   = 187;
  632. const int NPC_BRICK_YELLOW  = 188;
  633. const int NPC_BRICK_SILVER1     = 189;
  634. const int NPC_BRICK_SILVER2     = 190;
  635. const int NPC_BRICK_SILVER3     = 255; //not set up yet;
  636. const int NPC_BRICK_SILVER4     = 255; //not set up yet
  637. const int NPC_BRICK_GOLD    = 191;
  638.  
  639. ffc script brick
  640. {
  641.     void run()
  642.     {
  643.     }
  644.     bool hit (npc a, lewapon b)
  645.     {
  646.         /*
  647.         To determine where a brick was hit, we first scan each brick and look to see which was
  648.         hit at all, by our lweapon.
  649.        
  650.         The, we check if that ball is belove, above, right of, or left of the brick,
  651.         and we read its direction.
  652.        
  653.         Using a logic chain from this data, we determine the direction that the ball should next
  654.         take, when it bounces.
  655.        
  656.         */
  657.         //HitBy[]
  658.     }
  659.     //turns layer objects into npc bricks.
  660.     void setup()
  661.     {
  662.         int tempenem; npc bricks[1024]; int temp;
  663.         for ( int q = 0; q < 176; ++q )
  664.         {
  665.             //bricks on layer 1
  666.             //Trace(GetLayerComboD(1,q));
  667.             //while(!Input->Press[CB_A]) Waitframe();
  668.             tempenem = brick_to_npc(GetLayerComboD(1,q),false);
  669.             //TraceS("tempenem is: "); Trace(tempenem);
  670.             //while(!Input->Press[CB_A]) Waitframe();
  671.             if ( tempenem )
  672.             {
  673.                 bricks[temp] = Screen->CreateNPC(tempenem);
  674.                 //TraceS("Created npc: "); Trace(tempenem);
  675.                 bricks[temp]->X = ComboX(q);
  676.                 bricks[temp]->Y = ComboY(q);
  677.                 TraceS("Brick defence is: "); Trace(bricks[temp]->Defense[20]);
  678.                 tempenem = 0; ++temp;
  679.                
  680.             }
  681.             //bricks on layer 2, Y+8px
  682.             tempenem = brick_to_npc(GetLayerComboD(2,q),true);
  683.             //Trace(tempenem);
  684.             if ( tempenem )
  685.             {
  686.                 bricks[temp] = Screen->CreateNPC(tempenem);
  687.                 //TraceS("Created npc: "); Trace(tempenem);
  688.                 bricks[temp]->X = ComboX(q);
  689.                 bricks[temp]->Y = ComboY(q)+8;
  690.                 TraceS("Brick defence is: "); Trace(bricks[temp]->Defense[20]);
  691.                 tempenem = 0; ++temp;
  692.             }
  693.         }
  694.        
  695.     }
  696.     void clear_combos()
  697.     {
  698.         templayer[0] = Screen->LayerOpacity[0];
  699.         templayer[1] = Screen->LayerOpacity[1];
  700.         templayer[2] = Screen->LayerMap[0];
  701.         templayer[3] = Screen->LayerMap[1];
  702.         Screen->LayerOpacity[0] = 0;
  703.         Screen->LayerOpacity[1] = 0;
  704.         Screen->LayerMap[0] = 0;
  705.         Screen->LayerMap[1] = 0;
  706.     }
  707.    
  708.     int brick_to_npc(int combo_id, bool layer2)
  709.     {
  710.        
  711.         if ( !layer2 )
  712.         {
  713.             int brick_to_enemy[BRICK_MAX*2] =
  714.             {   CMB_BRICK_RED, CMB_BRICK_WHITE, CMB_BRICK_BLUE, CMB_BRICK_ORANGE, CMB_BRICK_TEAL,
  715.                 CMB_BRICK_VIOLET, CMB_BRICK_GREEN, CMB_BRICK_YELLOW, CMB_BRICK_SILVER1, CMB_BRICK_SILVER2,
  716.                 CMB_BRICK_SILVER3, CMB_BRICK_SILVER4, CMB_BRICK_GOLD,
  717.  
  718.                 NPC_BRICK_RED, NPC_BRICK_WHITE, NPC_BRICK_BLUE, NPC_BRICK_ORANGE, NPC_BRICK_TEAL,
  719.                 NPC_BRICK_VIOLET, NPC_BRICK_GREEN, NPC_BRICK_YELLOW, NPC_BRICK_SILVER1, NPC_BRICK_SILVER2,
  720.                 NPC_BRICK_SILVER3, NPC_BRICK_SILVER4, NPC_BRICK_GOLD
  721.             };
  722.             for ( int q = 0; q < BRICK_MAX; ++q )
  723.             {
  724.                 if ( brick_to_enemy[q] == combo_id )
  725.                 {
  726.                     //  TraceS("brick_to_npc : combo input: "); Trace(combo_id);
  727.                     //TraceS("brick_to_npc : enemy output: "); Trace(brick_to_enemy[BRICK_MAX+q]);
  728.                    
  729.                     return ( brick_to_enemy[BRICK_MAX+q-1] );
  730.                 }
  731.             }
  732.         }
  733.         else
  734.         {
  735.             int brick_to_enemy2[BRICK_MAX*2] =
  736.             {   CMB_BRICK_RED_LOW, CMB_BRICK_WHITE_LOW, CMB_BRICK_BLUE_LOW, CMB_BRICK_ORANGE_LOW, CMB_BRICK_TEAL_LOW,
  737.                 CMB_BRICK_VIOLET_LOW, CMB_BRICK_GREEN_LOW, CMB_BRICK_YELLOW_LOW, CMB_BRICK_SILVER1_LOW, CMB_BRICK_SILVER2_LOW,
  738.                 CMB_BRICK_SILVER3_LOW, CMB_BRICK_SILVER4_LOW, CMB_BRICK_GOLD_LOW,
  739.  
  740.                 NPC_BRICK_RED, NPC_BRICK_WHITE, NPC_BRICK_BLUE, NPC_BRICK_ORANGE, NPC_BRICK_TEAL,
  741.                 NPC_BRICK_VIOLET, NPC_BRICK_GREEN, NPC_BRICK_YELLOW, NPC_BRICK_SILVER1, NPC_BRICK_SILVER2,
  742.                 NPC_BRICK_SILVER3, NPC_BRICK_SILVER4, NPC_BRICK_GOLD
  743.             };
  744.             for ( int q = 0; q < BRICK_MAX; ++q )
  745.             {
  746.                 if ( brick_to_enemy2[q] == combo_id )
  747.                 {
  748.                     //TraceS("brick_to_npc : combo input: "); Trace(combo_id);
  749.                     //TraceS("brick_to_npc : enemy output: "); Trace(brick_to_enemy2[BRICK_MAX+q-1]);
  750.                     return ( brick_to_enemy2[BRICK_MAX+q-1] );
  751.                 }
  752.             }
  753.         }
  754.         return 0; //error
  755.     }
  756. }
  757.  
  758. global script onExit
  759. {
  760.     void run()
  761.     {
  762.         Screen->LayerOpacity[0] = templayer[0];
  763.         Screen->LayerOpacity[1] = templayer[1];
  764.         Screen->LayerMap[0] = templayer[2];
  765.         Screen->LayerMap[1] = templayer[3];
  766.         newstage = true;
  767.         //vaus->Misc[MISC_DEAD] = 0;
  768.  
  769.     }
  770. }  
  771.  
  772. global script init
  773. {
  774.     void run()
  775.     {
  776.         Link->CollDetection = false;
  777.         Link->DrawYOffset = -32768;
  778.     }
  779. }
  780.  
  781. global script Init
  782. {
  783.     void run()
  784.     {
  785.         Link->CollDetection = false;
  786.         Link->DrawYOffset = -32768;
  787.     }
  788. }
Add Comment
Please, Sign In to add comment