home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / xboing / part06 < prev    next >
Encoding:
Text File  |  1993-09-03  |  55.1 KB  |  1,968 lines

  1. Newsgroups: comp.sources.x
  2. From: jck@kimba.catt.citri.edu.au (Justin Kibell)
  3. Subject: v20i113:  xboing - a simple blockout type game, Part06/26
  4. Message-ID: <1993Sep3.123124.7005@sparky.sterling.com>
  5. X-Md4-Signature: bf255de538b1f2535654a751bfec63c4
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Fri, 3 Sep 1993 12:31:24 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: jck@kimba.catt.citri.edu.au (Justin Kibell)
  12. Posting-number: Volume 20, Issue 113
  13. Archive-name: xboing/part06
  14. Environment: X11, xpm, color
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  bitmaps/digit4.xpm bonus.c xaa
  21. # Wrapped by chris@sparky on Fri Sep  3 07:14:43 1993
  22. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 6 (of 26)."'
  25. if test -f 'bitmaps/digit4.xpm' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'bitmaps/digit4.xpm'\"
  27. else
  28.   echo shar: Extracting \"'bitmaps/digit4.xpm'\" \(1438 characters\)
  29.   sed "s/^X//" >'bitmaps/digit4.xpm' <<'END_OF_FILE'
  30. X/* XPM */
  31. Xstatic char * digit4_xpm[] = {
  32. X"30 40 2 1",
  33. X"     c None",
  34. X".    c red",
  35. X"                              ",
  36. X"                              ",
  37. X"                              ",
  38. X"                              ",
  39. X"                              ",
  40. X"   .                       .  ",
  41. X"   ..                     ..  ",
  42. X"   ...                   ...  ",
  43. X"   ....                 ....  ",
  44. X"   .....               .....  ",
  45. X"   .....               .....  ",
  46. X"   .....               .....  ",
  47. X"   .....               .....  ",
  48. X"   .....               .....  ",
  49. X"   .....               .....  ",
  50. X"   .....               .....  ",
  51. X"   .....               .....  ",
  52. X"   .....               .....  ",
  53. X"   .....               .....  ",
  54. X"   .... ............... ....  ",
  55. X"   ... ................. ...  ",
  56. X"      ...................     ",
  57. X"       ................. ...  ",
  58. X"        ............... ....  ",
  59. X"                       .....  ",
  60. X"                       .....  ",
  61. X"                       .....  ",
  62. X"                       .....  ",
  63. X"                       .....  ",
  64. X"                       .....  ",
  65. X"                       .....  ",
  66. X"                       .....  ",
  67. X"                       .....  ",
  68. X"                        ....  ",
  69. X"                         ...  ",
  70. X"                          ..  ",
  71. X"                           .  ",
  72. X"                              ",
  73. X"                              ",
  74. X"                              "};
  75. END_OF_FILE
  76.   if test 1438 -ne `wc -c <'bitmaps/digit4.xpm'`; then
  77.     echo shar: \"'bitmaps/digit4.xpm'\" unpacked with wrong size!
  78.   fi
  79.   # end of 'bitmaps/digit4.xpm'
  80. fi
  81. if test -f 'bonus.c' -a "${1}" != "-c" ; then 
  82.   echo shar: Will not clobber existing file \"'bonus.c'\"
  83. else
  84.   echo shar: Extracting \"'bonus.c'\" \(18804 characters\)
  85.   sed "s/^X//" >'bonus.c' <<'END_OF_FILE'
  86. X#include "copyright.h"
  87. X
  88. X/*
  89. X *  Include file dependencies:
  90. X */
  91. X
  92. X#include <stdio.h>
  93. X#include <stdlib.h>
  94. X#include <stddef.h>
  95. X#include <X11/Xlib.h>
  96. X#include <X11/Xutil.h>
  97. X#include <X11/Xos.h>
  98. X#include <xpm.h>
  99. X
  100. X#include "error.h"
  101. X#include "audio.h"
  102. X#include "highscore.h"
  103. X#include "misc.h"
  104. X#include "main.h"
  105. X#include "gun.h"
  106. X#include "init.h"
  107. X#include "stage.h"
  108. X#include "blocks.h"
  109. X#include "sfx.h"
  110. X#include "ball.h"
  111. X#include "score.h"
  112. X#include "paddle.h"
  113. X#include "level.h"
  114. X#include "mess.h"
  115. X#include "intro.h"
  116. X
  117. X#include "bitmaps/titleSmall.xpm"
  118. X
  119. X#include "bonus.h"
  120. X
  121. X/*
  122. X *  Internal macro definitions:
  123. X */
  124. X
  125. X#define GAP                    30
  126. X#define KEY_TYPE_VOL        50
  127. X#define LINE_DELAY            15
  128. X
  129. X#define BONUS_SCORE            3000
  130. X#define SUPER_BONUS_SCORE    50000
  131. X#define BULLET_SCORE        500
  132. X#define LEVEL_SCORE            1000
  133. X#define TIME_BONUS            100
  134. X
  135. X#define BORDER_LEFT            55
  136. X#define BORDER_RIGHT        ((PLAY_WIDTH + MAIN_WIDTH) - 50)
  137. X#define BORDER_TOP            73
  138. X#define BORDER_BOTTOM        ((PLAY_HEIGHT + MAIN_HEIGHT) - 85)
  139. X
  140. X/*
  141. X *  Internal type declarations:
  142. X */
  143. X
  144. X#if NeedFunctionPrototypes
  145. Xstatic void DoBullets(Display *display, Window window);
  146. Xstatic void DoTimeBonus(Display *display, Window window);
  147. X#else
  148. Xstatic void DoTimeBonus();
  149. Xstatic void DoBullets();
  150. X#endif
  151. X
  152. X/*
  153. X *  Internal variable declarations:
  154. X */
  155. X
  156. Xstatic int         nextFrame = 0;
  157. Xstatic int         count, numBonus;
  158. Xenum BonusStates BonusState;
  159. Xstatic Pixmap     titlePixmap, titlePixmapM;
  160. Xstatic int         ypos;
  161. Xstatic int         waitingFrame, waitMode;
  162. Xstatic char     string[80];
  163. Xstatic Pixmap     backingStoreTitle = (Pixmap) NULL;
  164. Xstatic u_long     bonusScore;
  165. Xstatic int         firstTime = True;
  166. X
  167. X
  168. X#if NeedFunctionPrototypes
  169. Xvoid SetUpBonus(Display *display, Window window, Colormap colormap)
  170. X#else
  171. Xvoid SetUpBonus(display, window, colormap)
  172. X    Display *display;
  173. X    Window window;
  174. X    Colormap colormap;
  175. X#endif
  176. X{
  177. X    XpmAttributes   attributes;
  178. X    int             XpmErrorStatus;
  179. X
  180. X    attributes.valuemask = XpmColormap;
  181. X    attributes.colormap = colormap;
  182. X
  183. X    /* Create the small title pixmap */
  184. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, titleSmall_xpm,
  185. X        &titlePixmap, &titlePixmapM, &attributes);
  186. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBonus()");
  187. X
  188. X    /* Free the xpm pixmap attributes */
  189. X    XpmFreeAttributes(&attributes);
  190. X}
  191. X
  192. X#if NeedFunctionPrototypes
  193. Xvoid DecNumberBonus(void)
  194. X#else
  195. Xvoid DecNumberBonus()
  196. X#endif
  197. X{
  198. X    /* bump down the number of bonuses. sic */
  199. X    numBonus--;
  200. X}
  201. X
  202. X#if NeedFunctionPrototypes
  203. Xvoid IncNumberBonus(void)
  204. X#else
  205. Xvoid IncNumberBonus()
  206. X#endif
  207. X{
  208. X    /* bump up the number of bonuses. sic */
  209. X    numBonus++;
  210. X}
  211. X
  212. X#if NeedFunctionPrototypes
  213. Xint GetNumberBonus(void)
  214. X#else
  215. Xint GetNumberBonus()
  216. X#endif
  217. X{
  218. X    /* Umm - return the number of bonuses */
  219. X    return numBonus;
  220. X}
  221. X
  222. X#if NeedFunctionPrototypes
  223. Xvoid ResetNumberBonus(void)
  224. X#else
  225. Xvoid ResetNumberBonus()
  226. X#endif
  227. X{
  228. X    /* No more bonuses thanks */
  229. X    numBonus = 0;
  230. X}
  231. X
  232. X#if NeedFunctionPrototypes
  233. Xvoid DrawBallBorder(Display *display, Window window)
  234. X#else
  235. Xvoid DrawBallBorder(display, window)
  236. X    Display *display;
  237. X    Window window;
  238. X#endif
  239. X{
  240. X    int x, y;
  241. X    static int slide = 0;
  242. X
  243. X    /* Draw a row of balls along the top and bottom of screen */
  244. X    for (x = BORDER_LEFT; x < BORDER_RIGHT; x += 22)
  245. X    {
  246. X        DrawTheBall(display, window, x, BORDER_TOP, slide);
  247. X        DrawTheBall(display, window, x, BORDER_BOTTOM, slide);
  248. X
  249. X        /* Next frame of ball animation */
  250. X        slide++;
  251. X
  252. X        /* Wrap around animation */
  253. X        if (slide == BALL_SLIDES) slide = 0;
  254. X    }
  255. X
  256. X    /* Draw a row of balls along both sides of the screen */
  257. X    for (y = BORDER_TOP; y < BORDER_BOTTOM; y += 22)
  258. X    {
  259. X        DrawTheBall(display, window, BORDER_LEFT, y, slide);
  260. X        DrawTheBall(display, window, BORDER_RIGHT, y, slide);
  261. X
  262. X        /* Next frame of ball animation */
  263. X        slide++;
  264. X
  265. X        /* Wrap around animation */
  266. X        if (slide == BALL_SLIDES) slide = 0;
  267. X    }
  268. X
  269. X}
  270. X
  271. X#if NeedFunctionPrototypes
  272. Xvoid DrawSmallIntroTitle(Display *display, Window window, int x, int y)
  273. X#else
  274. Xvoid DrawSmallIntroTitle(display, window, x, y)
  275. X    Display *display;
  276. X    Window window;
  277. X    int x;
  278. X    int y;
  279. X#endif
  280. X{
  281. X    /* Draw the small title pixmap */
  282. X    RenderShape(display, window, titlePixmap, titlePixmapM,
  283. X        x - SMALL_TITLE_WC, y - SMALL_TITLE_HC, 
  284. X        SMALL_TITLE_WIDTH, SMALL_TITLE_HEIGHT, False);
  285. X}
  286. X
  287. X#if NeedFunctionPrototypes
  288. Xvoid MoveSmallIntroTitle(Display *display, Window window, int x, int y)
  289. X#else
  290. Xvoid MoveSmallIntroTitle(display, window, x, y)
  291. X    Display *display;
  292. X    Window window;
  293. X    int x;
  294. X    int y;
  295. X#endif
  296. X{
  297. X    static int oldx, oldy;
  298. X
  299. X    /* Make a copy of the new titles position */
  300. X    if (backingStoreTitle != (Pixmap) NULL)
  301. X        XCopyArea(display, backingStoreTitle, window, gc,
  302. X            0, 0, SMALL_TITLE_WIDTH, SMALL_TITLE_HEIGHT, oldx, oldy);
  303. X    else
  304. X    {
  305. X        /* Create a pixmap for the backing store title */
  306. X        backingStoreTitle = XCreatePixmap(display, window,
  307. X            SMALL_TITLE_WIDTH, SMALL_TITLE_HEIGHT,
  308. X            DefaultDepth(display, XDefaultScreen(display)));
  309. X    }
  310. X
  311. X    /* Update the variables for the title position */
  312. X    oldx = x - SMALL_TITLE_WC; oldy = y - SMALL_TITLE_HC;
  313. X
  314. X    /* Copy back the old position picture */
  315. X    if (backingStoreTitle)
  316. X        XCopyArea(display, window, backingStoreTitle, gc,
  317. X            x - SMALL_TITLE_WC, y - SMALL_TITLE_HC, 
  318. X            SMALL_TITLE_WIDTH, SMALL_TITLE_HEIGHT, 0, 0);
  319. X
  320. X    DrawSmallIntroTitle(display, window, x, y);
  321. X}
  322. X
  323. X
  324. X#if NeedFunctionPrototypes
  325. Xvoid SetupBonusScreen(Display *display, Window window)
  326. X#else
  327. Xvoid SetupBonusScreen(display, window)
  328. X    Display *display;
  329. X    Window window;
  330. X#endif
  331. X{
  332. X    /* Clear the background again */
  333. X    ClearMainWindow(display, window);
  334. X
  335. X    /* Draw the rectangular border of balls */
  336. X    DrawBallBorder(display, window);
  337. X
  338. X    /* Draw the main title pixmap */
  339. X    DrawSmallIntroTitle(display, window, TOTAL_WIDTH / 2, 120);
  340. X
  341. X    /* The new state will be the text */
  342. X    ResetBonus();
  343. X
  344. X    /* Remove the window to show bonus stuff */
  345. X    XUnmapWindow(display, playWindow);
  346. X}
  347. X
  348. X#if NeedFunctionPrototypes
  349. Xvoid DrawTitleText(Display *display, Window window)
  350. X#else
  351. Xvoid DrawTitleText(display, window)
  352. X    Display *display;
  353. X    Window window;
  354. X#endif
  355. X{
  356. X    SetCurrentMessage(display, messWindow, "- Bonus Tally -", True);
  357. X    
  358. X    /* Indicate which level the bonus is for */
  359. X    sprintf(string, "- Level %d -", level);
  360. X    DrawShadowCentredText(display, window, titleFont, 
  361. X        string, ypos, red, TOTAL_WIDTH);
  362. X    ypos += (titleFont->ascent + GAP);
  363. X
  364. X    strcpy(string, "Press space for next level");
  365. X    DrawShadowCentredText(display, window, textFont, 
  366. X        string, PLAY_HEIGHT - 12, tann, TOTAL_WIDTH);
  367. X
  368. X    BonusState = BONUS_SCORE;
  369. X
  370. X    /* Just in case it has changed */
  371. X    SetGameSpeed(FAST_SPEED);
  372. X}
  373. X
  374. X#if NeedFunctionPrototypes
  375. Xstatic void DoScore(Display *display, Window window)
  376. X#else
  377. Xstatic void DoScore(display, window)
  378. X    Display *display;
  379. X    Window window;
  380. X#endif
  381. X{
  382. X    SetGameSpeed(MEDIUM_SPEED);
  383. X
  384. X    /* Nice message rewarding you for your efforts */
  385. X    strcpy(string, "Congratulations on finishing this level.");
  386. X    DrawShadowCentredText(display, window, textFont, 
  387. X        string, ypos, white, TOTAL_WIDTH);
  388. X    XFlush(display);
  389. X
  390. X    count = 0;
  391. X    ypos += (35 + GAP);
  392. X    SetBonusWait(BONUS_BONUS, frame + LINE_DELAY);
  393. X    SetGameSpeed(SLOW_SPEED);
  394. X}
  395. X
  396. X#if NeedFunctionPrototypes
  397. Xstatic void DoBonuses(Display *display, Window window)
  398. X#else
  399. Xstatic void DoBonuses(display, window)
  400. X    Display *display;
  401. X    Window window;
  402. X#endif
  403. X{
  404. X    int x, plen;
  405. X    static int maxLen;
  406. X
  407. X    if (firstTime)
  408. X    {
  409. X        /* Set up the bonus coin sequence */
  410. X        firstTime = False;
  411. X
  412. X        if (numBonus == 0)
  413. X        {
  414. X            /* No bonus coins - so tell user */
  415. X            strcpy(string, "Sorry, no bonus coins collected.");
  416. X            DrawShadowCentredText(display, window, textFont, 
  417. X                string, ypos, blue, TOTAL_WIDTH);
  418. X
  419. X            SetGameSpeed(MEDIUM_SPEED);
  420. X
  421. X            /* Now skip to the next sequence */
  422. X            SetBonusWait(BONUS_LEVEL, frame + LINE_DELAY);
  423. X            count = 0;
  424. X            firstTime = True;
  425. X            ypos += (textFont->ascent + GAP * 2);
  426. X            return;
  427. X        }
  428. X
  429. X        if (numBonus > MAX_BONUS)
  430. X        {
  431. X            /* Play the sound for the super bonus */
  432. X            if (noSound == False) 
  433. X                playSoundFile("superbonus", 80);
  434. X
  435. X            /* More than 10 coins collected - super bonus reward */
  436. X            sprintf(string, "Super Bonus - %d", SUPER_BONUS_SCORE);
  437. X                DrawShadowCentredText(display, window, titleFont, 
  438. X                    string, ypos, blue, TOTAL_WIDTH);
  439. X
  440. X            /* Update the score with more points */
  441. X            bonusScore += SUPER_BONUS_SCORE;
  442. X            DisplayScore(display, scoreWindow, bonusScore);
  443. X    
  444. X            SetGameSpeed(MEDIUM_SPEED);
  445. X
  446. X            /* Now skip to the next sequence */
  447. X            SetBonusWait(BONUS_LEVEL, frame + LINE_DELAY);
  448. X            count = 0;
  449. X            firstTime = True;
  450. X            ypos += (textFont->ascent + GAP * 2);
  451. X            return;
  452. X        }
  453. X
  454. X        /* Calculate where to draw these coins centred */
  455. X        maxLen = ((numBonus * 27) + (10 * numBonus) + 5);
  456. X    }
  457. X
  458. X    /* Find out where the next bonus coin will go next */
  459. X    plen = ((numBonus * 27) + (10 * numBonus));
  460. X    x = (((PLAY_WIDTH + MAIN_WIDTH) / 2) + (maxLen / 2)) - plen;
  461. X
  462. X    /* Draw the bonus coin shape */
  463. X    DrawTheBlock(display, window, x, ypos, BONUS_BLK, 0);
  464. X
  465. X    /* Play the sound for the bonus */
  466. X    if (noSound == False) 
  467. X        playSoundFile("bonus", 50);
  468. X
  469. X    /* Increment the score by the value of the bonus */
  470. X    bonusScore += BONUS_SCORE;
  471. X    DisplayScore(display, scoreWindow, bonusScore);
  472. X
  473. X    /* Reduce number of bonuses */
  474. X    DecNumberBonus();
  475. X
  476. X    if (numBonus <= 0)
  477. X    {
  478. X        /* Set up bonus state for next sequence */
  479. X        SetBonusWait(BONUS_LEVEL, frame + LINE_DELAY);
  480. X        count = 0;
  481. X
  482. X        /* Make sure bonus is reset */
  483. X        ResetNumberBonus();
  484. X
  485. X        ypos += (textFont->ascent + GAP * 1.5);
  486. X        firstTime = True;
  487. X
  488. X        SetGameSpeed(MEDIUM_SPEED);
  489. X    }
  490. X}
  491. X
  492. X#if NeedFunctionPrototypes
  493. Xstatic void DoLevel(Display *display, Window window)
  494. X#else
  495. Xstatic void DoLevel(display, window)
  496. X    Display *display;
  497. X    Window window;
  498. X#endif
  499. X{
  500. X    int secs, theLevel;
  501. X
  502. X    SetGameSpeed(MEDIUM_SPEED);
  503. X
  504. X    /* Get the number of seconds left on the clock */
  505. X    secs = GetLevelTimeBonus();
  506. X
  507. X    if (secs > 0)
  508. X    {
  509. X        /* Adjust the level so that the starting level is taken into account */
  510. X        theLevel = (int) level - GetStartingLevel() + 1;
  511. X
  512. X        /* Draw level bonus text */
  513. X        sprintf(string, "Level bonus - level %d x %d = %d points", 
  514. X            theLevel, LEVEL_SCORE, theLevel * LEVEL_SCORE);
  515. X        DrawShadowCentredText(display, window, textFont, 
  516. X            string, ypos, yellow, TOTAL_WIDTH);
  517. X
  518. X        /* Increment the score by the value of the level bonus */
  519. X        bonusScore += (LEVEL_SCORE * theLevel);
  520. X        DisplayScore(display, scoreWindow, bonusScore);
  521. X    }
  522. X    else
  523. X    {
  524. X        strcpy(string, "No level bonus - Timer ran out.");
  525. X        DrawShadowCentredText(display, window, textFont, 
  526. X            string, ypos, yellow, TOTAL_WIDTH);
  527. X    }
  528. X
  529. X    count = 0;
  530. X
  531. X    /* Next section setup */
  532. X    ypos += (textFont->ascent + GAP * 1.5);
  533. X    SetBonusWait(BONUS_BULLET, frame + LINE_DELAY);
  534. X}
  535. X
  536. X#if NeedFunctionPrototypes
  537. Xstatic void DoBullets(Display *display, Window window)
  538. X#else
  539. Xstatic void DoBullets(display, window)
  540. X    Display *display;
  541. X    Window window;
  542. X#endif
  543. X{
  544. X    int x, plen;
  545. X    static int maxLen;
  546. X
  547. X    if (firstTime)
  548. X    {
  549. X        /* For the first time setup the bullet bonus seq. */
  550. X        firstTime = False;
  551. X
  552. X        if (GetNumberBullets() == 0)
  553. X        {
  554. X            /* No bullets - say so */
  555. X            strcpy(string, "You have used all your bullets. No bonus!");
  556. X            DrawShadowCentredText(display, window, textFont, 
  557. X                string, ypos, blue, TOTAL_WIDTH);
  558. X            
  559. X            SetGameSpeed(MEDIUM_SPEED);
  560. X
  561. X            /* Get ready for the next sequence */
  562. X            SetBonusWait(BONUS_TIME, frame + LINE_DELAY);
  563. X            count = 0;
  564. X            firstTime = True;
  565. X            ypos += (textFont->ascent + GAP/2);
  566. X            return;
  567. X        }
  568. X
  569. X        /* Position where the first bullet will be drawn */
  570. X        maxLen = ((GetNumberBullets() * 7) + (3 * GetNumberBullets()));
  571. X    }
  572. X
  573. X    /* Find out where the next bonus bullet will go next */
  574. X    plen = ((GetNumberBullets() * 7) + (3 * GetNumberBullets()));
  575. X    x = (((PLAY_WIDTH + MAIN_WIDTH) / 2) + (maxLen / 2)) - plen;
  576. X
  577. X    DrawTheBullet(display, window, x, ypos);
  578. X
  579. X    /* Play the sound for the bullets */
  580. X    if (noSound == False) 
  581. X        playSoundFile("key", 50);
  582. X
  583. X    /* Increment the score by the value of the bullet bonus */
  584. X    bonusScore += BULLET_SCORE;
  585. X    DisplayScore(display, scoreWindow, bonusScore);
  586. X
  587. X    /* Ummm. Draw a bullet */
  588. X    DeleteABullet(display);    
  589. X
  590. X    if (GetNumberBullets() == 0)
  591. X    {
  592. X        /* Reset bullets and get ready for next sequence */
  593. X        SetBonusWait(BONUS_TIME, frame + LINE_DELAY);
  594. X        count = 0;
  595. X        ypos += (textFont->ascent + GAP/2);
  596. X        firstTime = True;
  597. X        SetGameSpeed(MEDIUM_SPEED);
  598. X    }
  599. X}
  600. X
  601. X#if NeedFunctionPrototypes
  602. Xstatic void DoTimeBonus(Display *display, Window window)
  603. X#else
  604. Xstatic void DoTimeBonus(display, window)
  605. X    Display *display;
  606. X    Window window;
  607. X#endif
  608. X{
  609. X    int secs = 0;
  610. X
  611. X    SetGameSpeed(MEDIUM_SPEED);
  612. X
  613. X    /* Get the number of seconds left on the clock */
  614. X    secs = GetLevelTimeBonus();
  615. X
  616. X    if (secs > 0)
  617. X    {
  618. X        /* Draw time bonus text */
  619. X        sprintf(string, "Time bonus - %d seconds x %d = %d points", 
  620. X            secs, TIME_BONUS, secs * TIME_BONUS);
  621. X        DrawShadowCentredText(display, window, textFont, 
  622. X            string, ypos, yellow, TOTAL_WIDTH);
  623. X
  624. X        /* Increment the score by the value of the time bonus */
  625. X        bonusScore += (TIME_BONUS * secs);
  626. X        DisplayScore(display, scoreWindow, bonusScore);
  627. X    }
  628. X    else
  629. X    {
  630. X        /* Draw no time bonus text */
  631. X        strcpy(string, "No time bonus - not quick enough!");
  632. X        DrawShadowCentredText(display, window, textFont, 
  633. X            string, ypos, yellow, TOTAL_WIDTH);
  634. X    }
  635. X
  636. X    /* Next section setup */
  637. X    ypos += (textFont->ascent + GAP/2);
  638. X    SetBonusWait(BONUS_HSCORE, frame + LINE_DELAY);
  639. X    count = 0;
  640. X}
  641. X
  642. X#if NeedFunctionPrototypes
  643. Xstatic void DoHighScore(Display *display, Window window)
  644. X#else
  645. Xstatic void DoHighScore(display, window)
  646. X    Display *display;
  647. X    Window window;
  648. X#endif
  649. X{
  650. X    int myrank = 0;
  651. X    char str[5];
  652. X
  653. X    SetGameSpeed(MEDIUM_SPEED);
  654. X
  655. X    /* Obtain current ranking for this score */
  656. X    myrank = GetHighScoreRanking(score);
  657. X
  658. X    if (myrank > 0)
  659. X    {
  660. X        /* Special case for first place */
  661. X        if (myrank == 1)
  662. X            sprintf(string, "You are ranked 1st. Well done!");
  663. X        else
  664. X        {
  665. X            /* Add the correct grammer for the sentence */
  666. X            switch (myrank)
  667. X            {
  668. X                case 1:
  669. X                    strcpy(str, "st");
  670. X                    break;
  671. X                
  672. X                case 2:
  673. X                    strcpy(str, "nd");
  674. X                    break;
  675. X                
  676. X                case 3:
  677. X                    strcpy(str, "rd");
  678. X                    break;
  679. X                
  680. X                case 4:
  681. X                case 5:
  682. X                case 6:
  683. X                case 7:
  684. X                case 8:
  685. X                case 9:
  686. X                case 10:
  687. X                    strcpy(str, "th");
  688. X                    break;
  689. X                
  690. X                default:
  691. X                    strcpy(str, "");
  692. X                    break;
  693. X            }
  694. X
  695. X            /* Construct beautiful sentence */
  696. X            sprintf(string, "You are currently ranked %d%s.", 
  697. X                myrank, str);
  698. X        }
  699. X    }
  700. X    else
  701. X        /* What a loser ;-) */
  702. X        strcpy(string, "You haven't even qualified for a highscore!");
  703. X
  704. X    /* Draw the text for the game ranking */
  705. X    DrawShadowCentredText(display, window, textFont, 
  706. X        string, ypos, red, TOTAL_WIDTH);
  707. X    ypos += (textFont->ascent + GAP/2);
  708. X
  709. X    count = 0;
  710. X    SetBonusWait(BONUS_END_TEXT, frame + LINE_DELAY);
  711. X}
  712. X
  713. X#if NeedFunctionPrototypes
  714. Xstatic void DoEndText(Display *display, Window window)
  715. X#else
  716. Xstatic void DoEndText(display, window)
  717. X    Display *display;
  718. X    Window window;
  719. X#endif
  720. X{
  721. X    SetGameSpeed(MEDIUM_SPEED);
  722. X
  723. X    /* Finishing sentence - so you know what level to do */
  724. X    sprintf(string, "Prepare for level %d", level+1);
  725. X    DrawShadowCentredText(display, window, textFont, 
  726. X        string, ypos, yellow, TOTAL_WIDTH);
  727. X    XFlush(display);
  728. X
  729. X    count = 0;
  730. X    SetBonusWait(BONUS_FINISH, frame + 60);
  731. X}
  732. X
  733. X#if NeedFunctionPrototypes
  734. Xstatic void DoFinish(Display *display, Window window)
  735. X#else
  736. Xstatic void DoFinish(display, window)
  737. X    Display *display;
  738. X    Window window;
  739. X#endif
  740. X{
  741. X    /* Setup game window for the next level */
  742. X    level++;
  743. X    SetupStage(display, playWindow);
  744. X
  745. X    BonusState = BONUS_TEXT;
  746. X    SetGameSpeed(FAST_SPEED);
  747. X
  748. X    mode = MODE_GAME;
  749. X
  750. X    XMapWindow(display, playWindow);
  751. X
  752. X    /* Only redraw if the server hasn't backing store on */
  753. X    if (DoesBackingStore(XDefaultScreenOfDisplay(display)) != Always)
  754. X        SelectiveRedraw(display);
  755. X}
  756. X
  757. X#if NeedFunctionPrototypes
  758. Xvoid SetBonusWait(int newMode, int waitFrame)
  759. X#else
  760. Xvoid SetBonusWait(newMode, waitFrame)
  761. X    int newMode;
  762. X    int waitFrame;
  763. X#endif
  764. X{
  765. X    waitingFrame = waitFrame;
  766. X    waitMode = newMode;
  767. X    BonusState = BONUS_WAIT;
  768. X}
  769. X
  770. X#if NeedFunctionPrototypes
  771. Xvoid DoBonusWait(void)
  772. X#else
  773. Xvoid DoBonusWait()
  774. X#endif
  775. X{
  776. X    /* Wait for the frame we want to come along - then change modes */
  777. X    if (frame == waitingFrame)
  778. X        BonusState = waitMode;
  779. X}
  780. X
  781. X#if NeedFunctionPrototypes
  782. Xvoid DoBonus(Display *display, Window window)
  783. X#else
  784. Xvoid DoBonus(display, window)
  785. X    Display *display;
  786. X    Window window;
  787. X#endif
  788. X{
  789. X    /* The states within the bonus mode */
  790. X    switch (BonusState)
  791. X    {
  792. X        case BONUS_TEXT:
  793. X            DrawTitleText(display, window);
  794. X            break;
  795. X
  796. X        case BONUS_SCORE:
  797. X            DoScore(display, window);
  798. X            break;
  799. X
  800. X        case BONUS_BONUS:
  801. X            DoBonuses(display, window);
  802. X            break;
  803. X
  804. X        case BONUS_LEVEL:
  805. X            DoLevel(display, window);
  806. X            break;
  807. X
  808. X        case BONUS_BULLET:
  809. X            DoBullets(display, window);
  810. X            break;
  811. X
  812. X        case BONUS_TIME:
  813. X            DoTimeBonus(display, window);
  814. X            break;
  815. X
  816. X        case BONUS_HSCORE:
  817. X            DoHighScore(display, window);
  818. X            break;
  819. X
  820. X        case BONUS_END_TEXT:
  821. X            DoEndText(display, window);
  822. X            break;
  823. X
  824. X        case BONUS_FINISH:
  825. X            DoFinish(display, window);
  826. X            break;
  827. X
  828. X        case BONUS_WAIT:
  829. X            DoBonusWait();
  830. X            break;
  831. X
  832. X        default:
  833. X            break;
  834. X    }
  835. X}
  836. X
  837. X#if NeedFunctionPrototypes
  838. Xvoid RedrawBonus(Display *display, Window window)
  839. X#else
  840. Xvoid RedrawBonus(display, window)
  841. X    Display *display;
  842. X    Window window;
  843. X#endif
  844. X{
  845. X    /* This will redraw the entire screen */
  846. X    SetupBonusScreen(display, mainWindow);
  847. X}
  848. X
  849. X#if NeedFunctionPrototypes
  850. Xvoid FreeBonus(Display *display)
  851. X#else
  852. Xvoid FreeBonus(display)
  853. X    Display *display;
  854. X#endif
  855. X{
  856. X    /* Free all the hungry memory leaks */
  857. X    if (titlePixmap)    XFreePixmap(display, titlePixmap);
  858. X    if (titlePixmapM)    XFreePixmap(display, titlePixmapM);
  859. X}
  860. X
  861. X#if NeedFunctionPrototypes
  862. Xvoid ComputeAndAddBonusScore(void)
  863. X#else
  864. Xvoid ComputeAndAddBonusScore()
  865. X#endif
  866. X{
  867. X    /* This function will pre compute the bonus score and add it to the
  868. X     * score. The bonus screen will only change the score by updating the
  869. X     * score display and not the score value. This means the user can hit
  870. X     * space and go to the next screen without delay. Cool.
  871. X     */
  872. X    int secs = 0;
  873. X    int theLevel = 0;
  874. X
  875. X    /* Compute bonus coin bonus */
  876. X    if (numBonus > MAX_BONUS)
  877. X    {
  878. X        /* More than MAX_BONUS bonus so give super bonus */
  879. X        AddToScore((u_long) SUPER_BONUS_SCORE);
  880. X    }
  881. X    else
  882. X    {
  883. X        /* Less than MAX_BONUS so work out bonus score */
  884. X        AddToScore((u_long) (numBonus * BONUS_SCORE));
  885. X    }
  886. X
  887. X       /* Adjust the level so that the starting level is taken into account */
  888. X       theLevel = (int) level - GetStartingLevel() + 1;
  889. X
  890. X    /* Increment the score by the value of the level bonus */
  891. X    AddToScore((u_long) (LEVEL_SCORE * theLevel));
  892. X
  893. X    /* Increment the score by the value of the bullet bonus */
  894. X    if (GetNumberBullets() != 0)
  895. X        AddToScore((u_long) (GetNumberBullets() * BULLET_SCORE));
  896. X
  897. X    /* Get the number of seconds left on the clock */
  898. X    secs = GetLevelTimeBonus();
  899. X    if (secs > 0)
  900. X    {
  901. X        /* Increment the score by the value of the time bonus */
  902. X        AddToScore((u_long) (TIME_BONUS * secs));
  903. X    }
  904. X}
  905. X
  906. X#if NeedFunctionPrototypes
  907. Xvoid ResetBonus(void)
  908. X#else
  909. Xvoid ResetBonus()
  910. X#endif
  911. X{
  912. X    /* Setup for bonus screen from start */
  913. X    BonusState = BONUS_TEXT;
  914. X    nextFrame = frame + 500;
  915. X    count = 0;
  916. X    firstTime = True;
  917. X    bonusScore = score;
  918. X    ComputeAndAddBonusScore();
  919. X    ypos = 180;
  920. X    SetGameSpeed(FAST_SPEED);
  921. X}
  922. END_OF_FILE
  923.   if test 18804 -ne `wc -c <'bonus.c'`; then
  924.     echo shar: \"'bonus.c'\" unpacked with wrong size!
  925.   fi
  926.   # end of 'bonus.c'
  927. fi
  928. if test -f 'xaa' -a "${1}" != "-c" ; then 
  929.   echo shar: Will not clobber existing file \"'xaa'\"
  930. else
  931.   echo shar: Extracting \"'xaa'\" \(31252 characters\)
  932.   sed "s/^X//" >'xaa' <<'END_OF_FILE'
  933. X#include "copyright.h"
  934. X
  935. X/*
  936. X *  Include file dependencies:
  937. X */
  938. X
  939. X#include <stdio.h>
  940. X#include <stdlib.h>
  941. X#include <stddef.h>
  942. X#include <X11/Xlib.h>
  943. X#include <X11/Xutil.h>
  944. X#include <X11/Xos.h>
  945. X#include <xpm.h>
  946. X
  947. X#include "bitmaps/blueblock.xpm"
  948. X#include "bitmaps/exblueblock1.xpm"
  949. X#include "bitmaps/exblueblock2.xpm"
  950. X#include "bitmaps/exblueblock3.xpm"
  951. X
  952. X#include "bitmaps/redblock.xpm"
  953. X#include "bitmaps/exredblock1.xpm"
  954. X#include "bitmaps/exredblock2.xpm"
  955. X#include "bitmaps/exredblock3.xpm"
  956. X
  957. X#include "bitmaps/yellowblock.xpm"
  958. X#include "bitmaps/exyellowblock1.xpm"
  959. X#include "bitmaps/exyellowblock2.xpm"
  960. X#include "bitmaps/exyellowblock3.xpm"
  961. X
  962. X#include "bitmaps/greenblock.xpm"
  963. X#include "bitmaps/exgreenblock1.xpm"
  964. X#include "bitmaps/exgreenblock2.xpm"
  965. X#include "bitmaps/exgreenblock3.xpm"
  966. X
  967. X#include "bitmaps/tanblock.xpm"
  968. X#include "bitmaps/extanblock1.xpm"
  969. X#include "bitmaps/extanblock2.xpm"
  970. X#include "bitmaps/extanblock3.xpm"
  971. X
  972. X#include "bitmaps/purpleblock.xpm"
  973. X#include "bitmaps/expurpleblock1.xpm"
  974. X#include "bitmaps/expurpleblock2.xpm"
  975. X#include "bitmaps/expurpleblock3.xpm"
  976. X
  977. X#include "bitmaps/bombblock.xpm"
  978. X#include "bitmaps/exbombblock1.xpm"
  979. X#include "bitmaps/exbombblock2.xpm"
  980. X#include "bitmaps/exbombblock3.xpm"
  981. X
  982. X#include "bitmaps/counterblock1.xpm"
  983. X#include "bitmaps/counterblock2.xpm"
  984. X#include "bitmaps/counterblock3.xpm"
  985. X#include "bitmaps/counterblock4.xpm"
  986. X#include "bitmaps/counterblock5.xpm"
  987. X#include "bitmaps/counterblock.xpm"
  988. X#include "bitmaps/excounterblock1.xpm"
  989. X#include "bitmaps/excounterblock2.xpm"
  990. X#include "bitmaps/excounterblock3.xpm"
  991. X
  992. X#include "bitmaps/blackblock.xpm"
  993. X#include "bitmaps/reverse.xpm"
  994. X#include "bitmaps/hyperspace.xpm"
  995. X#include "bitmaps/machinegun.xpm"
  996. X#include "bitmaps/walloff.xpm"
  997. X#include "bitmaps/multiballblock.xpm"
  998. X#include "bitmaps/stickyblock.xpm"
  999. X#include "bitmaps/paddleshrink.xpm"
  1000. X#include "bitmaps/paddleexpand.xpm"
  1001. X
  1002. X#include "bitmaps/xtraball.xpm"
  1003. X#include "bitmaps/xtraball2.xpm"
  1004. X
  1005. X#include "bitmaps/x2bonus1.xpm"
  1006. X#include "bitmaps/x2bonus2.xpm"
  1007. X#include "bitmaps/x2bonus3.xpm"
  1008. X#include "bitmaps/x2bonus4.xpm"
  1009. X
  1010. X#include "bitmaps/x4bonus1.xpm"
  1011. X#include "bitmaps/x4bonus2.xpm"
  1012. X#include "bitmaps/x4bonus3.xpm"
  1013. X#include "bitmaps/x4bonus4.xpm"
  1014. X
  1015. X#include "bitmaps/bonus1.xpm"
  1016. X#include "bitmaps/bonus2.xpm"
  1017. X#include "bitmaps/bonus3.xpm"
  1018. X#include "bitmaps/bonus4.xpm"
  1019. X
  1020. X#include "bitmaps/exx2bonus1.xpm"
  1021. X#include "bitmaps/exx2bonus2.xpm"
  1022. X#include "bitmaps/exx2bonus3.xpm"
  1023. X
  1024. X#include "bitmaps/death1.xpm"
  1025. X#include "bitmaps/death2.xpm"
  1026. X#include "bitmaps/death3.xpm"
  1027. X#include "bitmaps/death4.xpm"
  1028. X#include "bitmaps/death5.xpm"
  1029. X
  1030. X#include "bitmaps/exdeath1.xpm"
  1031. X#include "bitmaps/exdeath2.xpm"
  1032. X#include "bitmaps/exdeath3.xpm"
  1033. X#include "bitmaps/exdeath4.xpm"
  1034. X
  1035. X#include "audio.h"
  1036. X#include "misc.h"
  1037. X#include "mess.h"
  1038. X#include "gun.h"
  1039. X#include "error.h"
  1040. X#include "bonus.h"
  1041. X#include "special.h"
  1042. X#include "main.h"
  1043. X#include "init.h"
  1044. X#include "stage.h"
  1045. X#include "ball.h"
  1046. X#include "score.h"
  1047. X#include "paddle.h"
  1048. X#include "level.h"
  1049. X#include "sfx.h"
  1050. X
  1051. X#include "blocks.h"
  1052. X
  1053. X/*
  1054. X *  Internal macro definitions:
  1055. X */
  1056. X
  1057. X#define EXPLODE_DELAY                10    
  1058. X#define BONUS_DELAY                    150    
  1059. X#define BONUS_LENGTH                2000
  1060. X#define NUMBER_OF_BULLETS_NEW_LEVEL 4
  1061. X#define DEATH_DELAY1                100
  1062. X#define DEATH_DELAY2                700
  1063. X#define EXTRABALL_DELAY                300
  1064. X#define RANDOM_DELAY                500
  1065. X
  1066. X/*
  1067. X *  Internal type declarations:
  1068. X */
  1069. X
  1070. X#if NeedFunctionPrototypes
  1071. Xstatic void ClearBlock(int row, int col);
  1072. Xstatic void CalculateBlockGeometry(int row, int col);
  1073. Xstatic void SetBlockUpForExplosion(int row, int col, int frame);
  1074. X#else
  1075. Xstatic void SetBlockUpForExplosion();
  1076. Xstatic void ClearBlock();
  1077. Xstatic void CalculateBlockGeometry();
  1078. X#endif
  1079. X
  1080. X/*
  1081. X *  Internal variable declarations:
  1082. X */
  1083. X
  1084. Xstatic Pixmap    exredblock[3],        exredblockM[3];
  1085. Xstatic Pixmap    extanblock[3],        extanblockM[3];
  1086. Xstatic Pixmap    exyellowblock[3],    exyellowblockM[3];
  1087. Xstatic Pixmap    exgreenblock[3],    exgreenblockM[3];
  1088. Xstatic Pixmap    exblueblock[3],        exblueblockM[3];
  1089. Xstatic Pixmap    expurpleblock[3],    expurpleblockM[3];
  1090. Xstatic Pixmap    exbombblock[3],        exbombblockM[3];
  1091. Xstatic Pixmap    excounterblock[3],    excounterblockM[3];
  1092. Xstatic Pixmap    exx2bonus[3],        exx2bonusM[3];
  1093. Xstatic Pixmap    x2bonus[4],            x2bonusM[4];
  1094. Xstatic Pixmap    x4bonus[4],            x4bonusM[4];
  1095. Xstatic Pixmap    Bonus[4],            BonusM[4];
  1096. Xstatic Pixmap    death[5],            deathM[5];
  1097. Xstatic Pixmap    exdeath[5],            exdeathM[5];
  1098. Xstatic Pixmap    counterblock[6],    counterblockM[6];
  1099. Xstatic Pixmap    extraball[3],        extraballM[3];
  1100. X
  1101. Xstatic Pixmap    redblock, greenblock, blueblock, yellowblock, purpleblock;    
  1102. Xstatic Pixmap    tanblock, blackblock, bombblock, revblock,     hyperblock;
  1103. Xstatic Pixmap    mgunblock, walloffblock, multiball, sticky, paddleshrink;
  1104. Xstatic Pixmap    paddleexpand;
  1105. X
  1106. Xstatic Pixmap    redblockM, greenblockM, blueblockM, yellowblockM, purpleblockM;    
  1107. Xstatic Pixmap    tanblockM, blackblockM, bombblockM, revblockM,     hyperblockM;
  1108. Xstatic Pixmap    mgunblockM, walloffblockM, multiballM, stickyM, paddleshrinkM;
  1109. Xstatic Pixmap    paddleexpandM;
  1110. X
  1111. Xstruct aBlock     blocks[MAX_ROW][MAX_COL];
  1112. Xint            blocksExploding = 0;
  1113. Xint            rowHeight;
  1114. Xint            colWidth;
  1115. X
  1116. X#if NeedFunctionPrototypes
  1117. Xvoid InitialiseBlocks(Display *display, Window window, Colormap colormap)
  1118. X#else
  1119. Xvoid InitialiseBlocks(display, window, colormap)
  1120. X    Display *display;
  1121. X    Window window;
  1122. X    Colormap colormap;
  1123. X#endif
  1124. X{
  1125. X    XpmAttributes   attributes;
  1126. X    int             XpmErrorStatus;
  1127. X
  1128. X    attributes.valuemask = XpmColormap;
  1129. X    attributes.colormap = colormap;
  1130. X
  1131. X    /* Create all xpm pixmap blocks from the files */
  1132. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, redblock_xpm, 
  1133. X        &redblock, &redblockM, &attributes);
  1134. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(red)");
  1135. X
  1136. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, blueblock_xpm, 
  1137. X        &blueblock, &blueblockM, &attributes);
  1138. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(blue)");
  1139. X
  1140. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, greenblock_xpm, 
  1141. X        &greenblock, &greenblockM, &attributes);
  1142. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(green)");
  1143. X
  1144. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, yellowblock_xpm, 
  1145. X        &yellowblock, &yellowblockM, &attributes);
  1146. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(yellow)");
  1147. X
  1148. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, tanblock_xpm, 
  1149. X        &tanblock, &tanblockM, &attributes);
  1150. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(tan)");
  1151. X
  1152. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, purpleblock_xpm, 
  1153. X        &purpleblock, &purpleblockM, &attributes);
  1154. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(purple)");
  1155. X
  1156. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, blackblock_xpm, 
  1157. X        &blackblock, &blackblockM, &attributes);
  1158. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(wall)");
  1159. X
  1160. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, bombblock_xpm, 
  1161. X        &bombblock, &bombblockM, &attributes);
  1162. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(bomb)");
  1163. X
  1164. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, reverse_xpm, 
  1165. X        &revblock, &revblockM, &attributes);
  1166. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(reverse)");
  1167. X
  1168. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, hyperspace_xpm, 
  1169. X        &hyperblock, &hyperblockM, &attributes);
  1170. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(hyperspace)");
  1171. X
  1172. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, machinegun_xpm, 
  1173. X        &mgunblock, &mgunblockM, &attributes);
  1174. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(machinegun)");
  1175. X
  1176. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, walloff_xpm, 
  1177. X        &walloffblock, &walloffblockM, &attributes);
  1178. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(walloff)");
  1179. X
  1180. X    /* Explosion for yellow block */
  1181. X
  1182. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1183. X        exyellowblock1_xpm, &exyellowblock[0], &exyellowblockM[0], 
  1184. X        &attributes);
  1185. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exyellow)");
  1186. X
  1187. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1188. X        exyellowblock2_xpm, &exyellowblock[1], &exyellowblockM[1], 
  1189. X        &attributes);
  1190. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exyellow)");
  1191. X
  1192. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1193. X        exyellowblock3_xpm, &exyellowblock[2], &exyellowblockM[2], 
  1194. X        &attributes);
  1195. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exyellow)");
  1196. X
  1197. X    /* Explosion for red block */
  1198. X
  1199. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, exredblock1_xpm, 
  1200. X        &exredblock[0], &exredblockM[0], &attributes);
  1201. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exred)");
  1202. X
  1203. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, exredblock2_xpm, 
  1204. X        &exredblock[1], &exredblockM[1], &attributes);
  1205. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exred)");
  1206. X
  1207. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, exredblock3_xpm, 
  1208. X        &exredblock[2], &exredblockM[2], &attributes);
  1209. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exred)");
  1210. X
  1211. X    /* Explosion for green block */
  1212. X
  1213. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1214. X        exgreenblock1_xpm, &exgreenblock[0], &exgreenblockM[0], &attributes);
  1215. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exgreen)");
  1216. X
  1217. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1218. X        exgreenblock2_xpm, &exgreenblock[1], &exgreenblockM[1], &attributes);
  1219. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exgreen)");
  1220. X
  1221. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1222. X        exgreenblock3_xpm, &exgreenblock[2], &exgreenblockM[2], &attributes);
  1223. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exgreen)");
  1224. X
  1225. X    /* Explosion for blue block */
  1226. X
  1227. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1228. X        exblueblock1_xpm, &exblueblock[0], &exblueblockM[0], &attributes);
  1229. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exblue)");
  1230. X
  1231. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1232. X        exblueblock2_xpm, &exblueblock[1], &exblueblockM[1], &attributes);
  1233. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exblue)");
  1234. X
  1235. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1236. X        exblueblock3_xpm, &exblueblock[2], &exblueblockM[2], &attributes);
  1237. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exblue)");
  1238. X
  1239. X    /* Explosion for tan block */
  1240. X
  1241. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1242. X        extanblock1_xpm, &extanblock[0], &extanblockM[0], &attributes);
  1243. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(extan)");
  1244. X
  1245. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1246. X        extanblock2_xpm, &extanblock[1], &extanblockM[1], &attributes);
  1247. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(extan)");
  1248. X
  1249. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1250. X        extanblock3_xpm, &extanblock[2], &extanblockM[2], &attributes);
  1251. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(extan)");
  1252. X
  1253. X    /* Explosion for purple block */
  1254. X
  1255. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1256. X        expurpleblock1_xpm, &expurpleblock[0], &expurpleblockM[0], 
  1257. X        &attributes);
  1258. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(expurple)");
  1259. X
  1260. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1261. X        expurpleblock2_xpm, &expurpleblock[1], &expurpleblockM[1], 
  1262. X        &attributes);
  1263. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(expurple)");
  1264. X
  1265. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1266. X        expurpleblock3_xpm, &expurpleblock[2], &expurpleblockM[2], 
  1267. X        &attributes);
  1268. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(expurple)");
  1269. X
  1270. X    /* Explosion for bomb block */
  1271. X
  1272. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1273. X        exbombblock1_xpm, &exbombblock[0], &exbombblockM[0], &attributes);
  1274. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exbomb)");
  1275. X
  1276. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1277. X        exbombblock2_xpm, &exbombblock[1], &exbombblockM[1], &attributes);
  1278. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exbomb)");
  1279. X
  1280. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1281. X        exbombblock3_xpm, &exbombblock[2], &exbombblockM[2], &attributes);
  1282. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exbomb)");
  1283. X
  1284. X    /* Explosion for counter block */
  1285. X
  1286. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1287. X        excounterblock1_xpm, &excounterblock[0], &excounterblockM[0], 
  1288. X        &attributes);
  1289. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(excounter)");
  1290. X
  1291. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1292. X        excounterblock2_xpm, &excounterblock[1], &excounterblockM[1], 
  1293. X        &attributes);
  1294. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(excounter)");
  1295. X
  1296. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1297. X        excounterblock3_xpm, &excounterblock[2], &excounterblockM[2], 
  1298. X        &attributes);
  1299. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(excounter)");
  1300. X
  1301. X    /* countdown for counter block */
  1302. X
  1303. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1304. X        counterblock_xpm, &counterblock[0], &counterblockM[0], 
  1305. X        &attributes);
  1306. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(counter0)");
  1307. X
  1308. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1309. X        counterblock1_xpm, &counterblock[1], &counterblockM[1], 
  1310. X        &attributes);
  1311. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(counter1)");
  1312. X
  1313. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1314. X        counterblock2_xpm, &counterblock[2], &counterblockM[2], 
  1315. X        &attributes);
  1316. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(counter2)");
  1317. X
  1318. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1319. X        counterblock3_xpm, &counterblock[3], &counterblockM[3], 
  1320. X        &attributes);
  1321. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(counter3)");
  1322. X
  1323. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1324. X        counterblock4_xpm, &counterblock[4], &counterblockM[4], 
  1325. X        &attributes);
  1326. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(counter4)");
  1327. X
  1328. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1329. X        counterblock5_xpm, &counterblock[5], &counterblockM[5], 
  1330. X        &attributes);
  1331. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(counter5)");
  1332. X
  1333. X    /* Bonus block stuff */
  1334. X
  1335. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1336. X        x2bonus1_xpm, &x2bonus[0], &x2bonusM[0], &attributes);
  1337. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(x2bonus1)");
  1338. X
  1339. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1340. X        x2bonus2_xpm, &x2bonus[1], &x2bonusM[1], &attributes);
  1341. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(x2bonus2)");
  1342. X
  1343. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1344. X        x2bonus3_xpm, &x2bonus[2], &x2bonusM[2], &attributes);
  1345. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(x2bonus3)");
  1346. X
  1347. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1348. X        x2bonus4_xpm, &x2bonus[3], &x2bonusM[3], &attributes);
  1349. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(x2bonus4)");
  1350. X
  1351. X
  1352. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1353. X        x4bonus1_xpm, &x4bonus[0], &x4bonusM[0], &attributes);
  1354. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(x4bonus1)");
  1355. X
  1356. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1357. X        x4bonus2_xpm, &x4bonus[1], &x4bonusM[1], &attributes);
  1358. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(x4bonus2)");
  1359. X
  1360. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1361. X        x4bonus3_xpm, &x4bonus[2], &x4bonusM[2], &attributes);
  1362. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(x4bonus3)");
  1363. X
  1364. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1365. X        x4bonus4_xpm, &x4bonus[3], &x4bonusM[3], &attributes);
  1366. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(x4bonus4)");
  1367. X
  1368. X
  1369. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1370. X        bonus1_xpm, &Bonus[0], &BonusM[0], &attributes);
  1371. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(bonus1)");
  1372. X
  1373. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1374. X        bonus2_xpm, &Bonus[1], &BonusM[1], &attributes);
  1375. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(bonus2)");
  1376. X
  1377. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1378. X        bonus3_xpm, &Bonus[2], &BonusM[2], &attributes);
  1379. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(bonus3)");
  1380. X
  1381. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1382. X        bonus4_xpm, &Bonus[3], &BonusM[3], &attributes);
  1383. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(bonus4)");
  1384. X
  1385. X
  1386. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1387. X        exx2bonus1_xpm, &exx2bonus[0], &exx2bonusM[0], &attributes);
  1388. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exbonus)");
  1389. X
  1390. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1391. X        exx2bonus2_xpm, &exx2bonus[1], &exx2bonusM[1], &attributes);
  1392. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exbonus)");
  1393. X
  1394. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1395. X        exx2bonus3_xpm, &exx2bonus[2], &exx2bonusM[2], &attributes);
  1396. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exbonus)");
  1397. X
  1398. X    /* Death block initialisation */
  1399. X
  1400. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1401. X        death1_xpm, &death[0], &deathM[0], &attributes);
  1402. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(death)");
  1403. X
  1404. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1405. X        death2_xpm, &death[1], &deathM[1], &attributes);
  1406. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(death)");
  1407. X
  1408. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1409. X        death3_xpm, &death[2], &deathM[2], &attributes);
  1410. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(death)");
  1411. X
  1412. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1413. X        death4_xpm, &death[3], &deathM[3], &attributes);
  1414. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(death)");
  1415. X
  1416. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1417. X        death5_xpm, &death[4], &deathM[4], &attributes);
  1418. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(death)");
  1419. X
  1420. X    /* Death block explosion init */
  1421. X
  1422. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1423. X        exdeath1_xpm, &exdeath[0], &exdeathM[0], &attributes);
  1424. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exdeath)");
  1425. X
  1426. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1427. X        exdeath2_xpm, &exdeath[1], &exdeathM[1], &attributes);
  1428. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exdeath)");
  1429. X
  1430. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1431. X        exdeath3_xpm, &exdeath[2], &exdeathM[2], &attributes);
  1432. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exdeath)");
  1433. X
  1434. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1435. X        exdeath4_xpm, &exdeath[3], &exdeathM[3], &attributes);
  1436. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(exdeath)");
  1437. X
  1438. X    /* Extra balll pixmaps */
  1439. X
  1440. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1441. X        xtraball_xpm, &extraball[0], &extraballM[0], &attributes);
  1442. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(extraball)");
  1443. X
  1444. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1445. X        xtraball2_xpm, &extraball[1], &extraballM[1], &attributes);
  1446. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(extraball)");
  1447. X
  1448. X    /* Multiple ball pixmap */
  1449. X
  1450. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1451. X        multiballblock_xpm, &multiball, &multiballM, &attributes);
  1452. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(multiball)");
  1453. X
  1454. X    /* Sticky block */
  1455. X
  1456. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1457. X        stickyblock_xpm, &sticky, &stickyM, &attributes);
  1458. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(sticky)");
  1459. X
  1460. X    /* paddle shrink and expand block */
  1461. X
  1462. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1463. X        paddleshrink_xpm, &paddleshrink, &paddleshrinkM, &attributes);
  1464. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(paddleshrink)");
  1465. X
  1466. X    XpmErrorStatus = XpmCreatePixmapFromData(display, window, 
  1467. X        paddleexpand_xpm, &paddleexpand, &paddleexpandM, &attributes);
  1468. X    HandleXPMError(display, XpmErrorStatus, "InitialiseBlocks(paddleexpand)");
  1469. X
  1470. X    /* Free the xpm pixmap attributes */
  1471. X    XpmFreeAttributes(&attributes);
  1472. X}
  1473. X
  1474. X#if NeedFunctionPrototypes
  1475. Xvoid PlaySoundForBlock(int type)
  1476. X#else
  1477. Xvoid PlaySoundForBlock(type)
  1478. X    int type;
  1479. X#endif
  1480. X{
  1481. X    /* If no sound the no sound */
  1482. X    if (noSound == True) return;
  1483. X
  1484. X    /* Play the sound effect for the block being hit */
  1485. X    switch (type)
  1486. X    {
  1487. X        case BOMB_BLK:        
  1488. X            playSoundFile("bomb", 50);
  1489. X            break;
  1490. X
  1491. X        case BULLET_BLK:
  1492. X            playSoundFile("ammo", 50);
  1493. X            break;
  1494. X
  1495. X        case RED_BLK:
  1496. X        case GREEN_BLK:        
  1497. X        case BLUE_BLK:    
  1498. X        case TAN_BLK:
  1499. X        case PURPLE_BLK:    
  1500. X        case YELLOW_BLK:
  1501. X        case COUNTER_BLK:
  1502. X        case RANDOM_BLK:
  1503. X            playSoundFile("touch", 100);
  1504. X            break;
  1505. X
  1506. X        case BONUSX2_BLK:    
  1507. X        case BONUSX4_BLK:    
  1508. X        case BONUS_BLK:    
  1509. X        case MGUN_BLK:    
  1510. X        case EXTRABALL_BLK:    
  1511. X        case WALLOFF_BLK:    
  1512. X        case REVERSE_BLK:    
  1513. X        case MULTIBALL_BLK:
  1514. X        case STICKY_BLK:
  1515. X        case PAD_SHRINK_BLK:
  1516. X        case PAD_EXPAND_BLK:
  1517. X            playSoundFile("bonus", 50);
  1518. X            break;
  1519. X
  1520. X        case DEATH_BLK:    
  1521. X            playSoundFile("evillaugh", 100);
  1522. X            break;
  1523. X
  1524. X        case BLACK_BLK:        
  1525. X            playSoundFile("touch", 50);
  1526. X            break;
  1527. X
  1528. X        case HYPERSPACE_BLK:
  1529. X            playSoundFile("hyperspace", 70);
  1530. X            break;
  1531. X
  1532. X        case KILL_BLK:
  1533. X            ErrorMessage("Error: kill block type in PlaySoundForBlock()");
  1534. X            break;
  1535. X
  1536. X        default:
  1537. X            ErrorMessage("Error: Unknown block type in PlaySoundForBlock()");
  1538. X            break;
  1539. X    }
  1540. X}
  1541. X
  1542. X#if NeedFunctionPrototypes
  1543. Xvoid ExplodeBlockType(Display *display, Window window, int x, int y, 
  1544. X    int type, int slide)
  1545. X#else
  1546. Xvoid ExplodeBlockType(display, window, x, y, type, slide)
  1547. X    Display *display;
  1548. X    Window window;
  1549. X    int x;
  1550. X    int y; 
  1551. X    int type;
  1552. X    int slide;
  1553. X#endif
  1554. X{
  1555. X    /* Draw a frame from the blocks explode animation */
  1556. X    switch (type)
  1557. X    {
  1558. X        case BOMB_BLK:        /* Draw the bomb block explosion slide */
  1559. X            RenderShape(display, window, exbombblock[slide], 
  1560. X                exbombblockM[slide], x, y, 30, 30, True);
  1561. X            break;
  1562. X
  1563. X        case MULTIBALL_BLK:
  1564. X        case RED_BLK:        /* Draw a red block explosion slide */
  1565. X            RenderShape(display, window, exredblock[slide], 
  1566. X                exredblockM[slide], x, y, 40, 20, True);
  1567. X            break;
  1568. X
  1569. X        case GREEN_BLK:        /* Draw a green block explosion slide */
  1570. X            RenderShape(display, window, exgreenblock[slide], 
  1571. X                exgreenblockM[slide], x, y, 40, 20, True);
  1572. X            break;
  1573. X
  1574. X        case BLUE_BLK:        /* Draw a blue block explosion slide */
  1575. X            RenderShape(display, window, exblueblock[slide], 
  1576. X                exblueblockM[slide], x, y, 40, 20, True);
  1577. X            break;
  1578. X
  1579. X        case TAN_BLK:        /* Draw a tan block explosion slide */
  1580. X            RenderShape(display, window, extanblock[slide], 
  1581. X                extanblockM[slide], x, y, 40, 20, True);
  1582. X            break;
  1583. X
  1584. X        case PURPLE_BLK:    /* Draw a purple block explosion slide */
  1585. X            RenderShape(display, window, expurpleblock[slide], 
  1586. X                expurpleblockM[slide], x, y, 40, 20, True);
  1587. X            break;
  1588. X
  1589. X        case BULLET_BLK:    /* Draw a bullet block explosion slide */
  1590. X        case YELLOW_BLK:    /* Draw a yellow block explosion slide */
  1591. X            RenderShape(display, window, exyellowblock[slide], 
  1592. X                exyellowblockM[slide], x, y, 40, 20, True);
  1593. X            break;
  1594. X
  1595. X        case COUNTER_BLK:    /* Draw a counter block explosion slide */
  1596. X            RenderShape(display, window, excounterblock[slide], 
  1597. X                excounterblockM[slide], x, y, 40, 20, True);
  1598. X            break;
  1599. X
  1600. X        case BONUS_BLK:        /* Draw a bonus coin block explosion slide */
  1601. X        case BONUSX4_BLK:    /* Draw a bonus x2 oin block explosion slide */
  1602. X        case BONUSX2_BLK:    /* Draw a bonus x4 coin block explosion slide */
  1603. X            RenderShape(display, window, exx2bonus[slide], 
  1604. X                exx2bonusM[slide], x, y, 27, 27, True);
  1605. X            break;
  1606. X
  1607. X        case DEATH_BLK:        /* Draw a pirate death block explosion slide */
  1608. X            RenderShape(display, window, exdeath[slide], 
  1609. X                exdeathM[slide], x, y, 30, 30, True);
  1610. X            break;
  1611. X
  1612. X        case BLACK_BLK:        /* The wall doesn't have any animation */
  1613. X        case REVERSE_BLK:    /* The reverse doesn't have any animation */
  1614. X        case HYPERSPACE_BLK:/* The hyperspace doesn't have any animation */
  1615. X        case EXTRABALL_BLK:    /* The extra ball doesn't have any animation */
  1616. X        case MGUN_BLK:        /* The machine gun doesn't have any animation */
  1617. X        case WALLOFF_BLK:    /* The wall off doesn't have any animation */
  1618. X        case STICKY_BLK:    /* No animation for sticky block either */
  1619. X        case PAD_SHRINK_BLK:
  1620. X        case PAD_EXPAND_BLK:
  1621. X            break;
  1622. X
  1623. X            break;
  1624. X
  1625. X        default:
  1626. X            ErrorMessage("Error: Unknown block type in ExplodeBlockType()");
  1627. X            break;
  1628. X    }
  1629. X}
  1630. X
  1631. X#if NeedFunctionPrototypes
  1632. Xvoid AddBonusBlock(Display *display, Window window, int *row, int *col, 
  1633. X    int type)
  1634. X#else
  1635. Xvoid AddBonusBlock(display, window, row, col, type)
  1636. X    Display *display;
  1637. X    Window window;
  1638. X    int *row;
  1639. X    int *col;
  1640. X    int type;
  1641. X#endif
  1642. X{
  1643. X    int r, c;
  1644. X    struct aBlock *blockP;
  1645. X
  1646. X    /* Give me a new random block position */
  1647. X    r = rand() % (MAX_ROW - 4);
  1648. X    c = rand() % MAX_COL;
  1649. X
  1650. X    /* Pointer to the correct block we need - speed things up */
  1651. X    blockP = &blocks[r][c];
  1652. X
  1653. X    /* Add a bonus coin in this block only if it isn't occupied and 
  1654. X     * it isn't exploding.
  1655. X     */
  1656. X    if ((blockP->occupied == False) && (blockP->explodeStartFrame == 0))
  1657. X    {
  1658. X        AddNewBlock(display, window, r, c, type, 0);
  1659. X        bonusBlock = True;
  1660. X
  1661. X        /* Setup the block structure for new block */
  1662. X        blockP->nextFrame         = frame + BONUS_DELAY;
  1663. X        blockP->lastFrame         = frame + BONUS_LENGTH;
  1664. X        blockP->bonusSlide         = 3;
  1665. X
  1666. X        /* Return the new bonus row & coloumn position */
  1667. X        *row = r; *col = c;
  1668. X    }
  1669. X}
  1670. X
  1671. X#if NeedFunctionPrototypes
  1672. Xstatic int GetRandomType(void)
  1673. X#else
  1674. Xstatic int GetRandomType()
  1675. X#endif
  1676. X{
  1677. X    /* This function will return a random new block block type */
  1678. X    switch (rand() % 7)
  1679. X    {
  1680. X        case 0:
  1681. X            return RED_BLK;
  1682. X
  1683. X        case 1:
  1684. X            return BLUE_BLK;
  1685. X
  1686. X        case 2:
  1687. X            return GREEN_BLK;
  1688. X
  1689. X        case 3:
  1690. X            return TAN_BLK;
  1691. X
  1692. X        case 4:
  1693. X            return YELLOW_BLK;
  1694. X
  1695. X        case 5:
  1696. X            return PURPLE_BLK;
  1697. X
  1698. X        case 6:
  1699. X            return BULLET_BLK;
  1700. X    }
  1701. X
  1702. X    /* Shouldn't get here but it stops warnings on compiler */
  1703. X    return YELLOW_BLK;
  1704. X}
  1705. X
  1706. X#if NeedFunctionPrototypes
  1707. Xvoid HandlePendingBonuses(Display *display, Window window, int type, 
  1708. X    int r, int c)
  1709. X#else
  1710. Xvoid HandlePendingBonuses(display, window, type, r, c)
  1711. X    Display *display;
  1712. X    Window window;
  1713. X    int type;
  1714. X    int r, c;
  1715. X#endif
  1716. X{
  1717. X    struct aBlock *blockP;
  1718. X
  1719. X    blockP = &blocks[r][c];
  1720. X
  1721. X    if (blockP->nextFrame == frame) 
  1722. X    {
  1723. X        if (frame <= blockP->lastFrame)
  1724. X        {
  1725. X            /* Advance to the next frame of animation */
  1726. X            DrawTheBlock(display, window, 
  1727. X                blockP->x, blockP->y, 
  1728. X                type, blockP->bonusSlide);
  1729. X
  1730. X                blockP->nextFrame = frame + BONUS_DELAY;
  1731. X                blockP->bonusSlide--;
  1732. X
  1733. X                if (blockP->bonusSlide < 0)
  1734. X                blockP->bonusSlide = 3;
  1735. X        }
  1736. X        else
  1737. X        {
  1738. X            /* Kill off bonus block */
  1739. X            bonusBlock = False;
  1740. X            blockP->occupied = False;
  1741. X            XClearArea(display, window, 
  1742. X                blockP->x, blockP->y,
  1743. X                blockP->width, blockP->height, 
  1744. X                False);
  1745. X        }
  1746. X    }
  1747. X}
  1748. X
  1749. X#if NeedFunctionPrototypes
  1750. Xvoid HandlePendingAnimations(Display *display, Window window)
  1751. X#else
  1752. Xvoid HandlePendingAnimations(display, window)
  1753. X    Display *display;
  1754. X    Window window;
  1755. X#endif
  1756. X{
  1757. X    int r, c;
  1758. X    struct aBlock *blockP;
  1759. X
  1760. X    /* Cycle through all rows and columns and update any animations that
  1761. X     * need to be done every frame. ie: bonus etc
  1762. X     */
  1763. X    for (r = 0; r < MAX_ROW; r++)
  1764. X    {
  1765. X        for (c = 0; c < MAX_COL; c++)
  1766. X        {
  1767. X            blockP = &blocks[r][c];
  1768. X
  1769. X            /* Only bother if the block is occupied! */
  1770. X            if (blockP->occupied == True) 
  1771. X            {
  1772. X                switch (blockP->blockType)
  1773. X                {
  1774. X                    case BONUS_BLK:    /* Bonus coin symbol */
  1775. X                        HandlePendingBonuses(display, window, BONUS_BLK, r, c);
  1776. X                        break;
  1777. X
  1778. X                    case BONUSX2_BLK:    /* Bonus x2 coin symbol */
  1779. X                        HandlePendingBonuses(display, window, BONUSX2_BLK, r,c);
  1780. X                        break;
  1781. X
  1782. X                    case BONUSX4_BLK:    /* Bonus x4 coin symbol */
  1783. X                        HandlePendingBonuses(display, window, BONUSX4_BLK, r,c);
  1784. X                        break;
  1785. X
  1786. X                    case DEATH_BLK:    /* Death block animation */
  1787. X                        if (blockP->nextFrame == frame) 
  1788. X                        {
  1789. X                            /* Advance to the next frame of animation */
  1790. X                            DrawTheBlock(display, window, 
  1791. X                                blockP->x, blockP->y, 
  1792. X                                DEATH_BLK, blockP->bonusSlide);
  1793. X
  1794. X                            blockP->nextFrame = frame + DEATH_DELAY1;
  1795. X                            blockP->bonusSlide++;
  1796. X
  1797. X                            /* Have the delay bit between winks */
  1798. X                            if (blockP->bonusSlide > 4)
  1799. X                            {
  1800. X                                blockP->bonusSlide = 0;
  1801. X                                blockP->nextFrame = frame + DEATH_DELAY2;
  1802. X                                DrawTheBlock(display, window, 
  1803. X                                    blockP->x, blockP->y, 
  1804. X                                    DEATH_BLK, blockP->bonusSlide);
  1805. X                            }
  1806. X                        }
  1807. X                        break;
  1808. X
  1809. X                    case EXTRABALL_BLK:    /* extra ball block animation */
  1810. X                        if (blockP->nextFrame == frame) 
  1811. X                        {
  1812. X                            /* Advance to the next frame of animation */
  1813. X                            DrawTheBlock(display, window, 
  1814. X                                blockP->x, blockP->y, 
  1815. X                                EXTRABALL_BLK, blockP->bonusSlide);
  1816. X
  1817. X                            blockP->nextFrame = frame + EXTRABALL_DELAY;
  1818. X                            blockP->bonusSlide++;
  1819. X
  1820. X                            /* Have the delay bit between flashes */
  1821. X                            if (blockP->bonusSlide > 1)
  1822. X                                blockP->bonusSlide = 0;
  1823. X                        }
  1824. X                        break;
  1825. X                }
  1826. X
  1827. X                /* If it is a random block then change? */
  1828. X                if (blockP->random == True)
  1829. X                {
  1830. X                    if (blockP->nextFrame == frame) 
  1831. X                    {
  1832. X                        /* Change the block to a new block block. We should
  1833. X                         * be allright in just changing the blocktype etc.
  1834. X                         * as the blocks are all the same .
  1835. X                         */
  1836. X                        blockP->blockType = GetRandomType();
  1837. X                        blockP->bonusSlide = 0;
  1838. X
  1839. X                        DrawTheBlock(display, window, 
  1840. X                            blockP->x, blockP->y, 
  1841. X                            blockP->blockType, blockP->bonusSlide);
  1842. X
  1843. X                        blockP->nextFrame = 
  1844. X                            frame + (rand() % RANDOM_DELAY) + 300;
  1845. X                    }    
  1846. X                }
  1847. X            }
  1848. X        }
  1849. X    }
  1850. X}
  1851. X
  1852. X#if NeedFunctionPrototypes
  1853. Xvoid ExplodeBlocksPending(Display *display, Window window)
  1854. X#else
  1855. Xvoid ExplodeBlocksPending(display, window)
  1856. X    Display *display;
  1857. X    Window window;
  1858. X#endif
  1859. X{
  1860. X    int r, c, x, y, type;
  1861. X    struct aBlock *blockP;
  1862. X    char str[50];
  1863. X
  1864. X    /* If none are exploding then bug out */
  1865. X    if (blocksExploding == 0) return;
  1866. X
  1867. X    /* Cycle through all blocks exploding pending animation blocks */
  1868. X    for (r = 0; r < MAX_ROW; r++)
  1869. X    {
  1870. X        for (c = 0; c < MAX_COL; c++)
  1871. X        {
  1872. X            /* Get the pointer to the block we need */
  1873. X            blockP = &blocks[r][c];
  1874. X
  1875. X            /* Will be non-zero if animation is required */
  1876. X            if (blockP->explodeStartFrame)
  1877. X            {
  1878. X                /* Is it time to explode this frame */
  1879. X                if (blockP->explodeNextFrame == frame) 
  1880. X                {
  1881. X                    x = blockP->x;
  1882. X                    y = blockP->y;
  1883. X                    type = blockP->blockType;
  1884. X
  1885. X                    /* Switch on slide of animation */
  1886. X                    switch (blockP->explodeSlide)
  1887. X                    {
  1888. X                        case 1:    /* First frame of animation */
  1889. X                            ExplodeBlockType(display, window, x, y, type, 0);
  1890. X                            blockP->explodeNextFrame =
  1891. X                                blockP->explodeStartFrame;
  1892. X                            break;
  1893. X    
  1894. X                        case 2:    /* Second frame of animation */
  1895. X                            ExplodeBlockType(display, window, x, y, type, 1);
  1896. X                            break;
  1897. X    
  1898. X                        case 3:    /* Third frame of animation */
  1899. X                            ExplodeBlockType(display, window, x, y, type, 2);
  1900. X                            break;
  1901. X    
  1902. X                        case 4:    /* Last frame of animation  - clear */
  1903. X                            XClearArea(display, window, x, y, 
  1904. X                                blockP->width, 
  1905. X                                blockP->height, False);
  1906. X                            break;
  1907. X                    }
  1908. X    
  1909. X                    /* procede to next frame in animation */
  1910. X                    blockP->explodeSlide++;
  1911. X                    blockP->explodeNextFrame += EXPLODE_DELAY;
  1912. X    
  1913. X                    /* last frame so clean up animation and block */
  1914. X                    if (blockP->explodeSlide > 4)
  1915. X                    {
  1916. X                        blocksExploding--;
  1917. X                        blockP->occupied = 0;
  1918. X                        blockP->exploding = False;
  1919. X
  1920. X                        AddToScore((u_long) blockP->hitPoints);
  1921. X                        DisplayScore(display, scoreWindow, score);
  1922. X
  1923. X                        switch (blockP->blockType)
  1924. X                        {
  1925. X                            case BLACK_BLK:
  1926. X                            case PAD_SHRINK_BLK:
  1927. X                            case PAD_EXPAND_BLK:
  1928. X                                break;
  1929. X
  1930. X                            case BOMB_BLK:
  1931. X                                /* Explode all the ones around it */
  1932. X                                SetBlockUpForExplosion(r+1, c, 
  1933. END_OF_FILE
  1934.   if test 31252 -ne `wc -c <'xaa'`; then
  1935.     echo shar: \"'xaa'\" unpacked with wrong size!
  1936.   fi
  1937.   # end of 'xaa'
  1938. fi
  1939. echo shar: End of archive 6 \(of 26\).
  1940. cp /dev/null ark6isdone
  1941. MISSING=""
  1942. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ; do
  1943.     if test ! -f ark${I}isdone ; then
  1944.     MISSING="${MISSING} ${I}"
  1945.     fi
  1946. done
  1947. if test "${MISSING}" = "" ; then
  1948.     echo You have unpacked all 26 archives.
  1949.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1950.     echo "merging split files..."
  1951.     cat blocks.c[12] > blocks.c
  1952.     rm blocks.c[12]
  1953.     echo "blocks.c done"
  1954.     cat bitmaps/earth.xpm.Z.u.[ab] > bitmaps/earth.xpm.Z.uue
  1955.     rm bitmaps/earth.xpm.Z.u.[ab]
  1956.     echo "bitmaps/earth.xpm.Z.uue done"
  1957. else
  1958.     echo You still must unpack the following archives:
  1959.     echo "        " ${MISSING}
  1960. fi
  1961. exit 0
  1962. exit 0 # Just in case...
  1963. -- 
  1964.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1965. \X/  Amiga - The only way to fly! |    sources-x@sterling.com
  1966.  "It's intuitively obvious to the |
  1967.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1968.