home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume19 / xblckbst / part03 < prev    next >
Encoding:
Text File  |  1993-04-27  |  41.4 KB  |  1,439 lines

  1. Newsgroups: comp.sources.x
  2. From: master@cats.UCSC.EDU (Mark Wedel)
  3. Subject: v19i046:  xblockbuster - a variation of the break-out type games, Part03/05
  4. Message-ID: <1993Mar17.160310.568@sparky.imd.sterling.com>
  5. X-Md4-Signature: b7c1587b7d96ac44934bcfacd4a1cbfb
  6. Date: Wed, 17 Mar 1993 16:03:10 GMT
  7. Approved: chris@sparky.imd.sterling.com
  8.  
  9. Submitted-by: master@cats.UCSC.EDU (Mark Wedel)
  10. Posting-number: Volume 19, Issue 46
  11. Archive-name: xblockbuster/part03
  12. Environment: X11R5
  13.  
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 3 (of 5)."
  22. # Contents:  CHANGES FILES Imakefile RATIONAL.SV XBlockbuster.ad
  23. #   deflection.c icons/blockbuster.icon icons/brick_j_alt.pr save.c
  24. #   score.c stage.c stagemm.c stagemm.man xblockbuster.h
  25. # Wrapped by master@sleipner on Sat Mar 13 02:21:01 1993
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'CHANGES'\"
  29. else
  30. echo shar: Extracting \"'CHANGES'\" \(1247 characters\)
  31. sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
  32. XXBlockBuster v1.00:
  33. X
  34. X Converted to run under X11 instead of SunView.
  35. X
  36. X Clippers no longer leave the remains on the screen.
  37. X
  38. X When raising the pallet with button 1, it will now register a deflection
  39. Xif the pallet moved through where the ball is.  Therefor, if a ball is
  40. Xcoming down, you can raise the pallet without the ball slipping through it.
  41. X
  42. X The hit bonus is now displayed at the top of the screen.
  43. X
  44. X Escape is now used to save instead of 'R1'.
  45. X
  46. X Each ball is now launched by clicking the right mouse button.  Previously,
  47. Xonly the first ball for each stage was started with a click, and subsequent
  48. Xlaunches on that stage were automatic.
  49. X
  50. X The ball(s) stop moving when the pointer exits the window.
  51. X
  52. X The game can be saved as long as no bricks in the stage have been destroyed.
  53. XPreviously, the game could only be saved before play started on the stage.
  54. X
  55. X Color support (via X Resources) for the bricks has been added.  Also,
  56. Xalternate brick images for color have been added.
  57. X
  58. X Removed the *.SKEL files from the distribution.  I do not think that these
  59. Xfiles were really of any use, and you could easily use the programs these
  60. Xran without the shell script interface they provided (I believe some were
  61. Xoutdated by the changes Bill Randle made.)
  62. END_OF_FILE
  63. if test 1247 -ne `wc -c <'CHANGES'`; then
  64.     echo shar: \"'CHANGES'\" unpacked with wrong size!
  65. fi
  66. # end of 'CHANGES'
  67. fi
  68. if test -f 'FILES' -a "${1}" != "-c" ; then 
  69.   echo shar: Will not clobber existing file \"'FILES'\"
  70. else
  71. echo shar: Extracting \"'FILES'\" \(1727 characters\)
  72. sed "s/^X//" >'FILES' <<'END_OF_FILE'
  73. XSKELS
  74. XSTAGES
  75. XSTAGES/save
  76. XSTAGES.try
  77. XSTAGES.try/save
  78. XSTAGES.wacko
  79. XSTAGES.wacko/save
  80. Xicons
  81. XCHANGES
  82. XFILES
  83. XImakefile
  84. XMANIFEST
  85. XMakefile.noIm
  86. XRATIONAL.SV
  87. XREADME
  88. XREADME.SV
  89. XSKELS/stage.skel
  90. XSTAGES/stage0
  91. XSTAGES/stage1
  92. XSTAGES/stage10
  93. XSTAGES/stage11
  94. XSTAGES/stage12
  95. XSTAGES/stage13
  96. XSTAGES/stage14
  97. XSTAGES/stage15
  98. XSTAGES/stage16
  99. XSTAGES/stage17
  100. XSTAGES/stage18
  101. XSTAGES/stage19
  102. XSTAGES/stage2
  103. XSTAGES/stage20
  104. XSTAGES/stage21
  105. XSTAGES/stage22
  106. XSTAGES/stage23
  107. XSTAGES/stage3
  108. XSTAGES/stage4
  109. XSTAGES/stage5
  110. XSTAGES/stage6
  111. XSTAGES/stage7
  112. XSTAGES/stage8
  113. XSTAGES/stage9
  114. XSTAGES/nb_stages
  115. XSTAGES/scores
  116. XSTAGES.try/nb_stages
  117. XSTAGES.try/scores
  118. XSTAGES.wacko/stage0
  119. XSTAGES.wacko/stage1
  120. XSTAGES.wacko/nb_stages
  121. XSTAGES.wacko/scores
  122. XXBlockbuster.ad
  123. Xballs_pallet.c
  124. Xbricks.c
  125. Xdeflection.c
  126. Xicons/ball.pr
  127. Xicons/brick_0.pr
  128. Xicons/brick_1.pr
  129. Xicons/brick_2.pr
  130. Xicons/brick_3.pr
  131. Xicons/brick_4.pr
  132. Xicons/brick_5.pr
  133. Xicons/brick_6.pr
  134. Xicons/brick_7.pr
  135. Xicons/brick_8.pr
  136. Xicons/brick_9.pr
  137. Xicons/brick_A.pr
  138. Xicons/brick_C.pr
  139. Xicons/brick_D.pr
  140. Xicons/brick_E.pr
  141. Xicons/brick_G.pr
  142. Xicons/brick_H.pr
  143. Xicons/brick_L.pr
  144. Xicons/brick_M.pr
  145. Xicons/brick_P.pr
  146. Xicons/brick_R.pr
  147. Xicons/brick_S.pr
  148. Xicons/brick_T.pr
  149. Xicons/brick_U.pr
  150. Xicons/brick_W.pr
  151. Xicons/brick_X.pr
  152. Xicons/brick_a.pr
  153. Xicons/brick_b.pr
  154. Xicons/brick_c.pr
  155. Xicons/brick_d.pr
  156. Xicons/brick_e.pr
  157. Xicons/brick_j.pr
  158. Xicons/clear.pr
  159. Xicons/clear0.pr
  160. Xicons/launchNE.pr
  161. Xicons/launchNE0.pr
  162. Xicons/launchNW.pr
  163. Xicons/launchNW0.pr
  164. Xicons/solid.pr
  165. Xicons/solid0.pr
  166. Xicons/blockbuster.icon
  167. Xicons/brick_a_alt.pr
  168. Xicons/brick_b_alt.pr
  169. Xicons/brick_S_alt.pr
  170. Xicons/brick_c_alt.pr
  171. Xicons/brick_0_alt.pr
  172. Xicons/brick_d_alt.pr
  173. Xicons/brick_e_alt.pr
  174. Xicons/brick_j_alt.pr
  175. Xicons/cursor.pr
  176. Xpatchlevel.h
  177. Xsave.c
  178. Xscore.c
  179. Xstage.c
  180. Xstagemm.c
  181. Xstagemm.man
  182. Xxblockbuster.c
  183. Xxblockbuster.h
  184. Xxblockbuster.man
  185. END_OF_FILE
  186. if test 1727 -ne `wc -c <'FILES'`; then
  187.     echo shar: \"'FILES'\" unpacked with wrong size!
  188. fi
  189. # end of 'FILES'
  190. fi
  191. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  192.   echo shar: Will not clobber existing file \"'Imakefile'\"
  193. else
  194. echo shar: Extracting \"'Imakefile'\" \(1193 characters\)
  195. sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  196. XXCOMM $XConsortium: Imakefile,v 1.9 91/07/16 23:06:01 gildea Exp $
  197. X/*     BINDIR = /usr/games/
  198. X*/
  199. X       FONT    = -DFONT=\"10x20\"
  200. X/*     MANDIR = /usr/local/man/man6
  201. X*/
  202. X      MANSUFFIX = 6
  203. X/*
  204. X       STAGEDIR = /usr/games/lib/xblockbuster
  205. X*/
  206. X#ifndef STAGEDIR
  207. X#define STAGEDIR = LIBDIR
  208. X#endif
  209. X
  210. X    DEFINES = $(FONT) -DSTAGEDIR=\"$(STAGEDIR)\"
  211. X        DEPLIBS = $(DEPXLIB)
  212. XLOCAL_LIBRARIES = $(XLIB)
  213. X          SRCS1 = balls_pallet.c bricks.c deflection.c save.c score.c stage.c \
  214. X            xblockbuster.c
  215. X          OBJS1 = balls_pallet.o bricks.o deflection.o save.o score.o stage.o \
  216. X            xblockbuster.o
  217. X      SRCS2 = stagemm.c
  218. X      OBJS2 = stagemm.o
  219. X       PROGRAMS = xblockbuster stagemm
  220. X
  221. XComplexProgramTarget_1(xblockbuster,$(LOCAL_LIBRARIES),-lm)
  222. XSingleProgramTarget(stagemm,$(OBJS2), NullParameter, NullParameter)
  223. XInstallAppDefaults(XBlockbuster)
  224. XInstallManPage(xblockbuster, $(MANDIR))
  225. XInstallManPage(stagemm, $(MANDIR))
  226. XInstallProgram(stagemm, $(BINDIR))
  227. X/*
  228. X  There must be a better way of doing this install, other than listing
  229. X  the 40 or so files and doing a InstallMultiple.
  230. X*/
  231. Xinstall::
  232. X    MakeDir($(STAGEDIR))
  233. X    cp -r STAGES* $(STAGEDIR)
  234. X    chmod 666 $(STAGEDIR)/STAGES*/scores
  235. X    chmod 777 $(STAGEDIR)/STAGES*/save
  236. X
  237. END_OF_FILE
  238. if test 1193 -ne `wc -c <'Imakefile'`; then
  239.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  240. fi
  241. # end of 'Imakefile'
  242. fi
  243. if test -f 'RATIONAL.SV' -a "${1}" != "-c" ; then 
  244.   echo shar: Will not clobber existing file \"'RATIONAL.SV'\"
  245. else
  246. echo shar: Extracting \"'RATIONAL.SV'\" \(1343 characters\)
  247. sed "s/^X//" >'RATIONAL.SV' <<'END_OF_FILE'
  248. XThis game was written as an endeavour in learning Sunview.
  249. XA similar effort may someday be made in porting it to X11.
  250. X(unless someone beats me to it!)
  251. X
  252. XThe game as distributed has been played here on Sun 3.50 and 4c.
  253. XThe set of stages is, we believe, balanced both for novice players and experts.
  254. XThey can be modified easily, but as this makes it harder to compare scores,
  255. Xyou should provide a separate play ground.
  256. X
  257. XMakeable things:
  258. X- blockbuster
  259. X    Executable for whatever host your on.
  260. X    (must be executed from within a play ground directory)
  261. X- sun3.50 & sun4
  262. X    Assures tuning parameters are uptodate w.r.t. whatever was last made.
  263. X    (no crosscompilation though, you must be on a sun3.50 or sun4
  264. X        respectively)
  265. X- stagemm
  266. X    Small bookkeeping program, useful if you want to design your own stages.
  267. X
  268. XSkeleton shellscripts:
  269. X(You may wish to adjust, rename and put these in your path.)
  270. X- blockbuster.SKEL
  271. X    Main program (architecture, and directory independent)
  272. X- smm.SKEL
  273. X    Allows you to call stagemm by name ('grep (1)') or number.
  274. X    (must be called from within a play ground directory)
  275. X- tes.SKEL
  276. X    Allows you to edit a stage (starting from a default skeleton);
  277. X    likewise called by name or number (idem).
  278. X- try.SKEL
  279. X    Allows you to try out any stage (no score);
  280. X    likewise called by name or number (idem).
  281. X
  282. X-- Eric Van Gestel (ericvg@cs.kuleuven.ac.be)
  283. END_OF_FILE
  284. if test 1343 -ne `wc -c <'RATIONAL.SV'`; then
  285.     echo shar: \"'RATIONAL.SV'\" unpacked with wrong size!
  286. fi
  287. # end of 'RATIONAL.SV'
  288. fi
  289. if test -f 'XBlockbuster.ad' -a "${1}" != "-c" ; then 
  290.   echo shar: Will not clobber existing file \"'XBlockbuster.ad'\"
  291. else
  292. echo shar: Extracting \"'XBlockbuster.ad'\" \(1166 characters\)
  293. sed "s/^X//" >'XBlockbuster.ad' <<'END_OF_FILE'
  294. XXBlockbuster.alternate_bricks:    True
  295. X*brick0_fg:    darkseagreen
  296. X*brick0_bg:    blue2
  297. X*brick1_fg:    blue2
  298. X*brick1_bg:    green2
  299. X*brick2_fg:    blue2
  300. X*brick2_bg:    green2
  301. X*brick3_fg:    blue2
  302. X*brick3_bg:    green2
  303. X*brick4_fg:    blue2
  304. X*brick4_bg:    green2
  305. X*brick5_fg:    blue2
  306. X*brick5_bg:    green2
  307. X*brick6_fg:    blue2
  308. X*brick6_bg:    green2
  309. X*brick7_fg:    blue2
  310. X*brick7_bg:    green2
  311. X*brick8_fg:    blue2
  312. X*brick8_bg:    green2
  313. X*brick9_fg:    blue2
  314. X*brick9_bg:    green2
  315. X*bricka_fg:    blue1
  316. X*bricka_bg:    gold
  317. X*brickb_fg:    blue1
  318. X*brickb_bg:    gold
  319. X*brickc_fg:    blue1
  320. X*brickc_bg:    gold
  321. X*brickd_fg:    blue1
  322. X*brickd_bg:    gold
  323. X*bricke_fg:    blue1
  324. X*bricke_bg:    gold
  325. X*brickj_fg:    blue1
  326. X*brickj_bg:    gold
  327. X*brickA_fg:    pink
  328. X*brickA_bg:    coral
  329. X*brickC_fg:    plum
  330. X*brickC_bg:    red
  331. X*brickD_fg:    orange1
  332. X*brickD_bg:    blue1
  333. X*brickE_fg:    cyan2
  334. X*brickE_bg:    coral
  335. X*brickG_fg:    red
  336. X*brickG_bg:    azure
  337. X*brickH_fg:    blue1
  338. X*brickH_bg:    aquamarine
  339. X*brickL_fg:    cyan2
  340. X*brickL_bg:    coral
  341. X*brickM_fg:    red
  342. X*brickM_bg:    wheat
  343. X*brickP_fg:    cyan2
  344. X*brickP_bg:    blue1
  345. X*brickR_fg:    wheat
  346. X*brickR_bg:    indianred
  347. X*brickS_fg:    red
  348. X*brickT_fg:    orange1
  349. X*brickT_bg:    blue1
  350. X*brickU_fg:    coral
  351. X*brickU_bg:    blue1
  352. X*brickW_fg:    dodgerblue2
  353. X*brick%_fg:    dodgerblue2
  354. X*brickX_bg:    chartreuse2
  355. X*brick^_fg:    purple
  356. END_OF_FILE
  357. if test 1166 -ne `wc -c <'XBlockbuster.ad'`; then
  358.     echo shar: \"'XBlockbuster.ad'\" unpacked with wrong size!
  359. fi
  360. # end of 'XBlockbuster.ad'
  361. fi
  362. if test -f 'deflection.c' -a "${1}" != "-c" ; then 
  363.   echo shar: Will not clobber existing file \"'deflection.c'\"
  364. else
  365. echo shar: Extracting \"'deflection.c'\" \(2964 characters\)
  366. sed "s/^X//" >'deflection.c' <<'END_OF_FILE'
  367. X/*
  368. X * File:       deflection.c
  369. X * Author:     Eric Van Gestel
  370. X *
  371. X * For:                xblockbuster
  372. X *
  373. X * No changes required for X11 support - MSW
  374. X *
  375. X * Implementation:
  376. X *     Simple horizontal and vertical deflection only changes the quadrant,
  377. X *     reversing motion along the y and x axes respectively.
  378. X *     Deflection from the convex pallet is a function of excentricity,
  379. X *     as well as of incoming angle (given a sliding of the edge effect).
  380. X */
  381. X
  382. X#include "xblockbuster.h"
  383. X
  384. Xvoid
  385. Xbrick_deflection( hit, ball )
  386. X    register int    hit;    /* enumeration { HORIZONTAL, VERTICAL } */
  387. X    register struct Ball *ball;
  388. X{
  389. X    if ( hit == HORIZONTAL ) {
  390. X        switch ( ball->quadrant ) {
  391. X        case NE:
  392. X            ball->quadrant = SE;
  393. X            break;
  394. X        case NW:
  395. X            ball->quadrant = SW;
  396. X            break;
  397. X        case SW:
  398. X            ball->quadrant = NW;
  399. X            break;
  400. X        case SE:
  401. X            ball->quadrant = NE;
  402. X        }
  403. X        ball->y_speed = -( ball->y_speed );
  404. X    } else {        /* VERTICAL */
  405. X        switch ( ball->quadrant ) {
  406. X        case NE:
  407. X            ball->quadrant = NW;
  408. X            break;
  409. X        case NW:
  410. X            ball->quadrant = NE;
  411. X            break;
  412. X        case SW:
  413. X            ball->quadrant = SE;
  414. X            break;
  415. X        case SE:
  416. X            ball->quadrant = SW;
  417. X        };
  418. X        ball->x_speed = -( ball->x_speed );
  419. X    }
  420. X}
  421. X
  422. Xvoid
  423. Xpallet_deflection( ball )
  424. X    register struct Ball *ball;
  425. X{
  426. X    double          excentricity, true_angle;
  427. X
  428. X    switch ( ball->quadrant ) {
  429. X    case SW:
  430. X        excentricity = ball->x - pallet_x;
  431. X        break;
  432. X    case SE:
  433. X        excentricity = pallet_x - ball->x;
  434. X        break;
  435. X    default:
  436. X        return;        /* bouncing up from below */
  437. X    };
  438. X    ball->angle -= 2 * atan2( excentricity, pallet_height );
  439. X
  440. X    if ( ball->angle > -M_PI_4 )
  441. X        ball->quadrant = ( ball->quadrant == SW ) ? NW
  442. X             /* SE */ : NE;
  443. X    else {            /* rebound */
  444. X        ball->angle = -M_PI_2 - ball->angle;
  445. X        ball->quadrant = ( ball->quadrant == SW ) ? NE
  446. X             /* SE */ : NW;
  447. X    };
  448. X
  449. X    /*
  450. X     * avoid downward slide offs as well as infinite horizontal bounce
  451. X     * loops
  452. X     */
  453. X    if ( ball->angle > NEAR_HORIZONTAL )
  454. X        ball->angle = NEAR_HORIZONTAL;
  455. X
  456. X    true_angle = ( ball->quadrant == NE ) ? M_PI_4 - ball->angle
  457. X         /* NW */ : M_PI_3_4 + ball->angle;
  458. X    ball->x_speed = ball->speed * cos( true_angle );
  459. X    ball->y_speed = ball->speed * -sin( true_angle );
  460. X}
  461. X
  462. X#ifdef DEBUG_PDEFL
  463. Xmain(  )
  464. X{
  465. X    pallet_xI = 0;
  466. X    pallet_x = 0;
  467. X    printf( "\npallet_length & pallet_height:  " );
  468. X    scanf( "%d%d", &pallet_lengthI, &pallet_heightI );
  469. X    pallet_length = ( double ) pallet_lengthI;
  470. X    pallet_height = ( double ) pallet_heightI;
  471. X    if ( pallet_lengthI > 0 && pallet_heightI > pallet_lengthI )
  472. X        for ( ;; ) {
  473. X            printf( "\nquadrant, in angle & excentricity:  " );
  474. X            scanf( "%d%lf%lf", &ball1.quadrant, &ball1.angle, &ball1.x );
  475. X            if ( ball1.quadrant < 1 || ball1.quadrant > 4 ||
  476. X                 ball1.angle < -45 || ball1.angle > 45 ||
  477. X            ball1.x < -pallet_length || ball1.x > pallet_length )
  478. X                break;
  479. X            ball1.angle = ( ball1.angle / 45 ) * M_PI_4;
  480. X            pallet_deflection( &ball1 );
  481. X            ball1.angle = ( ball1.angle * 45 ) / M_PI_4;
  482. X            printf( "==> quadrant: %d  angle: %f\n", ball1.quadrant, ball1.angle );
  483. X        };
  484. X}
  485. X#endif DEBUG_PDEFL
  486. END_OF_FILE
  487. if test 2964 -ne `wc -c <'deflection.c'`; then
  488.     echo shar: \"'deflection.c'\" unpacked with wrong size!
  489. fi
  490. # end of 'deflection.c'
  491. fi
  492. if test -f 'icons/blockbuster.icon' -a "${1}" != "-c" ; then 
  493.   echo shar: Will not clobber existing file \"'icons/blockbuster.icon'\"
  494. else
  495. echo shar: Extracting \"'icons/blockbuster.icon'\" \(2689 characters\)
  496. sed "s/^X//" >'icons/blockbuster.icon' <<'END_OF_FILE'
  497. X#define blockbuster_width    64
  498. X#define blockbuster_height    64
  499. Xstatic char blockbuster_bits[] = {
  500. X0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  501. X0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,
  502. X0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  503. X0xFF,0x61,0x78,0xAF,0xE1,0x1E,0x86,0xFF,0xFF,0x61,0xB8,0xD7,0xE1,0x1D,0x86,0xFF,
  504. X0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x87,0x7F,0x78,0x87,0xEB,0x1E,0xFE,0xE1,
  505. X0x87,0x7F,0xB8,0x87,0xF5,0x1D,0xFE,0xE1,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  506. X0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,
  507. X0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x87,0x69,0x1A,0xAE,0x61,0x58,0x96,0xE1,
  508. X0x87,0x65,0x19,0xD6,0x61,0x98,0xA6,0xE1,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  509. X0xD7,0x7F,0x1A,0x86,0x6B,0x58,0xFE,0xEB,0xAF,0x7F,0x19,0x86,0x75,0x98,0xFE,0xF5,
  510. X0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x87,0xE1,0x1F,0xAE,0x61,0xF8,0x87,0xE1,
  511. X0x87,0xE1,0x1F,0xD6,0x61,0xF8,0x87,0xE1,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  512. X0xD7,0x61,0xFA,0x87,0xEB,0x5F,0x86,0xEB,0xAF,0x61,0xF9,0x87,0xF5,0x9F,0x86,0xF5,
  513. X0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x87,0x61,0x1A,0xAE,0x61,0x58,0x86,0xE1,
  514. X0x87,0x61,0x19,0xD6,0x61,0x98,0x86,0xE1,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  515. X0x03,0x04,0x00,0x00,0x00,0x00,0x40,0xC0,0x03,0x0A,0x00,0x00,0x00,0x00,0xA0,0xC0,
  516. X0x03,0x11,0x00,0x00,0x00,0x00,0x10,0xC1,0x83,0x00,0x00,0x00,0x00,0x00,0x08,0xC2,
  517. X0x43,0x40,0x00,0x00,0x00,0x00,0x04,0xC4,0x23,0x00,0x00,0x00,0x00,0x00,0x02,0xC8,
  518. X0x13,0x00,0x01,0x00,0x00,0x00,0x01,0xD0,0x0B,0x00,0x00,0x00,0x00,0x80,0x00,0xE0,
  519. X0x07,0x00,0x04,0x00,0x00,0x40,0x00,0xD0,0x0B,0x00,0x00,0x00,0x00,0x20,0x00,0xC8,
  520. X0x13,0x00,0x00,0x00,0x00,0x10,0x00,0xC4,0x23,0x00,0x00,0x00,0x00,0x08,0x00,0xC2,
  521. X0x43,0x00,0x00,0x00,0x00,0x04,0x00,0xC1,0x83,0x00,0x00,0x00,0x00,0x02,0x80,0xC0,
  522. X0x03,0x01,0x00,0x00,0x00,0x01,0x40,0xC0,0x03,0x02,0x00,0x00,0x80,0x00,0x20,0xC0,
  523. X0x03,0x04,0x00,0x00,0x40,0x00,0x08,0xC0,0x03,0x08,0x00,0x00,0x20,0x00,0x1C,0xC0,
  524. X0x03,0x10,0x00,0x00,0x10,0x00,0x08,0xC0,0x03,0x20,0x00,0x00,0x08,0x00,0x00,0xC0,
  525. X0x03,0x40,0x00,0x00,0x04,0x00,0x00,0xC0,0x03,0x80,0x00,0x00,0x02,0x00,0x00,0xC0,
  526. X0x03,0x00,0x01,0x00,0x01,0x00,0x00,0xC0,0x03,0x00,0x02,0x80,0x00,0x00,0x00,0xC0,
  527. X0x03,0x00,0x04,0x40,0x00,0x00,0x00,0xC0,0x03,0x00,0x08,0x20,0x00,0x00,0x00,0xC0,
  528. X0x03,0x00,0x10,0x10,0x00,0x00,0x00,0xC0,0x03,0x00,0x20,0x08,0x00,0x00,0x00,0xC0,
  529. X0x03,0x00,0x40,0x04,0x00,0x00,0x00,0xC0,0x03,0x00,0x80,0x02,0x00,0x00,0x00,0xC0,
  530. X0x03,0x00,0x00,0x01,0x00,0x00,0x00,0xC0,0x03,0x00,0xE0,0xFF,0x01,0x00,0x00,0xC0,
  531. X0xFF,0x03,0x20,0x00,0x01,0x00,0xC0,0xFF,0xFF,0x03,0xE0,0xFF,0x01,0x00,0xC0,0xFF,
  532. X};
  533. END_OF_FILE
  534. if test 2689 -ne `wc -c <'icons/blockbuster.icon'`; then
  535.     echo shar: \"'icons/blockbuster.icon'\" unpacked with wrong size!
  536. fi
  537. # end of 'icons/blockbuster.icon'
  538. fi
  539. if test -f 'icons/brick_j_alt.pr' -a "${1}" != "-c" ; then 
  540.   echo shar: Will not clobber existing file \"'icons/brick_j_alt.pr'\"
  541. else
  542. echo shar: Extracting \"'icons/brick_j_alt.pr'\" \(896 characters\)
  543. sed "s/^X//" >'icons/brick_j_alt.pr' <<'END_OF_FILE'
  544. X#define brick_j_alt_width 64
  545. X#define brick_j_alt_height 16
  546. Xstatic char brick_j_alt_bits[] = {
  547. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff,
  548. X   0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
  549. X   0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff,
  550. X   0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x79, 0x38, 0xfc, 0xff, 0x7f,
  551. X   0xfe, 0xff, 0x7f, 0x38, 0x93, 0xf9, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x39,
  552. X   0x93, 0xf9, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x39, 0x93, 0xf9, 0xff, 0x7f,
  553. X   0xfe, 0xff, 0xff, 0x39, 0x93, 0xf9, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x39,
  554. X   0x93, 0xf9, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x79, 0x38, 0xfc, 0xff, 0x7f,
  555. X   0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff,
  556. X   0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
  557. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  558. END_OF_FILE
  559. if test 896 -ne `wc -c <'icons/brick_j_alt.pr'`; then
  560.     echo shar: \"'icons/brick_j_alt.pr'\" unpacked with wrong size!
  561. fi
  562. # end of 'icons/brick_j_alt.pr'
  563. fi
  564. if test -f 'save.c' -a "${1}" != "-c" ; then 
  565.   echo shar: Will not clobber existing file \"'save.c'\"
  566. else
  567. echo shar: Extracting \"'save.c'\" \(1617 characters\)
  568. sed "s/^X//" >'save.c' <<'END_OF_FILE'
  569. X/*
  570. X * File:       save.c
  571. X * Author:     Eric Van Gestel
  572. X *
  573. X * For:                xblockbuster
  574. X * Updated for X11 by Mark S. Wedel
  575. X *
  576. X */
  577. X
  578. X#include "xblockbuster.h"
  579. X
  580. Xvoid
  581. Xstart_up(  )
  582. X{
  583. X    FILE           *fd;
  584. X    char            sve[SAVEFILE_LENGTH];
  585. X    register int    stage_nb_tmp;
  586. X
  587. X    if ((fd = fopen( sprintf( sve, SAVEFILE, playground, login ),"r+" ))) {
  588. X        /* restoring save file */
  589. X        XDrawImageString(display, win, gc, OFFSET_BALLS,
  590. X            font_height, "Restoring...",12);
  591. X
  592. X        fscanf( fd, "%d:%d::%d:%d::%d:%lf\n",
  593. X            &score, &balls_left,
  594. X            &nb_stages, &stage_nb,
  595. X            &pallet_modif, &launch_speed );
  596. X        for ( stage_nb_tmp = 0; stage_nb_tmp < MAX_NB_STAGES; )
  597. X            fscanf( fd, "%1d", &stages[stage_nb_tmp++] );
  598. X        fclose( fd );
  599. X        /* remove save file */
  600. X        unlink( sve );
  601. X        /* restart stage chosen when saved */
  602. X        get_stage(  );
  603. X    } else {
  604. X        /* no save file */
  605. X        score = 0;
  606. X        balls_left = INIT_BALLS;
  607. X        pallet_modif = 0;
  608. X        launch_speed = INIT_SPEED;
  609. X        nb_stages = 0;
  610. X        for ( stage_nb_tmp = 0; stage_nb_tmp < MAX_NB_STAGES; )
  611. X            stages[stage_nb_tmp++] = FALSE;
  612. X        /* start some stage */
  613. X        new_stage(  );
  614. X    }
  615. X}
  616. X
  617. Xvoid
  618. Xsave(  )
  619. X{
  620. X    FILE           *fd;
  621. X    char            sve[SAVEFILE_LENGTH];
  622. X    register int    stage_nb_tmp = 0;
  623. X
  624. X    if ( !( fd = fopen( sprintf( sve, SAVEFILE, playground, login ),
  625. X                "w" ) ) ) {
  626. X        perror( "Can't open save file" );
  627. X        exit( 1 );
  628. X    }
  629. X    fprintf( fd, "%d:%d::%d:%d::%d:%f\n",
  630. X         score, balls_left,
  631. X         nb_stages, stage_nb,
  632. X         pallet_modif, launch_speed );
  633. X    for ( stage_nb_tmp = 0; stage_nb_tmp < MAX_NB_STAGES; )
  634. X        fprintf( fd, "%1d", stages[stage_nb_tmp++] );
  635. X    close( fd );
  636. X
  637. X    show_score_board(  );    /* BYE !! */
  638. X}
  639. END_OF_FILE
  640. if test 1617 -ne `wc -c <'save.c'`; then
  641.     echo shar: \"'save.c'\" unpacked with wrong size!
  642. fi
  643. # end of 'save.c'
  644. fi
  645. if test -f 'score.c' -a "${1}" != "-c" ; then 
  646.   echo shar: Will not clobber existing file \"'score.c'\"
  647. else
  648. echo shar: Extracting \"'score.c'\" \(5698 characters\)
  649. sed "s/^X//" >'score.c' <<'END_OF_FILE'
  650. X/*
  651. X * File:       score.c
  652. X * Author:     Eric Van Gestel
  653. X * Updated for X11 by Mark S. Wedel
  654. X *
  655. X * For:                xblockbuster
  656. X *
  657. X * Implementation:
  658. X *     Upto USER_SCORES scores are logged per user.
  659. X *     The insertion low point (i.e., the entry that will disappear) is defined
  660. X *     to be either the user's previous save entry, or his USER_SCORES'th entry
  661. X *     or the last entry if neither exists.
  662. X *     Sometimes saved scores may not be completed
  663. X *     (e.g, if the game crashed or if the player Quit explicitly).
  664. X *     Such entries are given a negative number of balls when detected
  665. X *     (criterium: score not bettered).
  666. X */
  667. X
  668. X#include "xblockbuster.h"
  669. X
  670. Xstruct Score {
  671. X    int             score, balls_left;
  672. X    char            login[9];
  673. X}               score_board[NB_SCORES];
  674. X
  675. Xvoid center_text(offset, message )
  676. Xint offset;
  677. Xchar *message;
  678. X{
  679. X        XDrawImageString(display, win, gc, 
  680. X            ( STAGE_WIDTH_IN_PIXELS - strlen( message ) * font_width ) / 2,
  681. X                BORDER + ( 4 + offset ) * font_height, 
  682. X                message, strlen(message));
  683. X}
  684. X
  685. X
  686. Xvoid
  687. Xshow_score_board(  )
  688. X{
  689. X    register int    lows, s, ns,scorenum=0;
  690. X    register int    update = FALSE;
  691. X    register int    made_it = FALSE;
  692. X    FILE           *fd;
  693. X    char            buf[PATH_LENGTH];
  694. X
  695. X    XClearWindow(display,win);
  696. X
  697. X    /* initalize score board (in case it would be empty) */
  698. X    for ( s = 0; s < NB_SCORES; s++ ) {
  699. X        score_board[s].score = 100;
  700. X        score_board[s].balls_left = 0;
  701. X        ( void ) strcpy( score_board[s].login, "computer" );
  702. X    }
  703. X
  704. X    /* read the score file into the array */
  705. X    if ( !( fd = fopen( sprintf( buf, SCOREFILE, playground ), "r+" ) ) ) {
  706. X        perror( "No score file" );
  707. X        exit( 1 );
  708. X    }
  709. X    for ( s = 0; s < NB_SCORES; s++ ) {
  710. X        fscanf( fd, "%d:%d:%s\n", &score_board[s].score,
  711. X            &score_board[s].balls_left,
  712. X            score_board[s].login );
  713. X    }
  714. X
  715. X    /* find insertion low point */
  716. X    for ( lows = ns = 0; lows < NB_SCORES - 1; lows++ ) {
  717. X        if ( !strcmp( score_board[lows].login, login ) ) {
  718. X            if ( score_board[lows].balls_left > 0 ) {
  719. X                if ( score_board[lows].score > score ) {
  720. X                    /*
  721. X                     * an older incomplete game: complete
  722. X                     * it
  723. X                     */
  724. X                    score_board[lows].balls_left *= -1;
  725. X                    ns++;
  726. X                    update = TRUE;
  727. X                } else
  728. X                    /* (presumably) the previous save */
  729. X                    break;
  730. X            } else
  731. X                /* an older completed game */
  732. X                ns++;
  733. X            if ( ns >= USER_SCORES )
  734. X                break;
  735. X        }
  736. X    }
  737. X
  738. X    /* find insertion high point */
  739. X    for ( s = 0; s <= lows && score_board[s].score > score; s++ );
  740. X
  741. X    /* check to see if current score made it */
  742. X    if ( s <= lows ) {
  743. X        /* yes it did , so shift smaller scores */
  744. X        for (  /* lows = lows */ ; lows > s; lows-- )
  745. X            score_board[lows] = score_board[lows - 1];
  746. X        score_board[s].score = score;
  747. X        score_board[s].balls_left = balls_left;
  748. X        ( void ) strcpy( score_board[s].login, login );
  749. X        update = TRUE;
  750. X        made_it = TRUE;
  751. X        scorenum=s;
  752. X    }
  753. X    /* write updated score board */
  754. X    if ( update ) {
  755. X        rewind( fd );
  756. X        for ( s = 0; s < NB_SCORES; s++ ) {
  757. X            fprintf( fd, "%d:%d:%s\n", score_board[s].score,
  758. X                 score_board[s].balls_left,
  759. X                 score_board[s].login );
  760. X        }
  761. X    }
  762. X    fclose( fd );
  763. X
  764. X    /* show score board */
  765. X    center_text( 0, "Top Scores" );
  766. X    for ( s = 0; s < NB_SCORES; s++ ) {
  767. X        if ( score_board[s].balls_left > 99 ) {
  768. X            center_text( s + 2, sprintf( buf, "%7d (%3d)   %8s ",
  769. X                         score_board[s].score,
  770. X                         score_board[s].balls_left,
  771. X                         score_board[s].login ) );
  772. X        } else if ( score_board[s].balls_left > 9 ) {
  773. X            center_text( s + 2, sprintf( buf, "%7d  (%2d)   %8s ",
  774. X                         score_board[s].score,
  775. X                         score_board[s].balls_left,
  776. X                         score_board[s].login ) );
  777. X        } else if ( score_board[s].balls_left > 0 ) {
  778. X            center_text( s + 2, sprintf( buf, "%7d   (%1d)   %8s ",
  779. X                         score_board[s].score,
  780. X                         score_board[s].balls_left,
  781. X                         score_board[s].login ) );
  782. X        } else if ( score_board[s].balls_left < -99 ) {
  783. X            center_text( s + 2, sprintf( buf, "%7d (%3d) + %8s ",
  784. X                         score_board[s].score,
  785. X                         -score_board[s].balls_left,
  786. X                         score_board[s].login ) );
  787. X        } else if ( score_board[s].balls_left < -9 ) {
  788. X            center_text( s + 2, sprintf( buf, "%7d  (%2d) + %8s ",
  789. X                         score_board[s].score,
  790. X                         -score_board[s].balls_left,
  791. X                         score_board[s].login ) );
  792. X        } else if ( score_board[s].balls_left < 0 ) {
  793. X            center_text( s + 2, sprintf( buf, "%7d   (%1d) + %8s ",
  794. X                         score_board[s].score,
  795. X                         -score_board[s].balls_left,
  796. X                         score_board[s].login ) );
  797. X        } else {    /* no balls left */
  798. X            center_text( s + 2, sprintf( buf, "%7d         %8s ",
  799. X                         score_board[s].score,
  800. X                         score_board[s].login ) );
  801. X        }
  802. X        if ((s==scorenum) && made_it)
  803. X            XDrawImageString(display,win,gc,
  804. X            (STAGE_WIDTH_IN_PIXELS - strlen(buf)*font_width)/2 
  805. X            -4*font_width,
  806. X            BORDER+ (6+s)*font_height, ">>> ",4);
  807. X    }
  808. X            
  809. X
  810. X
  811. X
  812. X    /* make sure the current score is on the board */
  813. X    if ( !made_it ) {
  814. X        if ( balls_left > 99 ) {
  815. X            center_text( NB_SCORES + 3, sprintf( buf, "%7d (%3d)   %8s ",
  816. X                           score, balls_left, login ) );
  817. X        } else if ( balls_left > 9 ) {
  818. X            center_text( NB_SCORES + 3, sprintf( buf, "%7d  (%2d)   %8s ",
  819. X                           score, balls_left, login ) );
  820. X        } else if ( balls_left ) {
  821. X            center_text( NB_SCORES + 3, sprintf( buf, "%7d   (%1d)   %8s ",
  822. X                           score, balls_left, login ) );
  823. X        } else {    /* no balls left */
  824. X            center_text( NB_SCORES + 3, sprintf( buf, "%7d    <>   %8s ",
  825. X                             score, login ) );
  826. X        }
  827. X    }
  828. X    /* show the current pallet shrinkage */
  829. X    center_text( NB_SCORES + 5, sprintf( buf, "pallet >>> %2d %% <<<",
  830. X                ( pallet_modif * 100 ) / PALLET_DENOMINATOR ) );
  831. X
  832. X
  833. X    XFlush(display);
  834. X
  835. X    /* provide some time to read */
  836. X    sleep( 9 );
  837. X    XCloseDisplay(display);
  838. X    exit( 0 );        /* BYE !! */
  839. X}
  840. END_OF_FILE
  841. if test 5698 -ne `wc -c <'score.c'`; then
  842.     echo shar: \"'score.c'\" unpacked with wrong size!
  843. fi
  844. # end of 'score.c'
  845. fi
  846. if test -f 'stage.c' -a "${1}" != "-c" ; then 
  847.   echo shar: Will not clobber existing file \"'stage.c'\"
  848. else
  849. echo shar: Extracting \"'stage.c'\" \(4272 characters\)
  850. sed "s/^X//" >'stage.c' <<'END_OF_FILE'
  851. X/*
  852. X * File:       stage.c
  853. X * Author:     Eric Van Gestel
  854. X * Updated for X11 by Mark S. Wedel
  855. X *
  856. X * For:                xblockbuster
  857. X */
  858. X
  859. X#include "xblockbuster.h"
  860. X
  861. Xvoid
  862. Xget_stage(  )
  863. X{
  864. X    FILE           *fd;
  865. X    char            buf[MAX_COL + 3], stg[STAGEFILE_LENGTH];
  866. X    register int    row, col, tmp;
  867. X    register char   code;
  868. X
  869. X    nbricks = 0;
  870. X    score_incr = 1;
  871. X    loop_nhits = 0;
  872. X    last_busted_brick = NULL;
  873. X
  874. X    /* open next stage file */
  875. X    if ( !( fd = fopen( sprintf( stg, STAGEFILE, playground, stage_nb ),
  876. X                "r" ) ) ) {
  877. X        perror( "Can't open stage" );
  878. X        exit( 1 );
  879. X    }
  880. X    /* clear msg, but leave the top line so the bonus remains on screen */
  881. X    XFillRectangle( display,win, gc_erase,
  882. X        font_height+5, STAGE_WIDTH_IN_PIXELS - 1, 
  883. X        MSG_HEIGHT, STAGE_WIDTH_IN_PIXELS -1);
  884. X
  885. X    /* read stage name */
  886. X    fscanf( fd, "%s\n", stage_name );
  887. X    for ( tmp = 0; stage_name[tmp]; tmp++ )
  888. X        if ( stage_name[tmp] == '_' )
  889. X            stage_name[tmp] = ' ';
  890. X    for (  /* tmp = tmp */ ; tmp < NAME_LENGTH - 1; tmp++ )
  891. X        stage_name[tmp] = ' ';
  892. X    stage_name[NAME_LENGTH - 1] = '\0';
  893. X    XDrawImageString(display, win, gc, OFFSET_SPEED, font_height*2,
  894. X        stage_name, strlen(stage_name));
  895. X
  896. X    /* read pallet dimensions */
  897. X    fscanf( fd, "%d%d\n", &pallet_lengthI, &pallet_heightI );
  898. X    if ( pallet_lengthI < SHORT_PALLET_LENGTH ||
  899. X         pallet_lengthI > LONG_PALLET_LENGTH ||
  900. X         pallet_heightI < pallet_lengthI ||
  901. X         pallet_heightI > MAX_PALLET_HEIGHT ) {
  902. X        perror( "Inconsistent pallet dimensions" );
  903. X        exit( 1 );
  904. X    }
  905. X    /* modify for difficulty level */
  906. X    pallet_lengthI -= ( pallet_modif * pallet_lengthI ) / PALLET_DENOMINATOR;
  907. X    if ( pallet_lengthI < MIN_PALLET_LENGTH )
  908. X        pallet_lengthI = MIN_PALLET_LENGTH;
  909. X    if ( pallet_lengthI > MAX_PALLET_LENGTH )
  910. X        pallet_lengthI = MAX_PALLET_LENGTH;
  911. X    if ( pallet_heightI < pallet_lengthI )
  912. X        pallet_heightI = pallet_lengthI;
  913. X    pallet_length = ( double ) pallet_lengthI;
  914. X    pallet_height = ( double ) pallet_heightI;
  915. X
  916. X    /* read stage map */
  917. X    for ( row = 0; row <= MAX_ROW; row++ ) {
  918. X        if ( !fgets( buf, MAX_COL + 3, fd ) ) {
  919. X            perror( "Can't read stage" );
  920. X            exit( 1 );
  921. X        }
  922. X        for ( col = 0; col <= MAX_COL; col++ ) {
  923. X            code = buf[col];
  924. X            if ( IS_HIT_BRICK( code ) )
  925. X                nbricks++;
  926. X            switch ( code ) {
  927. X            case '/':
  928. X                launch_quadrant = NE;
  929. X                launch_row = row;
  930. X                launch_col = col;
  931. X                launch_x = ( double ) ( COL_X( col + 1 ) );
  932. X                launch_y = ( double ) ( ROW_Y( row ) );
  933. X                break;
  934. X            case '\\':
  935. X                launch_quadrant = NW;
  936. X                launch_row = row;
  937. X                launch_col = col;
  938. X                launch_x = ( double ) ( COL_X( col ) );
  939. X                launch_y = ( double ) ( ROW_Y( row ) );
  940. X                break;
  941. X            case '^':
  942. X                emit_row = row;
  943. X                emit_col = col;
  944. X            }
  945. X            stage[row][col].code = code;
  946. X            stage[row][col].nhits = 0;
  947. X        }
  948. X    }
  949. X    fclose( fd );
  950. X    XClearWindow(display, win);
  951. X
  952. X    /* draw new stage */
  953. X    for ( row = 0; row <= MAX_ROW; row++ ) {
  954. X        draw_brick0( row, 0 );
  955. X        for ( col = 1; col < MAX_COL; col++ )
  956. X            draw_brick( row, col );
  957. X        draw_brick0( row, MAX_COL );
  958. X    }
  959. X
  960. X    /* reset pallet location */
  961. X    pallet_y = ( double ) ( pallet_yI = PALLET_MAX_Y + 4 );
  962. X    pallet_row = MAX_ROW - 1;
  963. X    draw_pallet(  );
  964. X
  965. X    /* ready ? */
  966. X    XDrawImageString(display, win, gc, OFFSET_BALLS, font_height*2,
  967. X          "Press right mouse button when ready; Escape to save.      ",60);
  968. X
  969. X}
  970. X
  971. Xvoid
  972. Xnew_stage(  )
  973. X{
  974. X    FILE           *fd;
  975. X    register int    stage_index, stage_nb_tmp;
  976. X    char        buf[STAGEFILE_LENGTH], buf2[2*STAGEFILE_LENGTH];
  977. X
  978. X    /* go faster or make the pallet smaller */
  979. X    if ( launch_speed < MAX_SPEED )
  980. X        launch_speed += SPEED_INCR;
  981. X    else
  982. X        pallet_modif += PALLET_INCR;
  983. X
  984. X    /* determine stage number */
  985. X    if ( !nb_stages ) {
  986. X        /* read number of available stages */
  987. X        if ( !( fd = fopen( sprintf( buf, NB_STAGESFILE, playground ),
  988. X                    "r" ) ) ) {
  989. X            perror( sprintf( buf2, "Can't open number of stages file <%s>",
  990. X                     buf ) );
  991. X            exit( 1 );
  992. X        }
  993. X        fscanf( fd, "%d", &nb_stages );
  994. X        fclose( fd );
  995. X        /* clear stages memory */
  996. X        for ( stage_nb_tmp = 0; stage_nb_tmp < MAX_NB_STAGES; )
  997. X            stages[stage_nb_tmp++] = FALSE;
  998. X    }
  999. X    /* search for stage index'th available stage number */
  1000. X    stage_index = ( int ) ( random(  ) ) % nb_stages--;
  1001. X    if ( stage_index < 0 )
  1002. X        stage_index = -stage_index;
  1003. X    for ( stage_nb = 0; stages[stage_nb]; )
  1004. X        stage_nb++;
  1005. X    while ( stage_index-- ) {
  1006. X        while ( stages[++stage_nb] );
  1007. X    }
  1008. X    stages[stage_nb] = TRUE;
  1009. X
  1010. X    get_stage(  );
  1011. X}
  1012. END_OF_FILE
  1013. if test 4272 -ne `wc -c <'stage.c'`; then
  1014.     echo shar: \"'stage.c'\" unpacked with wrong size!
  1015. fi
  1016. # end of 'stage.c'
  1017. fi
  1018. if test -f 'stagemm.c' -a "${1}" != "-c" ; then 
  1019.   echo shar: Will not clobber existing file \"'stagemm.c'\"
  1020. else
  1021. echo shar: Extracting \"'stagemm.c'\" \(3120 characters\)
  1022. sed "s/^X//" >'stagemm.c' <<'END_OF_FILE'
  1023. X/*
  1024. X * File:       smm.c
  1025. X * Author:     Eric Van Gestel
  1026. X *
  1027. X * Aux. For:   blockbuster
  1028. X *
  1029. X * Implementation:
  1030. X *     Calculates a minimum and approximate maximum score for the stage.
  1031. X *     If there are both 'D's or 'T's and 'U's, this tends to grow rapidly.
  1032. X */
  1033. X
  1034. X#include "xblockbuster.h"
  1035. X
  1036. Xvoid
  1037. Xmain( argc, argv )
  1038. X    int             argc;
  1039. X    char           *argv[];
  1040. X
  1041. X{
  1042. X    FILE           *fd;
  1043. X    char            buf[MAX_COL + 3];
  1044. X    register int    row, col, tmp;
  1045. X    int    codes[256];    /* indexed by char */
  1046. X
  1047. X    for ( tmp = 0; tmp < 256; )
  1048. X        codes[tmp++] = 0;
  1049. X
  1050. X    /* open stage file */
  1051. X    if ( !( fd = fopen( argv[1], "r" ) ) ) {
  1052. X        perror( "Can't open stage" );
  1053. X        exit( 1 );
  1054. X    }
  1055. X    /* read stage name */
  1056. X    fscanf( fd, "%s\n", stage_name );
  1057. X    printf( "%>>> %s:", stage_name );
  1058. X
  1059. X    /* read pallet dimensions */
  1060. X    fscanf( fd, "%d%d\n", &pallet_lengthI, &pallet_heightI );
  1061. X    if ( pallet_lengthI < MIN_PALLET_LENGTH ||
  1062. X         pallet_lengthI > MAX_PALLET_LENGTH ||
  1063. X         pallet_heightI < pallet_lengthI ||
  1064. X         pallet_heightI > MAX_PALLET_HEIGHT ) {
  1065. X        perror( "Inconsistent pallet dimensions" );
  1066. X        exit( 1 );
  1067. X    }
  1068. X    /* read stage map */
  1069. X    for ( row = 0; row <= MAX_ROW; row++ ) {
  1070. X        if ( !fgets( buf, MAX_COL + 3, fd ) ) {
  1071. X            perror( "Can't read stage" );
  1072. X            exit( 1 );
  1073. X        }
  1074. X        for ( col = 0; col <= MAX_COL; col++ )
  1075. X            codes[buf[col]]++;
  1076. X    }
  1077. X    fclose( fd );
  1078. X
  1079. X    /* minimax approximation */
  1080. X    score = codes['1']
  1081. X        + codes['2'] * 3
  1082. X        + codes['3'] * 6
  1083. X        + codes['4'] * 10
  1084. X        + codes['5'] * 15
  1085. X        + codes['6'] * 21
  1086. X        + codes['7'] * 28
  1087. X        + codes['8'] * 36
  1088. X        + codes['9'] * 45;
  1089. X    printf( " from %d", score );
  1090. X    score += codes['I'] * 2
  1091. X        + codes['a'] * 10
  1092. X        + codes['b'] * 20
  1093. X        + codes['c'] * 30
  1094. X        + codes['d'] * 40
  1095. X        + codes['e'] * 50
  1096. X        + codes['j'] * 100;
  1097. X    for ( tmp = codes['D']; tmp; tmp-- )
  1098. X        score *= 2;
  1099. X    for ( tmp = codes['T']; tmp; tmp-- )
  1100. X        score *= 3;
  1101. X    if ( codes['U'] ) {
  1102. X        if ( codes['T'] )
  1103. X            for ( tmp = codes['U']; tmp; tmp-- )
  1104. X                score *= 3;
  1105. X        else if ( codes['D'] )
  1106. X            for ( tmp = codes['U']; tmp; tmp-- )
  1107. X                score *= 2;
  1108. X        else if ( codes['j'] )
  1109. X            score += codes['U'] * 100;
  1110. X        else if ( codes['e'] )
  1111. X            score += codes['U'] * 50;
  1112. X        else if ( codes['9'] )
  1113. X            score += codes['U'] * 45;
  1114. X        else if ( codes['d'] )
  1115. X            score += codes['U'] * 40;
  1116. X        else if ( codes['8'] )
  1117. X            score += codes['U'] * 36;
  1118. X        else if ( codes['c'] )
  1119. X            score += codes['U'] * 30;
  1120. X        else if ( codes['7'] )
  1121. X            score += codes['U'] * 28;
  1122. X        else if ( codes['6'] )
  1123. X            score += codes['U'] * 21;
  1124. X        else if ( codes['b'] )
  1125. X            score += codes['U'] * 20;
  1126. X        else if ( codes['5'] )
  1127. X            score += codes['U'] * 15;
  1128. X        else if ( codes['4'] )
  1129. X            score += codes['U'] * 11;
  1130. X        else if ( codes['a'] )
  1131. X            score += codes['U'] * 10;
  1132. X        else if ( codes['3'] )
  1133. X            score += codes['U'] * 6;
  1134. X        else if ( codes['2'] )
  1135. X            score += codes['U'] * 3;
  1136. X        else if ( codes['I'] )
  1137. X            score += codes['U'];
  1138. X        else if ( codes['1'] )
  1139. X            score += codes['U'];
  1140. X    }
  1141. X    printf( " to %d", score );
  1142. X    if ( codes['0'] )
  1143. X        printf( " and more" );
  1144. X    printf( "\n" );
  1145. X
  1146. X    /* verify stage map */
  1147. X    if ( codes['/'] + codes['\\'] != 1 )
  1148. X        printf( "*** no or several launchpads\n" );
  1149. X    if ( codes['A'] && codes['^'] != 1 )
  1150. X        printf( "*** no or several emitters\n" );
  1151. X}
  1152. END_OF_FILE
  1153. if test 3120 -ne `wc -c <'stagemm.c'`; then
  1154.     echo shar: \"'stagemm.c'\" unpacked with wrong size!
  1155. fi
  1156. # end of 'stagemm.c'
  1157. fi
  1158. if test -f 'stagemm.man' -a "${1}" != "-c" ; then 
  1159.   echo shar: Will not clobber existing file \"'stagemm.man'\"
  1160. else
  1161. echo shar: Extracting \"'stagemm.man'\" \(986 characters\)
  1162. sed "s/^X//" >'stagemm.man' <<'END_OF_FILE'
  1163. X.TH STAGEMM 6 "16 November 1992"
  1164. X.br
  1165. X.SH NAME
  1166. Xstagemm \- utility program for xblockbuster game
  1167. X.SH SYNOPSIS
  1168. X.B stagemm
  1169. X.I stage
  1170. X.SH DESCRIPTION
  1171. Xstagemm determines the mininum and maximum score that can be produced
  1172. Xby playing a stage.  It also does some checking to make sure the
  1173. Xstage data includes everything necessary, and that all values are
  1174. X"sane".   This can be useful for developing new stages
  1175. Xfor xblockbuster.
  1176. X.SH OUTPUT
  1177. Xstagemm will produce output like the following:
  1178. X
  1179. X>>> Zebra: from 574 to 634
  1180. X
  1181. X The low score reflects only hitting the bricks necessary to complete
  1182. Xthe stage.  The high score includes doubler, triplers, and the
  1183. X10, 20, 30, 40, 50 and 100 point bricks.  It also factors in the 
  1184. Xeffects of undo's on bricks.
  1185. X
  1186. X In addition, results from some stages will be like:
  1187. X
  1188. X>>> Snail: from 168 to 208 and more
  1189. X
  1190. X The 'and more' means that there are invisible bricks on the stage
  1191. X.SH AUTHOR
  1192. XStagemm was written by Eric Van Gestel.  This man page was written
  1193. Xby Mark Wedel.
  1194. END_OF_FILE
  1195. if test 986 -ne `wc -c <'stagemm.man'`; then
  1196.     echo shar: \"'stagemm.man'\" unpacked with wrong size!
  1197. fi
  1198. # end of 'stagemm.man'
  1199. fi
  1200. if test -f 'xblockbuster.h' -a "${1}" != "-c" ; then 
  1201.   echo shar: Will not clobber existing file \"'xblockbuster.h'\"
  1202. else
  1203. echo shar: Extracting \"'xblockbuster.h'\" \(5321 characters\)
  1204. sed "s/^X//" >'xblockbuster.h' <<'END_OF_FILE'
  1205. X/*
  1206. X * File:       xblockbuster.h
  1207. X * Author:     Eric Van Gestel
  1208. X * X11 Support by: Mark Wedel
  1209. X * For:                xblockbuster
  1210. X *
  1211. X */
  1212. X
  1213. X/* file paths are defined at the end of this file */
  1214. X
  1215. X#include <stdio.h>
  1216. X#include <pwd.h>
  1217. X/*#include <sys/file.h>
  1218. X#include <ctype.h>*/
  1219. X#include <math.h>
  1220. X#include <X11/Xlib.h>
  1221. X#include <X11/Xutil.h>
  1222. X#include <X11/Xos.h>
  1223. X#include <X11/Xatom.h>
  1224. X
  1225. X
  1226. X/*
  1227. X * #define M_PI                3.14159265358979323846
  1228. X * #define M_PI_2      1.57079632679489661923
  1229. X * #define M_PI_4      0.78539816339744830962
  1230. X */
  1231. X#define M_PI_3_4       2.35619449019234492885
  1232. X#define M_SQRT2_2      0.70710678118654752440
  1233. X#define NEAR_HORIZONTAL        0.7    /* < M_PI_4 */
  1234. X
  1235. XDisplay        *display;
  1236. XWindow        win;
  1237. XGC        gc, gc_erase, gc_xor,gc_color;
  1238. XXFontStruct    *font_info;
  1239. Xint        screen_num, font_width, font_height;
  1240. X
  1241. X/*** windowing objects ***/
  1242. X
  1243. X#define BORDER         50
  1244. X#define MSG_HEIGHT     font_height*2 + 4
  1245. X
  1246. X#define MAX_ROW                42
  1247. X#define MAX_COL                11
  1248. X
  1249. X/* upper left corner of brick in pixels */
  1250. X#define COL_X( col )   (col) ? (col) * 64 - 48 + BORDER : BORDER
  1251. X#define ROW_Y( row )   (row) * 16 + BORDER
  1252. X
  1253. X/* brick coordinates */
  1254. X#define X_COL( x )     ( (int)(x) - BORDER + 48 ) / 64
  1255. X#define Y_ROW( y )     ( (int)(y) - BORDER ) / 16
  1256. X
  1257. X#define STAGE_HEIGHT_IN_PIXELS ( ( MAX_ROW + 1 ) * 16 + 2 * BORDER )
  1258. X#define STAGE_WIDTH_IN_PIXELS  ( ( MAX_COL - 1 ) * 64 + 2 * ( BORDER + 16 ) )
  1259. X
  1260. X
  1261. X/*** messages ***/
  1262. X
  1263. X
  1264. X#define OFFSET_BALLS   20
  1265. X#define OFFSET_SCORE   250
  1266. X#define OFFSET_SPEED   550
  1267. X
  1268. X
  1269. X/*** active objects ***/
  1270. X
  1271. X#define NO_BALL        0
  1272. X#define NE     1
  1273. X#define NW     2
  1274. X#define SW     3
  1275. X#define SE     4
  1276. X
  1277. X#ifndef FALSE
  1278. X#define FALSE  0
  1279. X#endif
  1280. X#ifndef TRUE
  1281. X#define TRUE   1
  1282. X#endif
  1283. X
  1284. X#define HORIZONTAL     1
  1285. X#define VERTICAL       2
  1286. X
  1287. X#define INIT_BALLS     3
  1288. X#define LOOP_MAX       100
  1289. X
  1290. X#define INIT_SPEED     3.0
  1291. X#define MAX_SPEED      8.0
  1292. X#define SPEED_LIMIT    12.0
  1293. X#define SPEED_INCR     0.2
  1294. X#define SPEED_INCR_2   0.1    /* SPEED_INCR / 2 */
  1295. X#define SPEED_RESOLUTION       60    /* SPEED_LIMIT / SPEED_INCR */
  1296. X#define SPEED_RESOLUTION_FACTOR        5.0    /* SPEED_RESOLUTION /
  1297. X                         * SPEED_LIMI
  1298. X                         */
  1299. X
  1300. X#define NUM_BRICK_TYPES    37
  1301. X
  1302. X/* foreground/background colors for each of the bricks - MSW */
  1303. Xstruct    COLOR {
  1304. X    unsigned long    fg, bg;
  1305. X} brick_color[NUM_BRICK_TYPES+1];
  1306. X
  1307. X/* the stage is a two
  1308. X * dimensional array of
  1309. X * bricks */
  1310. X
  1311. Xstruct Brick {
  1312. X    char            code;    /* Q.V. map_codes */
  1313. X    short           nhits;
  1314. X}               stage[MAX_ROW + 1][MAX_COL + 1];
  1315. X
  1316. X#define IS_HIT_BRICK( code )   code > '0' && code <= '9'
  1317. X
  1318. Xstruct Ball {
  1319. X    int             quadrant;    /* enumeration { NO_BALL, NE, NW, SW,
  1320. X                     * SE } */
  1321. X    double          angle;    /* range -M_PI_4..NEAR_HORIZONTAL */
  1322. X    /*
  1323. X     * NW -P4|-P4 NE +NH | +NH >>>>>>+<<<<<<  (gap to avoid infinite
  1324. X     * horizontal bounce loops) +NH | +NH SW -P4|-P4 SE
  1325. X     */
  1326. X    int             row, col;    /* coordinates on the stage */
  1327. X    double          x, y;    /* coordinates in pixels */
  1328. X    double          speed, x_speed, y_speed;    /* motion per update in
  1329. X                             * pixels */
  1330. X    /*
  1331. X     * INVARIANT: x_speed == speed * cos( true_angle ) y_speed == speed *
  1332. X     * sin( true_angle )
  1333. X     */
  1334. X}               ball1, ball2, ball3;
  1335. X
  1336. Xint             launch_quadrant;/* enumeration { NE, NW } */
  1337. Xint             launch_row, launch_col;
  1338. Xdouble          launch_x, launch_y;
  1339. Xint             emit_row, emit_col;
  1340. X
  1341. X#define MIN_PALLET_LENGTH      12
  1342. X#define SHORT_PALLET_LENGTH    16
  1343. X#define LONG_PALLET_LENGTH     99
  1344. X#define MAX_PALLET_LENGTH      99
  1345. X#define MAX_PALLET_HEIGHT      999
  1346. X#define PALLET_INCR    100
  1347. X#define PALLET_DENOMINATOR     20000
  1348. X#define PALLET_MIN_Y   ROW_Y( MAX_ROW - 9 )
  1349. X#define PALLET_MAX_Y   ROW_Y( MAX_ROW - 1 )
  1350. X
  1351. Xint             pallet_lengthI;    /* range MIN_PALLET_LENGTH..MAX_PALLET_LENGTH */
  1352. Xint             pallet_heightI;    /* range pallet_lengthI..MAX_PALLET_HEIGHT */
  1353. Xint             pallet_xI;    /* range 0..STAGE_WIDTH_IN_PIXELS */
  1354. Xint             pallet_yI;    /* range PALLET_MAX_Y+4..PALLET_MIN_Y-12 */
  1355. Xint             pallet_row;    /* range MAX_ROW-1..MAX_ROW-9 */
  1356. Xdouble          pallet_length, pallet_height, pallet_x, pallet_y;
  1357. X
  1358. X/*
  1359. X * INVARIANT:
  1360. X *     pallet_* == (double) pallet_*I;
  1361. X *     pallet_width == 2 * pallet_length
  1362. X *     pallet_height >= pallet_length >= ABS( excentricity )
  1363. X *       =>  atan2( excentricity, pallet_height ) range -M_PI_4..M_PI_4
  1364. X */
  1365. Xint             mouse_yI;    /* range 0..STAGE_HEIGHT_IN_PIXELS *//* <HC> */
  1366. X
  1367. Xint             nb_stages, stage_nb, balls_left, score, score_incr, nbricks, loop_nhits, pallet_modif;
  1368. Xdouble          launch_speed;
  1369. X
  1370. X#define NAME_LENGTH    20
  1371. Xchar            stage_name[NAME_LENGTH];
  1372. X
  1373. X#define MAX_NB_STAGES  100
  1374. Xint             stages[MAX_NB_STAGES];
  1375. X
  1376. Xstruct Brick   *last_busted_brick;    /* NULL == none so far */
  1377. Xchar            last_busted_code;
  1378. Xint             last_busted_row, last_busted_col;
  1379. X
  1380. X
  1381. X
  1382. X/*** score and stages files ***/
  1383. X
  1384. X#define PATH_LENGTH    64
  1385. X
  1386. Xchar    *login;
  1387. Xchar    playground[PATH_LENGTH];
  1388. X
  1389. X#ifndef STAGEDIR
  1390. X#define STAGEDIR    "/usr/games/lib/blockbuster"
  1391. X#endif
  1392. X
  1393. X#define SCOREFILE      "%s/scores"
  1394. X#define NB_SCORES      12
  1395. X#define USER_SCORES    3
  1396. X
  1397. X#define NB_STAGESFILE  "%s/nb_stages"
  1398. X#define STAGEFILE      "%s/stage%d"
  1399. X#define STAGEFILE_LENGTH       PATH_LENGTH
  1400. X
  1401. X#define SAVEFILE       "%s/save/%s"
  1402. X#define SAVEFILE_LENGTH        PATH_LENGTH
  1403. X
  1404. X/* Timer information */
  1405. X
  1406. X#define ITIMER_DELAY    5000
  1407. X
  1408. END_OF_FILE
  1409. if test 5321 -ne `wc -c <'xblockbuster.h'`; then
  1410.     echo shar: \"'xblockbuster.h'\" unpacked with wrong size!
  1411. fi
  1412. # end of 'xblockbuster.h'
  1413. fi
  1414. echo shar: End of archive 3 \(of 5\).
  1415. cp /dev/null ark3isdone
  1416. MISSING=""
  1417. for I in 1 2 3 4 5 ; do
  1418.     if test ! -f ark${I}isdone ; then
  1419.     MISSING="${MISSING} ${I}"
  1420.     fi
  1421. done
  1422. if test "${MISSING}" = "" ; then
  1423.     echo You have unpacked all 5 archives.
  1424.     rm -f ark[1-9]isdone
  1425. else
  1426.     echo You still need to unpack the following archives:
  1427.     echo "        " ${MISSING}
  1428. fi
  1429. ##  End of shell archive.
  1430. exit 0
  1431.  
  1432.  
  1433. exit 0 # Just in case...
  1434. -- 
  1435.   // chris@IMD.Sterling.COM            | Send comp.sources.x submissions to:
  1436. \X/  Amiga - The only way to fly!      |
  1437.  "It's intuitively obvious to the most |    sources-x@imd.sterling.com
  1438.   casual observer..."                  |
  1439.