home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume13 / xastrds2 / part01 < prev    next >
Encoding:
Internet Message Format  |  1992-04-09  |  47.4 KB

  1. Path: uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v13i080:  xasteroids2 - asteroids arcade game for X, Part01/01
  5. Message-ID: <2667@master.CNA.TEK.COM>
  6. Date: 26 Mar 92 16:57:50 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1515
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: goetz@cs.Buffalo.EDU
  12. Posting-number: Volume 13, Issue 80
  13. Archive-name: xasteroids2/Part01
  14. Environment: X11, Xlib
  15.  
  16.     [I added a simple Imakefile and generated Makefile.std and split the
  17.      doc file from the source file.  -br]
  18.  
  19. #! /bin/sh
  20. # This is a shell archive.  Remove anything before this line, then unpack
  21. # it by saving it into a file and typing "sh file".  To overwrite existing
  22. # files, type "sh file -c".  You can also feed this as standard input via
  23. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  24. # will see the following message at the end:
  25. #        "End of archive 1 (of 1)."
  26. # Contents:  README Imakefile Makefile.std ast.c ast.doc
  27. # Wrapped by billr@saab on Thu Mar 26 08:44:49 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'README' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'README'\"
  31. else
  32. echo shar: Extracting \"'README'\" \(4947 characters\)
  33. sed "s/^X//" >'README' <<'END_OF_FILE'
  34. X     Here is the source to Xasteroids, version 4.  Changes include better
  35. Xcollision detection, shields, & explosions.  Many thanks to Peter
  36. XPhillips.  If anyone wants the shorter & simpler version 3.1, write me.
  37. X
  38. X     This program runs under UNIX in the X-Windows or OpenWindows
  39. Xenvironment.  It could probably be modified for other operating systems
  40. Xwithout difficulty.  I compile it under quasi-BSD with this command:
  41. X
  42. Xcc -I/util/X11/include -L/util/X11/lib ast.c -lX11 -lm -o ast.out -O
  43. X
  44. XThat is, include files /util/X11/include, use the library in /util/X11/lib,
  45. Xsource file ast.c, use the X11 library and the math library, object file
  46. Xwill be ast.out, and Optimize.
  47. X
  48. X     Cut the stuff below into ast.docs and ast.c.  Then compile ast.c.
  49. XI know it is bad practice to put everything in one file, but I wanted to
  50. Xmake it easy to compile.
  51. X
  52. X     If you like the game, please send $5 to
  53. X
  54. X    Phil Goetz
  55. X    4023 Huckleberry Row
  56. X    Ellicott City, MD 21043
  57. X
  58. X     Even if you don't register, please send a note to my e-mail address
  59. Xso I know how many people use Xasteroids.  Then I may be motivated to
  60. Xupdate it again, or write new programs...
  61. XSend any comments, suggestions, bug reports, modifications, etc., to
  62. X
  63. X    goetz@cs.buffalo.EDU
  64. X
  65. X     Lots of people have complained that Xasteroids wouldn't run fast
  66. Xenough on their display.  I had different ideas on how to affect the speed,
  67. Xand implemented all of them.  So Version 3 came with more speed controls
  68. Xthan most people like to think about:
  69. X
  70. X     1 2: Scale of movement (default 1):  Increasing this causes each object to
  71. Xmove further every turn.
  72. XAdvantage:    Can be changed in smaller amounts than moves/frame.
  73. XDisadvantage:    Increasing it too much can cause bullets to fly through
  74. Xasteroids without hitting them.  Looks jerky.
  75. X
  76. X     v b: Moves per frame (default 1):  Increasing this causes the main loop to
  77. Xexecute more times before updating the display.
  78. XAdvantages:    Avoids the problem of bullets flying through asteroids.
  79. XDisadvantages:    Increases only by integer amounts.
  80. X
  81. X     , .: Delay:    Used when your client runs too fast to play comfortably.
  82. X
  83. X     n m: Object size:    If your client is too slow, decrease the size and resize
  84. Xthe window to a smaller size.  Then type 'x' to use XFillRectangle erase.
  85. X
  86. X     x: XFillRectangle erase:  Use XFillRectangle to erase the entire pixmap
  87. Xeach turn.  Faster on small windows.
  88. X
  89. X     u: Undraw erase:  Erase each object line-by-line.  Faster on big windows.
  90. X
  91. X     Playing with scale of movement, object size, and window size can give you
  92. Xvery different games.
  93. X
  94. X     There are 3 known bugs, which apply to all versions:
  95. X1. The window does not accept keyboard input.  I think this only happens
  96. Xunder some versions of OpenWindows.  Works under mine.
  97. X2. While the game is paused (with a 'p'), you can
  98. Xinput commands to change direction and thrust, and they will be executed.
  99. XSo this is a way of cheating.  This could be corrected, but why bother?
  100. XIf you don't like it, don't do it.
  101. X3. Once, the game lost count of numasts and refused to give me a new asteroid
  102. Xfield.  Only once.  I have no idea why.  One other person has also reported
  103. Xthis.
  104. X     Also, David Elliot (dce@sonyusa.sony.com) says that he had to put
  105. Xan XSync(disp) after the XDrawLines call or he would get protocol errors.
  106. X
  107. X     On anything slower than a SPARCstation 1, or on any color screen,
  108. Xit will really drag.  There should be a way to set color screens to use
  109. Xa bitmap of depth 1, but I don't know how.  Please tell me if you do.
  110. X     The code is not optimized because the XWindows
  111. Xcalls take the vast majority of the time.  I tried, for instance,
  112. Xreading sines and cosines from a table instead of calculating them -
  113. Xit made no noticeable difference in speed.  Similarly, the collision
  114. Xdetection could be optimized only to check objects nearby - but why
  115. Xbother.  Same goes for using registers, pointers to frequently-referenced
  116. Xarray elements, etc.  It MIGHT make a significant difference in runtime
  117. Xif you replace the vector drawing with bitmaps.  It runs a LOT slower on
  118. Xcolor displays.
  119. X     The vast majority of time seems to be used in erasing the pixmap
  120. Xeach round, & there isn't much to do about that.  My tests have indicated
  121. Xthat blanking individual asteroids rather than the whole screen would
  122. Xtake comparable time, unless you had a complicated routine to optimize
  123. Xblanking.
  124. X     If you modify this program, please send me a copy.  Modifications
  125. XI would like to see include:  sound (esp. for Sparcstations), drawing
  126. Xthe asteroids to pixmaps so they can be put on the screen quicker
  127. X(though not much quicker - the X calls seem to take most of the time),
  128. Xan options screen to set parameters such as speed, whether bullets
  129. Xcan be fired before your current ones are dead, whether to start in the
  130. Xcenter of the screen between levels), a permanent high score file
  131. Xto be displayed sometimes between games, and jagged fractal asteroids
  132. X(not just removal of the lines to the center; I like those).
  133. END_OF_FILE
  134. if test 4947 -ne `wc -c <'README'`; then
  135.     echo shar: \"'README'\" unpacked with wrong size!
  136. fi
  137. # end of 'README'
  138. fi
  139. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  140.   echo shar: Will not clobber existing file \"'Imakefile'\"
  141. else
  142. echo shar: Extracting \"'Imakefile'\" \(115 characters\)
  143. sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  144. X# simple Imakefile for xasteroids
  145. XSRCS = ast.c
  146. XOBJS = ast.o
  147. X
  148. XEXTRA_LIBRARIES = -lX11 -lm
  149. X
  150. XSimpleProgramTarget(ast)
  151. END_OF_FILE
  152. if test 115 -ne `wc -c <'Imakefile'`; then
  153.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  154. fi
  155. # end of 'Imakefile'
  156. fi
  157. if test -f 'Makefile.std' -a "${1}" != "-c" ; then 
  158.   echo shar: Will not clobber existing file \"'Makefile.std'\"
  159. else
  160. echo shar: Extracting \"'Makefile.std'\" \(10307 characters\)
  161. sed "s/^X//" >'Makefile.std' <<'END_OF_FILE'
  162. X# Makefile generated by imake - do not edit!
  163. X# $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  164. X#
  165. X# The cpp used on this machine replaces all newlines and multiple tabs and
  166. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  167. X# for this, but is not always successful.
  168. X#
  169. X
  170. X# -------------------------------------------------------------------------
  171. X# Makefile generated from "Imake.tmpl" and </tmp/IIf.a06197>
  172. X# $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  173. X#
  174. X# Platform-specific parameters may be set in the appropriate <vendor>.cf
  175. X# configuration files.  Site-specific parameters should be set in the file
  176. X# site.def.  Full rebuilds are recommended if any parameters are changed.
  177. X#
  178. X# If your C preprocessor does not define any unique symbols, you will need
  179. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  180. X# "make World" the first time).
  181. X#
  182. X
  183. X# -------------------------------------------------------------------------
  184. X# site-specific configuration parameters that need to come before
  185. X# the platform-specific parameters - edit site.def to change
  186. X
  187. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  188. X
  189. X# -------------------------------------------------------------------------
  190. X# platform-specific configuration parameters - edit sun.cf to change
  191. X
  192. X# platform:  $XConsortium: sun.cf,v 1.69 91/09/09 18:23:59 rws Exp $
  193. X
  194. X# operating system:  SunOS 4.1.1
  195. X
  196. X# $XConsortium: sunLib.rules,v 1.6 91/03/24 17:55:58 rws Exp $
  197. X
  198. X# -------------------------------------------------------------------------
  199. X# site-specific configuration parameters that go after
  200. X# the platform-specific parameters - edit site.def to change
  201. X
  202. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  203. X
  204. X            SHELL = /bin/sh
  205. X
  206. X              TOP = .
  207. X      CURRENT_DIR = .
  208. X
  209. X               AR = ar clq
  210. X  BOOTSTRAPCFLAGS =
  211. X               CC = cc
  212. X               AS = as
  213. X
  214. X         COMPRESS = compress
  215. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  216. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  217. X          INSTALL = install
  218. X               LD = ld
  219. X             LINT = lint
  220. X      LINTLIBFLAG = -C
  221. X         LINTOPTS = -axz
  222. X               LN = ln -s
  223. X             MAKE = make
  224. X               MV = mv
  225. X               CP = cp
  226. X
  227. X           RANLIB = ranlib
  228. X  RANLIBINSTFLAGS =
  229. X
  230. X               RM = rm -f
  231. X            TROFF = psroff
  232. X         MSMACROS = -ms
  233. X              TBL = tbl
  234. X              EQN = eqn
  235. X     STD_INCLUDES =
  236. X  STD_CPP_DEFINES =
  237. X      STD_DEFINES =
  238. X EXTRA_LOAD_FLAGS =
  239. X  EXTRA_LIBRARIES =
  240. X             TAGS = ctags
  241. X
  242. X    SHAREDCODEDEF = -DSHAREDCODE
  243. X         SHLIBDEF = -DSUNSHLIB
  244. X
  245. X    PROTO_DEFINES =
  246. X
  247. X     INSTPGMFLAGS =
  248. X
  249. X     INSTBINFLAGS = -m 0755
  250. X     INSTUIDFLAGS = -m 4755
  251. X     INSTLIBFLAGS = -m 0644
  252. X     INSTINCFLAGS = -m 0444
  253. X     INSTMANFLAGS = -m 0444
  254. X     INSTDATFLAGS = -m 0444
  255. X    INSTKMEMFLAGS = -m 4755
  256. X
  257. X      PROJECTROOT = /usr/X11R5
  258. X
  259. X     TOP_INCLUDES = -I$(INCROOT)
  260. X
  261. X      CDEBUGFLAGS = -O
  262. X        CCOPTIONS = -pipe
  263. X
  264. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  265. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  266. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  267. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  268. X
  269. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  270. X
  271. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
  272. X
  273. X   LDCOMBINEFLAGS = -X -r
  274. X      DEPENDFLAGS =
  275. X
  276. X        MACROFILE = sun.cf
  277. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  278. X
  279. X    IMAKE_DEFINES =
  280. X
  281. X         IRULESRC = $(CONFIGDIR)
  282. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  283. X
  284. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  285. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  286. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  287. X
  288. X# -------------------------------------------------------------------------
  289. X# X Window System Build Parameters
  290. X# $XConsortium: Project.tmpl,v 1.138 91/09/10 09:02:12 rws Exp $
  291. X
  292. X# -------------------------------------------------------------------------
  293. X# X Window System make variables; this need to be coordinated with rules
  294. X
  295. X          PATHSEP = /
  296. X        USRLIBDIR = /usr/X11R5/lib
  297. X           BINDIR = /usr/X11R5/bin
  298. X          INCROOT = /usr/X11R5/include
  299. X     BUILDINCROOT = $(TOP)
  300. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  301. X      BUILDINCTOP = ..
  302. X           INCDIR = $(INCROOT)/X11
  303. X           ADMDIR = /usr/adm
  304. X           LIBDIR = $(USRLIBDIR)/X11
  305. X        CONFIGDIR = $(LIBDIR)/config
  306. X       LINTLIBDIR = $(USRLIBDIR)/lint
  307. X
  308. X          FONTDIR = $(LIBDIR)/fonts
  309. X         XINITDIR = $(LIBDIR)/xinit
  310. X           XDMDIR = $(LIBDIR)/xdm
  311. X           TWMDIR = $(LIBDIR)/twm
  312. X          MANPATH = /usr/X11R5/man
  313. X    MANSOURCEPATH = $(MANPATH)/man
  314. X        MANSUFFIX = n
  315. X     LIBMANSUFFIX = 3
  316. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  317. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  318. X           NLSDIR = $(LIBDIR)/nls
  319. X        PEXAPIDIR = $(LIBDIR)/PEX
  320. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  321. X       FONTCFLAGS = -t
  322. X
  323. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  324. X
  325. X            IMAKE = imake
  326. X           DEPEND = makedepend
  327. X              RGB = rgb
  328. X
  329. X            FONTC = bdftopcf
  330. X
  331. X        MKFONTDIR = mkfontdir
  332. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier
  333. X
  334. X        CONFIGSRC = $(TOP)/config
  335. X       DOCUTILSRC = $(TOP)/doc/util
  336. X        CLIENTSRC = $(TOP)/clients
  337. X          DEMOSRC = $(TOP)/demos
  338. X           LIBSRC = $(TOP)/lib
  339. X          FONTSRC = $(TOP)/fonts
  340. X       INCLUDESRC = $(TOP)/X11
  341. X        SERVERSRC = $(TOP)/server
  342. X          UTILSRC = $(TOP)/util
  343. X        SCRIPTSRC = $(UTILSRC)/scripts
  344. X       EXAMPLESRC = $(TOP)/examples
  345. X       CONTRIBSRC = $(TOP)/../contrib
  346. X           DOCSRC = $(TOP)/doc
  347. X           RGBSRC = $(TOP)/rgb
  348. X        DEPENDSRC = $(UTILSRC)/makedepend
  349. X         IMAKESRC = $(CONFIGSRC)
  350. X         XAUTHSRC = $(LIBSRC)/Xau
  351. X          XLIBSRC = $(LIBSRC)/X
  352. X           XMUSRC = $(LIBSRC)/Xmu
  353. X       TOOLKITSRC = $(LIBSRC)/Xt
  354. X       AWIDGETSRC = $(LIBSRC)/Xaw
  355. X       OLDXLIBSRC = $(LIBSRC)/oldX
  356. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  357. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  358. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  359. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  360. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  361. X         FSLIBSRC = $(FONTSRC)/lib/fs
  362. X    FONTSERVERSRC = $(FONTSRC)/server
  363. X     EXTENSIONSRC = $(TOP)/extensions
  364. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  365. X      PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX
  366. X
  367. X# $XConsortium: sunLib.tmpl,v 1.11 91/07/31 11:32:08 rws Exp $
  368. X
  369. XSHLIBLDFLAGS = -assert pure-text
  370. XPICFLAGS = -pic
  371. X
  372. X  DEPEXTENSIONLIB =
  373. X     EXTENSIONLIB = -lXext
  374. X
  375. X          DEPXLIB = $(DEPEXTENSIONLIB)
  376. X             XLIB = $(EXTENSIONLIB) -lX11
  377. X
  378. X        DEPXMULIB = $(USRLIBDIR)/libXmu.sa.$(SOXMUREV)
  379. X           XMULIB = -lXmu
  380. X
  381. X       DEPOLDXLIB =
  382. X          OLDXLIB = -loldX
  383. X
  384. X      DEPXTOOLLIB = $(USRLIBDIR)/libXt.sa.$(SOXTREV)
  385. X         XTOOLLIB = -lXt
  386. X
  387. X        DEPXAWLIB = $(USRLIBDIR)/libXaw.sa.$(SOXAWREV)
  388. X           XAWLIB = -lXaw
  389. X
  390. X        DEPXILIB =
  391. X           XILIB = -lXi
  392. X
  393. X        SOXLIBREV = 4.10
  394. X          SOXTREV = 4.10
  395. X         SOXAWREV = 5.0
  396. X        SOOLDXREV = 4.10
  397. X         SOXMUREV = 4.10
  398. X        SOXEXTREV = 4.10
  399. X      SOXINPUTREV = 4.10
  400. X
  401. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  402. X         XAUTHLIB =  -lXau
  403. X      DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
  404. X         XDMCPLIB =  -lXdmcp
  405. X
  406. X        DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
  407. X           PHIGSLIB =  -lphigs
  408. X
  409. X       DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
  410. X          XBSDLIB =  -lXbsd
  411. X
  412. X LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln
  413. X         LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln
  414. X          LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
  415. X        LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln
  416. X          LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
  417. X           LINTXI = $(LINTLIBDIR)/llib-lXi.ln
  418. X        LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
  419. X
  420. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  421. X
  422. X         DEPLIBS1 = $(DEPLIBS)
  423. X         DEPLIBS2 = $(DEPLIBS)
  424. X         DEPLIBS3 = $(DEPLIBS)
  425. X
  426. X# -------------------------------------------------------------------------
  427. X# Imake rules for building libraries, programs, scripts, and data files
  428. X# rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  429. X
  430. X# -------------------------------------------------------------------------
  431. X# start of Imakefile
  432. X
  433. X# simple Imakefile for xasteroids
  434. XSRCS = ast.c
  435. XOBJS = ast.o
  436. X
  437. XEXTRA_LIBRARIES = -lX11 -lm
  438. X
  439. X OBJS = ast.o
  440. X SRCS = ast.c
  441. X
  442. X PROGRAM = ast
  443. X
  444. Xall:: ast
  445. X
  446. Xast: $(OBJS) $(DEPLIBS)
  447. X    $(RM) $@
  448. X    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
  449. X
  450. Xsaber_ast:: $(SRCS)
  451. X    # load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  452. X
  453. Xosaber_ast:: $(OBJS)
  454. X    # load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  455. X
  456. Xinstall:: ast
  457. X    @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \
  458. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi
  459. X    $(INSTALL) -c $(INSTPGMFLAGS)  ast $(DESTDIR)$(BINDIR)
  460. X
  461. Xinstall.man:: ast.man
  462. X    @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \
  463. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi
  464. X    $(INSTALL) -c $(INSTMANFLAGS) ast.man $(DESTDIR)$(MANDIR)/ast.$(MANSUFFIX)
  465. X
  466. Xdepend::
  467. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  468. X
  469. Xlint:
  470. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  471. Xlint1:
  472. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  473. X
  474. Xclean::
  475. X    $(RM) $(PROGRAM)
  476. X
  477. X# -------------------------------------------------------------------------
  478. X# common rules for all Makefiles - do not edit
  479. X
  480. Xemptyrule::
  481. X
  482. Xclean::
  483. X    $(RM_CMD) "#"*
  484. X
  485. XMakefile::
  486. X    -@if [ -f Makefile ]; then set -x; \
  487. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  488. X    else exit 0; fi
  489. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  490. X
  491. Xtags::
  492. X    $(TAGS) -w *.[ch]
  493. X    $(TAGS) -xw *.[ch] > TAGS
  494. X
  495. Xsaber:
  496. X    # load $(ALLDEFINES) $(SRCS)
  497. X
  498. Xosaber:
  499. X    # load $(ALLDEFINES) $(OBJS)
  500. X
  501. X# -------------------------------------------------------------------------
  502. X# empty rules for directories that do not have SUBDIRS - do not edit
  503. X
  504. Xinstall::
  505. X    @echo "install in $(CURRENT_DIR) done"
  506. X
  507. Xinstall.man::
  508. X    @echo "install.man in $(CURRENT_DIR) done"
  509. X
  510. XMakefiles::
  511. X
  512. Xincludes::
  513. X
  514. X# -------------------------------------------------------------------------
  515. X# dependencies generated by makedepend
  516. X
  517. END_OF_FILE
  518. if test 10307 -ne `wc -c <'Makefile.std'`; then
  519.     echo shar: \"'Makefile.std'\" unpacked with wrong size!
  520. fi
  521. # end of 'Makefile.std'
  522. fi
  523. if test -f 'ast.c' -a "${1}" != "-c" ; then 
  524.   echo shar: Will not clobber existing file \"'ast.c'\"
  525. else
  526. echo shar: Extracting \"'ast.c'\" \(27201 characters\)
  527. sed "s/^X//" >'ast.c' <<'END_OF_FILE'
  528. X/*    Xasteroids
  529. X    Copyright 1990 by Phil Goetz
  530. X    goetz@cs.buffalo.EDU
  531. X    Version 4, 2/19/92
  532. X
  533. X    Changes from version 3.1:
  534. X
  535. X        Better collision detection:  Actually checks for intersection
  536. X            of line segments if non-round objects are very close.
  537. X        Explosions!  (Thanks to Peter Phillips.)
  538. X        Fine rotation repeating detected using KeyRelease.
  539. X        Thrust indicator behind ship.  (Thanks to Peter Phillips.)
  540. X        Doesn't place ship in center of screen for new levels.
  541. X            (Thanks to Peter Phillips.)
  542. X        Seeds random-number generator with time.
  543. X            (Thanks to Craig Smith.)
  544. X        Shields!  (Thanks to Peter Phillips.  I rewrote the bounce code
  545. X            & added the energy bar & other refinements.)
  546. X        Detects failure of XOpenDisplay. (Thanks to Pat Ryan.)
  547. X
  548. X    Contributors:    Peter Phillips <pphillip@cs.ubc.ca>
  549. X            Pat Ryan <pat@jaameri.gsfc.nasa.gov>
  550. X            Craig Smith <csmith@cscs.UUCP>
  551. X*/
  552. X#include <stdio.h>        /* For NULL    */
  553. X#include <X11/Xlib.h>
  554. X#include <X11/Xutil.h>
  555. X#include <X11/cursorfont.h>    /* For erasing cursor - not important    */
  556. X#include <math.h>
  557. X
  558. X/* Indexes for 1st dimension of obj    */
  559. X/* The order they are in is important    */
  560. X#define    AST    0
  561. X#define    ENEMY    96
  562. X#define ENEMYBUL 97
  563. X#define    FBUL    98
  564. X#define    LASTBUL    102
  565. X#define    SHIP    103
  566. X#define LASTOBJ 103    /* Must be ship!  See makeasts().    */
  567. X
  568. X/* Shapes    */
  569. X/* Order is important!  See collide().    */
  570. X#define    ASTSHAPE1    0
  571. X#define ASTSHAPE2    1
  572. X#define ASTSHAPE3    2
  573. X#define ENBULSH        3
  574. X#define    BULSHAPE    4
  575. X#define    SHIPSHAPE    5
  576. X#define SHIPTHRSHAPE    6
  577. X#define    ENEMYSHAPE    7
  578. X#define LASTSHAPE    7
  579. X
  580. X/* Masses    */
  581. X#define M_BIG    8.0
  582. X#define M_MED    4.0
  583. X#define M_SMALL    1.0
  584. X#define M_SHIP    1.5
  585. X#define M_ENEMY    1.0
  586. X#define M_BULLET 0.1
  587. X
  588. X/* Keys        */
  589. X#define FIRE        'p'
  590. X#define PAUSE        27    /* escape    */
  591. X#define SHIELD        '`'
  592. X#define THRUST        'o'
  593. X
  594. X#define BMAX        300    /* Max particles in a "boom" + 1    */
  595. X#define letheight    20    /* height of font    */
  596. X#define    pi        3.1415926535897932384
  597. X#define SHIPSIZE    28
  598. X
  599. Xtypedef struct _Boom *Boom;
  600. Xstruct _Boom {Boom next; int dur, part; double bcoord[BMAX][2], bvec[BMAX][2]};
  601. Xtypedef struct {int shape, alive, time;
  602. X        double mass, x, y, xvel, yvel, rot, rotvel} Objtype;
  603. Xtypedef struct {double angle; int length} PolarPair;
  604. Xtypedef struct {double x, y, mag} Vector;
  605. X
  606. X/* Global variables:    */
  607. XObjtype    obj[SHIP+1];
  608. X/*    In shapes pairs, 1st # is radians, 2nd is length in pixels.
  609. X    Degrees: 0 ->, pi/2 down, pi <-, 3*pi/2 up
  610. X    IF YOU CHANGE THE SHAPES, you MUST change numpairs & shapesize
  611. X*/
  612. XPolarPair shapes[LASTSHAPE+1][11] =
  613. X    {    {{0,0}, {3*pi/2,40}, {0,20}, {pi/4,28}, {pi/2,40}, /* just crossed 0-deg line */
  614. X         {3*pi/4,28},{pi,40},{5*pi/4,28},{3*pi/2,40},{7*pi/4,28},{0,20}},
  615. X/*    hexagon if you prefer
  616. X        {{0,0}, {3*pi/2, 20}, {pi/6, 20}, {pi/2, 20},
  617. X                 {5*pi/6, 20}, {7*pi/6, 20}, {3*pi/2, 20}, {11*pi/6, 20}},
  618. X*/
  619. X        {{0,0}, {3*pi/2,20}, {0,10}, {pi/4,14}, {pi/2,20},
  620. X         {3*pi/4,14},{pi,20},{5*pi/4,14},{3*pi/2,20},{7*pi/4,14},{0,10}},
  621. X        {{0,0}, {3*pi/2,10}, {0,5}, {pi/4,7}, {pi/2,10},
  622. X         {3*pi/4,7},{pi,10},{5*pi/4,7},{3*pi/2,10},{7*pi/4,7},{0,5}},
  623. X        {{0,0}, {7*pi/4, 4}, {pi/4, 4}, {3*pi/4, 4}, {5*pi/4, 4}},
  624. X        {{0,0}, {0,10}},
  625. X        {{0,0}, {5*pi/4,28}, {0,20}, {pi/4,28},{3*pi/4,28},{pi,20},{7*pi/4,28}},    /* Ship */
  626. X        {{0,0}, {5*pi/4,28}, {0,20}, {pi/4,28},{3*pi/4,28},{pi,20},
  627. X         {7*pi/4,28}, {3*pi/4, 7}, {9*pi/8, 13}, {15*pi/8, 13}},    /* Thrusting ship */
  628. X        {{0,0}, {pi,20},{7*pi/4,28},{pi/4,28},{pi,20}}
  629. X    };
  630. XBoom    blist = NULL;
  631. Xdouble    drawscale = 1, speedscale = 1;
  632. Xint    width, height,
  633. X    energy,        /* # of turns shield is good for    */
  634. X    highscore = 0,
  635. X    nextbul = FBUL,            /* Obj# of next bullet fired    */
  636. X    numasts, oldscore = 99,
  637. X    rndint = 73, ships, score,
  638. X    numpairs[LASTSHAPE+1]    = {11, 11, 11, 5, 2, 7, 10, 5},
  639. X    shapesize[LASTSHAPE+1]    = {44, 21, 10, 2, 1, SHIPSIZE+1, 35, 20},
  640. X    shield_on;
  641. X
  642. Xinitasts()
  643. X{    int i;
  644. X    extern Objtype obj[SHIP+1];
  645. X
  646. X    for (i = 0; i < LASTOBJ+1; i++)
  647. X    {    obj[i].rot = 0;
  648. X        obj[i].rotvel = 0;
  649. X    }
  650. X    for (i = 0; i < ENEMY; i++)
  651. X    {    obj[i].shape = ASTSHAPE1;
  652. X    }
  653. X    obj[SHIP].shape = SHIPSHAPE;
  654. X    obj[SHIP].mass = M_SHIP;
  655. X    obj[ENEMY].shape = ENEMYSHAPE;
  656. X    obj[ENEMY].mass = M_ENEMY;
  657. X    obj[ENEMYBUL].shape = ENBULSH;
  658. X    obj[ENEMYBUL].mass = M_BULLET;
  659. X    for (i = FBUL; i < LASTBUL+1; i++)
  660. X    {    obj[i].shape = BULSHAPE;
  661. X        obj[i].mass = M_BULLET;
  662. X}    }
  663. X
  664. Xmakeasts(level)
  665. X{    int i;
  666. X    extern Objtype obj[SHIP+1];
  667. X    extern int numasts, rndint;
  668. X    extern double speedscale;
  669. X    unsigned char a;
  670. X
  671. X    for (i = 0; i < SHIP; i++)
  672. X        obj[i].alive = 0; /* Erase objs from last level except ship */
  673. X    for (i = ENEMYBUL; i < LASTBUL+1; i++)
  674. X        obj[i].time = 0;        /* No bullets in the air */
  675. X    for (i = 0; i < level+4; i++)    /* Asteroids:            */
  676. X    {    a = rand(rndint); a>>=1;    /* a = rand# from 0 to 127 */
  677. X        if (a > 63)
  678. X            obj[i].x = (double) a;
  679. X            else obj[i].x = (double) (width - a);
  680. X        a = rand(rndint); a>>=1;    /* Now the same for y    */
  681. X        if (a >  63)
  682. X            obj[i].y = (double) a;
  683. X            else obj[i].y = (double) height - a;
  684. X        a = rand(rndint); a = 4 - a>>5;
  685. X        obj[i].rot = (double) a;
  686. X        a = rand(rndint);
  687. X        obj[i].rotvel = ((double) a)/2048;
  688. X        a = rand(rndint);
  689. X        obj[i].xvel = cos((double) a);
  690. X        obj[i].yvel = sin((double) a);
  691. X        obj[i].shape = ASTSHAPE1;
  692. X        obj[i].mass = M_BIG;
  693. X        obj[i].alive = 1;
  694. X    }
  695. X    numasts = i;
  696. X}
  697. X
  698. Xmakeenemy(level)    /* Start an enemy ship    */
  699. X    int level;
  700. X{    extern Objtype obj[SHIP+1];
  701. X    extern int height, rndint;
  702. X    unsigned char c;
  703. X
  704. X    obj[ENEMY].alive = 1;
  705. X    obj[ENEMY].x = 0;
  706. X    obj[ENEMY].y = (double) height/4;
  707. X    c = rand(rndint); obj[ENEMY].y += (double) c; /* May put enemy outside window    */
  708. X    obj[ENEMY].xvel = (double) level/2;
  709. X    obj[ENEMY].yvel = 0;
  710. X}
  711. X
  712. Xint nextast()    /* Find next unused asteroid object    */
  713. X{    extern Objtype obj[SHIP+1];
  714. X    int i;
  715. X    for (i = 0; obj[i].alive; i++);    /* guaranteed to find one    */
  716. X    return i;
  717. X}
  718. X
  719. Xint collide(i, j)    /* Returns non-zero if i collided with j    */
  720. X            /* Ship must be j!  (See below)            */
  721. X    int i, j;
  722. X{    extern Objtype obj[SHIP+1];
  723. X    extern int shapesize[LASTSHAPE+1];
  724. X    extern double drawscale;
  725. X    double    mi, mj,                /* Slopes of lines    */
  726. X        ix1, ix2, iy1, iy2, jx1, jx2, jy1, jy2,    /* Endpoints    */
  727. X        roti, rotj,
  728. X        xcross,    ycross,        /* coord of intersection    */
  729. X        z;
  730. X    int    diff, xd, yd,
  731. X        a, b,
  732. X        shapei, shapej;
  733. X    xd = obj[i].x - obj[j].x;
  734. X    yd = obj[i].y - obj[j].y;
  735. X    diff = sqrt((double)(xd*xd + yd*yd));
  736. X    shapei = obj[i].shape; shapej = obj[j].shape;
  737. X    /* Note this will miss if drawscale is < 0    */
  738. X    if (diff < (shapesize[shapei] + shapesize[shapej])*drawscale)
  739. X    {   /* If both are round objects, approximation is good */
  740. X        if (shapei < SHIPSHAPE && shapej < SHIPSHAPE) return 1;
  741. X        if (j == SHIP && shield_on) return 1;    /* Ship always j! */
  742. X        roti = obj[i].rot; rotj = obj[j].rot;
  743. X        ix1 = (double) obj[i].x; iy1 = (double) obj[i].y;
  744. X        for (a = 1; a < numpairs[shapei]; a++)
  745. X        {    ix2 = ix1 + (double) shapes[shapei][a].length * drawscale *
  746. X            cos(shapes[shapei][a].angle + roti);
  747. X        iy2 = iy1 + (double) shapes[shapei][a].length * drawscale *
  748. X            sin(shapes[shapei][a].angle + roti);
  749. X        if (ix1 == ix2)
  750. X        {    printf("\nif1 = if2"); return 1;} /* Easy way out */
  751. X        mi = (iy2-iy1)/(ix2-ix1);
  752. X        z = mi*ix1;
  753. X        jx1 = (double) obj[j].x; jy1 = (double) obj[j].y;
  754. X        for (b = 1; b < numpairs[shapej]; b++)
  755. X        {    jx2 = jx1 + (double) shapes[shapej][b].length *
  756. X                drawscale * cos(shapes[shapej][b].angle + rotj);
  757. X            jy2 = jy1 + (double) shapes[shapej][b].length *
  758. X                drawscale * sin(shapes[shapej][b].angle + rotj);
  759. X            if (jx1 == jx2)
  760. X            {    ycross = ix1 + (jx1-ix1)*mi;
  761. X                if ((jx1-ix1) * (ix2-jx1) >= 0 &&
  762. X                    (ycross-jy1)*(jy2-ycross) >= 0)
  763. X                    return 1;
  764. X            }
  765. X            mj = (jy2-jy1)/(jx2-jx1);
  766. X            if (mj == mi) continue;    /* Parallel lines */
  767. X            xcross = (iy1 - jy1 + mj*jx1 - z) / (mj - mi);
  768. X            if ((xcross-ix1) * (ix2-xcross) > 0
  769. X                && (xcross-jx1) * (jx2-xcross) > 0) return 1;
  770. X            jx1 = jx2; jy1 = jy2;
  771. X        }
  772. X        ix1 = ix2; iy1 = iy2;
  773. X    }   }
  774. X    return 0;
  775. X}
  776. X
  777. Xblastpair(i, j)        /* Generate random velocity vector v.    */
  778. X    int i, j ;    /* Add v to i, -v to j.            */
  779. X{    extern int rndint;
  780. X    extern Objtype obj[SHIP+1];
  781. X    unsigned char c;    /* for rand    */
  782. X    double vx, vy;
  783. X    c = rand(rndint);
  784. X/*    c = 4 - c>>5;    if you need angles from -3 to 4        */
  785. X    c>>2;        /* possibly save some time on sin/cos    */
  786. X    vx = cos((double) c); vy = sin((double) c);
  787. X    obj[i].xvel = obj[i].xvel + vx;
  788. X    obj[i].yvel = obj[i].yvel + vy;
  789. X    obj[j].xvel = obj[j].xvel - vx;
  790. X    obj[j].yvel = obj[j].yvel - vy;
  791. X    obj[i].rotvel = obj[i].rotvel + .05;
  792. X    obj[j].rotvel = obj[j].rotvel - .05;
  793. X}
  794. X
  795. X/* dot product of 2 vectors    */
  796. X#define dot(i,j)    (i.x*j.x + i.y*j.y)
  797. X/* rotational inertia (constant eliminated) of obj. i    */
  798. X#define rotinert(i)    (double) (obj[i].mass*shapesize[obj[i].shape]*shapesize[obj[i].shape])
  799. X
  800. X/* cause two objects to collide elastically    */
  801. Xbounce(i, j)
  802. Xint    i,j;
  803. X{
  804. Xdouble    rotrat, temp;
  805. Xextern    Objtype obj[SHIP+1];
  806. XVector    vi, vj,        /* velocity of objs i, j        */
  807. X    ij,        /* vector from center of i to center of j */
  808. X    vi_ij, vj_ij,    /* velocity of obj along vector ij    */
  809. X    vipij, vjpij,    /* velocity perpendicular to ij        */
  810. X    vi_ijf, vj_ijf;    /* post-collision velocity along ij    */
  811. X
  812. Xvi.x = obj[i].xvel; vi.y = obj[i].yvel;
  813. Xvj.x = obj[j].xvel; vj.y = obj[j].yvel;
  814. Xij.x = obj[j].x - obj[i].x; ij.y = obj[j].y - obj[i].y;
  815. Xij.mag = sqrt(ij.x*ij.x + ij.y*ij.y);
  816. X/*
  817. XCalculate velocities projected onto ij;
  818. X    vi_ij = vi*cos(a) = (vi dot ij) / |ij|        */
  819. Xvi_ij.mag = dot(vi, ij) / ij.mag;
  820. Xvi_ij.x = (ij.x * vi_ij.mag) / ij.mag;
  821. Xvi_ij.y = (ij.y * vi_ij.mag) / ij.mag;
  822. Xvj_ij.mag = dot(vj, ij) / ij.mag;
  823. Xvj_ij.x = (ij.x * vj_ij.mag) / ij.mag;
  824. Xvj_ij.y = (ij.y * vj_ij.mag) / ij.mag;
  825. Xif (vi_ij.mag - vj_ij.mag < 0)    /* Objs moving away from each other -
  826. X    Since objs are round (at least when bouncing), this means
  827. X    they are moving away from each other already.    */
  828. X    return;
  829. X/*
  830. XCalculate component of velocities perpendicular to ij:
  831. X    |vipij| = |vi|*sin(a) = |vi x ij| / |ij|
  832. XSame as
  833. X    |vipij| = |vi|*cos(pi/2 - a) = (vi dot (perp. to ij)) / |ij|    */
  834. Xtemp = vi.y*ij.x - vi.x*ij.y;    /* - (cross product when 3rd coord is 0)*/
  835. Xtemp /= (ij.mag*ij.mag);
  836. Xvipij.x = -ij.y*temp; vipij.y = ij.x*temp;
  837. Xtemp = (vj.x*ij.y - vj.y*ij.x) / (ij.mag*ij.mag);
  838. Xvjpij.x = -ij.y*temp; vjpij.y = ij.x*temp;
  839. X/*
  840. XCalculate the linear elastic collision along ij:
  841. X    mass(i)*vi_ij + mass(j)*vj_ij = mass(i)*vi_ijf + mass(j)*vj_ijf
  842. X    vi_ij + vi_ijf = vj_ij + vj_ijf    (derived by dividing equation
  843. X    for conservation of kinetic energy by eq. for cons. of momentum) */
  844. Xtemp = obj[i].mass/obj[j].mass;
  845. Xvj_ijf.x = (temp * (2*vi_ij.x - vj_ij.x) + vj_ij.x) / (1 + temp);
  846. Xvj_ijf.y = (temp * (2*vi_ij.y - vj_ij.y) + vj_ij.y) / (1 + temp);
  847. Xvi_ijf.x = vj_ijf.x + vj_ij.x - vi_ij.x;
  848. Xvi_ijf.y = vj_ijf.y + vj_ij.y - vi_ij.y;
  849. X/*
  850. XNow, given vi_ijf and vj_ijf, add them to the perpendicular
  851. X    components to get final velocity vectors        */
  852. Xobj[i].xvel = vi_ijf.x + vipij.x;
  853. Xobj[i].yvel = vi_ijf.y + vipij.y;
  854. Xobj[j].xvel = vj_ijf.x + vjpij.x;
  855. Xobj[j].yvel = vj_ijf.y + vjpij.y;
  856. X/*
  857. XNow calculate rotational velocity exchange    */
  858. Xrotrat = rotinert(i)/rotinert(j);
  859. Xtemp = rotrat * (2*obj[i].rotvel - obj[j].rotvel) / (1+rotrat);
  860. Xobj[i].rotvel = temp + obj[j].rotvel - obj[i].rotvel;
  861. Xobj[j].rotvel = temp;
  862. X}
  863. X
  864. Xbotline(disp, window, gc)    /* Print status line text    */
  865. X    Display *disp;
  866. X    Drawable window;
  867. X    GC gc;
  868. X{    extern int highscore, ships, score;
  869. X    char text[70];
  870. X    sprintf(text, "Ships:%2d   Score:%6d   Shield:        High:%6d",
  871. X        ships, score, highscore);
  872. X    XDrawImageString (disp, window, gc, 0, height+letheight,
  873. X            text, strlen(text));
  874. X}
  875. X
  876. Xprintss(disp, window, gc)    /* Print ships and score    */
  877. X    Display *disp;
  878. X    Drawable window;
  879. X    GC gc;
  880. X{    extern int height, highscore, oldscore, ships, score;
  881. X    extern Objtype obj[SHIP+1];    /* to kill ship    */
  882. X    char sstring[30];
  883. X
  884. X    if (score != oldscore)
  885. X    {    if (score/10000 > oldscore/10000)
  886. X        {    ships++; botline(disp, window, gc);}
  887. X        if (score/10000 < oldscore/10000)
  888. X        {    ships--; botline(disp, window, gc);
  889. X            if (!ships) obj[SHIP].alive = 0;
  890. X        }
  891. X        if (score > highscore)    /* Separate if to avoid flashing */
  892. X        {    highscore = score;
  893. X            sprintf(sstring, "%6d", highscore);
  894. X            XDrawImageString (disp, window, gc, 460,
  895. X                height+letheight, sstring, strlen(sstring));
  896. X        }
  897. X        sprintf(sstring, "%6d", score);
  898. X        XDrawImageString (disp, window, gc, 170, height+letheight,
  899. X                sstring, strlen(sstring));
  900. X        oldscore = score;
  901. X    }
  902. X
  903. X    /* Draw shield energy bar    */
  904. X    XFillRectangle(disp, window, gc, 340, height+8, energy>>1, 10);
  905. X    XClearArea(disp, window, 340+(energy>>1), height+8, 8, 10, False);
  906. X}
  907. X
  908. Xupscore(killer, up)    /* Only award score for things the player shot */
  909. X    int killer, up;
  910. X{    extern int score;
  911. X    if (killer != ENEMYBUL && killer != SHIP)
  912. X        score = score + up;
  913. X}
  914. X
  915. X/* boom, movebooms, drawbooms all by Peter Phillips */
  916. Xboom(ob, particles, duration)
  917. Xint ob;
  918. Xint particles;
  919. Xint duration;
  920. X{ extern int rndint;
  921. X  int i;
  922. X  unsigned int r1, r2;
  923. X  Boom b;
  924. X  double x, y;
  925. X  double angle, length;
  926. X
  927. X  b = (Boom) malloc(sizeof(struct _Boom));
  928. X  b->dur = duration;
  929. X  b->part = particles;
  930. X  x = obj[ob].x;
  931. X  y = obj[ob].y;
  932. X  for (i = 0; i < particles; i++) {
  933. X    r1 = (rand(rndint) >> 2) % 100;
  934. X    r2 = (rand(rndint) >> 2) % 7;
  935. X
  936. X    b->bcoord[i][0] = x;
  937. X    b->bcoord[i][1] = y;
  938. X    angle = r1 * pi / 50.0;
  939. X    length = 3 + r2;
  940. X    b->bvec[i][0] = cos(angle) * length + obj[ob].xvel;
  941. X    b->bvec[i][1] = sin(angle) * length + obj[ob].yvel;
  942. X  }
  943. X  b->next = blist;
  944. X  blist = b;
  945. X}
  946. X
  947. X/* move the various booms that are active */
  948. Xmovebooms()
  949. X{
  950. X  int i;
  951. X  Boom b, prevb;
  952. X
  953. X  prevb = NULL;
  954. X  b = blist;
  955. X  while (b != NULL) {
  956. X    b->dur--;
  957. X    if (b->dur < 0) { /* delete this boom */
  958. X      Boom temp;
  959. X
  960. X      temp = b;
  961. X      if (prevb == NULL) {
  962. X        blist = b->next;
  963. X      } else {
  964. X        prevb->next = b->next;
  965. X      }
  966. X      b = b->next;
  967. X      free(temp);
  968. X    } else {  /* move boom, advance list */
  969. X      for (i = 0; i < b->part; i++) {
  970. X        b->bcoord[i][0] += b->bvec[i][0];
  971. X        b->bcoord[i][1] += b->bvec[i][1];
  972. X      }
  973. X      prevb = b;
  974. X      b = b->next;
  975. X    }
  976. X  }
  977. X}
  978. X
  979. X/* Draw the various booms */
  980. Xdrawbooms(disp, window, gc)
  981. X     Display *disp;
  982. X     Drawable window;
  983. X     GC gc;
  984. X{
  985. X  int i;
  986. X  Boom b;
  987. X  XPoint figure[BMAX];
  988. X
  989. X  b = blist;
  990. X  while (b != NULL) {
  991. X    for (i = 0; i < b->part; i++) {
  992. X      figure[i].x = (int) b->bcoord[i][0];
  993. X      figure[i].y = (int) b->bcoord[i][1];
  994. X    }
  995. X    XDrawPoints(disp, window, gc, figure, b->part, CoordModeOrigin);
  996. X    b = b->next;
  997. X  }
  998. X}
  999. X
  1000. Xdeletebooms()    /* delete all booms */
  1001. X{    Boom b;
  1002. X
  1003. X    b = blist;
  1004. X    while (b != NULL)
  1005. X    {    b->dur = 0;
  1006. X        b = b->next;
  1007. X}    }
  1008. X
  1009. Xkillast(killer, i)
  1010. X    int killer, i;        /* i = Asteroid # to kill    */
  1011. X{    extern Objtype obj[SHIP+1];
  1012. X    extern int numasts;
  1013. X    int k, na, oldna;
  1014. X
  1015. X    if (obj[i].shape == ASTSHAPE1)
  1016. X    {    na = nextast();        /* Could put 6 lines in a sub */
  1017. X        obj[na].x = obj[i].x;
  1018. X        obj[na].y = obj[i].y;
  1019. X        obj[na].xvel = obj[i].xvel;
  1020. X        obj[na].yvel = obj[i].yvel;
  1021. X        obj[na].alive++;
  1022. X        obj[na].shape = ASTSHAPE2;
  1023. X        obj[na].mass = M_MED;
  1024. X        obj[i].shape = ASTSHAPE2;
  1025. X        obj[i].mass = M_MED;
  1026. X        blastpair(i, na);
  1027. X        boom(i, 30, 12);
  1028. X        numasts = numasts + 1;
  1029. X        upscore(killer, 25);
  1030. X    }
  1031. X    else if (obj[i].shape == ASTSHAPE2)
  1032. X    {
  1033. X        for (k = 0; k < 3; k++)
  1034. X        {    oldna = na;
  1035. X            na = nextast();
  1036. X            obj[na].x = obj[i].x;
  1037. X            obj[na].y = obj[i].y;
  1038. X            obj[na].xvel = obj[i].xvel;
  1039. X            obj[na].yvel = obj[i].yvel;
  1040. X            obj[na].alive++;
  1041. X            obj[na].shape = ASTSHAPE3;
  1042. X            obj[na].mass = M_SMALL;
  1043. X            if (k == 1) blastpair(oldna,na);
  1044. X        }
  1045. X        obj[i].shape = ASTSHAPE3;
  1046. X        obj[i].mass = M_SMALL;
  1047. X        blastpair(na, i);
  1048. X        boom(i, 20, 10);
  1049. X        numasts = numasts + 3;
  1050. X        upscore(killer, 50);
  1051. X    }
  1052. X    else if (obj[i].shape == ASTSHAPE3)
  1053. X    {    boom(i, 10, 8);
  1054. X        obj[i].alive = 0; numasts--; upscore(killer, 100);}
  1055. X    else    /* enemy {ship or bullet}    */
  1056. X    {    boom(i, 9, 7);
  1057. X        obj[i].alive = 0; upscore(killer, 500);}
  1058. X}
  1059. Xmoveobjs(crash)
  1060. X    int *crash;
  1061. X{    extern Objtype obj[SHIP+1];
  1062. X    extern int ships;
  1063. X    extern double speedscale;
  1064. X    int i, j;    /* Indexes    */
  1065. X    double *temp;
  1066. X
  1067. X    movebooms();
  1068. X    for (i = 0; i < LASTOBJ+1; i++)
  1069. X        if (obj[i].alive)
  1070. X        {    temp = &obj[i].x;
  1071. X            *temp = *temp + obj[i].xvel*speedscale;
  1072. X            while (*temp < 0) *temp = *temp + (double) width;
  1073. X            while (*temp > width) *temp = *temp - (double) width;
  1074. X            temp = &obj[i].y;
  1075. X            *temp = *temp + obj[i].yvel*speedscale;
  1076. X            while (*temp < 0) *temp = *temp + height;
  1077. X            while (*temp > height) *temp = *temp - height;
  1078. X            obj[i].rot = obj[i].rot + obj[i].rotvel;
  1079. X        }
  1080. X    for (i = 0; i < FBUL; i++)
  1081. X        if (obj[i].alive)
  1082. X        {
  1083. X        if (obj[SHIP].alive && collide(i, SHIP))
  1084. X        {    if (shield_on) bounce(SHIP, i);
  1085. X            else
  1086. X            {    *crash = 2;
  1087. X                ships--; obj[SHIP].alive = 0;
  1088. X                killast(SHIP, i);
  1089. X        }    }
  1090. X        for (j = ENEMYBUL; j < LASTBUL+1; j++)
  1091. X            if (obj[j].alive && collide(i, j) && (j != ENEMYBUL || (i != ENEMYBUL && i != ENEMY)))
  1092. X            {    obj[j].alive = 0;    /* Kill the bullet    */
  1093. X                killast(j,i);
  1094. X            }
  1095. X        }
  1096. X}
  1097. X
  1098. Xfire()
  1099. X{    extern Objtype obj[SHIP+1];
  1100. X    extern int width, nextbul;
  1101. X    extern double drawscale, speedscale;
  1102. X    double *shiprot, cosrot, sinrot;
  1103. X
  1104. X    obj[nextbul].alive++;
  1105. X    shiprot = &obj[SHIP].rot;
  1106. X    cosrot = cos(*shiprot); sinrot = sin(*shiprot);
  1107. X    obj[nextbul].x = obj[SHIP].x + 20 * cosrot * drawscale;
  1108. X    obj[nextbul].y = obj[SHIP].y + 20 * sinrot * drawscale;
  1109. X    obj[nextbul].xvel = obj[SHIP].xvel + 10 * cosrot;
  1110. X    obj[nextbul].yvel = obj[SHIP].yvel + 10 * sinrot;
  1111. X    obj[nextbul].rot = *shiprot;
  1112. X    obj[nextbul].time = width/(speedscale*11);    /* loops before bullet expires    */
  1113. X    nextbul++; if (nextbul == LASTBUL+1) nextbul = FBUL;
  1114. X}
  1115. X
  1116. Xhyper()
  1117. X{    extern Objtype obj[SHIP+1];
  1118. X    extern int width, height, rndint;
  1119. X    unsigned char c;
  1120. X    unsigned int i;
  1121. X
  1122. X    c = rand(rndint); i = c; i<<=2;    /* 0 - 1024    */
  1123. X    while (i > width) i -= width;
  1124. X    obj[SHIP].x = (double) i;
  1125. X    c = rand(rndint); i = c; i<<=2;    /* 0 - 1024    */
  1126. X    while (i > height) i -= height;
  1127. X    obj[SHIP].y = (double) i;
  1128. X}
  1129. X
  1130. Xvdraw(disp, window, gc, shape, x, y, rot)
  1131. X    Display *disp;
  1132. X    Drawable window;
  1133. X    GC gc;
  1134. X    int shape;
  1135. X    double x, y, rot;
  1136. X
  1137. X{    int line;
  1138. X    extern PolarPair shapes[LASTSHAPE+1][11];
  1139. X    extern int numpairs[LASTSHAPE+1];
  1140. X    extern double drawscale;
  1141. X    XPoint figure[20];
  1142. X    figure[0].x = (int) x; figure[0].y = (int) y;
  1143. X    for (line=1; line < numpairs[shape]; line++)    /* 2 pairs = 1 line */
  1144. X    {    figure[line].x  = (int) shapes[shape][line].length *
  1145. X            cos(shapes[shape][line].angle + rot) * drawscale;
  1146. X        figure[line].y  = (int) shapes[shape][line].length *
  1147. X            sin(shapes[shape][line].angle + rot) * drawscale;
  1148. X    }
  1149. X    XDrawLines (disp, window, gc, figure, numpairs[shape], CoordModePrevious);
  1150. X}
  1151. X
  1152. Xmain(argc, argv)
  1153. X    int argc;
  1154. X    char **argv;
  1155. X{    Colormap cmap;
  1156. X    Cursor cursor;
  1157. X    Display *disp;
  1158. X    Font font;
  1159. X    GC gc, pmgc;
  1160. X    KeySym key;
  1161. X    Pixmap pixmap;
  1162. X    Window window;
  1163. X    XColor black, exact;
  1164. X    XEvent event;
  1165. X    XSizeHints hint;
  1166. X    extern int width, height;
  1167. X    int screen, depth;
  1168. X    char text[30];
  1169. X    unsigned long fg, bg;
  1170. X
  1171. X    extern double drawscale, speedscale;
  1172. X    extern int numasts, rndint, ships, score, oldscore;
  1173. X    extern Objtype obj[SHIP+1];
  1174. X    unsigned char c;    /* for rand    */
  1175. X    double *temp, dx, dy, dist;
  1176. X    int level, crashed, flashon, len, pause = 0, delay = 64,
  1177. X        enemycount, undraw = 0, counter, counterstart = 1,
  1178. X        i,    /* index for drawing objs, counting bullets */
  1179. X        r;    /* radius of shield circle    */
  1180. X
  1181. X    disp = XOpenDisplay(0);
  1182. X    if (disp == (Display *) NULL)
  1183. X    {    fprintf(stderr, "Could not open display\n");
  1184. X        exit(1);
  1185. X    }
  1186. X    screen = DefaultScreen(disp);
  1187. X    bg = BlackPixel(disp, screen);
  1188. X    fg = WhitePixel(disp, screen);
  1189. X    hint.x = 150; hint.y = 200; hint.width = 550; hint.height = 550;
  1190. X    hint.flags = PPosition | PSize;
  1191. X    width = hint.width; height = hint.height-letheight-1;
  1192. X    depth = DefaultDepth (disp, screen);
  1193. X    window = XCreateSimpleWindow (disp, DefaultRootWindow(disp),
  1194. X        hint.x, hint.y, hint.width, hint.height, 5, fg, bg);
  1195. X    pixmap = XCreatePixmap (disp, window, width, height, depth);
  1196. X    XSetStandardProperties (disp, window, "asteroids", "asteroids", None,
  1197. X        argv, argc, &hint);
  1198. X    gc = XCreateGC (disp, window, 0, 0);
  1199. X    XSetGraphicsExposures(disp, gc, 0);    /* IMPORTANT!  If you do not
  1200. X        specifically ask not to get Expose events, every XCopyArea
  1201. X        will generate one, & the event queue will fill up.    */
  1202. X    font = XLoadFont(disp, "10x20\0");    /* If you don't have this
  1203. X        font, try replacing it with 9x15\0    */
  1204. X    XSetFont(disp, gc, font);
  1205. X    pmgc = XCreateGC (disp, window, 0, 0);
  1206. X    XSetBackground (disp, gc, bg);
  1207. X    XSetForeground (disp, gc, fg);
  1208. X    XSetForeground (disp, pmgc, bg);  /* fg of pixmap is bg of window */
  1209. X    XSelectInput (disp, window,
  1210. X        KeyPressMask | KeyReleaseMask | StructureNotifyMask);
  1211. X    XMapRaised (disp, window);
  1212. X
  1213. X    /* Erase cursor. Just delete next 5 lines if any error.    */
  1214. X    cmap = XDefaultColormap(disp, screen);
  1215. X    XAllocNamedColor(disp, cmap, "Black", &exact, &black);
  1216. X    cursor = XCreateFontCursor(disp, XC_dot);
  1217. X    XRecolorCursor(disp, cursor, &black, &black);
  1218. X    XDefineCursor(disp, window, cursor);
  1219. X
  1220. X    XFillRectangle (disp, pixmap, pmgc, 0, 0, width, height);
  1221. X/*    Can delete next line if it causes trouble    */
  1222. X    srand((unsigned) time(0));    /* By Craig Smith    */
  1223. X    initasts();
  1224. XNewgame:
  1225. X    deletebooms();
  1226. X    ships = 3;
  1227. X    score = 0; oldscore = -1;
  1228. X    for (level = 0; ;)
  1229. X    {   if (level < 8) level++;
  1230. X        makeasts (level);
  1231. XNewship:    botline(disp, window, gc);
  1232. X        if (!obj[SHIP].alive)
  1233. X        {    obj[SHIP].x = width/2;
  1234. X        obj[SHIP].y = height/2;
  1235. X        obj[SHIP].xvel = 0;
  1236. X        obj[SHIP].yvel = 0;
  1237. X        obj[SHIP].rot = 3*pi/2;
  1238. X        obj[SHIP].rotvel = 0;
  1239. X        energy = 80;
  1240. X        shield_on = 0;
  1241. X        }
  1242. X        obj[SHIP].alive = (ships > 0);
  1243. X        crashed = 0; flashon = 0; enemycount = 20;
  1244. X        counter = 0;
  1245. X        while (numasts)
  1246. X        {    for (i = FBUL; i < LASTBUL+1; i++)  /* Bullet timer */
  1247. X            if (obj[i].alive)
  1248. X            {    obj[i].time--;
  1249. X            if (!obj[i].time) obj[i].alive = 0; /* Not --! */
  1250. X            }
  1251. X        while (XEventsQueued(disp, QueuedAfterReading))
  1252. X        {   XNextEvent(disp, &event);
  1253. X            switch (event.type)
  1254. X            {    case MappingNotify:
  1255. X                XRefreshKeyboardMapping (&event);
  1256. X                break;
  1257. X            case ConfigureNotify:
  1258. X                width = event.xconfigure.width;
  1259. X                height = event.xconfigure.height-letheight-1;
  1260. X                XFreePixmap (disp, pixmap);
  1261. X                pixmap = XCreatePixmap (disp, window, width, height, depth);
  1262. X                XFillRectangle (disp, pixmap, pmgc, 0, 0, width, height);
  1263. X                botline(disp, window, gc);
  1264. X                break;
  1265. X            case KeyPress:
  1266. X                len = XLookupString (&event, text, 10, &key, 0);
  1267. X                if (len == 1 && !shield_on) switch (text[0])
  1268. X                {    case 'e':
  1269. X                    obj[SHIP].rotvel = obj[SHIP].rotvel - .1; break;
  1270. X                case 'r':
  1271. X                    obj[SHIP].rotvel = obj[SHIP].rotvel + .1; break;
  1272. X                case 'w':
  1273. X                    obj[SHIP].rot -= pi/4; break;
  1274. X                case 't':
  1275. X                    obj[SHIP].rot += pi/4; break;
  1276. X                case 'd':
  1277. X                    obj[SHIP].rotvel = obj[SHIP].rotvel - .02; break;
  1278. X                case 'f':
  1279. X                    obj[SHIP].rotvel = obj[SHIP].rotvel + .02; break;
  1280. X                case THRUST:
  1281. X                    obj[SHIP].xvel += cos(obj[SHIP].rot);
  1282. X                    obj[SHIP].yvel += sin(obj[SHIP].rot);
  1283. X                    obj[SHIP].shape = SHIPTHRSHAPE;
  1284. X                    break;
  1285. X                case FIRE:
  1286. X                    if (obj[SHIP].alive) fire(); break;
  1287. X                case ' ':
  1288. X                    if (obj[SHIP].alive)
  1289. X                    {    hyper(); flashon = 1;
  1290. X/*                    NOT XSetForeground (disp, gc, bg);
  1291. X    If you set the fg black, & print the highscore, it will effectively erase it.    */
  1292. X                        XSetForeground (disp, pmgc, fg);
  1293. X                    XFillRectangle (disp, pixmap, pmgc, 0, 0, width, height);
  1294. X                    }
  1295. X                    break;
  1296. X                case SHIELD:
  1297. X                    if (energy)
  1298. X                    {    shield_on = 1;
  1299. X                    obj[SHIP].shape = SHIPSHAPE;}
  1300. X                    break;
  1301. X                case '.':    /* decrease delay    */
  1302. X                    if (delay > 1) delay >>=1; break;
  1303. X                case ',':    /* increase delay    */
  1304. X                    delay <<=1; break;
  1305. X                case 'm':    /* decrease drawscale - may go negative */
  1306. X                    drawscale -= .1; break;
  1307. X                case 'n':    /* increase drawscale    */
  1308. X                    drawscale += .1; break;
  1309. X                case '2':    /* increase speedscale    */
  1310. X                    speedscale += .1; break;
  1311. X                case '1':    /* decrease speedscale    */
  1312. X                    speedscale -= .1; break;
  1313. X                case 'b':    /* increase moves/update */
  1314. X                    counterstart++; break;
  1315. X                case 'v':    /* decrease moves/update */
  1316. X                    if (counterstart > 1) counterstart--;
  1317. X                    break;
  1318. X                case 'u':    /* undraw erase    */
  1319. X                    undraw = 1; break;
  1320. X                case 'x':    /* XFill erase    */
  1321. X                    undraw = 0; break;
  1322. X                case PAUSE:    /* pause    */
  1323. X                    pause = 1 - pause; break;
  1324. X                case '+':    /* cheat    */
  1325. X                    ships++; botline(disp, window, gc); break;
  1326. X                case 'Q':    /* quit        */
  1327. X                    goto End;
  1328. X                case 's':    /* start new ship */
  1329. X                    if (!obj[SHIP].alive)
  1330. X                    if (ships < 1) goto Newgame;
  1331. X                    else goto Newship;
  1332. X                    break;
  1333. X                }
  1334. X                break;
  1335. X            case KeyRelease:
  1336. X                len = XLookupString(&event, text, 10, &key, 0);
  1337. X                if (len == 1) switch (text[0])
  1338. X                {    case 'e':
  1339. X                    obj[SHIP].rotvel = 0; break;
  1340. X                case 'r':
  1341. X                    obj[SHIP].rotvel = 0; break;
  1342. X                case THRUST:
  1343. X                    obj[SHIP].shape = SHIPSHAPE;
  1344. X                    break;
  1345. X                case SHIELD:
  1346. X                    shield_on = 0; break;
  1347. X                }
  1348. X/*                break;        */
  1349. X        }   }
  1350. X        if (!pause)
  1351. X        {   moveobjs(&crashed);
  1352. X            if (ships) score--;    /* timer effect    */
  1353. X            if (!counter)
  1354. X            {    counter = counterstart;    /* Restart counter */
  1355. X            if (crashed == 2)
  1356. X            {   crashed--; flashon++;
  1357. X                boom(SHIP, BMAX-1, 70);
  1358. X                XSetForeground (disp, pmgc, fg);
  1359. X                XFillRectangle (disp, pixmap, pmgc, 0, 0, width, height);
  1360. X                botline(disp, window, gc);
  1361. X            }
  1362. X            /* Write copyright notice    */
  1363. X            if (!ships && blist == NULL && !undraw)
  1364. X            {   sprintf(text, "Xasteroids");
  1365. X                XDrawImageString (disp, pixmap, gc,
  1366. X                width/2-50, height/2-2*letheight,
  1367. X                text, strlen(text));
  1368. X                sprintf(text, "Copyright 1990 by Phil Goetz");
  1369. X                XDrawImageString (disp, pixmap, gc,
  1370. X                width/2-140, height/2,
  1371. X                text, strlen(text));
  1372. X                sprintf(text, "goetz@cs.buffalo.edu");
  1373. X                XDrawImageString (disp, pixmap, gc,
  1374. X                width/2-100, height/2+2*letheight,
  1375. X                text, strlen(text));
  1376. X            }
  1377. X            /*    Draw objects    */
  1378. X            for (i = 0; i <= LASTOBJ; i++)
  1379. X                if (obj[i].alive)
  1380. X                vdraw(disp, pixmap, gc, obj[i].shape,
  1381. X                    obj[i].x, obj[i].y, obj[i].rot);
  1382. X            if (shield_on && obj[SHIP].alive)
  1383. X            {   r = abs((int) (drawscale*SHIPSIZE));
  1384. X                XDrawArc(disp, pixmap, gc,
  1385. X                ((int) obj[SHIP].x) - r,
  1386. X                ((int) obj[SHIP].y) - r,
  1387. X                2*r, 2*r, 0, 360*64);
  1388. X                energy--;
  1389. X                if (!energy) shield_on = 0;
  1390. X            }
  1391. X            drawbooms(disp, pixmap, gc);
  1392. X            /* update display:    */
  1393. X            XCopyArea(disp, pixmap, window, gc, 0, 0, width, height, 0, 0);
  1394. X            printss(disp, window, gc);
  1395. X            /* erase objects    */
  1396. X            if (undraw)
  1397. X            {   for (i = 0; i <= LASTOBJ; i++)
  1398. X                if (obj[i].alive)
  1399. X                    vdraw(disp, pixmap, pmgc, obj[i].shape,
  1400. X                    obj[i].x, obj[i].y, obj[i].rot);
  1401. X            }
  1402. X            else
  1403. X                XFillRectangle (disp, pixmap, pmgc, 0, 0, width, height);
  1404. X            if (flashon)
  1405. X            {   flashon--;
  1406. X                XSetForeground (disp, pmgc, bg);
  1407. X                XFillRectangle (disp, pixmap, pmgc, 0, 0, width, height);
  1408. X            }
  1409. X            XSync(disp, 0);
  1410. X            }
  1411. X            counter--;
  1412. X            c = rand(rndint)>>8;
  1413. X            if (!obj[ENEMY].alive)
  1414. X            {   if (c < level)
  1415. X                {    c = rand(rndint);
  1416. X                if (c < level * 10) makeenemy(level);
  1417. X            }   }
  1418. X            else
  1419. X            obj[ENEMY].yvel += (c>128+6*obj[ENEMY].yvel) ? .5 : -.5;
  1420. X            enemycount--; if (!enemycount)
  1421. X            {    enemycount = 100;
  1422. X            if (obj[ENEMY].alive)
  1423. X            {   obj[ENEMYBUL].alive++;
  1424. X                obj[ENEMYBUL].x = obj[ENEMY].x;
  1425. X                obj[ENEMYBUL].y = obj[ENEMY].y;
  1426. X                dx = obj[SHIP].x - obj[ENEMY].x;
  1427. X                dy = obj[SHIP].y - obj[ENEMY].y;
  1428. X                dist = sqrt(dx*dx + dy*dy);
  1429. X                obj[ENEMYBUL].xvel = 3*dx/dist;
  1430. X                obj[ENEMYBUL].yvel = 3*dy/dist;
  1431. X            }
  1432. X            else    obj[ENEMYBUL].alive = 0;
  1433. X            }
  1434. X            for (i = 0; i < delay; i++);
  1435. X        }
  1436. X        }
  1437. X    }
  1438. XEnd:    printf("\nYour high score was %d\n", highscore);
  1439. X    XFreeGC (disp, gc);
  1440. X    XFreeGC (disp, pmgc);
  1441. X    XFreePixmap (disp, pixmap);
  1442. X    XDestroyWindow (disp, window);
  1443. X    XCloseDisplay (disp);
  1444. X    exit(0);
  1445. X}
  1446. END_OF_FILE
  1447. if test 27201 -ne `wc -c <'ast.c'`; then
  1448.     echo shar: \"'ast.c'\" unpacked with wrong size!
  1449. fi
  1450. # end of 'ast.c'
  1451. fi
  1452. if test -f 'ast.doc' -a "${1}" != "-c" ; then 
  1453.   echo shar: Will not clobber existing file \"'ast.doc'\"
  1454. else
  1455. echo shar: Extracting \"'ast.doc'\" \(1291 characters\)
  1456. sed "s/^X//" >'ast.doc' <<'END_OF_FILE'
  1457. X         Xasteroids
  1458. X    Copyright 1990 by Phil Goetz
  1459. X        goetz@cs.Buffalo.EDU
  1460. X
  1461. XKeypress    Command
  1462. X--------        -------
  1463. X    e        Rotate counterclockwise ("left")
  1464. X    r        Rotate clockwise ("right")
  1465. X    w        Rotate 45 degrees counterclockwise
  1466. X    t        Rotate 45 degrees clockwise
  1467. X    d        Increase counterclockwise rotational velocity
  1468. X    f        Increase clockwise rotational velocity
  1469. X    o        Thrust
  1470. X    p        Fire
  1471. X    `        Shields
  1472. X  space        Hyperspace
  1473. X    s        Start new ship in center of playing field
  1474. X        (Also used to start a new game)
  1475. X   esc         Pause
  1476. X    Q        Quit
  1477. XSpeed commands:    Key associated with faster speed is to the right of its
  1478. X        corresponding key associated with slower speed.
  1479. X    .        Decrease delay:  Speed game up
  1480. X    ,        Increase delay:  Slow the game down
  1481. X    m        Decrease size    ("Minimize")
  1482. X    n        Increase size
  1483. X    b        Increase # of moves/frame
  1484. X    v        Decrease # of moves/frame
  1485. X    2        Increase scale of movement
  1486. X    1        Decrease scale of movement
  1487. X    x        Use XFillRectangle to erase screen
  1488. X    u        Use undraw to erase screen
  1489. X
  1490. XObject        Score
  1491. X-------        -----
  1492. XBig asteroid    25
  1493. XMedium asteroid    50
  1494. XLittle asteroid    100
  1495. XEnemy spaceship    500
  1496. XEnemy bullet    500
  1497. X
  1498. XCommands can only be entered when the mouse pointer is in the
  1499. Xasteroids window.
  1500. X
  1501. XResize the window with your window manager
  1502. Xat any time for a different playing field.
  1503. END_OF_FILE
  1504. if test 1291 -ne `wc -c <'ast.doc'`; then
  1505.     echo shar: \"'ast.doc'\" unpacked with wrong size!
  1506. fi
  1507. # end of 'ast.doc'
  1508. fi
  1509. echo shar: End of archive 1 \(of 1\).
  1510. cp /dev/null ark1isdone
  1511. MISSING=""
  1512. for I in 1 ; do
  1513.     if test ! -f ark${I}isdone ; then
  1514.     MISSING="${MISSING} ${I}"
  1515.     fi
  1516. done
  1517. if test "${MISSING}" = "" ; then
  1518.     echo You have the archive.
  1519.     rm -f ark[1-9]isdone
  1520. else
  1521.     echo You still need to unpack the following archives:
  1522.     echo "        " ${MISSING}
  1523. fi
  1524. ##  End of shell archive.
  1525. exit 0
  1526.