Advertisement
ZoriaRPG

Arkanoid.zs (Alpha 0.30)

Aug 30th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 90.47 KB | None | 0 0
  1. import "std.zh"
  2.  
  3. //TODO:
  4. // Add catch, and laser
  5. // Add corner check for WALLS for various angles.
  6. // Implement new angles after collision with walls and bricks.
  7. // Implement enemies.
  8.  
  9.     /*Capsule Rewrite
  10.  
  11.  
  12.     1. Use itemdata->attribs for caps type
  13.     2. Use itemdata->sprites for the sprite to use on an eweapon
  14.     3. If the item appears, spawn an eweapon in its place and remove the item
  15.     4. Apply the itemdata->id to ew->Misc[] and read it in place of the item id
  16.         4(a).   eweapons wouldnt need to be manually moved:
  17.             Just set their dir = down and a step speed
  18.         4(b).   Blocks can use item dropsets for pills to drop
  19.     5. Set the default item drawyoffset to offscreen, so that eweapon spawns aren't visible
  20.         5(a).   Now we can rid ourselves of the script draws and the loops to move everything
  21.     6. Perform removal of eweapons every 10 frames with capsule.cleanup() called if !(frame%10)
  22.     */
  23.  
  24. /* Wall drop issue might be because the dir is being set
  25. when the ball is past the wall, then the ball is being
  26. moved BACK tot he wall, and the dir is being checked again.
  27.  
  28. Might be fixed by either storing the previous ball dir on a change, and
  29. if it goes out of bounds, force that dir again after moving it back into bounds;
  30. or by only checking for equality on the walls.
  31. */
  32.  
  33. //Arkanoid script
  34. //v0.30
  35. //30th August, 2018
  36.  
  37. //////////////////////
  38. /// Script issues: ///
  39. //////////////////////
  40.  
  41. // We need to either re-arrange the living/dead/death logic, or add another animation phase.
  42. // May as well set up the Vaus explosion and add it with a SPARKLE LWeapon.
  43.  
  44.  
  45. /* ZC issues:
  46.     Continue script does not run when Init script runs. It NEEDS to do that! Otherwise, settings that affect things such as Link's tile
  47.     don't happen before the opening wipe.
  48.    
  49. */
  50.  
  51. ffc script version_alpha_0_30
  52. {
  53.     void run(){}
  54. }
  55.  
  56. /// Changes, Revision History
  57. ///
  58. ///
  59. /// Alpha 0.16: Reverted Alpha 0.15 changes back to before adding any angular physics.
  60. ///     Then, re-implemented ONLY the Vaus midpoint physics.
  61. ///     Fixed the hack for UID in brick.take_hit(). This means that ZC 2.54 Alpha **32** is now the minimum ZC version.
  62.  
  63. ///Alpha 0.18: Added 'fast mouse' mode, enabled using V to increase the fast mouse speed, and C tpo decrease it.
  64. ///     The mouse mode must be enabled for this to function!
  65. /// Fast Mouse moves the Vaus N pixels per frame, based on the distance that the mouse travels * fast_mouse.
  66.  
  67. ///Alpha 0.19: Added a frame check to keyboard keys V and B.
  68.  
  69. ///Alpha 0.20: Added an ffc script that reports the version when assigning slots after compiling.
  70.  
  71. ///Alpha 0.21: Added code for advancing to the next stage.
  72.  
  73. ///Alpha 0.22: Fixed code for level advancement. Added second stage.
  74. ///Alpha 0.23: Fixed brick.all_gone() counting gold bricks.
  75. ///Alpha 0.24: Fixed a bug in ball.check_rightwall() where a right-up moving ball was set to a right-ward angle/dir on contact.
  76. ///      : This was the cause of the ball falling like a stone.
  77. ///      : Fixed a bug where angles that we were comparing against in ball.check_hitvaus() had the wrong equality constants,
  78. ///      : and thus, were returning false.  
  79. ///      : Added hold_Link_y() to the additional while loops so that the player can't escape that screen by holding directions
  80. ///      : on the single frame where that loop runs.
  81. ///Alpha 0.25: Added capsule class, and set up base functions, to generate capsules and make them fall.
  82. ///      : Capsules now appear int he game, but as of this time, they do not activate any power-ups.
  83. ///
  84. ///Alpha 0.26: Added more capsule functions.
  85. ///Alpha 0.27: Wrote capsule.check_hitvaus() and polished other capsule functions, adding traces to test them.
  86. ///      : Added drawover() functions to capsule and ball classes.
  87. ///      : Added extend state capabilities to game. Extend capsules now extend the Vaus.
  88. ///      : Added slow capsule powerups that function.
  89. ///      : Added Extra Vaus powerups that function.
  90. ///Alpha 0.28: Converted capsules to eweapons.
  91. ///      : Fixed extended movement with both KB/JP and Mouse.
  92. ///Alpha 0.29: Added laser sprite change on powerup collection. Refactored powerup sounds.
  93. ///      : Refactor extend status to be controlled by the capsules, and added capsule.alloff(ffc), called on stage end or death.
  94. ///      : Added more sound effects.
  95. ///      : Added POINTS on collecting capsules. Capsule points are set in itemdata->Attributes[1].
  96. ///      : Began adding extra life on score reaching certain numbers.
  97. ///      : Added high_score, and score clear system.
  98. ///      : Extra life from points set to 1000. Capsules award 10 points each.
  99. ///      : Shift+M now enabled mouse and sets fast_mouse = 2;
  100. ///Alpha 0.30: Fixed timing for music playing and vaus spawning, and fixed visual bugs created by calling capsule.alloff() with improper sequencing.
  101. /// NOTE:  VAUS BREAK could use 'moving link' to the next screen to scroll it as an effect.
  102.  
  103. //! Bug: Right side of vaus angle zones are reversed. RUU is to the right of RU. RRU seems not to exist.
  104. //! I should be drawing red v-lines over the points where the ball zones are on the paddle.
  105.  
  106. typedef const int config;
  107.  
  108.  
  109. config BRICK_CHANCE_CAPSULE     = 50;
  110. config FAST_MOUSE_MAX       = 6;
  111. config MAX_STAGES       = 2; //Number of stages/levels in the game.
  112. config MAX_BALL_SPEED       = 300;
  113. config MIN_ZC_ALPHA_BUILD   = 35; //Alphas are negatives, so we neex to check maximum, not minimum.
  114. config STARTING_LIVES       = 5;
  115. config CAPSULE_FALL_SPEED   = 1;
  116. config BALL_INITIAL_STEP    = 90;
  117. config CAPSULE_STEP     = 80;
  118.  
  119.  
  120. typedef const int sfx;
  121.  
  122. sfx SFC_LASER = 3;
  123. sfx SFX_KILLENEMY = 2;
  124. sfx SFX_EXTEND = 4;
  125. sfx SFX_BALL_HIT_VAUS = 6;
  126. sfx SFX_BALL_HIT_BLOCK= 7;
  127. sfx SFX_BALL_HIT_SILVER= 8;
  128. sfx SFX_EXTRA_VAUS = 9;
  129. sfx SFX_VAUS_EXPLODE = 10;
  130. sfx SFX_ESCAPE = 11;
  131. sfx SFX_MATERIALISE = 12;
  132. sfx SFX_BEEP = 1;
  133. sfx SFX_ARK2_LASER = 13;
  134. sfx SFX_ARK2_KILLENEMY = 14;
  135. sfx SFX_ARK2_HITGREY = 15;
  136. sfx SFX_ARK2_HITGOLD = 16;
  137. sfx SFX_ARK2_EXTRAVAUS = 17;
  138.  
  139. sfx SFX_ARK2_HITVAUS = 18;
  140. sfx SFX_ARK2_HITWALL = 19;
  141. sfx SFX_ARK2_POWERUP = 20;
  142. sfx SFX_ARK2_EXTEND = 21; //too quiet
  143. sfx SFX_ARK2_POWERUP2 = 22; //
  144. sfx SFX_ARK2_VAUSEXPLODE = 23;
  145. sfx SFX_ARK2_WOOSH = 24;
  146. sfx SFX_ARK2_MATERIALISE = 25;
  147. sfx SFX_ARK2_BOSSALERT = 26;
  148. sfx SFX_ARK2_CRYSTAL = 27;
  149. sfx SFX_ARK2_ESCAPE = 28;
  150. sfx SFX_ARK2_BELLS_CHIMES = 29;
  151.  
  152. const float ARKANOID_VERSION = 0.25;
  153.  
  154. //Radians for special directions.
  155. const float DIR_UUL = 4.3197;
  156. const float DIR_LUU = 4.3197;
  157. const float DIR_LLU = 3.5343;
  158. const float DIR_ULL = 3.5343;
  159. const float DIR_LLD = 2.7489;
  160. const float DIR_DLL = 2.7489;
  161. const float DIR_DDL = 1.9635;
  162. const float DIR_LDD = 1.9635;
  163. const float DIR_DDR = 1.1781;
  164. const float DIR_RDD = 1.1781;
  165. const float DIR_RRD = 0.3927;
  166. const float DIR_DRR = 0.3927;
  167. const float DIR_RRU = 5.1051;
  168. const float DIR_URR = 5.1051;
  169. const float DIR_RUU = 5.1141;
  170. const float DIR_UUR = 5.1141;
  171.  
  172. int last_mouse_x;
  173. int fast_mouse;
  174.  
  175.  
  176.  
  177.  
  178.  
  179. int GAME[256];
  180. const int GAME_MISC_FLAGS = 0;
  181. const int GMFS_PLAYED_GAME_OVER_MUSIC = 0x01;
  182.  
  183. const int FFC_VAUS = 1;
  184. const int CMB_VAUS_EXTENDED = 1528;
  185. const int CMB_VAUS = 1524;
  186. const int CMB_VAUS_DEAD = 1520;
  187. const int CMB_VAUS_LASER = 1532;
  188.  
  189. const int MID_STAGE_START = 4;
  190. const int NPCM_AWARDED_POINTS = 3; //brick->Misc[], flag to mark if points were awarded to the player.
  191. const int NPC_ATTRIB_POINTS = 0; //brick->Attributes[], value for score.
  192. const int CAPS_EW_MISC_POINTS = 6;
  193.  
  194. //Counters
  195. const int CR_SCORE = 7; //script 1
  196. const int CR_LIVES = 8;
  197. const int CR_HIGH_SCORE = 9;
  198.  
  199. int high_score; //saved with quest.
  200. int last_score_award;
  201. config SCORE_BONUS_LIFE_AT = 1000;
  202.  
  203. //game objects
  204. int ball_uid;
  205.  
  206. //game states
  207. int quit;
  208. int frame;
  209.  
  210. bool newstage = true;
  211. bool leveldone = false;
  212. int cur_stage;
  213.  
  214. const int QUIT_TITLE = -1;
  215. const int QUIT_GAME_RUNNING = 0; //i.e., !quit
  216. const int QUIT_GAMEOVER = 1;
  217.  
  218. const int FRAMES_PER_MOVEMENT = 10;
  219. int USE_ACCEL = 0; //Do we accelerate KB/JP input?
  220. int USE_MOUSE = 0; //Are we using the mouse?
  221.  
  222. //Vaus states
  223. bool revive_vaus = false;
  224. bool extended;
  225. bool laser;
  226. int caught; //States: 0, none. 1: Vaus can catch ball. 2: Vaus is holding the ball.
  227. const int CATCH_NONE = 0;
  228. const int CATCH_ALLOW = 1;
  229. const int CATCH_HOLDING_BALL = 2;
  230.  
  231. //Ball properties (probably unused at this point)
  232. int ball_x;
  233. int ball_y;
  234. int ball_dir;
  235. int ball_angle;
  236. int ball_speed;
  237. int ball_vx;
  238. int ball_vy;
  239. int paddle_x;
  240. int paddle_y;
  241. int paddle_width = 16;
  242. int paddle_speed = 2;
  243.  
  244. //animation
  245. int death_frame;
  246.  
  247. const int DEATH_ANIM_MAX = 8;
  248.  
  249. int death_anim[DEATH_ANIM_MAX];
  250. const int DEATH_ANIM_TIMER = 0;
  251. const int DEATH_ANIM_1 = 1; //1-7 Unused
  252. const int DEATH_ANIM_2 = 2;
  253. const int DEATH_ANIM_3 = 3;
  254. const int DEATH_ANIM_4 = 4;
  255. const int DEATH_ANIM_5 = 5;
  256. const int DEATH_ANIM_6 = 6;
  257. const int DEATH_ANIM_COUNTDOWN_TO_QUIT = 7;
  258.  
  259. const int COUNTDOWN_TO_QUIT_FRAMES = 289; //36*8+1;
  260.  
  261. int templayer[4];
  262.  
  263. int input_accel; //pressing left and right for multiple frames increases this
  264. int frames_pressed[18];
  265.  
  266. //ffc paddle;
  267.  
  268. int hit_zones[5]; //angle offsets for where the ball strikes the paddle
  269.  
  270. const int WALL_LEFT = 24;
  271. const int WALL_TOP = 8; //Mix Ball Y
  272. const int WALL_RIGHT = 232;
  273.  
  274. const int BALL_MIN_Y = 9; //ceiling +1
  275. const int BALL_MAX_Y = 145; //one pixel under paddle top
  276. const int BALL_MIN_X = 25; //left wall +1
  277. const int BALL_MAX_X = 229; //right wall -1
  278.  
  279.  
  280.  
  281. const int START_PADDLE_X = 62;
  282. const int START_PADDLE_Y = 160;
  283. const int START_PADDLE_WIDTH = 32;
  284. const int START_PADDLE_HEIGHT = 8;
  285. const int BALL_WIDTH = 4;
  286. const int BALL_HEIGHT = 4;
  287. const int START_BALL_X = 98; //(START_PADDLE_X + 36);
  288. const int START_BALL_Y = 156; //START_PADDLE_Y - 4;
  289. const int START_BALL_DIR = 5; //DIR_UPRIGHT;
  290. const int START_BALL_RADS = 220; //angle in radians
  291. const int START_BALL_SPEED = 45;
  292. const int START_BALL_VX = 0;
  293. const int START_BALL_VY = 0;
  294.  
  295. const int PADDLE_MIN_X = 25;
  296. const int PADDLE_MAX_X = 200; //WALL_RIGHT -32; //This one varies as the paddle width may change.
  297. const int PADDLE_MAX_X_EXTENDED = 184; //WALL_RIGHT - 48; //This one varies as the paddle width may change.
  298. const int PADDLE_MIN_X_EXTENDED = 25;
  299.  
  300. const int _MOUSE_X = 0;
  301. const int _MOUSE_Y = 1;
  302. const int _MOUSE_LCLICK = 2;
  303.  
  304. //const float ACCEL_FACTOR = 0.25;
  305.  
  306.  
  307.  
  308.  
  309. /*
  310. const int CB_UP     = 0;
  311. const int CB_DOWN   = 1;
  312. const int CB_LEFT   = 2;
  313. const int CB_RIGHT  = 3;
  314. const int CB_A      = 4;
  315. const int CB_B      = 5;
  316. const int CB_L      = 7;
  317. const int CB_R      = 8;
  318. const int CB_START  = 6;
  319. const int CB_MAP    = 9;
  320. const int CB_EX1    = 10;
  321. const int CB_EX2    = 11;
  322. const int CB_EX3    = 12;
  323. const int CB_EX4    = 13;
  324. const int CB_AXIS_UP    = 14;
  325. const int CB_AXIS_DOWN  = 15;
  326. const int CB_AXIS_LEFT  = 16;
  327. const int CB_AXIS_RIGHT = 17;
  328.  
  329. */
  330.  
  331. ffc script paddle
  332. {
  333.     void run(){}
  334.    
  335.     bool move(bool mouse, bool accel, ffc p)
  336.     {
  337.         int dir; int dist;
  338.         if ( mouse )
  339.         {
  340.             Game->ClickToFreezeEnabled = false;
  341.             if ( fast_mouse )
  342.             {
  343.                 int distx = Input->Mouse[_MOUSE_X] - last_mouse_x;
  344.                 //Trace(distx);
  345.                 last_mouse_x = Input->Mouse[_MOUSE_X];
  346.                 if ( !extended )
  347.                 {
  348.                    
  349.                     if ( distx < 0 )
  350.                     {
  351.                         //Trace(distx);
  352.                         for ( int q = Abs(distx) * fast_mouse; q > 0 ; --q )
  353.                         {
  354.                            
  355.                             if ( p->X > PADDLE_MIN_X )
  356.                             {
  357.                                 --p->X;
  358.                             }
  359.                            
  360.                         }
  361.                     }
  362.                     else if ( distx > 0 )
  363.                     {
  364.                         //Trace(distx);
  365.                         for ( int q = Abs(distx) * fast_mouse; q > 0 ; --q )
  366.                         {
  367.                            
  368.                             if ( p->X < PADDLE_MAX_X )
  369.                             {
  370.                                 ++p->X;
  371.                             }
  372.                            
  373.                         }
  374.                     }
  375.                 }
  376.                 else //extended
  377.                 {
  378.                    
  379.                     if ( distx < 0 )
  380.                     {
  381.                         for ( int q = Abs(distx); q > 0 ; --q )
  382.                         {
  383.                             for ( int q = fast_mouse; q > 0; --q )
  384.                             {
  385.                                 if ( p->X > PADDLE_MIN_X_EXTENDED+(frame%2) )
  386.                                 {
  387.                                     p->X -= (1+(frame%2)); //move left
  388.                                 }
  389.                             }
  390.                         }
  391.                     }
  392.                     else
  393.                     {
  394.                         for ( int q = Abs(distx); q > 0 ; --q )
  395.                         {
  396.                             for ( int q = fast_mouse; q > 0; --q )
  397.                             {
  398.                                 if ( p->X < PADDLE_MAX_X_EXTENDED-(frame%2) )
  399.                                 {
  400.                                     p->X += (1+(frame%2)); //move right
  401.                                 }
  402.                             }
  403.                         }
  404.                     }
  405.                 }
  406.                
  407.             }
  408.             else
  409.             {
  410.                 //get the mouse movement this frame and apply a relative amount to the paddle
  411.                 //set the dir here
  412.                 //set the dist here
  413.                 //if moving left
  414.                 //if ( p->X > PADDLE_MIN_X )
  415.                 //{
  416.                 //  p->X = Input->Mouse[_MOUSE_X];
  417.                     //apply change -- ZC has no special mouse tracking.
  418.                 //}
  419.                 //if moving right
  420.                 if ( !extended )
  421.                 {
  422.                     if ( Input->Mouse[_MOUSE_X] <= PADDLE_MAX_X )
  423.                     {
  424.                         if ( Input->Mouse[_MOUSE_X] >= PADDLE_MIN_X )
  425.                         {
  426.                             //apply change
  427.                             p->X = Input->Mouse[_MOUSE_X];
  428.                         }
  429.                     }
  430.                 }
  431.                 else
  432.                 {
  433.                     if ( Input->Mouse[_MOUSE_X] <= PADDLE_MAX_X_EXTENDED )
  434.                     {
  435.                         if ( Input->Mouse[_MOUSE_X] >= PADDLE_MIN_X_EXTENDED )
  436.                         {
  437.                             //apply change
  438.                             p->X = Input->Mouse[_MOUSE_X];
  439.                         }
  440.                     }
  441.                 }
  442.             }
  443.         }
  444.         else //using a KB or joypad
  445.         {
  446.             Game->ClickToFreezeEnabled = true;
  447.             //check how long the dir button is held
  448.             if ( accel ) //if we allow acceleratiopn, move N pixeld * accel factor * frames held
  449.             {
  450.                
  451.                 if ( !extended )
  452.                 {
  453.                     if (  Input->Button[CB_LEFT] )
  454.                     {
  455.                         for ( int q = frames_pressed[CB_LEFT]; q > 0 ; --q )
  456.                         {
  457.                             if ( p->X > PADDLE_MIN_X )
  458.                             {
  459.                                 --p->X;
  460.                             }
  461.                         }
  462.                     }
  463.                     if (  Input->Button[CB_RIGHT] )
  464.                     {
  465.                         for ( int q = frames_pressed[CB_RIGHT]; q > 0; --q )
  466.                         {
  467.                             if ( p->X < PADDLE_MAX_X )
  468.                             {
  469.                                 ++p->X;
  470.                             }
  471.                         }
  472.                     }
  473.                 }
  474.                 else
  475.                 {
  476.                     if (  Input->Button[CB_LEFT] )
  477.                     {
  478.                         for ( int q = frames_pressed[CB_LEFT]; q > 0 ; --q )
  479.                         {
  480.                             if ( p->X > PADDLE_MIN_X_EXTENDED )
  481.                             {
  482.                                 --p->X;
  483.                             }
  484.                         }
  485.                     }
  486.                     if (  Input->Button[CB_RIGHT] )
  487.                     {
  488.                         for ( int q = frames_pressed[CB_RIGHT]; q > 0; --q )
  489.                         {
  490.                             if ( p->X < PADDLE_MAX_X_EXTENDED )
  491.                             {
  492.                                 ++p->X;
  493.                             }
  494.                         }
  495.                     }
  496.                    
  497.                 }
  498.                
  499.             }
  500.            
  501.             else //no accel offered, move a static number of pixels
  502.             {
  503.                
  504.                 if ( !extended )
  505.                 {
  506.                     if (  Input->Button[CB_LEFT] )
  507.                     {
  508.                         for ( int q = 0; q < paddle_speed; ++q )
  509.                         {
  510.                             if ( p->X > PADDLE_MIN_X )
  511.                             {
  512.                                 --p->X;
  513.                             }
  514.                         }
  515.                     }
  516.                     if (  Input->Button[CB_RIGHT] )
  517.                     {
  518.                         for ( int q = 0; q < paddle_speed; ++q )
  519.                         {
  520.                             if ( p->X < PADDLE_MAX_X )
  521.                             {
  522.                                 ++p->X;
  523.                             }
  524.                         }
  525.                     }
  526.                 }
  527.                 else
  528.                 {
  529.                     if (  Input->Button[CB_LEFT] )
  530.                     {
  531.                         if ( p->X > PADDLE_MIN_X_EXTENDED )
  532.                         {
  533.                             p->X -= (1+(frame%2));
  534.                         }
  535.                     }
  536.                     if (  Input->Button[CB_RIGHT] ) {
  537.                         if ( p->X < PADDLE_MAX_X_EXTENDED )
  538.                         {
  539.                             p->X += (1+(frame%2));
  540.                         }
  541.                     }
  542.                    
  543.                 }
  544.             }
  545.         }
  546.        
  547.     }
  548.  
  549.     void check_input()
  550.     {
  551.         if ( Input->Button[CB_LEFT] ) ++frames_pressed[CB_LEFT];
  552.         else frames_pressed[CB_LEFT] = 0;
  553.         if ( Input->Button[CB_RIGHT] ) ++frames_pressed[CB_RIGHT];
  554.         else frames_pressed[CB_RIGHT] = 0;
  555.        
  556.     }
  557.    
  558.     void extend(ffc p)
  559.     {
  560.         if ( extended )
  561.         {
  562.             if ( p->TileWidth < 3 )
  563.             {
  564.                 p->Data = CMB_VAUS_EXTENDED;
  565.                 p->TileWidth = 3;
  566.             }
  567.         }
  568.         else
  569.         {
  570.             if ( p->TileWidth > 2 )
  571.             {
  572.                 p->Data = CMB_VAUS;
  573.                 p->TileWidth = 2;
  574.             }
  575.         }
  576.     }
  577.     void setup(ffc p)
  578.     {
  579.         Game->PlaySound(SFX_MATERIALISE);
  580.         p->Y = START_PADDLE_Y;
  581.         p->X = START_PADDLE_X;
  582.         Waitframe();
  583.         p->Data = CMB_VAUS;
  584.         p->TileWidth = 2;
  585.        
  586.     }
  587.     void dead(ffc p)
  588.     {
  589.         p->Data = CMB_VAUS_DEAD;
  590.         p->TileWidth = 2;
  591.         death_frame = frame;
  592.     }
  593.    
  594.    
  595. }
  596.  
  597. const int MISC_BALLID = 0; //Misc index of Vaud->Misc[]
  598. const int MISC_DEAD = 1; //Misc index of Vaud->Misc[]
  599. const int MISC_LAUNCHED = 0; //Misc index of ball->Misc[]
  600.  
  601. const int BALL_MINIMUM_Y = 24; //Invisible line at which point, ball is lost.
  602.  
  603. ffc script holdlink
  604. {
  605.     void run()
  606.     {
  607.         while(1)
  608.         {
  609.             Link->Y = START_PADDLE_Y - 4;
  610.             Waitframe();
  611.         }
  612.     }
  613. }
  614.        
  615. const int TEST_254_GETPIXEL = 1;
  616.  
  617. global script arkanoid
  618. {
  619.    
  620.     void run()
  621.     {
  622.         check_min_zc_build();
  623.        
  624.         TraceNL(); TraceS("Starting Arkanoid"); TraceNL(); TraceS("Game 'quit' state: "); Trace(quit);
  625.         TraceNL(); TraceS("Game version, Alpha "); Trace(ARKANOID_VERSION);
  626.        
  627.         //frame = -1;
  628.         ffc vaus = Screen->LoadFFC(FFC_VAUS);
  629.         lweapon movingball;
  630.         npc vaus_guard;
  631.         bool ext;
  632.         Link->CollDetection = false;
  633.         Link->DrawYOffset = -32768;
  634.        
  635.         if ( TEST_254_GETPIXEL )
  636.         {
  637.             bitmap bmp = Game->LoadBitmapID(RT_SCREEN);
  638.             int col[20];
  639.             for ( int q = 0; q < 20; ++ q )
  640.             {
  641.                 col[q] = bmp->GetPixel(10+q*8,10+q*8);
  642.             }
  643.             TraceNL();
  644.             for ( int q = 0; q < 20; ++q )
  645.             {
  646.                 TraceS("Bitmap col: "); Trace(col[q]);
  647.             }
  648.            
  649.             Screen->SetRenderTarget(2);
  650.             Screen->Rectangle(0, 0, 0, 256, 256, 0x55, 100, 0, 0, 0, true, 128);
  651.             Screen->SetRenderTarget(RT_SCREEN);
  652.             Waitframe();
  653.            
  654.             bitmap offscreen = Game->LoadBitmapID(2);
  655.             int col2[20];
  656.             for ( int q = 0; q < 20; ++ q )
  657.             {
  658.                 col2[q] = offscreen->GetPixel(10+q*8,10+q*8);
  659.             }
  660.             TraceNL();
  661.             for ( int q = 0; q < 20; ++q )
  662.             {
  663.                 TraceS("Offscreen Bitmap col: "); Trace(col2[q]);
  664.             }
  665.         }
  666.        
  667.         ball.setup_sprite(SPR_BALL);
  668.        
  669.         while(true)
  670.         {
  671.             while(!quit)
  672.             {
  673.                 ++frame;
  674.                 if ( Input->Key[KEY_L] ) ++Game->Counter[CR_LIVES];
  675.                 hold_Link_y(); //Don't allow Link to leave the screen, bt
  676.                     //keep his X and Y matched to the Vaus!
  677.                 hold_Link_x(vaus); //Link is used to cause floating enemies to home in on the vaus.
  678.                 while ( newstage )
  679.                 {
  680.                    
  681.                    
  682.                     capsule.all_clear(); //remove visible capsules
  683.                    
  684.                     hold_Link_y();
  685.                     vaus = Screen->LoadFFC(FFC_VAUS);
  686.                     //vaus_guard = Screen->CreateNPC(NPC_VAUSGUARD);
  687.                     Game->PlayMIDI(MID_STAGE_START);
  688.                    
  689.                     brick.setup();
  690.                     Waitframes(6);
  691.                    
  692.                     brick.clear_combos();
  693.                    
  694.                     for ( int q = 0; q < 180; ++q ) WaitNoAction();
  695.                     TraceS("Setting up Vaus on a new stage");
  696.                     paddle.setup(vaus);
  697.                     capsule.alloff(vaus); //clear powerup status
  698.                     TraceS("Creating a ball on a new stage");
  699.                     ball.create(vaus);
  700.                     movingball = vaus->Misc[MISC_BALLID];
  701.                     vaus->Misc[MISC_DEAD] = 0;
  702.                     newstage = false; //on a new stage, these aren't working right yet.
  703.                    
  704.                    
  705.                    
  706.                 }
  707.                 while ( leveldone )
  708.                 {
  709.                     capsule.all_clear();
  710.                     hold_Link_y();
  711.                     //play stage end music
  712.                     //Warp to new screen here.
  713.                     if ( cur_stage < MAX_STAGES )
  714.                     {
  715.                    
  716.                         Link->PitWarp(Game->GetCurDMap(), Game->GetCurScreen()+1);
  717.                         ++cur_stage;
  718.                         newstage = true;
  719.                         //continue;
  720.                     }
  721.                     else
  722.                     {
  723.                         Game->PlayMIDI(1);
  724.                         while(1)
  725.                         {
  726.                             Screen->DrawString(6, 96, 80, 1, 0x51, 0x00, 0, "DEMO OVER", 128);
  727.                             Waitdraw(); Waitframe();
  728.                         }
  729.                     }
  730.                     leveldone = false;
  731.                 }
  732.                 if ( revive_vaus ) //when this is called, the ball breaks through all bricks. Something isn't being set.
  733.                 {
  734.                     vaus->Data = 0; //make it invisible for the moment, to stop the death anim.
  735.                     capsule.all_clear();
  736.                    
  737.                     Game->PlayMIDI(MID_STAGE_START);
  738.                     for ( int q = 0; q < 180; ++q ) WaitNoAction();
  739.                    
  740.                     vaus->Misc[MISC_DEAD] = 0;
  741.                     revive_vaus = false;
  742.                    
  743.                     paddle.setup(vaus);
  744.                     capsule.alloff(vaus);
  745.                     ball.create(vaus);
  746.                     movingball = vaus->Misc[MISC_BALLID];
  747.                 }
  748.                
  749.                 if ( !vaus->Misc[MISC_DEAD] )
  750.                 {
  751.                     if ( !newstage )
  752.                     {
  753.                         if ( !Screen->NumNPCs() )
  754.                         {
  755.                             leveldone = true;
  756.                             continue;
  757.                         }
  758.                            
  759.                         if ( brick.all_gone() )
  760.                         {
  761.                        
  762.                             leveldone = true;
  763.                             continue;
  764.                         }
  765.                        
  766.                        
  767.                     }
  768.                     if ( Input->Key[KEY_9] )
  769.                     {
  770.                         bitmap bmp = Game->LoadBitmapID(RT_SCREEN);
  771.                         int col[20];
  772.                         for ( int q = 0; q < 20; ++ q )
  773.                         {
  774.                             col[q] = bmp->GetPixel(10+q*8,10+q*8);
  775.                         }
  776.                         TraceNL();
  777.                         for ( int q = 0; q < 20; ++q )
  778.                         {
  779.                             TraceS("Bitmap col: "); Trace(col[q]);
  780.                         }
  781.                        
  782.                         Screen->SetRenderTarget(2);
  783.                         Screen->Rectangle(0, 0, 0, 256, 256, 0x55, 100, 0, 0, 0, true, 128);
  784.                         Screen->SetRenderTarget(RT_SCREEN);
  785.                         Waitframe();
  786.                        
  787.                         bitmap offscreen = Game->LoadBitmapID(2);
  788.                         int col2[20];
  789.                         for ( int q = 0; q < 20; ++ q )
  790.                         {
  791.                             col2[q] = offscreen->GetPixel(10+q*8,10+q*8);
  792.                         }
  793.                         TraceNL();
  794.                         for ( int q = 0; q < 20; ++q )
  795.                         {
  796.                             TraceS("Offscreen Bitmap col: "); Trace(col2[q]);
  797.                         }
  798.                     }  
  799.                    
  800.                     //if ( Input->Key[KEY_P] ) Trace(movingball->UID); //Frick, I'm an idiot. HIT_BY_LWEAPON is the SCREEN INDEX< not the UID!!
  801.                         //2.54 Absolutely needs HitBy_UID!
  802.                     if ( Input->Key[KEY_1] ) Trace(frame);
  803.                     //if ( frame%60 == 0 ) { Trace(movingball->Step); }
  804.                     //Trace(movingball->Step);
  805.                     change_setting(); //check for a setting change_setting
  806.                     //paddle.extend(vaus);
  807.                     paddle.check_input();
  808.                     paddle.move(USE_MOUSE, USE_ACCEL, vaus);
  809.                    
  810.                     ball.launch(movingball);
  811.                     if ( !ball.launched(movingball) )
  812.                     {
  813.                         ball.move_with_vaus(movingball, vaus);
  814.                     }
  815.                    
  816.                     ball.drawover(movingball);
  817.                     //clamp within bounds - MANDATORY because very fast Step speeds can cause the ball
  818.                     //to *phase* through pseudo-solid objects, such as walls and the Vaus.
  819.                     ball.clamp_rightwall(movingball);
  820.                     ball.clamp_ceiling(movingball);
  821.                     ball.clamp_leftwall(movingball);
  822.                     ball.clamp_bottom(movingball, vaus);
  823.                    
  824.                    
  825.                     //ball wall bounce checks
  826.                     ball.check_ceiling(movingball);
  827.                     ball.check_leftwall(movingball);
  828.                     ball.check_rightwall(movingball);
  829.                     ball.check_hitvaus(movingball, vaus);
  830.                     //ball.set_speed(movingball);
  831.                     /*
  832.                    
  833.                     I moved this to after Waitdraw, because I wanted the post-draw timing for ball bounce, and to ensure that
  834.                     the movingball lweapon stayed alive. -Z (Alpha 0.10)
  835.                     //Bounce ball on bricks.
  836.                     for ( int q = Screen->NumNPCs(); q > 0; --q )
  837.                     {
  838.                         npc b = Screen->LoadNPC(q);
  839.                         if ( b->Type != NPCT_OTHER ) continue;
  840.                         TraceNL(); TraceS("movingball->X = "); Trace(movingball->X);
  841.                         TraceNL(); TraceS("movingball->Y = "); Trace(movingball->Y);
  842.                         brick.take_hit(b, movingball);
  843.                     }
  844.                     */
  845.                     movingball->DeadState = WDS_ALIVE; //Force it alive at all times if the vaus is alive.
  846.                         //We'll need another solition once we do the 3-way split ball. Bleah.
  847.                 }
  848.                
  849.                 //It's probably unwise to run this block twice! Where do I want it, before or after Waitdraw() ? -Z
  850.                 else
  851.                 {
  852.                     paddle.dead(vaus); //Set the death animation here.
  853.                    
  854.                     /*
  855.                     while ( (frame - 100) < death_frame )
  856.                     {
  857.                         //we should hide the vaus, and restart the stage here.
  858.                         ++frame;
  859.                         Waitdraw(); //Something is preventing the vaus from changing into the explosion style. S
  860.                         Waitframe();
  861.                     }
  862.                     lweapon deadball = movingball;
  863.                     deadball->DeadState = WDS_DEAD;
  864.                     movingball = vaus->Misc[10];
  865.                     if ( Game->Counter[CR_LIVES] )
  866.                     {
  867.                         --Game->Counter[CR_LIVES];
  868.                         revive_vaus = true;
  869.                     }
  870.                     */
  871.                    
  872.                 }
  873.                
  874.                 //Capsule mechanics
  875.                 //capsule.all_fall(vaus, movingball); //Handles all capsule interactions.
  876.                 capsule.convert();
  877.                 capsule._run(vaus, movingball);
  878.                 check_score_extralife();
  879.                 if ( !(frame%30) ) capsule.cleanup();
  880.                
  881.                 Waitdraw();
  882.                
  883.                 if ( Input->Key[KEY_7] )
  884.                     {
  885.                         bitmap bmp = Game->LoadBitmapID(RT_SCREEN);
  886.                         int col[20];
  887.                         for ( int q = 0; q < 20; ++ q )
  888.                         {
  889.                             col[q] = bmp->GetPixel(10+q*8,10+q*8);
  890.                         }
  891.                         TraceNL();
  892.                         for ( int q = 0; q < 20; ++q )
  893.                         {
  894.                             TraceS("Bitmap col: "); Trace(col[q]);
  895.                         }
  896.                        
  897.                         Screen->SetRenderTarget(2);
  898.                         Screen->Rectangle(0, 0, 0, 256, 256, 0x55, 100, 0, 0, 0, true, 128);
  899.                         Screen->SetRenderTarget(RT_SCREEN);
  900.                         Waitframe();
  901.                        
  902.                         bitmap offscreen = Game->LoadBitmapID(2);
  903.                         int col2[20];
  904.                         for ( int q = 0; q < 20; ++ q )
  905.                         {
  906.                             col2[q] = offscreen->GetPixel(10+q*8,10+q*8);
  907.                         }
  908.                         TraceNL();
  909.                         for ( int q = 0; q < 20; ++q )
  910.                         {
  911.                             TraceS("Offscreen Bitmap col: "); Trace(col2[q]);
  912.                         }
  913.                     }
  914.                    
  915.                 if ( Input->Key[KEY_4] )
  916.                 {
  917.                     TraceNL(); TraceS(" 'vaus' Pointer is: "); Trace(vaus);
  918.                     TraceNL(); TraceS(" 'movingball' Pointer is: "); Trace(movingball);
  919.                     TraceNL(); TraceS(" 'vaus_guard' Pointer is: "); Trace(vaus_guard);
  920.                    
  921.                 }
  922.                
  923.                 hold_Link_y();
  924.                
  925.                 if ( !vaus->Misc[MISC_DEAD] )
  926.                 {
  927.                     movingball->DeadState = WDS_ALIVE;
  928.                    
  929.                     //Bounce ball on bricks.
  930.                     for ( int q = Screen->NumNPCs(); q > 0; --q )
  931.                     {
  932.                         npc b = Screen->LoadNPC(q);
  933.                         if ( b->Type != NPCT_OTHER ) continue;
  934.                         //TraceNL(); TraceS("movingball->X = "); Trace(movingball->X);
  935.                         //TraceNL(); TraceS("movingball->Y = "); Trace(movingball->Y);
  936.                         movingball->DeadState = WDS_ALIVE;
  937.                         //TraceNL(); TraceS("movingball ptr: "); Trace(movingball);
  938.                         brick.take_hit(b, movingball);
  939.                     }
  940.                    
  941.                 }
  942.                 else
  943.                 {
  944.                     paddle.dead(vaus);
  945.                     while ( (frame - 100) < death_frame )
  946.                     {
  947.                         //we should hide the vaus, and restart the stage here.
  948.                         ++frame;
  949.                         Waitdraw();
  950.                         Waitframe();
  951.                     }
  952.                     lweapon deadball = movingball;
  953.                     deadball->DeadState = WDS_DEAD;
  954.                     movingball = Debug->NULL(); //Because = NULL() requires alpha 32. :D
  955.                     if ( Game->Counter[CR_LIVES] )
  956.                     {
  957.                         --Game->Counter[CR_LIVES];
  958.                         revive_vaus = true;
  959.                     }
  960.                     else //Ugh, this is a mess. I might want to rewrite the gane over portion, as it feels as if it'll be a biugger kludge than just calling break.
  961.                     {
  962.                         if ( !death_anim[DEATH_ANIM_COUNTDOWN_TO_QUIT] )
  963.                         {
  964.                             death_anim[DEATH_ANIM_COUNTDOWN_TO_QUIT] = COUNTDOWN_TO_QUIT_FRAMES;
  965.                             continue;
  966.                         }
  967.                         else
  968.                         {
  969.                             --death_anim[DEATH_ANIM_COUNTDOWN_TO_QUIT];
  970.                             if ( death_anim[DEATH_ANIM_COUNTDOWN_TO_QUIT] == 1 )
  971.                             {
  972.                                 quit = QUIT_GAMEOVER; //Game over state.
  973.                                 TraceNL(); TraceS("Game 'quit' state is now: "); Trace(quit);
  974.                             }
  975.                         }
  976.                     }
  977.                        
  978.                 }
  979.                
  980.                 Waitframe();
  981.             }
  982.            
  983.             while (quit == QUIT_GAMEOVER) //Game Over
  984.             {
  985.                 if ( !(GAME[GAME_MISC_FLAGS]&GMFS_PLAYED_GAME_OVER_MUSIC) )
  986.                 {
  987.                     GAME[GAME_MISC_FLAGS]|=GMFS_PLAYED_GAME_OVER_MUSIC;
  988.                     //Play Game over MIDI
  989.                     Game->PlayMIDI(1);
  990.                     clearscore();
  991.                     update_high_score_display();
  992.                 }
  993.                    
  994.                 Screen->DrawString(6, 96, 80, 1, 0x51, 0x00, 0, "GAME OVER", 128);
  995.                
  996.                 Waitdraw();
  997.                 Waitframe();
  998.             }
  999.             //We should never reach here.
  1000.             Waitframe();
  1001.         }
  1002.     }
  1003.     void check_score_extralife()
  1004.     {
  1005.         int score = Game->Counter[CR_SCORE];
  1006.         if ( score >= (last_score_award+SCORE_BONUS_LIFE_AT) )
  1007.         {
  1008.             last_score_award += SCORE_BONUS_LIFE_AT;
  1009.             Game->PlaySound(SFX_EXTRA_VAUS);
  1010.             ++Game->Counter[CR_LIVES];
  1011.            
  1012.         }
  1013.     }
  1014.     void clearscore()
  1015.     {
  1016.         if ( last_score_award > high_score ) high_score = last_score_award;
  1017.         last_score_award = 0;
  1018.        
  1019.     }
  1020.     void update_high_score_display()
  1021.     {
  1022.         Game->Counter[CR_HIGH_SCORE] = high_score;
  1023.     }
  1024.     void change_setting()
  1025.     {
  1026.         if ( Input->Key[KEY_V] && (frame%10 == 0)) { if ( fast_mouse < FAST_MOUSE_MAX ) ++fast_mouse; TraceNL(); TraceS("fast_mouse is now: "); Trace(fast_mouse);  }
  1027.         if ( Input->Key[KEY_C] && (frame%10 == 0) ) { if ( fast_mouse > 0 ) --fast_mouse; TraceNL(); TraceS("fast_mouse is now: "); Trace(fast_mouse);  }
  1028.         if ( Input->Key[KEY_M] )
  1029.         {
  1030.             if ( PressShift() )
  1031.             {
  1032.                 USE_MOUSE = 1;
  1033.                 fast_mouse = 2;
  1034.             }
  1035.             else    USE_MOUSE = 1;
  1036.         }
  1037.         if ( Input->Key[KEY_N] ) USE_MOUSE = 0;
  1038.         if ( Input->Key[KEY_F] ) USE_ACCEL = 1;
  1039.         if ( Input->Key[KEY_G] ) USE_ACCEL = 0;
  1040.         if ( Input->Key[KEY_T] ) --paddle_speed; // paddle_speed = vbound(paddle_speed
  1041.         if ( Input->Key[KEY_Y] ) ++paddle_speed; // paddle_speed = vbound(paddle_speed
  1042.     }
  1043.     void hold_Link_x(ffc v)
  1044.     {
  1045.         Link->X = v->X+(v->TileWidth*8);
  1046.     }
  1047.     void hold_Link_y()
  1048.     {
  1049.         Link->Y = START_PADDLE_Y - 4;
  1050.     }
  1051.     bool quit() { return ( quit ); }
  1052.    
  1053.     void check_min_zc_build()
  1054.     {
  1055.         if ( Game->Beta < MIN_ZC_ALPHA_BUILD )
  1056.         {
  1057.             Game->PlayMIDI(9);
  1058.             int v_too_early = 600; int req_vers[3]; itoa(req_vers, MIN_ZC_ALPHA_BUILD);
  1059.             TraceNL(); int vers[3]; itoa(vers,Game->Beta);
  1060.             TraceS("This version of Arkanoid.qst requires Zelda Classic v2.54, Alpha (");
  1061.             TraceS(req_vers);
  1062.             TraceS("), or later.");
  1063.             TraceNL();
  1064.             TraceS("I'm detecting Zelda Classic v2.54, Alpha (");
  1065.             TraceS(vers);
  1066.             TraceS(") and therefore, I must refuse to run. :) ");
  1067.             TraceNL();
  1068.            
  1069.             while(v_too_early--)
  1070.             {
  1071.                 //Screen->DrawString(7, 4, 40, 1, 0x04, 0x5F, 0,
  1072.                 //"This version of Arkanoid.qst requires Zelda Classic 2.54, Alpha 32",
  1073.                 //128);
  1074.                 Screen->DrawString(7, 15, 40, 1, 0x04, 0x5F, 0,
  1075.                 "You are not using a version of ZC adequate to run         ",
  1076.                 128);
  1077.                
  1078.                 Screen->DrawString(7, 15, 55, 1, 0x04, 0x5F, 0,
  1079.                 "this quest. Please see allegro.log for details.                   ",
  1080.                 128);
  1081.            
  1082.                 Waitdraw();
  1083.                 WaitNoAction();
  1084.             }
  1085.             Game->End();
  1086.            
  1087.         }
  1088.     }
  1089.    
  1090. }
  1091.  
  1092. const int TILE_BALL = 50512;
  1093. const int SPR_BALL = 100;
  1094.  
  1095.  
  1096.  
  1097. //preliminary ball
  1098. ffc script ball
  1099. {
  1100.     void run(){}
  1101.     void setup_sprite(int sprite_id)
  1102.     {
  1103.         spritedata sd = Game->LoadSpriteData(sprite_id);
  1104.         sd->Tile = TILE_BALL;
  1105.     }
  1106.     void set_speed(lweapon b, int speed)
  1107.     {
  1108.         //Trace(bounces);
  1109.         b->Step = speed; // bound(bounces,0,MAX_BOUNCES);
  1110.         //Trace(b->Step);
  1111.     }
  1112.     void create(ffc vaus_id) //send the ball lweapon pointer back to the vaus
  1113.     {
  1114.         lweapon ball = Screen->CreateLWeapon(LW_SCRIPT1);
  1115.         TraceNL(); TraceS("Creating ball with Script UID: "); Trace(ball->UID);
  1116.         ball->HitWidth = 6; //Not 4, so that the ball bounces when its edges touch a brick.
  1117.         ball->HitHeight = 6; //Not 4, so that the ball bounces when its edges touch a brick.
  1118.         ball->UseSprite(SPR_BALL);
  1119.         ball->X = vaus_id->X+18;
  1120.         ball->Y = vaus_id->Y-2;
  1121.         ball->Damage = 1;
  1122.         ball_uid = ball->UID;
  1123.         ball->HitXOffset = -1; //so that the ball bounces when its edges touch a brick.
  1124.         ball->HitYOffset = -1; //so that the ball bounces when its edges touch a brick.
  1125.         vaus_id->Misc[MISC_BALLID] = ball;
  1126.         TraceNL();TraceS("ball pointer: "); Trace(ball);
  1127.         TraceNL();TraceS("ball Pointer, stored: "); Trace(vaus_id->Misc[MISC_BALLID]);
  1128.     }
  1129.     void drawover(lweapon b)
  1130.     {
  1131.         b->DrawYOffset = -32768; //I'm not sure why the script draw for this is mis-drawing relative to the angle of the ball.
  1132.         Screen->DrawTile(6,b->X,b->Y,b->Tile,b->TileWidth,b->TileHeight,b->CSet,-1,-1,0,0,0,0,true,128);
  1133.     }
  1134.     void launch(lweapon b)
  1135.     {
  1136.         if ( b->Misc[MISC_LAUNCHED] ) return;
  1137.         bool launched;
  1138.         for ( int q = CB_A; q < CB_R; ++q )
  1139.         {
  1140.             if ( Input->Press[q] ) { launched = true; break; }
  1141.         }
  1142.         if ( USE_MOUSE )
  1143.         {
  1144.             //if ( Input->Mouse[_MOUSE_LCLICK] )  //Not working?!
  1145.             if ( Link->InputMouseB )
  1146.                 launched = true;
  1147.         }
  1148.         if ( launched )
  1149.         {
  1150.             //b->Angular = true;
  1151.             Game->PlaySound(SFX_BALL_HIT_VAUS);
  1152.             b->Dir = DIR_RIGHTUP;  
  1153.             b->Step = BALL_INITIAL_STEP;
  1154.             b->Misc[MISC_LAUNCHED] = 1;
  1155.         }
  1156.     }
  1157.     bool launched(lweapon b)
  1158.     {
  1159.         return (b->Misc[MISC_LAUNCHED]);
  1160.     }
  1161.     void launched(lweapon b, bool state)
  1162.     {
  1163.         b->Misc[MISC_LAUNCHED] = state;
  1164.     }
  1165.     void move(lweapon b)
  1166.     {
  1167.        
  1168.     }
  1169.     float bound(int val, int min, int max)
  1170.     {
  1171.         if ( val < min ) return min;
  1172.         if ( val > max ) return max;
  1173.         return val;
  1174.     }
  1175.     //Not launched yet.
  1176.     void move_with_vaus(lweapon b, ffc v)
  1177.     {
  1178.         b->X = v->X+18;
  1179.     }
  1180.     //ball.clamp*() are needed for when the step speed is so great that the ball skips past the equality checks.
  1181.     void clamp_ceiling(lweapon b)
  1182.     {
  1183.         if ( b->Y < BALL_MIN_Y )           
  1184.         {
  1185.             b->Y = BALL_MIN_Y;
  1186.         }
  1187.     }
  1188.     void clamp_leftwall(lweapon b)
  1189.     {
  1190.         if ( caught == CATCH_HOLDING_BALL ) return; //don't do anything while the vaus is holding the ball
  1191.         if ( b->X < BALL_MIN_X ) b ->X = BALL_MIN_X;
  1192.     }
  1193.     void clamp_rightwall(lweapon b)
  1194.     {
  1195.         if ( caught == CATCH_HOLDING_BALL ) return; //don't do anything while the vaus is holding the ball
  1196.         if ( b->X > BALL_MAX_X ) b->X = BALL_MAX_X;
  1197.     }
  1198.     /*
  1199.     void clamp_bottom(lweapon b, ffc v)
  1200.     {
  1201.         if ( caught == CATCH_HOLDING_BALL ) return; //don't do anything while the vaus is holding the ball
  1202.         if ( b->Y+4 > v->Y+8 ) dead(b,v);
  1203.     }
  1204.     */
  1205.     //A function to check of the bounding will prevent the ball from falling out of field.
  1206.     void clamp_bottom(lweapon b, ffc v)
  1207.     {
  1208.         if ( caught == CATCH_HOLDING_BALL ) return; //don't do anything while the vaus is holding the ball
  1209.         if ( b->Y+4 > v->Y ) b->Y = v->Y-4;
  1210.     }
  1211.     void check_ceiling(lweapon b)
  1212.     {
  1213.         if ( b->Y == BALL_MIN_Y )          
  1214.         {
  1215.             Game->PlaySound(SFX_BALL_HIT_BLOCK);
  1216.             if ( b->Angular )
  1217.             {
  1218.                 switch(b->Angle)
  1219.                 {
  1220.                     case DIR_LLU:
  1221.                     {
  1222.                         b->Angular = false;
  1223.                         b->Dir = DIR_LEFTDOWN;
  1224.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1225.                         break;
  1226.                     }
  1227.                     case DIR_LUU:
  1228.                     {
  1229.                         b->Angular = false;
  1230.                         b->Dir = DIR_LEFTDOWN;
  1231.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1232.                         break;
  1233.                     }
  1234.                     case DIR_RRU:
  1235.                     {
  1236.                         b->Angular = false;
  1237.                         b->Dir = DIR_RIGHTDOWN;
  1238.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1239.                         break;
  1240.                     }
  1241.                     case DIR_RUU:
  1242.                     {
  1243.                         b->Angular = false;
  1244.                         b->Dir = DIR_RIGHTDOWN;
  1245.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1246.                         break;
  1247.                     }
  1248.                    
  1249.                 }
  1250.             }
  1251.             else
  1252.             {
  1253.                 switch(b->Dir)
  1254.                 {
  1255.                     case DIR_RIGHTUP: { b->Dir = DIR_RIGHTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1256.                     case DIR_LEFTUP: { b->Dir = DIR_LEFTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1257.                     default: {
  1258.                         TraceNL(); TraceS("Ball direction invalid for ball.check_ceiling().");
  1259.                             TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  1260.                         b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1261.                 }
  1262.             }
  1263.         }
  1264.     }
  1265.     void check_leftwall(lweapon b)
  1266.     {
  1267.         if ( caught == CATCH_HOLDING_BALL ) return; //don't do anything while the vaus is holding the ball
  1268.         if ( b->X == BALL_MIN_X )
  1269.         {
  1270.             Game->PlaySound(SFX_BALL_HIT_BLOCK);
  1271.             if ( b->Angular )
  1272.             {
  1273.                 switch(b->Angle)
  1274.                 {
  1275.                     case DIR_LLU:
  1276.                     {
  1277.                         b->Angular = false;
  1278.                         b->Dir = DIR_RIGHTUP;
  1279.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1280.                         break;
  1281.                     }
  1282.                     case DIR_LUU:
  1283.                     {
  1284.                         b->Angular = false;
  1285.                         b->Dir = DIR_RIGHTUP;
  1286.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1287.                         break;
  1288.                     }
  1289.                     case DIR_LLD:
  1290.                     {
  1291.                         b->Angular = false;
  1292.                         b->Dir = DIR_RIGHTDOWN;
  1293.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1294.                         break;
  1295.                     }
  1296.                     case DIR_LDD:
  1297.                     {
  1298.                         b->Angular = false;
  1299.                         b->Dir = DIR_RIGHTDOWN;
  1300.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1301.                         break;
  1302.                     }
  1303.                    
  1304.                 }
  1305.             }
  1306.             else
  1307.             {
  1308.                 switch(b->Dir)
  1309.                 {
  1310.                     case DIR_LEFTDOWN: { b->Dir = DIR_RIGHTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1311.                     case DIR_LEFTUP: { b->Dir = DIR_RIGHTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1312.                     default: {
  1313.                         TraceNL(); TraceS("Ball direction invalid for ball.check_leftwall().");
  1314.                             TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  1315.                         b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1316.                 }
  1317.             }
  1318.         }
  1319.     }
  1320.     void check_rightwall(lweapon b)
  1321.     {
  1322.         if ( caught == CATCH_HOLDING_BALL ) return; //don't do anything while the vaus is holding the ball
  1323.         if ( b->X == BALL_MAX_X )
  1324.         {
  1325.             Game->PlaySound(SFX_BALL_HIT_BLOCK);
  1326.             if ( b->Angular )
  1327.             {
  1328.                 switch(b->Angle)
  1329.                 {
  1330.                     case DIR_RRD:
  1331.                     {
  1332.                         b->Angular = false;
  1333.                         b->Dir = DIR_LEFTDOWN;
  1334.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1335.                         break;
  1336.                     }
  1337.                     case DIR_RDD:
  1338.                     {
  1339.                         b->Angular = false;
  1340.                         b->Dir = DIR_LEFTDOWN;
  1341.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1342.                         break;
  1343.                     }
  1344.                     case DIR_RRU:
  1345.                     {
  1346.                         b->Angular = false;
  1347.                         b->Dir = DIR_LEFTUP;
  1348.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1349.                         break;
  1350.                     }
  1351.                     case DIR_RUU:
  1352.                     {
  1353.                         b->Angular = false;
  1354.                         b->Dir = DIR_LEFTUP;
  1355.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1356.                         break;
  1357.                     }
  1358.                    
  1359.                 }
  1360.             }
  1361.             else
  1362.             {
  1363.                 switch(b->Dir)
  1364.                 {
  1365.                     case DIR_RIGHTDOWN: { b->Dir = DIR_LEFTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1366.                     case DIR_RIGHTUP: { b->Dir = DIR_LEFTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1367.                     default: {
  1368.                         TraceNL(); TraceS("Ball direction invalid for ball.check_rightwall().");
  1369.                             TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  1370.                         b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1371.                 }
  1372.             }
  1373.         }
  1374.     }
  1375.     void check_hitvaus(lweapon b, ffc v)
  1376.     {
  1377.         if ( launched(b) )
  1378.         {
  1379.            
  1380.             if ( b->Angular )
  1381.             {
  1382.                 if ( b->Angle == DIR_UUR ){ return; }
  1383.                 if ( b->Angle == DIR_UUL ) { return; }
  1384.                 if ( b->Angle == DIR_ULL ) { return; }
  1385.                 if ( b->Angle == DIR_URR ) { return; }
  1386.             }
  1387.             else
  1388.             {
  1389.                 if ( b->Dir == DIR_RIGHTUP ) { return; }
  1390.                 if ( b->Dir == DIR_LEFTUP ) { return; }
  1391.             }
  1392.             //if ( Collision(b,v) ) //We'll refine this, later.
  1393.            
  1394.             //else
  1395.             //{
  1396.                 int hit_position; int vaus_midpoint =  v->X+(((v->TileWidth*16)/2)-1);
  1397.                 int midpoint_segment = v->X+(((v->TileWidth*16)/6));
  1398.                 int ball_midpoint = b->X+3;
  1399.                
  1400.                 if ( b->Y+4 == v->Y )
  1401.                     //Now we need to check here, if the paddle is under the ball:
  1402.                 {
  1403.                     if ( b->X >= v->X-3 ) //-3, because the ball is 4px wide, so we cover the last pixel of the ball against the furst pixel of the Vaus
  1404.                     {
  1405.                         if ( b->X <= v->X+((v->TileWidth*16)+4) ) //no +3 here, because it's the actual X, so the first pixel of the ball is covered by the last pixel of the vaus.
  1406.                         {
  1407.                             Game->PlaySound(SFX_BALL_HIT_VAUS);
  1408.                             //b->Y = v->Y-1;
  1409.                            
  1410.                             if ( ball_midpoint <= vaus_midpoint ) //hit left side of vaus
  1411.                             {
  1412.                                 //more left than up, hit end of Vaus
  1413.                                 if ( b->X <= (v->X-1) )
  1414.                                 //if ( Abs(ball_midpoint-vaus_midpoint) <= 2 )
  1415.                                 {
  1416.                                     //angular up
  1417.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR Left-left-Up");
  1418.                                    
  1419.                                     b->Angular = true;
  1420.                                     b->Angle = DIR_LLU;
  1421.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_LUU);
  1422.                                     return;
  1423.                                 }
  1424.                                
  1425.                                 //more up than left, hit close to centre
  1426.                                 //else if ( (Abs(b->X+2)-vaus_midpoint) <= 3 )
  1427.                                 //if ( Abs(ball_midpoint-vaus_midpoint) <= 2 )
  1428.                                 if ( (Abs(vaus_midpoint - b->X+2)) <= 3 )
  1429.                                 {
  1430.                                     //angular up
  1431.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR Left-Up-Up");
  1432.                                    
  1433.                                     b->Angular = true;
  1434.                                     b->Angle = DIR_LUU;
  1435.                                     b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1436.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_LUU);
  1437.                                     return;
  1438.                                 }
  1439.                                 //hit between the zones, normal left-up
  1440.                                 else
  1441.                                 {
  1442.                                
  1443.                                     //hit the centre midpoint
  1444.                                     //set angular = false
  1445.                                     //set DIR_UL
  1446.                                     TraceNL(); TraceS("Setting ball dir to DIGITAL Left-Up");
  1447.                                     //b->Y = v->Y-1;
  1448.                                     b->Angular = false;
  1449.                                     b->Dir = DIR_UPLEFT;
  1450.                                     b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1451.                                     return;
  1452.                                 }
  1453.                                
  1454.                             }
  1455.                             else if ( ball_midpoint > vaus_midpoint ) //hit right side of vaus
  1456.                             {
  1457.                                 /*
  1458.                                 if ( Abs(ball_midpoint-vaus_midpoint) <= 2 )
  1459.                                 {
  1460.                                     //angular up
  1461.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR RIGHT-Up-Up");
  1462.                                     --b->Y;
  1463.                                     b->Angular = true;
  1464.                                     b->Angle = DIR_RUU;
  1465.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_RUU);
  1466.                        
  1467.                                 }
  1468.                                 if ( b->X >= (v->X+(v->TileWidth*16)-2) )
  1469.                                 {
  1470.                                     //angular, sideways
  1471.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR right-right-Up");
  1472.                                     --b->Y;
  1473.                                     b->Angular = true;
  1474.                                     b->Angle = DIR_RRU;
  1475.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_RRU);
  1476.                        
  1477.                                 }
  1478.                                 */
  1479.                                 //more up then right, hit vaus close to centre
  1480.                                 if ( (Abs(vaus_midpoint - b->X)) <= 3 )
  1481.                                 {
  1482.                                     //angular up
  1483.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR RIGHT-Up-Up");
  1484.                                    
  1485.                                     b->Angular = true;
  1486.                                     b->Angle = DIR_RUU;
  1487.                                     b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1488.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_RUU);
  1489.                                     return;
  1490.                                 }
  1491.                                 //more right than up, hit end of vaus
  1492.                                 else if ( b->X > ( vaus_midpoint + ((v->TileWidth*16)/2)-4) )
  1493.                                 //else if ( (Abs(vaus_midpoint - b->X)) >= v->X+((v->TileWidth*16)/2)-1 )
  1494.                                 {
  1495.                                     //angular up
  1496.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR RIGHT-right-Up");
  1497.                                    
  1498.                                     b->Angular = true;
  1499.                                     b->Angle = DIR_RRU;
  1500.                                     b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1501.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_RUU);
  1502.                                     return;
  1503.                                 }
  1504.                                 else
  1505.                                 {
  1506.                                     //hit the centre midpoint
  1507.                                     //set angular = false
  1508.                                     //set DIR_UR
  1509.                                     TraceNL(); TraceS("Setting ball dir to DIGITAL Right-Up");
  1510.                                     //b->Y = v->Y-6;
  1511.                                     b->Angular = false;
  1512.                                     b->Dir = DIR_UPRIGHT;
  1513.                                     //b->Dir = DIR_UPRIGHT;
  1514.                                     b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1515.                                     return;
  1516.                                 }
  1517.                                
  1518.                             }
  1519.                                
  1520.                             else //catchall
  1521.                             {
  1522.                                 switch(b->Dir)
  1523.                                 {
  1524.                                     case DIR_LEFTDOWN: { b->Dir = DIR_LEFTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1525.                                     case DIR_RIGHTDOWN: { b->Dir = DIR_RIGHTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1526.                                     default: { b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1527.                                 }
  1528.                             }
  1529.                         }
  1530.                         else
  1531.                         {
  1532.                             dead(b,v);
  1533.                         }
  1534.                     }
  1535.                     else
  1536.                     {
  1537.                         dead(b,v);
  1538.                     }
  1539.                 }
  1540.             //}
  1541.            
  1542.         }
  1543.     }
  1544.     void dead(lweapon b, ffc v)
  1545.     {
  1546.        
  1547.         Game->PlayMIDI(5);
  1548.         //remove the ball
  1549.         b->Y = -32768; b->Step = 0;
  1550.         v->Misc[MISC_DEAD] = 1;
  1551.         //if there are more balls in play, switch movingball to one of those
  1552.         //otherwise,
  1553.         //check next life
  1554.         //if more lives, reset playfield
  1555.         //otherwise game over
  1556.        
  1557.     }
  1558.    
  1559.    
  1560.    
  1561. }
  1562.  
  1563. ffc script ball_controller
  1564. {
  1565.     void run()
  1566.     {
  1567.         lweapon ball;
  1568.         lweapon active_ball; //will be used for when we have multiple balls.
  1569.         lweapon balls[3]; //for divide
  1570.         ball = Screen->CreateLWeapon(LW_SCRIPT1);
  1571.         ball->X = START_BALL_X;
  1572.         ball->Y = START_BALL_Y;
  1573.         this->Vx = START_BALL_VX;
  1574.         this->Vy = START_BALL_VY;
  1575.         bool alive = true;
  1576.         int num_balls = 1;
  1577.         while(alive)
  1578.         {
  1579.             if ( ball->Y <= BALL_MIN_Y )
  1580.             {
  1581.                 bounce();
  1582.             }
  1583.             if ( ball->X <= BALL_MIN_X )
  1584.             {
  1585.                 bounce();
  1586.             }
  1587.             if ( ball->X >= BALL_MAX_X )
  1588.             {
  1589.                 bounce();
  1590.             }
  1591.                
  1592.             if ( ball->Y >= BALL_MAX_Y )
  1593.             {
  1594.                 if ( num_balls < 2 )
  1595.                 {
  1596.                     alive = false;
  1597.                 }
  1598.                 else
  1599.                 {
  1600.                     kill_ball(ball); //removes this ball, and sets another ball to be the active one
  1601.                     --num_balls;
  1602.                 }
  1603.             }
  1604.             Waitframe();
  1605.         }
  1606.     }
  1607.     void bounce(){}
  1608.     void kill_ball(lweapon b){}
  1609.    
  1610. }
  1611.  
  1612. const int BRICK_MAX = 14;
  1613.  
  1614. //Layer 1
  1615. const int CMB_BRICK_RED     = 1488;
  1616. const int CMB_BRICK_WHITE   = 1490;
  1617. const int CMB_BRICK_BLUE    = 1492;
  1618. const int CMB_BRICK_ORANGE  = 1494;
  1619. const int CMB_BRICK_TEAL    = 1496;
  1620. const int CMB_BRICK_VIOLET  = 1498;
  1621. const int CMB_BRICK_GREEN   = 1500;
  1622. const int CMB_BRICK_YELLOW  = 1502;
  1623. const int CMB_BRICK_SILVER1 = 1504;
  1624. const int CMB_BRICK_SILVER2 = 1506;
  1625. const int CMB_BRICK_SILVER3 = 1508;
  1626. const int CMB_BRICK_SILVER4 = 1510;
  1627. const int CMB_BRICK_GOLD    = 1516;
  1628.  
  1629.  
  1630. //layer 2
  1631. const int CMB_BRICK_RED_LOW     = 1489;
  1632. const int CMB_BRICK_WHITE_LOW   = 1491;
  1633. const int CMB_BRICK_BLUE_LOW    = 1493;
  1634. const int CMB_BRICK_ORANGE_LOW  = 1495;
  1635. const int CMB_BRICK_TEAL_LOW    = 1497;
  1636. const int CMB_BRICK_VIOLET_LOW  = 1499;
  1637. const int CMB_BRICK_GREEN_LOW   = 1501;
  1638. const int CMB_BRICK_YELLOW_LOW  = 1503;
  1639. const int CMB_BRICK_SILVER1_LOW = 1505;
  1640. const int CMB_BRICK_SILVER2_LOW = 1507;
  1641. const int CMB_BRICK_SILVER3_LOW = 1509;
  1642. const int CMB_BRICK_SILVER4_LOW = 1511;
  1643. const int CMB_BRICK_GOLD_LOW    = 1517;
  1644.  
  1645. //enemies
  1646. const int NPC_BRICK_RED     = 181;
  1647. const int NPC_BRICK_WHITE   = 182;
  1648. const int NPC_BRICK_BLUE    = 183;
  1649. const int NPC_BRICK_ORANGE  = 184;
  1650. const int NPC_BRICK_TEAL    = 185;
  1651. const int NPC_BRICK_VIOLET  = 186;
  1652. const int NPC_BRICK_GREEN   = 187;
  1653. const int NPC_BRICK_YELLOW  = 188;
  1654. const int NPC_BRICK_SILVER1     = 189;
  1655. const int NPC_BRICK_SILVER2     = 190;
  1656. const int NPC_BRICK_SILVER3     = 255; //not set up yet;
  1657. const int NPC_BRICK_SILVER4     = 255; //not set up yet
  1658. const int NPC_BRICK_GOLD    = 191;
  1659.  
  1660.  
  1661. const int HIT_BY_LWEAPON = 2;
  1662. const int HIT_BY_LWEAPON_UID = 6;
  1663.  
  1664.  
  1665.  
  1666. const int CAPS_TYPE_EXTEND = 126;
  1667. const int CAPS_TYPE_BREAK = 129;
  1668. const int CAPS_TYPE_CATCH = 125;
  1669. const int CAPS_TYPE_DIVIDE = 128;
  1670. const int CAPS_TYPE_LASER = 127;
  1671. const int CAPS_TYPE_VAUS = 123;
  1672. const int CAPS_TYPE_SLOW = 124;
  1673.  
  1674.  
  1675. ffc script capsule
  1676. {
  1677.     void run(ffc v, lweapon b)
  1678.     {
  1679.         for ( int q = Screen->NumLWeapons(); q > 0; --q )
  1680.         {
  1681.             lweapon c = Screen->LoadLWeapon(q);
  1682.             if ( c->ID == LW_SCRIPT2 )
  1683.             {
  1684.                 if ( check_hitvaus(c,v,b) ) Remove(c);
  1685.                 if ( c->Y > 256 ) Remove(c);
  1686.             }
  1687.         }
  1688.     }
  1689.     void _run(ffc v, lweapon b)
  1690.     {
  1691.         for ( int q = Screen->NumLWeapons(); q > 0; --q )
  1692.         {
  1693.             lweapon c = Screen->LoadLWeapon(q);
  1694.             if ( c->ID == LW_SCRIPT2 )
  1695.             {
  1696.                 if ( check_hitvaus(c,v,b) ) Remove(c);
  1697.                 if ( c->Y > 256 ) Remove(c);
  1698.             }
  1699.         }
  1700.     }
  1701.     void create(int x, int y)
  1702.     {
  1703.         int type = choosetype();
  1704.         if ( type > 0 )
  1705.         {
  1706.             item capsule = Screen->CreateItem(type);
  1707.             capsule->X = x;
  1708.             capsule->Y = y;
  1709.         }
  1710.     }
  1711.     void convert()
  1712.     {
  1713.         const int CAPS_EW_MISC_TYPE = 5;
  1714.         const int CAPS_ITEM_ATTRIB_TYPE = 0;
  1715.         const int CAPS_ITEM_SPRITE = 0;
  1716.         //const int CAPS_EW_MISC_POINTS = 6; //global
  1717.         const int CAPS_ITEM_ATTRIB_POINTS = 1;
  1718.         item c; itemdata id;
  1719.         for ( int q = Screen->NumItems(); q > 0; --q )
  1720.         {
  1721.             c = Screen->LoadItem(q);
  1722.             id = Game->LoadItemData(c->ID);
  1723.             if ( id->Family == IC_CUSTOM1 )
  1724.             {
  1725.                 lweapon cap = Screen->CreateLWeapon(EW_SCRIPT2);
  1726.                 cap->X = c->X;
  1727.                 cap->Y = c->Y;
  1728.                 cap->Misc[CAPS_EW_MISC_TYPE] = id->Attributes[CAPS_ITEM_ATTRIB_TYPE];
  1729.                 cap->UseSprite(id->Sprites[CAPS_ITEM_SPRITE]);
  1730.                 cap->Misc[CAPS_EW_MISC_POINTS] = id->Attributes[CAPS_ITEM_ATTRIB_POINTS];
  1731.                 //c->DrawYOffset = -16000;
  1732.                 cap->HitWidth = c->HitWidth;
  1733.                 cap->HitHeight = c->HitHeight;
  1734.                 Remove(c);
  1735.                
  1736.                 cap->Dir = DIR_DOWN;
  1737.                
  1738.                 cap->Step = CAPSULE_STEP;
  1739.                 cap->CollDetection = false;
  1740.                 cap->Behind = false;
  1741.                 TraceNL(); TraceS("Behind is: "); TraceB(cap->Behind);
  1742.             }
  1743.         }
  1744.     }
  1745.     int get_type(lweapon c)
  1746.     {
  1747.         const int CAPS_EW_MISC_TYPE = 5;
  1748.         return c->Misc[CAPS_EW_MISC_TYPE];
  1749.     }
  1750.     void drawover(item c)
  1751.     {
  1752.         DrawToLayer(c, 5, 128);
  1753.     }
  1754.     bool check_hitvaus(lweapon c, ffc v, lweapon b)
  1755.     {
  1756.         //mask out the area of the screen where the Vaus paddle isn't located, relative to the capsule hitbox.
  1757.         if ( (c->Y+c->HitHeight) < START_PADDLE_Y ) return false;
  1758.         if ( c->Y > (START_PADDLE_Y+START_PADDLE_HEIGHT-2) ) return false; //last two pixels of vaus
  1759.         if ( (c->X+c->HitWidth) < v->X ) return false;
  1760.         if ( c->X > (v->X+(v->TileWidth*16)) ) return false;
  1761.         //if it hits, check the type
  1762.         int captype = c->ID;
  1763.         switch(get_type(c))
  1764.         {
  1765.             case CAPS_TYPE_EXTEND: { extend(v); Game->Counter[CR_SCORE] += c->Misc[CAPS_EW_MISC_POINTS]; return true; }
  1766.             case CAPS_TYPE_BREAK: { escape(v); Game->Counter[CR_SCORE] += c->Misc[CAPS_EW_MISC_POINTS]; return true; }
  1767.             case CAPS_TYPE_CATCH: { catchball(v); Game->Counter[CR_SCORE] += c->Misc[CAPS_EW_MISC_POINTS]; return true; }
  1768.             case CAPS_TYPE_DIVIDE: { split(v,b); Game->Counter[CR_SCORE] += c->Misc[CAPS_EW_MISC_POINTS]; return true; }
  1769.             case CAPS_TYPE_LASER: { laser(v); Game->Counter[CR_SCORE] += c->Misc[CAPS_EW_MISC_POINTS]; return true; }
  1770.             case CAPS_TYPE_VAUS:{ extravaus(v); Game->Counter[CR_SCORE] += c->Misc[CAPS_EW_MISC_POINTS]; return true; }
  1771.             case CAPS_TYPE_SLOW:{ slow(v,b); Game->Counter[CR_SCORE] += c->Misc[CAPS_EW_MISC_POINTS]; return true; }
  1772.             default: break;
  1773.         }
  1774.                
  1775.         return false;      
  1776.            
  1777.            
  1778.     }
  1779.     bool check_hitvaus(item c, ffc v, lweapon b)
  1780.     {
  1781.         //mask out the area of the screen where the Vaus paddle isn't located, relative to the capsule hitbox.
  1782.         if ( (c->Y+c->HitHeight) < START_PADDLE_Y ) return false;
  1783.         if ( c->Y > (START_PADDLE_Y+START_PADDLE_HEIGHT-2) ) return false; //last two pixels of vaus
  1784.         if ( (c->X+c->HitWidth) < v->X ) return false;
  1785.         if ( c->X > (v->X+(v->TileWidth*16)) ) return false;
  1786.         //if it hits, check the type
  1787.         int captype = c->ID;
  1788.         switch(captype)
  1789.         {
  1790.             case CAPS_TYPE_EXTEND: { extend(v); return true; }
  1791.             case CAPS_TYPE_BREAK: { escape(v); return true; }
  1792.             case CAPS_TYPE_CATCH: { catchball(v); return true; }
  1793.             case CAPS_TYPE_DIVIDE: { split(v,b); return true; }
  1794.             case CAPS_TYPE_LASER: { laser(v); return true; }
  1795.             case CAPS_TYPE_VAUS:{ extravaus(v); return true; }
  1796.             case CAPS_TYPE_SLOW:{ slow(v,b); return true; }
  1797.             default: break;
  1798.         }
  1799.                
  1800.         return false;      
  1801.            
  1802.            
  1803.     }
  1804.     void laser(ffc v)
  1805.     {
  1806.         TraceNL(); TraceS("Capsule LASER struck vaus!!");
  1807.         extended = false;
  1808.         Game->PlaySound(SFX_ARK2_POWERUP2);
  1809.         v->Data = CMB_VAUS_LASER;
  1810.         v->TileWidth = 2;
  1811.         //Game->PlaySound(capsule)
  1812.         //change the vaus data to the laser
  1813.         laser = true;
  1814.         caught = CATCH_NONE;
  1815.        
  1816.     }
  1817.     void extend(ffc v)
  1818.     {
  1819.         TraceNL(); TraceS("Capsule EXTEND struck vaus!!");
  1820.         Game->PlaySound(SFX_EXTEND);
  1821.         //change the vaus data to the default
  1822.         //this is needed because collecting any powerup after
  1823.         //a laser capsule reverts fromt he laser status
  1824.         laser = false;
  1825.         extended = true;
  1826.         v->Data = CMB_VAUS_EXTENDED;
  1827.         v->TileWidth = 3;
  1828.         caught = CATCH_NONE;
  1829.     }
  1830.     void slow(ffc v, lweapon b)
  1831.     {
  1832.         TraceNL(); TraceS("Capsule SLOW struck vaus!!");;
  1833.         Game->PlaySound(SFX_ARK2_POWERUP2);
  1834.         laser = false;
  1835.         extended = false;
  1836.         v->Data = CMB_VAUS;
  1837.         v->TileWidth = 2;
  1838.         caught = CATCH_NONE;
  1839.         b->Step = BALL_INITIAL_STEP;
  1840.     }
  1841.     void escape(ffc v)
  1842.     {
  1843.         Game->PlaySound(SFX_ARK2_POWERUP);
  1844.         TraceNL(); TraceS("Capsule BREAK struck vaus!!");
  1845.         extended = false;
  1846.         v->Data = CMB_VAUS;
  1847.         v->TileWidth = 2;
  1848.         ////Game->PlaySound(capsule)
  1849.         laser = false;
  1850.         caught = CATCH_NONE;
  1851.        
  1852.         //create exit
  1853.     }
  1854.     void extravaus(ffc v)
  1855.     {
  1856.         TraceNL(); TraceS("Capsule VAUS struck vaus!!");
  1857.         Game->PlaySound(SFX_EXTRA_VAUS);
  1858.         laser = false;
  1859.         extended = false;
  1860.         caught = CATCH_NONE;
  1861.         v->Data = CMB_VAUS;
  1862.         v->TileWidth = 2;
  1863.         ++Game->Counter[CR_LIVES];
  1864.     }
  1865.     void split(ffc v, lweapon b)
  1866.     {
  1867.         Game->PlaySound(SFX_ARK2_POWERUP2);
  1868.         TraceNL(); TraceS("Capsule SPLIT struck vaus!!");
  1869.         extended = false;
  1870.         v->Data = CMB_VAUS;
  1871.         v->TileWidth = 2;
  1872.         ////Game->PlaySound(capsule)
  1873.         laser = false;
  1874.         caught = CATCH_NONE;
  1875.        
  1876.         //! fuck this is going to be hard to add
  1877.        
  1878.     }
  1879.     void catchball(ffc v)
  1880.     {
  1881.         Game->PlaySound(SFX_ARK2_POWERUP2);
  1882.         TraceNL(); TraceS("Capsule CATCH struck vaus!!");
  1883.         extended = false;
  1884.         v->Data = CMB_VAUS;
  1885.         v->TileWidth = 2;
  1886.         ////Game->PlaySound(capsule)
  1887.         laser = false;
  1888.         extended = false;
  1889.         caught = CATCH_ALLOW;
  1890.        
  1891.         /* For catching the ball:
  1892.             When the catch state is 1, then if the ball strikes the vaus **AND** the vaus state is NOT HOLDING_BALL,
  1893.             then its Step is saved to a misc index (MISC_CAUGHT_STEP) for its lweapon, and its Step is set to 0.
  1894.             Then, its catch state is set to 2, and a Vaus misc index is set to HOLDING_BALL.
  1895.             When the player presses a LAUNCH button, the Step speed recorded to b->Misc[MISC_CAUGHT_STEP] is set
  1896.             to b->Step, the Misc[] index is cleared, v->Misc[HOLDING_BALL] is set to 0, and catch is set back to 1.
  1897.         */
  1898.        
  1899.     }
  1900.     void alloff(ffc v)
  1901.     {
  1902.         TraceNL(); TraceS("Clearing all power-up conditions.");
  1903.         laser = false;
  1904.         extended = false;
  1905.         v->Data = CMB_VAUS;
  1906.         v->TileWidth = 2;
  1907.         caught = CATCH_NONE;
  1908.     }
  1909.     int choosetype()
  1910.     {
  1911.         int typetable[] =
  1912.         {
  1913.             CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND,
  1914.             CAPS_TYPE_CATCH, CAPS_TYPE_CATCH, CAPS_TYPE_CATCH,
  1915.             CAPS_TYPE_DIVIDE, CAPS_TYPE_DIVIDE, CAPS_TYPE_DIVIDE,
  1916.             CAPS_TYPE_LASER, CAPS_TYPE_LASER, CAPS_TYPE_LASER,
  1917.             CAPS_TYPE_SLOW, CAPS_TYPE_SLOW, CAPS_TYPE_SLOW, CAPS_TYPE_SLOW, CAPS_TYPE_SLOW,
  1918.             CAPS_TYPE_VAUS, CAPS_TYPE_BREAK
  1919.            
  1920.            
  1921.         }; //each index is equal to a 1% chance
  1922.         //return ( typetable[Rand(0,99)] );
  1923.         //return CAPS_TYPE_EXTEND; //Testing this with one type, first.
  1924.         return ( typetable[Rand(0,SizeOfArray(typetable)-1)] );
  1925.     }
  1926.     void fall(item c)
  1927.     {
  1928.         for ( int q = 0; q < CAPSULE_FALL_SPEED; ++q )
  1929.         {
  1930.             ++c->Y;
  1931.         }
  1932.     }
  1933.     void all_fall(ffc v, lweapon b)
  1934.     {
  1935.         for ( int q = Screen->NumItems(); q > 0; --q )
  1936.         {
  1937.             item c = Screen->LoadItem(q);
  1938.             fall(c);
  1939.             drawover(c);
  1940.             if ( check_hitvaus(c, v, b) ) Remove(c);
  1941.             //TraceNL(); TraceS("Capsule Hit State: "); TraceB(hit);
  1942.             if ( c->Y > 256 ) Remove(c);
  1943.         }
  1944.     }
  1945.     void _do(ffc v, lweapon b)
  1946.     {
  1947.         for ( int q = Screen->NumLWeapons(); q > 0; --q )
  1948.         {
  1949.             lweapon c = Screen->LoadLWeapon(q);
  1950.             if ( c->ID == EW_SCRIPT2 )
  1951.             {
  1952.                 if ( check_hitvaus(c,v,b) ) Remove(c);
  1953.                 if ( c->Y > 256 ) Remove(c);
  1954.             }
  1955.         }
  1956.     }
  1957.     void cleanup()
  1958.     {
  1959.         for ( int q = Screen->NumLWeapons(); q > 0; --q )
  1960.         {
  1961.             lweapon c = Screen->LoadLWeapon(q);
  1962.             if ( c->ID == EW_SCRIPT2 )
  1963.             {
  1964.                 if ( c->Y > 256 ) Remove(c);
  1965.             }
  1966.         }
  1967.     }
  1968.     void cleanup(item c)
  1969.     {
  1970.         if ( c->Y > 256 ) Remove(c);
  1971.     }
  1972.     void all_clear()
  1973.     {
  1974.         for ( int q = Screen->NumLWeapons(); q > 0; --q )
  1975.         {
  1976.             lweapon c = Screen->LoadLWeapon(q);
  1977.             if ( c->ID == EW_SCRIPT2 )
  1978.             {
  1979.                 Remove(c);
  1980.             }
  1981.         }
  1982.     }
  1983.    
  1984. }
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990. ffc script brick
  1991. {
  1992.     void run()
  1993.     {
  1994.     }
  1995.     bool drop_capsule(npc a)
  1996.     {
  1997.         if ( Rand(1,100) <= BRICK_CHANCE_CAPSULE )
  1998.         {
  1999.             capsule.create(a->X, a->Y);
  2000.         }
  2001.     }
  2002.     bool all_gone()
  2003.     {
  2004.         npc n; int count;
  2005.         for ( int q = Screen->NumNPCs(); q > 0; --q )
  2006.         {
  2007.             n = Screen->LoadNPC(q);
  2008.             if ( n->Type == NPCT_OTHER )
  2009.             {
  2010.                 if ( n->HP < 1000 ) ++count;
  2011.             }
  2012.         }
  2013.         return ( count <= 0 );
  2014.     }
  2015.     float bound(int val, int min, int max)
  2016.     {
  2017.         if ( val < min ) return min;
  2018.         if ( val > max ) return max;
  2019.         return val;
  2020.     }
  2021.     bool hit(npc a, lweapon v)
  2022.     {
  2023.         /*
  2024.         if ( a->HitBy[HIT_BY_LWEAPON] < 1 ) return false;
  2025.         a->Misc[12] = Screen->LoadLWeapon(a->HitBy[HIT_BY_LWEAPON]);
  2026.         lweapon hitwpn = a->Misc[12];
  2027.         return ( hitwpn->UID == v->UID );
  2028.         */
  2029.         if ( a->HitBy[HIT_BY_LWEAPON_UID] == v->UID )
  2030.         {
  2031.            
  2032.            
  2033.             TraceNL(); TraceS("Brick hit by Weapon Type: "); Trace(a->HitBy[12]);
  2034.             TraceNL(); TraceS("Brick hit by Weapon from Item ID: "); Trace(a->HitBy[15]);
  2035.            
  2036.             return true;
  2037.         }
  2038.         return ( a->HitBy[HIT_BY_LWEAPON_UID] == v->UID );
  2039.         //int indx; //Until we have UIDs working for HitBy[], we need to do it this way.
  2040.         //for ( int q = Screen->NumLWeapons(); q > 0; --q )
  2041.         //{
  2042.         //  lweapon temp = Screen->LoadLWeapon(q);
  2043.         //  if ( temp->UID == v->UID )
  2044.         //  {
  2045.         //      indx = q; break;
  2046.         //  }
  2047.         //}
  2048.         //Link->Misc[0] = v; //We'll use this as scratch untyped space for the moment. -Z
  2049.         //TraceS("brick.hit() Link->Misc[] is: "); Trace(Link->Misc[0]);
  2050.         //TraceS("brick.hit() v is: "); Trace(v);
  2051.         //int temp_UID = v->UID * 10000; //this is a bug in HITBY[]. The HitBy value being stored is being multiplied by 10000, and it should not be.
  2052.             //as UID is not, and NEVER should be!!!
  2053.         //TraceNL(); TraceS("v->UID is: "); Trace(v->UID);
  2054.         /*
  2055.         To determine where a brick was hit, we first scan each brick and look to see which was
  2056.         hit at all, by our lweapon.
  2057.        
  2058.         The, we check if that ball is belove, above, right of, or left of the brick,
  2059.         and we read its direction.
  2060.        
  2061.         Using a logic chain from this data, we determine the direction that the ball should next
  2062.         take, when it bounces.
  2063.        
  2064.         */
  2065.         //HitBy[]
  2066.        
  2067.         //if ( a->HitBy[HIT_BY_LWEAPON] )
  2068.         //{
  2069.         //  TraceNL(); TraceS("a->HitBy[HIT_BY_LWEAPON] id: "); Trace(a->HitBy[HIT_BY_LWEAPON]);
  2070.         //  TraceNL();
  2071.         //  TraceS("Our Link->Misc scratch value `is: "); Trace((Link->Misc[0]+1));
  2072.         //}
  2073.        
  2074.         //! We'll use this method again when we add UIDs to HitBy[] ! -Z
  2075.         //return ( a->HitBy[HIT_BY_LWEAPON] == temp_UID );
  2076.         //return ( a->HitBy[HIT_BY_LWEAPON] == indx ); //(Link->Misc[0]+1) );
  2077.        
  2078.     }
  2079.     bool hit_below(npc a, lweapon v)
  2080.     {
  2081.         if ( v->Y == (a->Y + 8) ) return true; //we could do bounce here.
  2082.     }
  2083.     bool hit_above(npc a, lweapon v)
  2084.     {
  2085.         if ( v->Y == (a->Y - 4) ) return true; //we could do bounce here.
  2086.     }
  2087.     bool hit_left(npc a, lweapon v)
  2088.     {
  2089.         if ( v->X == (a->X - 4) ) return true; //we could do bounce here.
  2090.     }
  2091.     bool hit_right(npc a, lweapon v)
  2092.     {
  2093.         if ( v->X == (a->X + 16 ) ) return true; //we could do bounce here.
  2094.     }
  2095.    
  2096.     void take_hit(npc a, lweapon b)
  2097.     {
  2098.         if ( hit(a,b) )
  2099.         {
  2100.             //TraceNL(); TraceS("Brick hit!");
  2101.             b->DeadState = WDS_ALIVE;
  2102.             //TraceNL(); TraceS("brick->X = "); Trace(a->X);
  2103.             //TraceNL(); TraceS("brick->Y = "); Trace(a->Y);
  2104.             //TraceNL(); TraceS("ball->X = "); Trace(v->X);
  2105.             //TraceNL(); TraceS("ball->Y = "); Trace(v->Y);
  2106.             if ( hit_below(a,b) )
  2107.             {
  2108.                 //check the corners:
  2109.                 //lower-left corner
  2110.                 if ( hit_left(a,b) )
  2111.                 {
  2112.                    
  2113.                     if ( b->Angular )
  2114.                     {
  2115.                         switch(b->Angle)
  2116.                         {
  2117.                             case DIR_RRU:
  2118.                             {
  2119.                                 b->Angular = false;
  2120.                                 b->Dir = DIR_RIGHTDOWN;
  2121.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2122.                                 break;
  2123.                             }
  2124.                             case DIR_RRD:
  2125.                             {
  2126.                                 b->Angular = false;
  2127.                                 b->Dir = DIR_RIGHTUP;
  2128.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2129.                                 break;
  2130.                             }
  2131.                             case DIR_RUU:
  2132.                             {
  2133.                                 b->Angular = false;
  2134.                                 b->Dir = DIR_RIGHTDOWN;
  2135.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2136.                                 break;
  2137.                             }
  2138.                             case DIR_RDD:
  2139.                             {
  2140.                                 b->Angular = false;
  2141.                                 b->Dir = DIR_RIGHTUP;
  2142.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2143.                                 break;
  2144.                             }
  2145.                             case DIR_LLU:
  2146.                             {
  2147.                                 b->Angular = false;
  2148.                                 b->Dir = DIR_RIGHTDOWN;
  2149.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2150.                                 break;
  2151.                             }
  2152.                             case DIR_LUU:
  2153.                             {
  2154.                                 b->Angular = false;
  2155.                                 b->Dir = DIR_RIGHTDOWN;
  2156.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2157.                                 break;
  2158.                             }
  2159.                             case DIR_LLD:
  2160.                             {
  2161.                                 b->Angular = false;
  2162.                                 b->Dir = DIR_RIGHTUP;
  2163.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2164.                                 break;
  2165.                             }
  2166.                             case DIR_LDD:
  2167.                             {
  2168.                                 b->Angular = false;
  2169.                                 b->Dir = DIR_RIGHTUP;
  2170.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2171.                                 break;
  2172.                             }
  2173.                            
  2174.                         }
  2175.                     }
  2176.                     else
  2177.                     {
  2178.                         switch(b->Dir)
  2179.                         {
  2180.                             case DIR_DOWNRIGHT:
  2181.                             {
  2182.                                 b->Angular = false;
  2183.                                 b->Dir = DIR_UPLEFT;
  2184.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2185.                                 break;
  2186.                             }
  2187.                             case DIR_DOWNLEFT:
  2188.                             {
  2189.                                 b->Angular = false;
  2190.                                 b->Dir = DIR_UPRIGHT;
  2191.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2192.                                 break;
  2193.                             }
  2194.                             case DIR_UPRIGHT:
  2195.                             {
  2196.                                 b->Angular = false;
  2197.                                 b->Dir = DIR_DOWNLEFT;
  2198.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2199.                                 break;
  2200.                             }
  2201.                             case DIR_UPLEFT:
  2202.                             {
  2203.                                 b->Angular = false;
  2204.                                 b->Dir = DIR_DOWNRIGHT;
  2205.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2206.                                 break;
  2207.                             }  
  2208.                            
  2209.                         }
  2210.                     }
  2211.                    
  2212.                 }//end lower-left corner
  2213.                
  2214.                 else if ( hit_right(a,b) )
  2215.                     //lower-right corner
  2216.                 {
  2217.                    
  2218.                     if ( b->Angular )
  2219.                     {
  2220.                         switch(b->Angle)
  2221.                         {
  2222.                             case DIR_LLU:
  2223.                             {
  2224.                                 b->Angular = false;
  2225.                                 b->Dir = DIR_RIGHTDOWN;
  2226.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2227.                                 break;
  2228.                             }
  2229.                             case DIR_LLD:
  2230.                             {
  2231.                                 b->Angular = false;
  2232.                                 b->Dir = DIR_RIGHTDOWN;
  2233.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2234.                                 break;
  2235.                             }
  2236.                             case DIR_RUU:
  2237.                             {
  2238.                                 b->Angular = false;
  2239.                                 b->Dir = DIR_RIGHTDOWN;
  2240.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2241.                                 break;
  2242.                             }
  2243.                             case DIR_RDD:
  2244.                             {
  2245.                                 b->Angular = false;
  2246.                                 b->Dir = DIR_LEFTUP;
  2247.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2248.                                 break;
  2249.                             }
  2250.                             case DIR_LLU:
  2251.                             {
  2252.                                 b->Angular = false;
  2253.                                 b->Dir = DIR_RIGHTDOWN;
  2254.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2255.                                 break;
  2256.                             }
  2257.                             case DIR_LUU:
  2258.                             {
  2259.                                 b->Angular = false;
  2260.                                 b->Dir = DIR_RIGHTDOWN;
  2261.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2262.                                 break;
  2263.                             }
  2264.                             case DIR_LLD:
  2265.                             {
  2266.                                 b->Angular = false;
  2267.                                 b->Dir = DIR_LEFTUP;
  2268.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2269.                                 break;
  2270.                             }
  2271.                             case DIR_LDD:
  2272.                             {
  2273.                                 b->Angular = false;
  2274.                                 b->Dir = DIR_LEFTUP;
  2275.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2276.                                 break;
  2277.                             }
  2278.                            
  2279.                         }
  2280.                     }
  2281.                     else
  2282.                     {
  2283.                         switch(b->Dir)
  2284.                         {
  2285.                             case DIR_DOWNRIGHT:
  2286.                             {
  2287.                                 b->Angular = false;
  2288.                                 b->Dir = DIR_UPLEFT;
  2289.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2290.                                 break;
  2291.                             }
  2292.                             case DIR_DOWNLEFT:
  2293.                             {
  2294.                                 b->Angular = false;
  2295.                                 b->Dir = DIR_UPRIGHT;
  2296.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2297.                                 break;
  2298.                             }
  2299.                             case DIR_UPRIGHT:
  2300.                             {
  2301.                                 b->Angular = false;
  2302.                                 b->Dir = DIR_DOWNLEFT;
  2303.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2304.                                 break;
  2305.                             }
  2306.                             case DIR_UPLEFT:
  2307.                             {
  2308.                                 b->Angular = false;
  2309.                                 b->Dir = DIR_DOWNRIGHT;
  2310.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2311.                                 break;
  2312.                             }  
  2313.                            
  2314.                         }
  2315.                     }
  2316.                    
  2317.                    
  2318.                 }//end lower-right corner
  2319.                
  2320.                
  2321.                 else
  2322.                 {
  2323.                
  2324.                     if ( b->Angular )
  2325.                     {
  2326.                         switch(b->Angle)
  2327.                         {
  2328.                             case DIR_LLU:
  2329.                             {
  2330.                                 b->Angular = false;
  2331.                                 b->Dir = DIR_LEFTDOWN;
  2332.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2333.                                 break;
  2334.                             }
  2335.                             case DIR_LUU:
  2336.                             {
  2337.                                 b->Angular = false;
  2338.                                 b->Dir = DIR_LEFTDOWN;
  2339.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2340.                                 break;
  2341.                             }
  2342.                             case DIR_RRU:
  2343.                             {
  2344.                                 b->Angular = false;
  2345.                                 b->Dir = DIR_RIGHTDOWN;
  2346.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2347.                                 break;
  2348.                             }
  2349.                             case DIR_RUU:
  2350.                             {
  2351.                                 b->Angular = false;
  2352.                                 b->Dir = DIR_RIGHTDOWN;
  2353.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2354.                                 break;
  2355.                             }
  2356.                            
  2357.                         }
  2358.                     }
  2359.                     else
  2360.                     {
  2361.                         switch(b->Dir)
  2362.                         {
  2363.                             case DIR_RIGHTUP: { b->Dir = DIR_RIGHTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2364.                             case DIR_LEFTUP: { b->Dir = DIR_LEFTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2365.                             default: { TraceNL(); TraceS("Ball direction invalid for brick.take_hit(hit_below()).");
  2366.                                 TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  2367.                                 b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2368.                         }
  2369.                     }
  2370.                 }
  2371.                 /*
  2372.                 switch ( v->Dir )
  2373.                 {
  2374.                     case DIR_UPRIGHT: { v->Dir = DIR_DOWNRIGHT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED); break; }
  2375.                     case DIR_UPLEFT: { v->Dir = DIR_DOWNLEFT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED); break; }
  2376.                     default: { TraceS("hit_below() found an illegal ball direction"); break; }
  2377.                 }
  2378.                 */
  2379.                 if ( a->HP <= 0 )
  2380.                 {
  2381.                     //TraceS("Brick is dead. "); TraceNL();
  2382.                     //TraceS("a->Misc[NPCM_AWARDED_POINTS] is: "); Trace(a->Misc[NPCM_AWARDED_POINTS]); TraceNL();
  2383.                     if ( !a->Misc[NPCM_AWARDED_POINTS] )
  2384.                     {
  2385.                         //TraceS("Can award points!"); TraceNL();
  2386.                         a->Misc[18] = 1;
  2387.                         //TraceS("The points for this brick are: "); Trace(a->Attributes[NPC_ATTRIB_POINTS]); TraceNL();
  2388.                         Game->Counter[CR_SCRIPT1] += a->Attributes[NPC_ATTRIB_POINTS];
  2389.                         drop_capsule(a);
  2390.                     }
  2391.                 }
  2392.             }
  2393.            
  2394.             else if ( hit_above(a,b) )
  2395.             {
  2396.                 //upper-left corner
  2397.                 if ( hit_left(a,b) )
  2398.                 {
  2399.                    
  2400.                     if ( b->Angular )
  2401.                     {
  2402.                         switch(b->Angle)
  2403.                         {
  2404.                             case DIR_RRD:
  2405.                             {
  2406.                                 b->Angular = false;
  2407.                                 b->Dir = DIR_LEFTDOWN;
  2408.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2409.                                 break;
  2410.                             }
  2411.                             case DIR_RDD:
  2412.                             {
  2413.                                 b->Angular = false;
  2414.                                 b->Dir = DIR_LEFTDOWN;
  2415.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2416.                                 break;
  2417.                             }
  2418.                             case DIR_RUU:
  2419.                             {
  2420.                                 b->Angular = false;
  2421.                                 b->Dir = DIR_LEFTUP;
  2422.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2423.                                 break;
  2424.                             }
  2425.                             case DIR_RDD:
  2426.                             {
  2427.                                 b->Angular = false;
  2428.                                 b->Dir = DIR_LEFTUP;
  2429.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2430.                                 break;
  2431.                             }
  2432.                             case DIR_LLU:
  2433.                             {
  2434.                                 b->Angular = false;
  2435.                                 b->Dir = DIR_LEFTDOWN;
  2436.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2437.                                 break;
  2438.                             }
  2439.                             case DIR_LUU:
  2440.                             {
  2441.                                 b->Angular = false;
  2442.                                 b->Dir = DIR_LEFTDOWN;
  2443.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2444.                                 break;
  2445.                             }
  2446.                             case DIR_LLD:
  2447.                             {
  2448.                                 b->Angular = false;
  2449.                                 b->Dir = DIR_RIGHTDOWN;
  2450.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2451.                                 break;
  2452.                             }
  2453.                             case DIR_LDD:
  2454.                             {
  2455.                                 b->Angular = false;
  2456.                                 b->Dir = DIR_RIGHTDOWN;
  2457.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2458.                                 break;
  2459.                             }
  2460.                            
  2461.                         }
  2462.                     }
  2463.                     else
  2464.                     {
  2465.                         switch(b->Dir)
  2466.                         {
  2467.                             case DIR_DOWNRIGHT:
  2468.                             {
  2469.                                 b->Angular = false;
  2470.                                 b->Dir = DIR_UPLEFT;
  2471.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2472.                                 break;
  2473.                             }
  2474.                             case DIR_DOWNLEFT:
  2475.                             {
  2476.                                 b->Angular = false;
  2477.                                 b->Dir = DIR_UPRIGHT;
  2478.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2479.                                 break;
  2480.                             }
  2481.                             case DIR_UPRIGHT:
  2482.                             {
  2483.                                 b->Angular = false;
  2484.                                 b->Dir = DIR_DOWNLEFT;
  2485.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2486.                                 break;
  2487.                             }
  2488.                             case DIR_UPLEFT:
  2489.                             {
  2490.                                 b->Angular = false;
  2491.                                 b->Dir = DIR_DOWNRIGHT;
  2492.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2493.                                 break;
  2494.                             }
  2495.                            
  2496.                         }
  2497.                     }
  2498.                    
  2499.                 }//end upper-left corner
  2500.                
  2501.                 //upper-right corner
  2502.                 else if ( hit_right(a,b) )
  2503.                 {
  2504.                    
  2505.                     if ( b->Angular )
  2506.                     {
  2507.                         switch(b->Angle)
  2508.                         {
  2509.                             case DIR_RRD:
  2510.                             {
  2511.                                 b->Angular = false;
  2512.                                 b->Dir = DIR_RIGHTUP;
  2513.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2514.                                 break;
  2515.                             }
  2516.                             case DIR_RDD:
  2517.                             {
  2518.                                 b->Angular = false;
  2519.                                 b->Dir = DIR_RIGHTUP;
  2520.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2521.                                 break;
  2522.                             }
  2523.                             case DIR_RUU:
  2524.                             {
  2525.                                 b->Angular = false;
  2526.                                 b->Dir = DIR_RIGHTDOWN;
  2527.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2528.                                 break;
  2529.                             }
  2530.                             case DIR_RDD:
  2531.                             {
  2532.                                 b->Angular = false;
  2533.                                 b->Dir = DIR_RIGHTDOWN;
  2534.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2535.                                 break;
  2536.                             }
  2537.                             case DIR_LLU:
  2538.                             {
  2539.                                 b->Angular = false;
  2540.                                 b->Dir = DIR_RIGHTUP;
  2541.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2542.                                 break;
  2543.                             }
  2544.                             case DIR_LUU:
  2545.                             {
  2546.                                 b->Angular = false;
  2547.                                 b->Dir = DIR_RIGHTUP;
  2548.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2549.                                 break;
  2550.                             }
  2551.                             case DIR_LLD:
  2552.                             {
  2553.                                 b->Angular = false;
  2554.                                 b->Dir = DIR_LEFTUP;
  2555.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2556.                                 break;
  2557.                             }
  2558.                             case DIR_LDD:
  2559.                             {
  2560.                                 b->Angular = false;
  2561.                                 b->Dir = DIR_LEFTUP;
  2562.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2563.                                 break;
  2564.                             }
  2565.                            
  2566.                         }
  2567.                     }
  2568.                     else
  2569.                     {
  2570.                         switch(b->Dir)
  2571.                         {
  2572.                             case DIR_DOWNRIGHT:
  2573.                             {
  2574.                                 b->Angular = false;
  2575.                                 b->Dir = DIR_UPLEFT;
  2576.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2577.                                 break;
  2578.                             }
  2579.                             case DIR_DOWNLEFT:
  2580.                             {
  2581.                                 b->Angular = false;
  2582.                                 b->Dir = DIR_UPRIGHT;
  2583.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2584.                                 break;
  2585.                             }
  2586.                             case DIR_UPRIGHT:
  2587.                             {
  2588.                                 b->Angular = false;
  2589.                                 b->Dir = DIR_DOWNLEFT;
  2590.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2591.                                 break;
  2592.                             }
  2593.                             case DIR_UPLEFT:
  2594.                             {
  2595.                                 b->Angular = false;
  2596.                                 b->Dir = DIR_DOWNRIGHT;
  2597.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2598.                                 break;
  2599.                             }
  2600.                            
  2601.                         }
  2602.                     }
  2603.                    
  2604.                 }
  2605.                 //end upper-right corners
  2606.                
  2607.                 //
  2608.                 else
  2609.                 {
  2610.                     if ( b->Angular )
  2611.                     {
  2612.                         switch(b->Angle)
  2613.                         {
  2614.                             case DIR_LLD:
  2615.                             {
  2616.                                 b->Angular = false;
  2617.                                 b->Dir = DIR_LEFTUP;
  2618.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2619.                                 break;
  2620.                             }
  2621.                             case DIR_LDD:
  2622.                             {
  2623.                                 b->Angular = false;
  2624.                                 b->Dir = DIR_LEFTUP;
  2625.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2626.                                 break;
  2627.                             }
  2628.                             case DIR_RRD:
  2629.                             {
  2630.                                 b->Angular = false;
  2631.                                 b->Dir = DIR_RIGHTUP;
  2632.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2633.                                 break;
  2634.                             }
  2635.                             case DIR_RDD:
  2636.                             {
  2637.                                 b->Angular = false;
  2638.                                 b->Dir = DIR_RIGHTUP;
  2639.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2640.                                 break;
  2641.                             }
  2642.                            
  2643.                         }
  2644.                     }
  2645.                     else
  2646.                     {
  2647.                         switch(b->Dir)
  2648.                         {
  2649.                             case DIR_DOWNLEFT: { b->Dir = DIR_UPLEFT; b->Step = bound(b->Step+2, 0, MAX_BALL_SPEED); break; }
  2650.                             case DIR_DOWNRIGHT: { b ->Dir = DIR_UPRIGHT; b->Step = bound(b->Step+2, 0, MAX_BALL_SPEED); break; }
  2651.                             default: {
  2652.                                 TraceNL(); TraceS("Ball direction invalid for brick.take_hit(hit_above()).");
  2653.                                 TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  2654.                                
  2655.                                 b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2656.                         }
  2657.                     }
  2658.                    
  2659.                     if ( a->HP <= 0 )
  2660.                     {
  2661.                         if ( !a->Misc[NPCM_AWARDED_POINTS] )
  2662.                         {
  2663.                             a->Misc[NPCM_AWARDED_POINTS] = 1;
  2664.                             Game->Counter[CR_SCRIPT1] += a->Attributes[NPC_ATTRIB_POINTS];
  2665.                             drop_capsule(a);
  2666.                         }
  2667.                     }
  2668.                 }
  2669.             }
  2670.            
  2671.             else if ( hit_left(a,b) )
  2672.             {
  2673.                 //upper corners
  2674.                
  2675.                 //upper-left corner
  2676.                 if ( hit_above(a,b) )
  2677.                 {
  2678.                    
  2679.                     if ( b->Angular )
  2680.                     {
  2681.                         switch(b->Angle)
  2682.                         {
  2683.                             case DIR_RRD:
  2684.                             {
  2685.                                 b->Angular = false;
  2686.                                 b->Dir = DIR_LEFTDOWN;
  2687.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2688.                                 break;
  2689.                             }
  2690.                             case DIR_RDD:
  2691.                             {
  2692.                                 b->Angular = false;
  2693.                                 b->Dir = DIR_LEFTDOWN;
  2694.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2695.                                 break;
  2696.                             }
  2697.                             case DIR_RUU:
  2698.                             {
  2699.                                 b->Angular = false;
  2700.                                 b->Dir = DIR_LEFTUP;
  2701.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2702.                                 break;
  2703.                             }
  2704.                             case DIR_RDD:
  2705.                             {
  2706.                                 b->Angular = false;
  2707.                                 b->Dir = DIR_LEFTUP;
  2708.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2709.                                 break;
  2710.                             }
  2711.                             case DIR_LLU:
  2712.                             {
  2713.                                 b->Angular = false;
  2714.                                 b->Dir = DIR_LEFTDOWN;
  2715.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2716.                                 break;
  2717.                             }
  2718.                             case DIR_LUU:
  2719.                             {
  2720.                                 b->Angular = false;
  2721.                                 b->Dir = DIR_LEFTDOWN;
  2722.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2723.                                 break;
  2724.                             }
  2725.                             case DIR_LLD:
  2726.                             {
  2727.                                 b->Angular = false;
  2728.                                 b->Dir = DIR_RIGHTDOWN;
  2729.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2730.                                 break;
  2731.                             }
  2732.                             case DIR_LDD:
  2733.                             {
  2734.                                 b->Angular = false;
  2735.                                 b->Dir = DIR_RIGHTDOWN;
  2736.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2737.                                 break;
  2738.                             }
  2739.                            
  2740.                         }
  2741.                     }
  2742.                     else
  2743.                     {
  2744.                         switch(b->Dir)
  2745.                         {
  2746.                             case DIR_DOWNRIGHT:
  2747.                             {
  2748.                                 b->Angular = false;
  2749.                                 b->Dir = DIR_UPLEFT;
  2750.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2751.                                 break;
  2752.                             }
  2753.                             case DIR_DOWNLEFT:
  2754.                             {
  2755.                                 b->Angular = false;
  2756.                                 b->Dir = DIR_UPRIGHT;
  2757.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2758.                                 break;
  2759.                             }
  2760.                             case DIR_UPRIGHT:
  2761.                             {
  2762.                                 b->Angular = false;
  2763.                                 b->Dir = DIR_DOWNLEFT;
  2764.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2765.                                 break;
  2766.                             }
  2767.                             case DIR_UPLEFT:
  2768.                             {
  2769.                                 b->Angular = false;
  2770.                                 b->Dir = DIR_DOWNRIGHT;
  2771.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2772.                                 break;
  2773.                             }
  2774.                            
  2775.                         }
  2776.                     }
  2777.                    
  2778.                 }//end upper-left corner
  2779.                
  2780.                 else if ( hit_below(a,b) )
  2781.                     //lower-left corner
  2782.                 {
  2783.                    
  2784.                     if ( b->Angular )
  2785.                     {
  2786.                         switch(b->Angle)
  2787.                         {
  2788.                             case DIR_RRU:
  2789.                             {
  2790.                                 b->Angular = false;
  2791.                                 b->Dir = DIR_RIGHTDOWN;
  2792.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2793.                                 break;
  2794.                             }
  2795.                             case DIR_RRD:
  2796.                             {
  2797.                                 b->Angular = false;
  2798.                                 b->Dir = DIR_RIGHTUP;
  2799.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2800.                                 break;
  2801.                             }
  2802.                             case DIR_RUU:
  2803.                             {
  2804.                                 b->Angular = false;
  2805.                                 b->Dir = DIR_RIGHTDOWN;
  2806.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2807.                                 break;
  2808.                             }
  2809.                             case DIR_RDD:
  2810.                             {
  2811.                                 b->Angular = false;
  2812.                                 b->Dir = DIR_RIGHTUP;
  2813.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2814.                                 break;
  2815.                             }
  2816.                             case DIR_LLU:
  2817.                             {
  2818.                                 b->Angular = false;
  2819.                                 b->Dir = DIR_RIGHTDOWN;
  2820.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2821.                                 break;
  2822.                             }
  2823.                             case DIR_LUU:
  2824.                             {
  2825.                                 b->Angular = false;
  2826.                                 b->Dir = DIR_RIGHTDOWN;
  2827.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2828.                                 break;
  2829.                             }
  2830.                             case DIR_LLD:
  2831.                             {
  2832.                                 b->Angular = false;
  2833.                                 b->Dir = DIR_RIGHTUP;
  2834.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2835.                                 break;
  2836.                             }
  2837.                             case DIR_LDD:
  2838.                             {
  2839.                                 b->Angular = false;
  2840.                                 b->Dir = DIR_RIGHTUP;
  2841.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2842.                                 break;
  2843.                             }
  2844.                            
  2845.                         }
  2846.                     }
  2847.                     else
  2848.                     {
  2849.                         switch(b->Dir)
  2850.                         {
  2851.                             case DIR_DOWNRIGHT:
  2852.                             {
  2853.                                 b->Angular = false;
  2854.                                 b->Dir = DIR_UPLEFT;
  2855.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2856.                                 break;
  2857.                             }
  2858.                             case DIR_DOWNLEFT:
  2859.                             {
  2860.                                 b->Angular = false;
  2861.                                 b->Dir = DIR_UPRIGHT;
  2862.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2863.                                 break;
  2864.                             }
  2865.                             case DIR_UPRIGHT:
  2866.                             {
  2867.                                 b->Angular = false;
  2868.                                 b->Dir = DIR_DOWNLEFT;
  2869.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2870.                                 break;
  2871.                             }
  2872.                             case DIR_UPLEFT:
  2873.                             {
  2874.                                 b->Angular = false;
  2875.                                 b->Dir = DIR_DOWNRIGHT;
  2876.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2877.                                 break;
  2878.                             }  
  2879.                            
  2880.                         }
  2881.                     }
  2882.                                    
  2883.                 }//end lower-left corner
  2884.                
  2885.                 else
  2886.                 {
  2887.                     if ( b->Angular )
  2888.                     {
  2889.                         switch(b->Angle)
  2890.                         {
  2891.                             case DIR_LLU:
  2892.                             {
  2893.                                 b->Angular = false;
  2894.                                 b->Dir = DIR_RIGHTUP;
  2895.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2896.                                 break;
  2897.                             }
  2898.                             case DIR_LUU:
  2899.                             {
  2900.                                 b->Angular = false;
  2901.                                 b->Dir = DIR_RIGHTUP;
  2902.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2903.                                 break;
  2904.                             }
  2905.                             case DIR_LLD:
  2906.                             {
  2907.                                 b->Angular = false;
  2908.                                 b->Dir = DIR_RIGHTDOWN;
  2909.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2910.                                 break;
  2911.                             }
  2912.                             case DIR_LDD:
  2913.                             {
  2914.                                 b->Angular = false;
  2915.                                 b->Dir = DIR_RIGHTDOWN;
  2916.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2917.                                 break;
  2918.                             }
  2919.                            
  2920.                         }
  2921.                     }
  2922.                     else
  2923.                     {
  2924.                         switch(b->Dir)
  2925.                         {
  2926.                             case DIR_RIGHTDOWN: { b->Dir = DIR_LEFTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2927.                             case DIR_RIGHTUP: { b->Dir = DIR_LEFTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2928.                             default: {
  2929.                                 TraceNL(); TraceS("Ball direction invalid for brick.take_hit(hit(left)).");
  2930.                                 TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  2931.                                 b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2932.                         }
  2933.                     }
  2934.                     /*
  2935.                     switch ( v->Dir )
  2936.                     {
  2937.                         case DIR_UPRIGHT: { v->Dir = DIR_UPLEFT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED); break; }
  2938.                         case DIR_DOWNRIGHT: { v->Dir = DIR_DOWNLEFT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED);  break; }
  2939.                         default: { TraceS("hit_left() found an illegal ball direction"); break; }
  2940.                     }
  2941.                     */
  2942.                 }
  2943.                 if ( a->HP <= 0 )
  2944.                 {
  2945.                     if ( !a->Misc[NPCM_AWARDED_POINTS] )
  2946.                     {
  2947.                         a->Misc[NPCM_AWARDED_POINTS] = 1;
  2948.                         Game->Counter[CR_SCRIPT1] += a->Attributes[NPC_ATTRIB_POINTS];
  2949.                         drop_capsule(a);
  2950.                     }
  2951.                 }
  2952.             }
  2953.             else if ( hit_right(a,b) )
  2954.             {
  2955.                 //lower-right corners
  2956.                 if ( hit_below(a,b) )
  2957.                     //lower-right corner
  2958.                 {
  2959.                    
  2960.                     if ( b->Angular )
  2961.                     {
  2962.                         switch(b->Angle)
  2963.                         {
  2964.                             case DIR_LLU:
  2965.                             {
  2966.                                 b->Angular = false;
  2967.                                 b->Dir = DIR_RIGHTDOWN;
  2968.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2969.                                 break;
  2970.                             }
  2971.                             case DIR_LLD:
  2972.                             {
  2973.                                 b->Angular = false;
  2974.                                 b->Dir = DIR_RIGHTDOWN;
  2975.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2976.                                 break;
  2977.                             }
  2978.                             case DIR_RUU:
  2979.                             {
  2980.                                 b->Angular = false;
  2981.                                 b->Dir = DIR_RIGHTDOWN;
  2982.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2983.                                 break;
  2984.                             }
  2985.                             case DIR_RDD:
  2986.                             {
  2987.                                 b->Angular = false;
  2988.                                 b->Dir = DIR_LEFTUP;
  2989.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2990.                                 break;
  2991.                             }
  2992.                             case DIR_LLU:
  2993.                             {
  2994.                                 b->Angular = false;
  2995.                                 b->Dir = DIR_RIGHTDOWN;
  2996.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2997.                                 break;
  2998.                             }
  2999.                             case DIR_LUU:
  3000.                             {
  3001.                                 b->Angular = false;
  3002.                                 b->Dir = DIR_RIGHTDOWN;
  3003.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3004.                                 break;
  3005.                             }
  3006.                             case DIR_LLD:
  3007.                             {
  3008.                                 b->Angular = false;
  3009.                                 b->Dir = DIR_LEFTUP;
  3010.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3011.                                 break;
  3012.                             }
  3013.                             case DIR_LDD:
  3014.                             {
  3015.                                 b->Angular = false;
  3016.                                 b->Dir = DIR_LEFTUP;
  3017.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3018.                                 break;
  3019.                             }
  3020.                            
  3021.                         }
  3022.                     }
  3023.                     else
  3024.                     {
  3025.                         switch(b->Dir)
  3026.                         {
  3027.                             case DIR_DOWNRIGHT:
  3028.                             {
  3029.                                 b->Angular = false;
  3030.                                 b->Dir = DIR_UPLEFT;
  3031.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3032.                                 break;
  3033.                             }
  3034.                             case DIR_DOWNLEFT:
  3035.                             {
  3036.                                 b->Angular = false;
  3037.                                 b->Dir = DIR_UPRIGHT;
  3038.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3039.                                 break;
  3040.                             }
  3041.                             case DIR_UPRIGHT:
  3042.                             {
  3043.                                 b->Angular = false;
  3044.                                 b->Dir = DIR_DOWNLEFT;
  3045.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3046.                                 break;
  3047.                             }
  3048.                             case DIR_UPLEFT:
  3049.                             {
  3050.                                 b->Angular = false;
  3051.                                 b->Dir = DIR_DOWNRIGHT;
  3052.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3053.                                 break;
  3054.                             }  
  3055.                            
  3056.                         }
  3057.                     }
  3058.                    
  3059.                 }//end lower-right corner
  3060.                
  3061.                 //upper-right corner
  3062.                 else if ( hit_above(a,b) )
  3063.                 {
  3064.                    
  3065.                     if ( b->Angular )
  3066.                     {
  3067.                         switch(b->Angle)
  3068.                         {
  3069.                             case DIR_RRD:
  3070.                             {
  3071.                                 b->Angular = false;
  3072.                                 b->Dir = DIR_RIGHTUP;
  3073.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3074.                                 break;
  3075.                             }
  3076.                             case DIR_RDD:
  3077.                             {
  3078.                                 b->Angular = false;
  3079.                                 b->Dir = DIR_RIGHTUP;
  3080.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3081.                                 break;
  3082.                             }
  3083.                             case DIR_RUU:
  3084.                             {
  3085.                                 b->Angular = false;
  3086.                                 b->Dir = DIR_RIGHTDOWN;
  3087.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3088.                                 break;
  3089.                             }
  3090.                             case DIR_RDD:
  3091.                             {
  3092.                                 b->Angular = false;
  3093.                                 b->Dir = DIR_RIGHTDOWN;
  3094.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3095.                                 break;
  3096.                             }
  3097.                             case DIR_LLU:
  3098.                             {
  3099.                                 b->Angular = false;
  3100.                                 b->Dir = DIR_RIGHTUP;
  3101.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3102.                                 break;
  3103.                             }
  3104.                             case DIR_LUU:
  3105.                             {
  3106.                                 b->Angular = false;
  3107.                                 b->Dir = DIR_RIGHTUP;
  3108.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3109.                                 break;
  3110.                             }
  3111.                             case DIR_LLD:
  3112.                             {
  3113.                                 b->Angular = false;
  3114.                                 b->Dir = DIR_LEFTUP;
  3115.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3116.                                 break;
  3117.                             }
  3118.                             case DIR_LDD:
  3119.                             {
  3120.                                 b->Angular = false;
  3121.                                 b->Dir = DIR_LEFTUP;
  3122.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3123.                                 break;
  3124.                             }
  3125.                            
  3126.                         }
  3127.                     }
  3128.                     else
  3129.                     {
  3130.                         switch(b->Dir)
  3131.                         {
  3132.                             case DIR_DOWNRIGHT:
  3133.                             {
  3134.                                 b->Angular = false;
  3135.                                 b->Dir = DIR_UPLEFT;
  3136.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3137.                                 break;
  3138.                             }
  3139.                             case DIR_DOWNLEFT:
  3140.                             {
  3141.                                 b->Angular = false;
  3142.                                 b->Dir = DIR_UPRIGHT;
  3143.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3144.                                 break;
  3145.                             }
  3146.                             case DIR_UPRIGHT:
  3147.                             {
  3148.                                 b->Angular = false;
  3149.                                 b->Dir = DIR_DOWNLEFT;
  3150.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3151.                                 break;
  3152.                             }
  3153.                             case DIR_UPLEFT:
  3154.                             {
  3155.                                 b->Angular = false;
  3156.                                 b->Dir = DIR_DOWNRIGHT;
  3157.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3158.                                 break;
  3159.                             }
  3160.                            
  3161.                         }
  3162.                     }
  3163.                 }
  3164.                 //end upper-right corners
  3165.                 else
  3166.                 {
  3167.                     if ( b->Angular )
  3168.                     {
  3169.                         switch(b->Angle)
  3170.                         {
  3171.                             case DIR_RRD:
  3172.                             {
  3173.                                 b->Angular = false;
  3174.                                 b->Dir = DIR_LEFTDOWN;
  3175.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3176.                                 break;
  3177.                             }
  3178.                             case DIR_RDD:
  3179.                             {
  3180.                                 b->Angular = false;
  3181.                                 b->Dir = DIR_LEFTDOWN;
  3182.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3183.                                 break;
  3184.                             }
  3185.                             case DIR_RRU:
  3186.                             {
  3187.                                 b->Angular = false;
  3188.                                 b->Dir = DIR_LEFTUP;
  3189.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3190.                                 break;
  3191.                             }
  3192.                             case DIR_RUU:
  3193.                             {
  3194.                                 b->Angular = false;
  3195.                                 b->Dir = DIR_LEFTUP;
  3196.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  3197.                                 break;
  3198.                             }
  3199.                            
  3200.                         }
  3201.                     }
  3202.                     else
  3203.                     {
  3204.                         switch(b->Dir)
  3205.                         {
  3206.                             case DIR_LEFTDOWN: { b->Dir = DIR_RIGHTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  3207.                             case DIR_LEFTUP: { b->Dir = DIR_RIGHTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  3208.                             default: {
  3209.                                 TraceNL(); TraceS("Ball direction invalid for brick.take_hit(hit_right()).");
  3210.                                 TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  3211.                                 b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  3212.                         }
  3213.                     }
  3214.                     /*
  3215.                     switch ( v->Dir )
  3216.                     {
  3217.                         case DIR_UPLEFT: { v->Dir = DIR_UPRIGHT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED); break; }
  3218.                         case DIR_DOWNLEFT: { v->Dir = DIR_DOWNRIGHT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED); break; }
  3219.                         default: { TraceS("hit_below() found an illegal ball direction"); break; }
  3220.                     }
  3221.                     */
  3222.                     if ( a->HP <= 0 )
  3223.                     {
  3224.                         if ( !a->Misc[NPCM_AWARDED_POINTS] )
  3225.                         {
  3226.                             a->Misc[NPCM_AWARDED_POINTS] = 1;
  3227.                             Game->Counter[CR_SCRIPT1] += a->Attributes[NPC_ATTRIB_POINTS];
  3228.                             drop_capsule(a);
  3229.                         }
  3230.                     }
  3231.                 }
  3232.             }
  3233.            
  3234.             else
  3235.             {
  3236.                 TraceS("brick.hit() returned true, but couldn't determine a valid ball location!");
  3237.                 return;
  3238.             }
  3239.         }
  3240.                    
  3241.            
  3242.     }
  3243.     //turns layer objects into npc bricks.
  3244.     void setup()
  3245.     {
  3246.         int tempenem; npc bricks[1024]; int temp;
  3247.         for ( int q = 0; q < 176; ++q )
  3248.         {
  3249.             //bricks on layer 1
  3250.             //Trace(GetLayerComboD(1,q));
  3251.             //while(!Input->Press[CB_A]) Waitframe();
  3252.             tempenem = brick_to_npc(GetLayerComboD(1,q),false);
  3253.             //TraceS("tempenem is: "); Trace(tempenem);
  3254.             //while(!Input->Press[CB_A]) Waitframe();
  3255.             if ( tempenem )
  3256.             {
  3257.                 bricks[temp] = Screen->CreateNPC(tempenem);
  3258.                 //TraceS("Created npc: "); Trace(tempenem);
  3259.                 bricks[temp]->X = ComboX(q);
  3260.                 bricks[temp]->Y = ComboY(q);
  3261.                 //TraceS("Brick defence is: "); Trace(bricks[temp]->Defense[20]);
  3262.                 tempenem = 0; ++temp;
  3263.                
  3264.             }
  3265.             //bricks on layer 2, Y+8px
  3266.             tempenem = brick_to_npc(GetLayerComboD(2,q),true);
  3267.             //Trace(tempenem);
  3268.             if ( tempenem )
  3269.             {
  3270.                 bricks[temp] = Screen->CreateNPC(tempenem);
  3271.                 //TraceS("Created npc: "); Trace(tempenem);
  3272.                 bricks[temp]->X = ComboX(q);
  3273.                 bricks[temp]->Y = ComboY(q)+8;
  3274.                 //TraceS("Brick defence is: "); Trace(bricks[temp]->Defense[20]);
  3275.                 tempenem = 0; ++temp;
  3276.             }
  3277.         }
  3278.        
  3279.     }
  3280.     void clear_combos()
  3281.     {
  3282.         templayer[0] = Screen->LayerOpacity[0];
  3283.         templayer[1] = Screen->LayerOpacity[1];
  3284.         templayer[2] = Screen->LayerMap[0];
  3285.         templayer[3] = Screen->LayerMap[1];
  3286.         Screen->LayerOpacity[0] = 0;
  3287.         Screen->LayerOpacity[1] = 0;
  3288.         Screen->LayerMap[0] = 0;
  3289.         Screen->LayerMap[1] = 0;
  3290.     }
  3291.    
  3292.     int brick_to_npc(int combo_id, bool layer2)
  3293.     {
  3294.        
  3295.         if ( !layer2 )
  3296.         {
  3297.             int brick_to_enemy[BRICK_MAX*2] =
  3298.             {   CMB_BRICK_RED, CMB_BRICK_WHITE, CMB_BRICK_BLUE, CMB_BRICK_ORANGE, CMB_BRICK_TEAL,
  3299.                 CMB_BRICK_VIOLET, CMB_BRICK_GREEN, CMB_BRICK_YELLOW, CMB_BRICK_SILVER1, CMB_BRICK_SILVER2,
  3300.                 CMB_BRICK_SILVER3, CMB_BRICK_SILVER4, CMB_BRICK_GOLD,
  3301.  
  3302.                 NPC_BRICK_RED, NPC_BRICK_WHITE, NPC_BRICK_BLUE, NPC_BRICK_ORANGE, NPC_BRICK_TEAL,
  3303.                 NPC_BRICK_VIOLET, NPC_BRICK_GREEN, NPC_BRICK_YELLOW, NPC_BRICK_SILVER1, NPC_BRICK_SILVER2,
  3304.                 NPC_BRICK_SILVER3, NPC_BRICK_SILVER4, NPC_BRICK_GOLD
  3305.             };
  3306.             for ( int q = 0; q < BRICK_MAX; ++q )
  3307.             {
  3308.                 if ( brick_to_enemy[q] == combo_id )
  3309.                 {
  3310.                     //  TraceS("brick_to_npc : combo input: "); Trace(combo_id);
  3311.                     //TraceS("brick_to_npc : enemy output: "); Trace(brick_to_enemy[BRICK_MAX+q]);
  3312.                    
  3313.                     return ( brick_to_enemy[BRICK_MAX+q-1] );
  3314.                 }
  3315.             }
  3316.         }
  3317.         else
  3318.         {
  3319.             int brick_to_enemy2[BRICK_MAX*2] =
  3320.             {   CMB_BRICK_RED_LOW, CMB_BRICK_WHITE_LOW, CMB_BRICK_BLUE_LOW, CMB_BRICK_ORANGE_LOW, CMB_BRICK_TEAL_LOW,
  3321.                 CMB_BRICK_VIOLET_LOW, CMB_BRICK_GREEN_LOW, CMB_BRICK_YELLOW_LOW, CMB_BRICK_SILVER1_LOW, CMB_BRICK_SILVER2_LOW,
  3322.                 CMB_BRICK_SILVER3_LOW, CMB_BRICK_SILVER4_LOW, CMB_BRICK_GOLD_LOW,
  3323.  
  3324.                 NPC_BRICK_RED, NPC_BRICK_WHITE, NPC_BRICK_BLUE, NPC_BRICK_ORANGE, NPC_BRICK_TEAL,
  3325.                 NPC_BRICK_VIOLET, NPC_BRICK_GREEN, NPC_BRICK_YELLOW, NPC_BRICK_SILVER1, NPC_BRICK_SILVER2,
  3326.                 NPC_BRICK_SILVER3, NPC_BRICK_SILVER4, NPC_BRICK_GOLD
  3327.             };
  3328.             for ( int q = 0; q < BRICK_MAX; ++q )
  3329.             {
  3330.                 if ( brick_to_enemy2[q] == combo_id )
  3331.                 {
  3332.                     //TraceS("brick_to_npc : combo input: "); Trace(combo_id);
  3333.                     //TraceS("brick_to_npc : enemy output: "); Trace(brick_to_enemy2[BRICK_MAX+q-1]);
  3334.                     return ( brick_to_enemy2[BRICK_MAX+q-1] );
  3335.                 }
  3336.             }
  3337.         }
  3338.         return 0; //error
  3339.     }
  3340. }
  3341.  
  3342. global script onExit
  3343. {
  3344.     void run()
  3345.     {
  3346.         Screen->LayerOpacity[0] = templayer[0];
  3347.         Screen->LayerOpacity[1] = templayer[1];
  3348.         Screen->LayerMap[0] = templayer[2];
  3349.         Screen->LayerMap[1] = templayer[3];
  3350.         newstage = true;
  3351.         arkanoid.clearscore();
  3352.         arkanoid.update_high_score_display();
  3353.         //vaus->Misc[MISC_DEAD] = 0;
  3354.  
  3355.     }
  3356. }  
  3357.  
  3358. global script init
  3359. {
  3360.     void run()
  3361.     {
  3362.         quit = 0;
  3363.         frame = -1;
  3364.         cur_stage = 1;
  3365.         Game->Counter[CR_LIVES] = STARTING_LIVES;
  3366.         Link->CollDetection = false;
  3367.         Link->DrawYOffset = -32768;
  3368.     }
  3369. }
  3370.  
  3371. global script Init
  3372. {
  3373.     void run()
  3374.     {
  3375.         quit = 0;
  3376.         frame = -1;
  3377.         cur_stage = 1;
  3378.         Game->Counter[CR_LIVES] = STARTING_LIVES;
  3379.         Link->CollDetection = false;
  3380.         Link->DrawYOffset = -32768;
  3381.     }
  3382. }
  3383.  
  3384. global script onContinue
  3385. {
  3386.     void run()
  3387.     {
  3388.         quit = 0;
  3389.         frame = -1;
  3390.         //cur_stage = 1;
  3391.         //ffc vaus = Screen->LoadFFC(FFC_VAUS);
  3392.         //paddle.setup(vaus);
  3393.         Game->Counter[CR_LIVES] = STARTING_LIVES;
  3394.         Link->Invisible = true;
  3395.         Link->CollDetection = false;
  3396.         Link->DrawYOffset = -32768;
  3397.     }
  3398. }
  3399.  
  3400. /////////////////////////
  3401. /// DEAD Script Bugs: ///
  3402. /////////////////////////
  3403.  
  3404. /*
  3405. //FIXED with ball.clamp().
  3406. //There's a step speed at which the ball phases *through* the vaus!
  3407.                     //Perhaps we should make the vaus an enemy, too? An invisible enemy to act as a failsafe?
  3408.                     //if the ball hits the vaus, it bounces.
  3409.                     //Or just scrap the vaus ffc, and use an npc for it in general?
  3410.  
  3411. //BALL NEEDS TO HAVE A 6PX BY 6PX HITBOX, AND THUS A HIT OFFSET OF -1,-1, so that ->HitBy[] returns when the ball hits a block, and
  3412. //the ball is still not yet inside that object
  3413. */
  3414.  
  3415. //////////////////////
  3416. /// DEAD ZC Issues //////////////////////////////////////////////////////////////////////////////
  3417. /// I fixed these issues, in specific Alphas of ZC 2.54, noted below for historical purposes: ///
  3418. /////////////////////////////////////////////////////////////////////////////////////////////////
  3419.  
  3420.  
  3421. /*
  3422. FIXED in Alpha 32
  3423. I forgot to expand ->Misc[] in sprite.cpp, which should be fixed int he source for Alpha 32.
  3424.     This meant that r/w to ptr->Misc[>15] would use invalid data, or overwrite other data. bad, bad, bad.
  3425.    
  3426.     FIXED in Alpha 32
  3427.     //Note: We also need to store the UID of each ball, as HitBy[] works from the UID, not the pointer.
  3428.    
  3429. */
  3430.  
  3431. ffc script TestGetPixel
  3432. {
  3433.     void run()
  3434.     {
  3435.         while(1)
  3436.         {
  3437.            
  3438.             if ( Input->Key[KEY_8] )
  3439.             {
  3440.                 bitmap bmp = Game->LoadBitmapID(RT_SCREEN);
  3441.                 int col[20];
  3442.                 for ( int q = 0; q < 20; ++ q )
  3443.                 {
  3444.                     col[q] = bmp->GetPixel(40, 0+q*8);
  3445.                 }
  3446.                 TraceNL();
  3447.                 for ( int q = 0; q < 20; ++q )
  3448.                 {
  3449.                     TraceS("Bitmap col: "); Trace(col[q]);
  3450.                 }
  3451.                
  3452.                 Screen->SetRenderTarget(2);
  3453.                 Screen->Rectangle(0, 0, 0, 256, 256, 0x55, 100, 0, 0, 0, true, 128);
  3454.                 Screen->SetRenderTarget(RT_SCREEN);
  3455.                 Waitframe();
  3456.                
  3457.                 bitmap offscreen = Game->LoadBitmapID(2);
  3458.                 int col2[20];
  3459.                 for ( int q = 0; q < 20; ++ q )
  3460.                 {
  3461.                     col2[q] = offscreen->GetPixel(10+q*8,10+q*8);
  3462.                 }
  3463.                 TraceNL();
  3464.                 for ( int q = 0; q < 20; ++q )
  3465.                 {
  3466.                     TraceS("Offscreen Bitmap col: "); Trace(col2[q]);
  3467.                 }
  3468.             }  
  3469.             Waitframe();
  3470.         }
  3471.     }
  3472. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement