[comp.sources.x] v05i046: golddig2 -- A game for X11, Part02/04

kent@ssbell.uu.net (Kent Landfield) (12/14/89)

Submitted-by: Alexander Siegel <siegel@cs.cornell.edu>
Posting-number: Volume 5, Issue 46
Archive-name: golddig2/part02

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 4)."
# Contents:  golddig2/Makefile golddig2/golddig.h golddig2/golddig.p
#   golddig2/goldlev010 golddig2/goldlev011 golddig2/goldlev012
#   golddig2/goldlev013 golddig2/goldlev014 golddig2/goldlev015
#   golddig2/goldlev016 golddig2/goldlev018 golddig2/makelev.c
#   golddig2/scores.c
# Wrapped by kent@ssbell on Wed Dec 13 20:36:50 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'golddig2/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/Makefile'\"
else
echo shar: Extracting \"'golddig2/Makefile'\" \(2241 characters\)
sed "s/^X//" >'golddig2/Makefile' <<'END_OF_FILE'
X# This program was written by Alexander Siegel in September of 1989   
X# at Cornell University.  It may may copied freely for private use or 
X# public dispersion provided that this comment is not removed.  This  
X# program, any portion of this program, or any derivative of this     
X# program may not be sold or traded for financial gain.
X
X# Name of game executable
XGAME = golddig
X# Name of level editor executable
XEDITOR = makelev
X# Directory where games binaries are stored
XBIN = /usr/public/${HOSTTYPE}/games
X# Directory where the library for this game will be stored
XLIB = /usr/public/sun3/games/lib/${GAME}
X# Directory where manual pages are kept
XMANEXT = p
XMAN = /usr/public/man/man${MANEXT}
X# Font used to display score
XSCOREFONT = -adobe-times-bold-r-normal--18-180-75-75-p-99-iso8859-1
X# Height of SCOREFONT
XSCORESIZE = 18
X
X# Common compilers
X#CC = cc
XCC = gcc
X
X# Some common choices for CFLAGS.
X#CFLAGS = -O2
X#CFLAGS = -O
XCFLAGS = -O -W -Wreturn-type -Wunused -g -finline-functions
X#CFLAGS = -g
XLDFLAGS = -g
X
Xall: ${GAME} ${EDITOR}
X
Xinstall: all
X	-mkdir ${LIB}
X	cp ${GAME} ${EDITOR} ${BIN}
X# The next line sets up the level files so that anyone can edit all of
X# the levels.  Remove this line to have better security.
X	chmod 4755 ${BIN}/${EDITOR}
X	touch ${LIB}/scores
X# Allow anyone to modify the high score file.  An alternative is to
X# change the mode bits of ${GAME} to be 4755.
X	chmod 666 ${LIB}/scores
X	cp goldlev* default ${LIB}
X	cp golddig.p ${MAN}/golddig.${MANEXT}
X
Xupdate: all
X	cp ${GAME} ${EDITOR} ${BIN}
X# The next line sets up the level files so that anyone can edit all of
X# the levels.  Remove this line to have better security.
X	chmod 4755 ${BIN}/${EDITOR}
X
Xclean:
X	rm -f *.o *~ bitmap/*~ core ${GAME} ${EDITOR}
X
XSRCS = golddig.c shared.c badguy.c movement.c scores.c
XOBJS = golddig.o shared.o badguy.o movement.o scores.o
X
Xlint:
X	lint -DLIB=\"${LIB}\" -DSCOREFONT=\"${SCOREFONT}\" \
X                       -DSCORESIZE=${SCORESIZE} ${SRCS}
X
X${GAME}: ${OBJS}
X	${CC} ${LDFLAGS} -o ${GAME} ${OBJS} -lX11
X
X${EDITOR}: makelev.o shared.o
X	${CC} ${LDFLAGS} -o ${EDITOR} makelev.o shared.o -lX11
X
X.c.o:
X	${CC} ${CFLAGS} -c -DLIB=\"${LIB}\" -DSCOREFONT=\"${SCOREFONT}\" \
X                       -DSCORESIZE=${SCORESIZE} $<
END_OF_FILE
if test 2241 -ne `wc -c <'golddig2/Makefile'`; then
    echo shar: \"'golddig2/Makefile'\" unpacked with wrong size!
fi
# end of 'golddig2/Makefile'
fi
if test -f 'golddig2/golddig.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/golddig.h'\"
else
echo shar: Extracting \"'golddig2/golddig.h'\" \(7140 characters\)
sed "s/^X//" >'golddig2/golddig.h' <<'END_OF_FILE'
X/* This program was written by Alexander Siegel in September of 1989   */
X/* at Cornell University.  It may may copied freely for private use or */
X/* public dispersion provided that this comment is not removed.  This  */
X/* program, any portion of this program, or any derivative of this     */
X/* program may not be sold or traded for financial gain.               */
X
X/* Start up default values */
X#define DEFWORLD "goldlev"  /* Default world name */
X
Xint xsize,ysize;        /* Current level width and height */
Xint levelstart;         /* Level that player started at */
Xint levelnum;           /* Current level number */
Xint score;              /* Total score */
Xint speed;              /* Speed of game.  1 is slowest, 5 is default */
Xint goldleft;           /* Total number of treasure blocks left */
Xchar *worldname;        /* Name of world (set of levels) */
Xchar filename[300];     /* Current file name of this level */
Xint curtick;            /* Current clock tick number */
X
XDisplay *disp;          /* X11 display of client */
XWindow wind;            /* X11 window where game is displayed */
X
X/* Enumerated type to described direction or activity */
Xenum directs {
X  STAND,UP,DOWN,LEFT,RIGHT,DIGLEFT,DIGRIGHT,PUTDOWN
X};
X/* Structure describing all stats of thing */
Xstruct thing_s {
X  int xstart,ystart;        /* Starting position of thing.  For both */
X                            /* this pair and (xpos,ypos), the value is */
X                            /* actually 2 times the expected value. */
X                            /* This allows for describing when a thing */
X                            /* is half way between one block and another. */
X  int xpos,ypos;            /* Current position of thing */
X  int xold,yold;            /* Previous position before last movement */
X  int redraw;               /* Non-zero if thing should be redrawn */
X  enum directs dir;         /* Current movement direction or action */
X  char hold;                /* What is it carrying */
X} player;   /* The player is a thing too */
X
X/* These are used in the bit pattern for the generalized block */
X/* description data structure which is in shared.c.  New bit */
X/* descriptor can be added without modifying anything else. */
X#define UPLEVEL 0x2         /* Jump to next level on contact */
X#define ULEAVE  0x4         /* Can you leave this block upwards */
X#define DLEAVE  0x8         /* Can you leave this block downwards */
X#define LLEAVE  0x10        /* Can you leave this block to the left */
X#define RLEAVE  0x20        /* Can you leave this block to the right */
X#define HENTER  0x40        /* Can you enter this block horizontally */
X#define VENTER  0x80        /* Can you enter this block vertically */
X#define STOPBAD 0x100       /* Stops badguys from passing through. */
X                            /* They must climb out. */
X#define CANDIG  0x200       /* Can this block be dug */
X#define INACTIVE 0x400      /* Does this block activate after treasure */
X                            /* is gone, space is used otherwise */
X#define TREASURE 0x800      /* Get points for contact, then turned */
X                            /* into space */
X#define KILLIN  0x1000      /* Kills anyone standing in it */
X#define NODRAW  0x2000      /* Can not draw it in editor */
X#define DIGUND  0x4000      /* Can dig out underneath this block */
X#define PICKUP  0x8000      /* Can pickup block and replace it with space */
X#define TELEPORT 0x10000    /* Does this cause teleportation on contact */
X#define ARMOR   0x20000     /* Grants invulnerability to player if held */
X#define STOPFALL 0x40000    /* Prevent holder from falling */
X#define NSHOVEL 0x80000     /* Holder can dig much bigger holes */
X#define TIMESTOP 0x100000   /* Stop time for all except player if held */
X#define REVERSE 0x200000    /* Reverse bad guy direction if player holds */
X#define UPTWO   0x400000    /* Causes jump up two spaces on contact */
X#define ANCHOR  0x800000    /* Slows movement to one half if held, and */
X                            /* prevents jumps or teleports */
X#define UPALL  0x1000000    /* Jump to the top of screen on contact */
X#define SPEED  0x2000000    /* Allow player double movement if held */
X#define PSHOVEL 0x4000000   /* Makes holes permanent when dug */
X#define RSHOVEL 0x8000000   /* Make bricks out of space */
X#define DFALL   0x10000000  /* Fall downwards out of this space */
X#define UFALL   0x20000000  /* Fall upwards out of this space */
X#define LFALL   0x40000000  /* Fall to the left out of this space */
X#define RFALL   0x80000000  /* Fall to the right out of this space */
X#define CANFALL (DFALL | UFALL | LFALL | RFALL) /* Bitmask for */
X                                                /* detecting gravity */
X
X/* Predefined important block types.  Other types can be added WITHOUT */
X/* adding to this list. */
X#define SPACE ' '
X#define BRICK '#'
X#define STONE '@'
X#define HOLE1 '1'
X#define PLAYER 'p'
X#define BADGUY 'b'
X
X#define MAXLEVEL 5000     /* Maximum size of a level */
Xchar level[MAXLEVEL];     /* Array describing level using characters */
X                          /* from above */
Xchar moveallow[MAXLEVEL]; /* Array describing which directions can be moved */
X                          /* out of any position in level */
X/* Bit patterns for moveallow array */
X#define MOVEUP    0x1   /* Upward movement is allowed */
X#define MOVEDOWN  0x2   /* Downward movement is allowed */
X#define MOVELEFT  0x4   /* Left movement is allowed */
X#define MOVERIGHT 0x8   /* Right movement is allowed */
X#define FORCEUP    0x10 /* Upward movement is forced */
X#define FORCEDOWN  0x20 /* Downward movement is forced */
X#define FORCELEFT  0x40 /* Left movement is forced */
X#define FORCERIGHT 0x80 /* Right movement is forced */
X#define FORCEALL   0xf0 /* Movement is forced in some direction */
X
X/* Array of block type descriptors.  The actual values for this array */
X/* are in shared.c. */
Xstruct symbs_s {
X  char symb;    /* Character symbol representing block */
X  char inplay;  /* Character describing what this block looks like */
X                /* during actual play.  It is the symbol character */
X                /* for this or another block type. */
X  char *name;   /* Symbol name in English */
X  char *bits;   /* Bitmap defined by a X11 bitmap file. */
X  long code;    /* Bit code describing properties of block */
X  KeySym xkey1,xkey2;   /* One or two X11 keyboard symbols for symbol */
X};
X
X/* Array for fast lookup of block types.  This array is index by the */
X/* actual block character. */
Xstruct fast_s {
X  GC gc;        /* Graphics cursor used for drawing block */
X  long code;    /* Code describing block properties */
X} fast_lookup[256];
X
X/* Global declarations of some functions */
XGC makegc();
Xvoid xstart();
Xvoid xend();
Xvoid setchar();
Xvoid draw_block();
Xvoid draw_level();
Xvoid load_level();
Xvoid save_level();
Xint overlap_badguy();
Xvoid move_badguy();
Xvoid init_badguy();
Xvoid start_badguy();
Xvoid move_badguys();
Xvoid draw_badguys();
Xint in_hole();
Xint movething();
Xvoid fill_hole();
Xvoid regen_tree();
Xvoid regen_allow();
Xvoid add_score();
Xvoid draw_score();
Xvoid change_holes();
Xvoid redrawall();
END_OF_FILE
if test 7140 -ne `wc -c <'golddig2/golddig.h'`; then
    echo shar: \"'golddig2/golddig.h'\" unpacked with wrong size!
fi
# end of 'golddig2/golddig.h'
fi
if test -f 'golddig2/golddig.p' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/golddig.p'\"
else
echo shar: Extracting \"'golddig2/golddig.p'\" \(5026 characters\)
sed "s/^X//" >'golddig2/golddig.p' <<'END_OF_FILE'
X.TH GOLDDIG P "September 29 1989"
X.UC 4
X.SH NAME
Xgolddig - Getting the Gold and Avoiding Death
X.SH
X.B golddig
X[
X.B \-l
X.I level
X]
X[
X.B \-s
X.I speed
X]
X[
X.I world
X]
X.br
X.B makelev
X.B \-l
X.I level
X[
X.B \-w
X.I width
X]
X[
X.B \-h
X.I height
X]
X[
X.I world
X]
X.SH DESCRIPTION
X.PP
X.I golddig
Xis a fast action game designed for use with the X window system.
X.I makelev
Xis used to create and edit new levels which can be used by
X.I golddig.
X.PP
XThe goal in
X.I golddig
Xis to pick up all the gold pieces and then go to the next level
Xwithout getting eaten by one of the bad guys.  The gold pieces are
Xdistinctive small circular coins.  After picking up all of the gold,
Xthe player must get to an open door or the top row of the level.
XAfter accomplishing this, the game will start the next level.
X.PP
XThe
X.B "\-l"
Xoption sets the level number for editing or for starting the game.
XThis may be any integer greater than 0.  By default, the game starts
Xat level 1.  The
X.B "\-s"
Xoptions sets the game speed.  A value of 1 is very slow and a value of
X10 is fast.  The default value is 5.  The
X.B "\-w"
Xand
X.B "\-h"
Xoptions set the width and height of the level when creating a new
Xlevel.  The
X.B world
Xoption is used to select a world name.  A world is a distinct set of
Xnumbered levels.  Any valid file name may be used as the world name.
XDifferent worlds may be used to allow users to control private sets of
Xlevels.
X.PP
XWhen playing
X.I golddig
Xthe following keyboard commands may be used:
X.PP
X<space>,R11 \- stop
X.br
Xa,j,left arrow \- move left
X.br
Xd,l,right arrow \- move right
X.br
Xw,i,up arrow \- move up
X.br
Xs,k,down arrow \- move down
X.br
Xz,<,q,u,R13 \- make hole left
X.br
Xx,>,e,o,R15 \- make hole right
X.br
Xr,y,R7 \- put down any held item
X.br
X1\-9 \- change the game speed during the game
X.PP
XIn addition, some control keys can be used:
X.PP
X^S,^Z \- freeze the game
X.br
X^Q,^Y \- reactivate the game
X.br
X^C,^U,^\\ \- kill the game
X.br
X^R - redraw the level
X.PP
XThe mouse must be placed in the game window to use the keyboard
Xcommands.  When a level starts, everything is frozen, and any key will
Xstart the game.
X.PP
X.I makelev
Xis used as a graphics editor.  Each level is divided into a grid of
Xblocks.  The blocks are "painted" by pressing the left mouse button
Xdown and moving the mouse.  The right mouse button always erases
Xblocks.  A new block type is selected by a keyboard
Xkey.  Currently, the following block types are supported:
X.PP
X<space> \- draw spaces
X.br
X! \- draw escapes
X.br
X# \- draw walls
X.br
X$ \- draw golds
X.br
X- \- draw ropes
X.br
X< \- draw left arrows
X.br
X= \- draw tubes
X.br
X> \- draw right arrows
X.br
X@ \- draw stones
X.br
X^ \- draw anti-spaces
X.br
Xa \- draw armors
X.br
Xb \- draw bad guys
X.br
Xc \- draw chutes
X.br
Xd \- draw down arrows
X.br
Xe \- draw reverse monsters
X.br
Xf \- draw up arrows
X.br
Xg \- draw ghost bricks
X.br
Xi \- draw invisible blocks
X.br
Xj \- draw jump pads
X.br
Xk \- draw kill zones
X.br
Xl \- draw power shovels
X.br
Xm \- draw super jump pads
X.br
Xn \- draw nuclear shovels
X.br
Xo \- draw anchors
X.br
Xp \- draw players
X.br
Xq \- draw speed boots
X.br
Xr \- draw parachutes
X.br
Xs \- draw step ladders
X.br
Xt \- draw teleporters
X.br
Xu \- draw leave levels
X.br
Xv \- draw vertical ropes
X.br
Xw \- draw windows
X.br
Xx \- draw extra bricks
X.br
Xy \- draw heavy fogs
X.br
Xz \- draw time stops
X.br
X| \- draw ladders
X.br
X~ \- draw portable ropes
X.PP
XA player block sets where the player begins in the level.  If more
Xthan one is used in a level, all but one will be ignored.  Bad guy
Xblocks set where the bad guys begin the level.  There is a limit to
Xthe total number of bad guys, and that number is compiled into the game.
XPressing control W inside the editor window will stop editing
Xand save the level.  Pressing control C quits without saving.
XPressing control E will erase the contents of the
Xeditor.  The properties of the rest of the block can be
Xdetermined with experimentation.
X.PP
XA really good level has several properties.  The first important
Xproperty is efficiency.  A good level makes careful use of all of the
Xavailable space unless it is trying to achieve a specific effect.
XAnother critical property is fairness.  A player should always be
Xforewarned or have an escape if trouble comes up.  Nothing is more
Xirritating than a killer trap where the user had no way of guessing that
Xit was coming up.  It is also important to avoid tedious and repetative
Xlevels.  Really difficult traps should be rewarded with lots of gold.
X.SH AUTHORS
XAlex Siegel at Cornell University during September of 1989.
X.SH
X/usr/games/golddig - golddig executable
X.br
X/usr/games/makelev - level editor executable
X.br
X/usr/games/lib/golddig - directory for storing files which are private to
X.I golddig
X.br
X/usr/games/lib/golddig/scores - file for storing high score list
X.br
X/usr/games/lib/golddig/default - default level for use when no
Xgenerated level is available
X.br
X/usr/games/lib/golddig/goldlev### - default levels used when no world
Xname is specified
X.SH BUGS
XThis game is the first totally bug free program ever written.
END_OF_FILE
if test 5026 -ne `wc -c <'golddig2/golddig.p'`; then
    echo shar: \"'golddig2/golddig.p'\" unpacked with wrong size!
fi
# end of 'golddig2/golddig.p'
fi
if test -f 'golddig2/goldlev010' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/goldlev010'\"
else
echo shar: Extracting \"'golddig2/goldlev010'\" \(1536 characters\)
sed "s/^X//" >'golddig2/goldlev010' <<'END_OF_FILE'
X50 30
X          !                          !            
X-- |------!                          !     ------ 
X| -|      |--     $$    $      $$    |#@@#@      |
X|         |  @@@@@@@@@@@@@@@@@@@@@@@ |           |
X|         |    $$$      b      $$$   |      |#|##|
X|         |   |@@@@@@@@###@@@@@@@@   |  $   |$|$$|
X|  $ $ $  |   |    $$   b   $$   |   | $|   |#|##|
X|         |   |   |@@@@###@@@@   |   | |$   |$|$$|
X|         |   |   |     b    |   |   | $|   |#|##|
X|         |   |   |   |@#@   |   |   | |$   |$|$$|
X|         |   |   |   |-$| @ | @ | @ | $|   |#|##|
X|   p     |   |   |   | -| $ | $ | $ | |$   |$|$$|
X|  @@@@@@ |   |   |   |  | @ | @ | @ | $|   |#|##|
X|  @$== @ |   |   |   |  | $ | $ | $ | |$   |$|$$|
X|   $  v  |   |   |   |  | @ | @ | @ | $|   |####|
X|      v  |   |   |   |  | $ | $ | $ | |$   |    |
X|      v  |   |   |-$ |  | @ | @ | @ | $| @ |$$$$|
X| |# ##v  |   |-$ |   |  |  @|  @|   | |$ @@@@@@@@
X| |####v  |   |   | #$|b $ # |   |   | $|         
X| |   #v  |   |   | ######## |   |   | |$ #b      
X| | $ #v  |   | # | $  b   $   # |   | $| #######|
X| |####v  |   | ################ |   | |$ #      |
X|   $  v  | # |  $  $     $        # | $| #|######
X|-  $  v  | ##|##################### | |  #|      
X|   c  v  |  $|$$  $    $   $$  $$   |  | #######|
X|  @$==v@ | #|####|####|#####|####|  | |   ----- |
X|  @@  @@ |  |$$ b|    |b    |b $$|  |  |  |$$$$$|
X|---------| |######################| | |   |     |
X$$      $$| |$$    $$       $$   $$| | |- |######|
X##########|##########################|           |
END_OF_FILE
if test 1536 -ne `wc -c <'golddig2/goldlev010'`; then
    echo shar: \"'golddig2/goldlev010'\" unpacked with wrong size!
fi
# end of 'golddig2/goldlev010'
fi
if test -f 'golddig2/goldlev011' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/goldlev011'\"
else
echo shar: Extracting \"'golddig2/goldlev011'\" \(1536 characters\)
sed "s/^X//" >'golddig2/goldlev011' <<'END_OF_FILE'
X50 30
X                                    @   @         
X |||                                 @ @          
X |v| |= |- |- | |                @ @     @ @      
X | | |= |  |   |                   $!@ @          
X              |                   ^^# @ @         
X        | |                      ^^@^ $  @        
X         |  == || c-            $^^i^^$           
X        | | cc ||  c            ^^^iii$           
X                  -             ^^i  $t$          
X |----------------------        ^i   $|$          
X |  i iii i i iii i i i i      ^^i  $t$t$         
X |i $$$$$$$$$$$$$$$$$$$$$      ^^i  $|$|$         
X | i ii  i i i  ii i   i i     ^i  $t$t$t$        
X |  $i     i  i    i    $i    $^i  $|$|$|$        
X |  i  i i  i i i ibi   i     ^^i $t$t$t$t$       
X |  $     i   i        i$ i   ^i  $|$|$|$|$       
X |   ii iibi i i i iii i i    ^i  t$t$t$t$t       
X | i$            i      $    $^i k|-|-|-|-|k      
X |  i $ii$i i$$$i i$i $ i  i ^^i$t$t$t$t$t$t$     
X |i $i       i      i ii$    ^i $|$|$|$|$|$|$     
X | i i  ii iii i iii   i i  i^i$t$t$t$t$t$t$t$    
X |  $ i        i     i  $i   ^i$|$|$|$|$|$|$|$    
X |i i   i iii ibi i ii ii   ^^it!t!t!t t!t!t!t    
X |  $i  i         i ib  $ i ^i j!!!!!!c!!!!!!j    
X | i i i i i i i i   i  ii  ^i b!c c!ccc!c c!b    
X |  $ $ $ $ $ $ $ $ $ $i$  i^i  !   ! c !   !     
X |  i ii  i i   i ii  i  ii ^i  !   ! c !   !     
X | i     i    i     i         i !   ! c !   !  i  
X ||                         p @ !   !@m@!   ! @   
X##################################################
END_OF_FILE
if test 1536 -ne `wc -c <'golddig2/goldlev011'`; then
    echo shar: \"'golddig2/goldlev011'\" unpacked with wrong size!
fi
# end of 'golddig2/goldlev011'
fi
if test -f 'golddig2/goldlev012' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/goldlev012'\"
else
echo shar: Extracting \"'golddig2/goldlev012'\" \(3556 characters\)
sed "s/^X//" >'golddig2/goldlev012' <<'END_OF_FILE'
X70 50
X                                                                      
X                                                !----------------     
X                                                  $$k ##       k$^    
X                                                 ^^ ^ ^^  ^^^^ ^^^    
X                            @@@                  ^^   ^k^ ^ ^k ^^     
X                           @@$@                  ^^### ^^ ^^^^^^^     
X                           @$|@ @@@@@             ^$$^#$^k^^ ##^^     
X                        @@@@$|@ @$$ @@           ^^^^^^ ^^ ^^^^$^     
X                        @$---|@@@|-$ @           ^k^ ^^ ^^^k^^^^^     
X                        @$  $|$   $|$$           ^^^$$$$^k^$$^^ ^     
X                       @@@@|@@@@@@@@@@@|         ^## ^^^##^^ ^###     
X                       @  b|           |         ^^^ ^^^^#^^ ^^k^     
X                       @|@@@@@@|@@@@@|#|         | k$$$ $^|^ ^^^^     
X                       @|   @|-| @ $ |@|         | ^^^^ ^^^^$$^^^     
X                       @| $ @|-$$@$|$|@|         |    k^ ^k^^^ #^     
X                       @|$|$@$-|$@|@@@@|  #      | ^^^^^ ^^ ^^^^^     
X                       @|$|$@|  $@|$ $@ |#       |                    
X                       @| | @|$  @$|$|@ |=#|-----|                    
X@@@@@@@@@@@@@@@      @@@@@@@@@@@@@@@@@@@@@@@     |                    
Xd<<<<<<<<<<<<<<      @ $$$$$$$$$$$$$$$$$$        |                    
Xd>>>>>>>>>>>>df    @@@ #############|####f<<     |                    
Xdfd<<<<<<<<<<df    $$$<>>>>>>>>>>>>df<|>dff|k    |####@#|             
Xdfd>>>>>>>>dfdf    |=|kf<<d<<>>>>dd>fdfd<<<f     |     @              
X f f <<<<<< f f    #j#>>>fkdffd<<d>>>ffd>>|f     |###@#j              
X f f -    f f f    #j#fd<|>>ffddf|f>>>f>fk|f     |    @               
Xbfbfb $$$ fbfbf    #j#fdk|>>>|ddfdffkd<<<<df     |##@#j               
Xdfdfd ### fdfdf!   #j#f>ffd<<<<kfdfff<>>dfdf     |   @                
Xdfdfd     fdfdf    #j#fd<fd>d>>>f>>ff<fk<fdf     |#@#j                
Xdfdf>>>>>>fdfdf    #j#fdffdf<f|<<<<d<|f<<f<f     |  @                 
Xdfdf<<<<<<<<fdf    #j#fdff>>>fd<><fdff>kff>f     |@#j      @          
Xdf>>>>>>>>>>fdf    #j#fdf|<<|<|>f>fdff|>ffd      |@|$$$    @          
Xdf<<<<<<<<<<<<f    #j#fdf<<<<d<<<fddfffd<f<      |@@@@@@@@@@          
Xd         >>  f    #j#f>>d>d|>>|ff<<d|fdf<|k@    |         -          
X>>>>>>>>>>f####|-- #j#fd<dfdfd<d|<d<dffd>df    -=========== @|        
X  b    b    b     |#j#fdf>fdfdfdkf<f<ff>fdf  |#- #        @ @|        
X$$yyyyyyyyyyyyyyy#|#j#fdf<<<fdf|>>>>>|fd<<f  |# #  $$$-t  @s@|        
X#|y#|########|#|#   |  >>>>>|>>>d>>>>>|>>>f  |@>===>>>>>  @ @|        
Xy|yy|y$$yyyyy|y|@@@@@@@@@       >f           |@@@@@@@@@@  @  |        
X#####y|#y#|###y|@           #                |         tc @  @        
Xyyyyyy|yyy|yyyy|@###@@@@|    #       #       |   t-$$$--  @@@@        
Xy###|#######|#y|@   @   |        #           |   <<<<<<<<@            
Xyyyy|yyyyyyy|yy|@###@   |  $ #   $   $ |     |   @@@@@@@@             
Xy#|########|##y|    @ b |    $## $ $ $ |     |  ct                    
Xyy|yy$$yyyy|y$y|@@@@@   | #    $      $|     |   --$$$-t              
Xy|##y#|y#|##y|y|@       | $ ##   $ $   |     | @>>>>>>>>              
Xy|yyyy|yy|yyy|y|@       |#  $$ $#   $ #|     |  @@@@@@@@              
X###########|##y|@       |  #     $   $ |     |         tc             
X$$yyyyyyyyy|yyy|@       | $# $   # # # |     |  ---$$$--              
X#|y##|########y|@       |      $   $   |     |  <<<<<<<<<@|           
Xy|yyy|yyyyyyyy |@  lx  p|###   ##   ## |     |  @@@@@@@@@ |           
END_OF_FILE
if test 3556 -ne `wc -c <'golddig2/goldlev012'`; then
    echo shar: \"'golddig2/goldlev012'\" unpacked with wrong size!
fi
# end of 'golddig2/goldlev012'
fi
if test -f 'golddig2/goldlev013' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/goldlev013'\"
else
echo shar: Extracting \"'golddig2/goldlev013'\" \(3556 characters\)
sed "s/^X//" >'golddig2/goldlev013' <<'END_OF_FILE'
X70 50
X   -------------   d             d                                    
X ######## | | | |@-~-------------~----------------#|                  
X #######  | | | |@dd<<<<d>>dd>>>d |||||||||||||||||#|                 
X #######  | | | |@fd<<<>f<>dd>>dd ||||||||||||||||-j#|                
X #######  | | | |@fdff<ff<<ddfd<d |||||||||||||||||# |#yyyyyyyyyyyyyy|
X #######  | | | |@fd>>>>f>fd>f>dd |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X #######  | | | |@fd>>>>ff>dfffdd |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X $$$$$$# > >  |>|@f><<d>>f>dfffdd |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X ####### f| | | |@fd>ff<f<<dfffdd |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X ####### f|<|<|<|@f<f<fddf>dfffdd |||||||||||||||||#v|#yyyyyyyyyyyy$ |
X #######  | | |f|@f>d<d>f<fd|<<<d |||||||||||||||||#v|#yyyyyyyyyyyy##|
X ####### >|>|>|f|@ff>>>>dd>ddddfd |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X ####### f| | | |@f<ff<<d><d>>dfd |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X ####### f|<|<|<|@fd>f>ddd>dddddd |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X $$$$$$#  | | |f|@f<<f<<<<<<dd>dd |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X ####### > > >|f|@kkkkkkkkkkkkkd> |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X ####### f| | | |@>>>>>>>>>>>>>d# |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X ####### f|<|<|<|@| |$|$|$|$|$|d# |||||||||||||||||#v|#yyyyyyyyyyyyyy|
X #######  # # | |@|q|$|$|$|$|$|d# |||||||||||||||||#vv#@@@@@@@@@@@@@@@
X ####### |    |j|@| |$|$|$|$|$| # |||||||||||||||||#vv                
X ####### |#b #| |@| |$|$|$|$|$| # |||||||||||||||||#v>>>>>>>>         
X $$$$$$# |####| |@| |$|$|$|$|$| # |||||||||||||||||#v<d<<<<<<-->>>>>>>
X ####### ||-|-| |@| |$|$|$|$|$| # |||||||||||||||||# fd        f      
X ####### || | | |@| |-|-|-|-|-| # |||||||||||||||||# fd        f      
X ######$ || | | | < | | | | | | # |||||||||||||||||# fd  a   d-f      
X #######@@@@@@@@|####g#g#g#g#g#g# |||||||||||||||||# fd      d        
X ####### kg     |#m|m|m|m|m|m|m|#k#||||||||||||||||# fd      d        
X #######kj-od   |################################### fd      d        
X $$$$$$# <j-gd  |----------------------------------| f>>>>>>>d        
X #######  >j-gd |                                  | f<<<<<<<$<       
X #######   dj-gd|                                  |         #        
X #######d$$ fj-g|                                  |                  
X #######d###g-jg| r                               |r $$$$$$$$$$$$$$$$ 
X #######  dg-jg |#v#y#y#y#y#y#y#y#y#y#y#y#y#y#y#y##v##################
X ####### dg-jg  |#vy#y#y#y#y#y#y#y#y#y#y#y#y#y#y#y#v#|--              
X $$$$$$#dg-jg   |#v#y#y#y#y#y#y#y#y#y#y#y#y#y#y#y##v#| @ $            
Xb#######g-jg    |#vy#y#y#y#y#y#y#y#y#y#y#y#y#y#y#y#v#| @@@            
X        -jg    $|#v#y#y#y#y#y#y#y#y#y#y#y#y#y#y#y##v#|                
Xm@      j p$$$$$|#vy#y#y#y#y#y#y#y#y#y#y#y#y#y#y#y#v#|                
X@@@@@@@#@@@@@@@@@#v#y#y#y#y#y#y#y#y#y#y#y#y#y#y#y##v#|                
X b           b #t#vy#y#y#y#y#y#y#y#y#y#y#y#y#y#y#y#v#|                
Xt|t|t|t|t|t|t|t# #v#y#y#y#y#y#y#y#y#y#y#y#y#y#y#y##v#|                
X|$|$|$|$|$|$|$|# #vy#y#y#y $ y#y#y#y#y#y $ y#y#y#y#v#|      @ @ @ @ @ 
Xt| | | | | | |t# #v#y#y#y#####y#y#y#y#y#####y#y#y##v#|     @ = @ = @$@
X|$#$#$#$#$#$#$|# #v========== = == == = ===========v#|    u@v@v@v@v@v@
Xt|t|t|t|t|t|t|t#     e       # g     g #           # |     @v@v@v@v@v@
X|$|$|$|$|$|$|$|# #####|                           $  |  !-|@v@v@v@v@v@
Xt|t|t|t|t|t|t|t#-#$   |#                         |#  |  !@|@v@v@v@v@v@
X|$|$|$|$|$|$|r|# ###### # ----  b               |# # |@b!@|@v@v@v@v@v@
Xt|t|t|t|t|t---t#t######  #yyyyyyyyyyyyyyyyyyyyyy#   #|@@@@| |@|=|@|=|@
END_OF_FILE
if test 3556 -ne `wc -c <'golddig2/goldlev013'`; then
    echo shar: \"'golddig2/goldlev013'\" unpacked with wrong size!
fi
# end of 'golddig2/goldlev013'
fi
if test -f 'golddig2/goldlev014' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/goldlev014'\"
else
echo shar: Extracting \"'golddig2/goldlev014'\" \(1536 characters\)
sed "s/^X//" >'golddig2/goldlev014' <<'END_OF_FILE'
X50 30
X||||||||||||  |                  !               @
X|        # |  |                  !       b       @
X|@@@@@@@@# |  |                  !               @
X|@        #|##|------------      !               @
X|@|#@####@##@#|                  !               @
X|@|  |### @###|         #b###|###!$$$$$$$ $$$$$$ @
X|@|##@#@###@##|         #|###|##################|@
X|@|###########|         #|#$#|#$#|$$$$$$$ $$$$$$|@
X|@|$$$$$$$####|         #|###|###|###############@
X|@|###########|         #|#$#|#$#|$$$$$$$ $$$$$$|@
X|@@@@@@@@@@@@@|##########|###|##################|@
X|             |      |-|#|#$#|#$#|$$$$$$$ $$$$$$|@
X|   @@@@   - -|      |#|#|###|###|###############@
X|   @$     |         |#|#|#$#|#$#|               @
X|  @@@ @###############|#|###|###|               @
X|  @ @@@               |#|#$#|#$#|         #| |  @
X@@@@                   |#|###|################|  @
X                       |#|#$#|#$#            #|  @
X     |     |  #|# #|  #|#|###|###            #|  @
X#####|  ###|###|###|###|#|#$#|#$#            #|  @
X|  $-|$-## |$-#|$-#|#-$|#|###|###            #|  @
X|                      |#|#$#|#$#            #|  @
X|@@@@@@@@@@@@@@@@@@@@@@@#|#@$$$$$$           -| p@
X|#b$$$$$$$$$$$$$$$$$$$$$ |  ##################### 
X|####################### @                      b@
X|####################### @ @@@@@@@@@@@@@@@@@@@@@@@
X|!!!!!!!!!!!!!!!!!!!!|!!!!-    @ @ @--------------
X|!!!!!!!!!!!!!!!!!!!!|--|!- |@|@|@|@ $$$$$$$$$$$$|
X|!!!!!!!!!!!!!!!!!!!!|!!|!- |@| | |  ------------|
X|!!!!!!!!!!!!!!!!!!!!|!!|#@@@@@@@@@@@@@@@@@@@@@@@@
END_OF_FILE
if test 1536 -ne `wc -c <'golddig2/goldlev014'`; then
    echo shar: \"'golddig2/goldlev014'\" unpacked with wrong size!
fi
# end of 'golddig2/goldlev014'
fi
if test -f 'golddig2/goldlev015' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/goldlev015'\"
else
echo shar: Extracting \"'golddig2/goldlev015'\" \(1536 characters\)
sed "s/^X//" >'golddig2/goldlev015' <<'END_OF_FILE'
X50 30
Xl>            $$$$        $$$$                    
X|$##@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
X$|@                                              @
X|$@                                              @
X$|@                                              @
X|$@k$$                                           @
X$|@ ##@@@@@                   ##      # ##@@@@@@ @
X|$@ @|----|@                  ###     # @|-----|@@
X$|@ @|$$$$|@  $$$$$$$         # #     # @|$$$$$|@@
X|$@ @|$$$$|@|@@@@@@@@         # ##    # @|$$$$$|@@
X$|@ @|$$$$|@|                 #  #    # @|$$$$$|@@
X|$@ @|$$$$|@|                 #  ##   # @|$$$$$|@@
X$|@ @|$$$$|@| !!!!!!!-!#!     #   #   # @|$$$$$|@@
X|$@ @|----b@| k!!!!!!!#!!!    #   ##  # @|$$$$$|@@
X$|@ @@@@@@@ | k|----|@@@@@    #    #  # @|-----b@@
X|$@ @       | k|kk!!#bs  i    #    ## # @@@@@@@@ @
X$|@ @       | k|--|@@@@@@@    #     # # @        @
X|$@ @$      | kkkk#!!!!!!!    #     ### @        @
X$|@ @|------| !!!#!$!!!!!!    #       # @        @
X|$@ @|        !!!#!#!!!!!!    #       # @        @
X$|@ -|        !!!###!!!!!!                       @
X|$@     b                                        @
X$|@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##
X|$  $    $     $   b   $      $    $     $        
X ###############################################| 
X    $    $     $   b   $      $    $     $      |@
X|##########################|####################@w
X|   $    $     $   b   $      $    $     $      p!
X|################################################|
X|   $    $     $       $      $    $     $       |
END_OF_FILE
if test 1536 -ne `wc -c <'golddig2/goldlev015'`; then
    echo shar: \"'golddig2/goldlev015'\" unpacked with wrong size!
fi
# end of 'golddig2/goldlev015'
fi
if test -f 'golddig2/goldlev016' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/goldlev016'\"
else
echo shar: Extracting \"'golddig2/goldlev016'\" \(1536 characters\)
sed "s/^X//" >'golddig2/goldlev016' <<'END_OF_FILE'
X50 30
X#!b####b####b####b####b####b####b####b####b####b##
X !t    t    t    t    t    t    t    t    t    |  
X !|    |    |    |    |    |    |    |    |    |  
X$!|  $ |  $ |  $ | $$$| $$$| $$$|  $ | $ ||| $ | $
X|!| $| |  | |  | |  | |  | |  | |  | | | |t| | |$|
X##|####|####|####|####|####|####|####|###|||###|##
X  |    |    |    |    |    |    |   |||   |    |  
X$$|  $ |  $ |  $ |    |  $ |  $ |  $|t| $ |  $ |$$
X@@|@@@@|@@@@|@@@@|@@@@|@@@@|@@@@|@@@|||@@@|@@@@|@@
X  |    |    |    |    |    |   |||   |    |    |  
X$$|  $ |  $ |  $ |    |  $ |  $|t| $ |  $ |  $ |$$
X@@|@@@@|@@@@|@@@@|@@@@|@@@@|@@@|||@@@|@@@@|@@@@|@@
X  |    |    |    |    |   |||   |    |    |    |  
X$$|  $ |  $ |  $ |  $ |  $|t| $ |  $ |  $ |  $ |$$
X##|####|####|####|####|###|||###|####|####|####|##
X  |    |    |    |   |||   |    |    |    |    |  
X$$|  $ |  $ |  $ |  $|t| $ |  $ |  $ |  $ |  $ |$$
X##|####|####|####|###|||###|####|####|####|####|##
X  |    |    |   |||   |    |    |    |    |    |  
X$$|  $ |  $ |  $|t| $ |  $ |  $ |  $ |  $ |  $ |$$
X##|####|####|###|||###|####|####|####|####|####|##
X  |    |   |||   |    |    |    |    |    |    |  
X$$|  $ |  $|t| $ |  $ |  $ |  $ |  $ |  $ |  $ |$$
X##|####|###|||###|####|####|####|####|####|####|##
X  |   |||   |    |    |    |    |    |    |    |  
X$$|  $|t| $ |  $ |  $ |  $ |  $ |  $ |  $ |  $ |$$
X##|###|||###|####|####|####|####|####|####|####|##
X$|||   |    |    |    |    |    |    |    |    |  
Xp|t| $ |  $ |  $ |  $ |  $ |  $ |  $ |  $ |  $ |$$
X#|||##############################################
END_OF_FILE
if test 1536 -ne `wc -c <'golddig2/goldlev016'`; then
    echo shar: \"'golddig2/goldlev016'\" unpacked with wrong size!
fi
# end of 'golddig2/goldlev016'
fi
if test -f 'golddig2/goldlev018' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/goldlev018'\"
else
echo shar: Extracting \"'golddig2/goldlev018'\" \(1536 characters\)
sed "s/^X//" >'golddig2/goldlev018' <<'END_OF_FILE'
X50 30
X  b# $ $ $ $ $ $  i    $-- $-k  v  v |   -   |    
X>  #|@@@@@@@@@@@@#$    vk-kv--$ $--$k  | $- $  v -
X > #f$$------$~$#@#    | --|k -k|$k| -v  | v-$| v 
X   -==-|-------v####$   v$k $- $-| k$ |k|$ $ - - v
X m -===========f#@@##    | kv k|-$k--k   |--$k c  
X   f$$---------$~$####$   v$-$- $| -k|-$k  $|c$ k 
X   -=-|----------v#####    | = cv k$ v |$ -|k-|k |
X m -=============f#@@@##$   v$k-v$ -|$ k-|kk-| |  
X   f$$------------$~$####    | $|-$k$-v$ k$|- k - 
X   -=-|-------------v#####$   |-  |-|  | $| kk |  
X m -================f#@@@##    |-k  $-|$k- k$-  $$
X   f$$---------------$~$####$     -|v$ -$ck v ####
X   -=-|----------------v#@@@#   k-|  |- |c -|k    
X m -===================f  $$@#$#   k   $|c v      
X   f$$$~-#   $$v$$$$$$$$$$@|###        | -vk      
X   -===-|#   |@t@@#########|############  $       
X m |#@#@##   | v -~-|     i| ===========      $   
X   f$$~-#$$$$|$@ $  |    i |  $$$$$$ ==========   
X   -==-|#|#####t@$~-|   i  |   @@@@|           c  
X m |#@@##|$$$$@b $$ |  i   | b   b |            = 
X   f$~-#@@###|   $@ |  i   | $   $ |             =
X   -=-|#|---~|   $u |  i   | ~   ~ |              
X m |#@##|           |p#    | ~   ~ |              
X   f$~-#######@ @######    | ~   ~ |              
X   -=-|##@@@@@ t      i    | ~   ~ |              
X m |#@##$<<         ii     | ~   ~ |              
X   f$~-$~ f       ii       | ~   ~ |              
X>  -=-|$$#f   $ @ $$$$$$$$$|c~   ~c|$$$$$$$$$     
X > |#@#@@#f$ ~s$# |            @            | @   
X @m@$$$$$$ $@ #################=|#############=   
END_OF_FILE
if test 1536 -ne `wc -c <'golddig2/goldlev018'`; then
    echo shar: \"'golddig2/goldlev018'\" unpacked with wrong size!
fi
# end of 'golddig2/goldlev018'
fi
if test -f 'golddig2/makelev.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/makelev.c'\"
else
echo shar: Extracting \"'golddig2/makelev.c'\" \(6268 characters\)
sed "s/^X//" >'golddig2/makelev.c' <<'END_OF_FILE'
X/* This program was written by Alexander Siegel in September of 1989   */
X/* at Cornell University.  It may may copied freely for private use or */
X/* public dispersion provided that this comment is not removed.  This  */
X/* program, any portion of this program, or any derivative of this     */
X/* program may not be sold or traded for financial gain.               */
X
X/* Modified by Josh Siegel to work with NeWS/X11                       */
X
X#include <stdio.h>
X#include <X11/Xlib.h>
X#include <X11/keysym.h>
X#include <X11/Xutil.h>
X#include "golddig.h"
X
X#define EVMASK KeyPressMask | ExposureMask | ButtonMotionMask | ButtonPressMask
X
X/* Plug into original block type definitions in shared.c */
Xextern struct symbs_s symbs[];
X
X/* Current drawing character */
Xchar curchar = ' ';
X
X/* Redraw the entire level */
Xvoid redrawall()
X{
X  draw_level();
X  XFlush(disp);
X}
X
X/* Set the score to be equal to the number of gold pieces */
Xvoid count_gold()
X{
X  register int i,levsize;
X
X  levsize = xsize*ysize;
X  score = 0;
X  for(i=0;i<levsize;++i)
X    if(fast_lookup[level[i]].code & TREASURE)
X      score ++;
X}
X
X/* Main routine for editing levels */
Xvoid main(argc,argv)
Xint argc;
Xchar **argv;
X{
X  register int i;
X  static XEvent xev;
X  KeySym keyhit;
X  int keycount;
X  char buf[50];
X
X  /* Set up default values for describing world */
X  worldname = DEFWORLD;
X  levelnum = -1;
X  goldleft = 0;
X  score = 0;
X  speed = 0;
X  /* Use size of default level as default level size */
X  xsize = -1;
X  ysize = -1;
X
X  /* Read in command line options */
X  for(i=1;i<argc;++i) {
X    if(argv[i][0] == '-') {
X      /* -w sets the level width */
X      if(argv[i][1] == 'w') {
X        if(argv[i][2] == '\0' && i+1 < argc) {
X          sscanf(argv[i+1],"%d",&xsize);
X          i++;
X        }
X        else
X          sscanf(argv[i]+2,"%d",&xsize);
X      }
X      /* -h sets the level height */
X      else if(argv[i][1] == 'h') {
X        if(argv[i][2] == '\0' && i+1 < argc) {
X          sscanf(argv[i+1],"%d",&ysize);
X          i++;
X        }
X        else
X          sscanf(argv[i]+2,"%d",&ysize);
X      }
X      /* -l sets the level number */
X      else if(argv[i][1] == 'l') {
X        if(argv[i][2] == '\0' && i+1 < argc) {
X          sscanf(argv[i+1],"%d",&levelnum);
X          i++;
X        }
X        else
X          sscanf(argv[i]+2,"%d",&levelnum);
X      }
X      else {
X        printf("usage: makelev [-h <height>] [-w <width>] -l <level> [<world name>]\n");
X        exit(1);
X      }
X    }
X    /* If it doesn't start with a dash, it must a the world name */
X    else {
X      worldname = argv[i];
X      break;
X    }
X  }
X  /* Make sure some value was chosen for the level number.  This */
X  /* discourages everybody editing the same level all the time. */
X  if(levelnum == -1) {
X    printf("usage: levelmake [-h <height>] [-w <width>] -l <level> [<world name>]\n");
X    exit(1);
X  }
X
X  /* Load in level data from file. */
X  load_level();
X
X  printf("Welcome.  Type h for help.\n");
X
X  /* Start up X windows and create all graphics cursors */
X  xstart(EVMASK);
X  /* Set the name of the output window */
X  XStoreName(disp,wind,"Gold Digger 2.0 Level Generator");
X
X  /* Main event loop */
X  do {
X    /* Get the next X window event */
X    XWindowEvent(disp,wind,EVMASK,&xev);
X    /* If it was an expose event, redraw everything */
X    if(xev.type == Expose) {
X      /* Count the number of gold pieces in level */
X      count_gold();
X      /* Redraw the level */
X      redrawall();
X    }
X    else if(xev.type == KeyPress) {
X      keycount = XLookupString(&xev,buf,50,&keyhit,(XComposeStatus *) NULL);
X      /* If the 'h', '?' or '/' key was hit, print out the text */
X      /* descriptions of each block type */
X      if(keyhit == XK_H || keyhit == XK_h || keyhit == XK_question ||
X         keyhit == XK_slash) {
X        for(i=0;symbs[i].symb != '\0';++i)
X          if(! (symbs[i].code & NODRAW))
X            printf("%c - draw %ss\n",symbs[i].symb,symbs[i].name);
X        puts("Type ^W to finish editing and save the level.");
X        puts("Type ^C to quit editing.");
X        puts("Type ^E to erase level.");
X        puts("Use the left mouse button to paint blocks.");
X        puts("Use the right mouse button to erase blocks.");
X        putchar('\n');
X      }
X      /* A ^E erases the entire level */
X      else if((keyhit == XK_E || keyhit == XK_e) &&
X              (xev.xkey.state & ControlMask)) {
X        /* Replice level contents with space */
X        for(i=0;i<xsize*ysize;++i)
X          level[i] = SPACE;
X        /* There is no gold now */
X        score = 0;
X        /* Redraw empty level */
X        redrawall();
X      }
X      else {
X        /* Search through the block descriptions for one which has a */
X        /* key code which matches the key code of the key which was */
X        /* hit. */
X        for(i=0;symbs[i].symb != '\0';++i)
X          if(! (symbs[i].code & NODRAW))
X            if(keyhit == symbs[i].xkey1 || keyhit == symbs[i].xkey2) {
X              /* Change the current drawing character to the symbol */
X              /* which was found. */
X              curchar = symbs[i].symb;
X              /* Count and display the number of gold pieces in level */
X              count_gold();
X              draw_score();
X              break;
X            }
X      }
X    }
X    /* If the mouse moves with the button pressed, or the button is */
X    /* pressed, draw the current block at that position */
X    else if(xev.type == MotionNotify) {
X      if(xev.xmotion.state & Button3Mask)
X        setchar(xev.xmotion.x >> 4,xev.xmotion.y >> 4,SPACE);
X      else
X        setchar(xev.xmotion.x >> 4,xev.xmotion.y >> 4,curchar);
X    }
X    else if(xev.type == ButtonPress) {
X      if(xev.xbutton.button == Button3)
X        setchar(xev.xbutton.x >> 4,xev.xbutton.y >> 4,SPACE);
X      else
X        setchar(xev.xbutton.x >> 4,xev.xbutton.y >> 4,curchar);
X    }
X    /* Flush the graphics commands out to the server */
X    XFlush(disp);
X  /* Loop until a control key is pressed */
X  } while(xev.type != KeyPress ||
X          (keyhit != XK_C && keyhit != XK_c &&
X           keyhit != XK_W && keyhit != XK_w) ||
X          ! (xev.xkey.state & ControlMask));
X  
X  /* Terminated X windows connection */
X  xend();
X  /* Save level to data file */
X  if(keyhit == XK_W || keyhit == XK_w)
X    save_level();
X  exit(0);
X}
END_OF_FILE
if test 6268 -ne `wc -c <'golddig2/makelev.c'`; then
    echo shar: \"'golddig2/makelev.c'\" unpacked with wrong size!
fi
# end of 'golddig2/makelev.c'
fi
if test -f 'golddig2/scores.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'golddig2/scores.c'\"
else
echo shar: Extracting \"'golddig2/scores.c'\" \(3716 characters\)
sed "s/^X//" >'golddig2/scores.c' <<'END_OF_FILE'
X/* This program was written by Alexander Siegel in September of 1989   */
X/* at Cornell University.  It may may copied freely for private use or */
X/* public dispersion provided that this comment is not removed.  This  */
X/* program, any portion of this program, or any derivative of this     */
X/* program may not be sold or traded for financial gain.               */
X
X#include <stdio.h>
X#include <X11/Xlib.h>
X#include <X11/keysym.h>
X#include "golddig.h"
X
Xchar *getenv(),*sprintf();
X
X#define NUMHIGH 15  /* Number of high scores that will be remembered */
X
X/* Add a high score to the high score list */
Xvoid add_score(whydie)
Xchar *whydie;       /* Textual description of reason for death */
X{
X  /* Structure containing top game results */
X  struct {
X    int score;      /* Final score */
X    int slev,elev;  /* Starting and ending level */
X    int uid;        /* Player account uid */
X    char desc[80];  /* Text description */
X  } tops[NUMHIGH],next;
X  FILE *sfile;      /* High score file */
X  char buf[200];
X  register int i;
X  int numscore,cur,numgame;
X
X  /* Generate name of high score file */
X  sprintf(buf,"%s/scores",LIB);
X  /* Open high score file */
X  sfile = fopen(buf,"r");
X  /* Set default values for number of games and high scores */
X  numscore = 0;
X  numgame = 0;
X  /* If file is readable, load in old high score list */
X  if(sfile != NULL) {
X    /* Load a line on text */
X    if(fgets(buf,200,sfile))
X      sscanf(buf,"%d",&numgame);
X    /* Extract score information from line */
X    while(fgets(buf,200,sfile) && numscore < NUMHIGH) {
X      sscanf(buf,"%d %d %d %d %[^\n]",&(next.score),&(next.slev),&(next.elev),
X         &(next.uid),next.desc);
X      tops[numscore] = next;
X      numscore ++;
X    }
X    fclose(sfile);
X  }
X
X  /* Contruct the structure containing the score for this game */
X  next.score = score;
X  next.slev = levelstart;
X  next.elev = levelnum;
X  next.uid = getuid();
X  sprintf(next.desc,"%s %s",getenv("USER"),whydie);
X  cur = -1;
X  /* Insert new score in old high score list */
X  if(numscore < NUMHIGH || tops[NUMHIGH - 1].score < next.score) {
X    /* Iterate through high score list */
X    for(i = (numscore >= NUMHIGH ? NUMHIGH-2 : numscore-1);i >= 0;i--) {
X      /* Look for place for insertion */
X      if(next.score > tops[i].score)
X        tops[i+1] = tops[i];    /* Move old scores down one place in list */
X      else
X        break;                  /* Found spot for insertion */
X    }
X    tops[i+1] = next;   /* Overwrite entry in high score list */
X    cur = i+1;          /* Remember where new high score was inserted */
X    /* Increment the number of high scores */
X    if(numscore < NUMHIGH)
X      numscore ++;
X  }
X
X  /* Increment and print the number of games played */
X  numgame ++;
X  printf("High scores after %d games played:\n",numgame);
X  /* Print out new high score list */
X  for(i=0;i<numscore;++i) {
X    /* Flag new high score with a leading > */
X    if(i == cur)
X      putchar('>');
X    else
X      putchar(' ');
X    printf("%s on level %d (started at %d).  Final score was %d.\n",
X       tops[i].desc,tops[i].elev,tops[i].slev,tops[i].score);
X  }
X  /* If current game did not make it to the high score list, print it */
X  /* afterwords */
X  if(cur == -1) {
X    puts("...");
X    printf(">%s on level %d (started at %d).  Final score was %d.\n",
X       next.desc,next.elev,next.slev,next.score);
X  }
X
X  /* Save new high score list to score file */
X  sprintf(buf,"%s/scores",LIB);
X  sfile = fopen(buf,"w");
X  if(sfile == NULL) {
X    perror(buf);
X    return;
X  }
X  fprintf(sfile,"%d\n",numgame);
X  for(i=0;i<numscore;++i)
X    fprintf(sfile,"%d %d %d %d %s\n",tops[i].score,tops[i].slev,
X         tops[i].elev,tops[i].uid,tops[i].desc);
X  fclose(sfile);
X}
END_OF_FILE
if test 3716 -ne `wc -c <'golddig2/scores.c'`; then
    echo shar: \"'golddig2/scores.c'\" unpacked with wrong size!
fi
# end of 'golddig2/scores.c'
fi
echo shar: End of archive 2 \(of 4\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 4 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0