home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!zephyr.ens.tek.com!master!saab!billr
- From: billr@saab.CNA.TEK.COM (Bill Randle)
- Newsgroups: comp.sources.games
- Subject: v13i025: engarde - an X/MOTIF strategy game involving "magnets", Part02/02
- Message-ID: <2344@masterCNA.TEK.COM>
- Date: 25 Jan 92 01:24:29 GMT
- Sender: news@masterCNA.TEK.COM
- Lines: 358
- Approved: billr@saab.CNA.TEK.COM
-
- Submitted-by: Bill James <wjames@Jupiter.SAIC.COM>
- Posting-number: Volume 13, Issue 25
- Archive-name: engarde/Part02
- Environment: SUNOS SYSVR4 X11R4 MOTIF Sun HP
-
-
- #! /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 2)."
- # Contents: Makefile board.h engarde.RULES menus.c menus.h
- # patchlevel.h sun40add.c
- # Wrapped by billr@saab on Fri Jan 24 17:21:01 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(550 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- XINCDIR = -I/usr/include/X11/Motif1.0
- XLIBS = -lXm -lXt -lX11
- XLIBDIR = -L/usr/lib/X11/Motif1.0 -L/usr/lib
- XCFLAGS = -D_NO_PROTO $(INCDIR) -O
- XLFLAGS = -s
- X
- X# Use this for SunOs 4.0x, if the MOTIF libraries were compiled with 4.1x
- XTOBJS = engarde.o board.o xboard.o menus.o sun40add.o
- X
- X# Use this for SunOs 4.1x
- X# TOBJS = engarde.o board.o xboard.o menus.o
- X
- X
- Xengarde: $(TOBJS)
- X cc -o engarde $(LFLAGS) $(LIBDIR) $(TOBJS) $(LIBS)
- X
- Xboard.o: board.h xboard.h
- Xxboard.o: board.h xboard.h menus.h
- Xengarde.o: board.h xboard.h bitmaps.h help.h
- Xmenus.o: menus.h
- END_OF_FILE
- if test 550 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'board.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'board.h'\"
- else
- echo shar: Extracting \"'board.h'\" \(750 characters\)
- sed "s/^X//" >'board.h' <<'END_OF_FILE'
- X#define POSITIVE 1
- X#define NEGATIVE -1
- X#define UNCHARGED 0
- X#define BOARD_WIDTH 6
- X#define BOARD_HEIGHT 6
- X#define PIECE_BLACK 1
- X#define PIECE_WHITE 0
- X#define PIECE_ROUND 0
- X#define PIECE_SQUARE 1
- X#define NPIECES 6
- X
- X#define MIN2(x,y) (((x)<(y))? (x):(y))
- X
- Xstruct _PieceType {
- X int color;
- X int type;
- X};
- Xtypedef struct _PieceType PieceType;
- X
- Xstruct _SideType {
- X PieceType *p[6];
- X};
- Xtypedef struct _SideType SideType;
- X
- Xvoid FlipPiece();
- X
- Xstruct _BoardType {
- X char **magnets;
- X PieceType ***pieces;
- X int height, width;
- X};
- Xtypedef struct _BoardType BoardType;
- X
- Xvoid Magnetize();
- Xvoid KillBoard();
- Xvoid InitBoard();
- XPieceType * GetPiece();
- Xint GetPolarity();
- Xint MovePiece();
- Xvoid BoardShuffle();
- Xint SumSet();
- Xint CheckWinner();
- Xvoid Randomize();
- END_OF_FILE
- if test 750 -ne `wc -c <'board.h'`; then
- echo shar: \"'board.h'\" unpacked with wrong size!
- fi
- # end of 'board.h'
- fi
- if test -f 'engarde.RULES' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'engarde.RULES'\"
- else
- echo shar: Extracting \"'engarde.RULES'\" \(3657 characters\)
- sed "s/^X//" >'engarde.RULES' <<'END_OF_FILE'
- X
- X ENGARDE v1.0
- X--------------------------------------------------------------------------
- X A game written for X11R4 with OSF/MOTIF widgets by Bill James.
- X--------------------------------------------------------------------------
- X
- XOBJECT:
- X
- XTo have 4 pieces in a row, column, diagonal that are all of one player's
- Xcolor, that player is to be considered the winner.
- X
- X
- XDESIGNATIONS:
- X
- X - The center set of squares is know as the "grid".
- X - The single columns to the right and left of the grid are
- X called "side-bars", possible preceded by a "left" or "right".
- X - The squares and circles are called "pieces", with the unfilled
- X piece being "white", and the filled piece being "black".
- X
- X
- XCHARACTERISTICS OF THE BOARD:
- X
- X Each piece is to be considered a magnet with one pole painted
- Xwhite, and the other painted black. A piece is considered to be
- Xwhite if the white side is face up, else it is black. On circular
- Xpieces the positive side is painted white, while on the squares it
- Xis the negative side. The grid is also merely a set of magnetized
- Xsquares, with either the positive or negative side facing upwards.
- XThe grid also contains spaces that are not magnets at all, but are
- Xmerely null spots, and do not affect the pieces at all.
- X
- XExamples:
- XSample Grid :
- X
- X + + - + O - + = positive grid face up
- X - - + - + - - = negative grid face up
- X O - + - - + O = null grid space
- X + + - + + -
- X - + + O - -
- X - - - - + +
- X
- XEvery new game, the board shuffles it's magnets to form a new
- Xgrid.
- X
- XWhen a player moves a piece onto the grid, the magnetic interactions
- Xcause the piece to show the color painted on the magnet side with
- Xthe same polarity as the grid place. e.g. when a piece moves on
- Xa positive grid place, the positive side of the magnet is repulsed,
- Xand is therefore face up.
- X
- X Before Move After Move Piece is:
- X Piece is: When moved onto grid with magnet:
- X--------------------------------------------------
- X| Shape | Color ||| Positive | Negative | Null |
- X--------------------------------------------------
- X| SQU | Wh ||| Bl | Wh | Wh |
- X| SQU | Bl ||| Bl | Wh | Bl |
- X| CIR | Wh ||| Wh | Bl | Wh |
- X| CIR | Bl ||| Wh | Bl | Bl |
- X--------------------------------------------------
- X
- XRULES OF MOVEMENT:
- X
- XThe arrows to either side of the message box designate whose turn it is.
- XThis player has the following options:
- X
- X1. The player may take a piece from his side-bar and place it
- X on any space on the center grid where there is no other piece.
- X
- X2. The player may move any piece that is currently on the grid
- X EXCEPT the last piece moved to another spot guided by these rules:
- X 2a. Piece cannot move to occupied place.
- X 2b. Piece may only move in one direction.
- X 2c. Piece cannot move more than 2 spaces in a single direction,
- X either Up, Down, Left, Right, or the Diagonals.
- X 2d. Piece may only be moved 2 spaces in a direction if the first
- X space in that direction is occupied (it jumps the first piece).
- X 2e. Piece may not be placed back onto side-bar.
- X
- X
- XSTRATEGY HINTS:
- X
- X - Try to save a piece on your side-bar, being able to place it anywhere
- X on the grid may save your neck.
- X
- X - Try to keep track of what polarity the grid locations are as you find
- X them out, they won't change until the next game.
- X
- X - Don't forget about the null spaces. If a piece keeps the same color
- X when it moves, a null space is always a possibility.
- X
- X----------------------------------------------------------------------------
- END_OF_FILE
- if test 3657 -ne `wc -c <'engarde.RULES'`; then
- echo shar: \"'engarde.RULES'\" unpacked with wrong size!
- fi
- # end of 'engarde.RULES'
- fi
- if test -f 'menus.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'menus.c'\"
- else
- echo shar: Extracting \"'menus.c'\" \(2093 characters\)
- sed "s/^X//" >'menus.c' <<'END_OF_FILE'
- X/*********************************************************************
- X Engarde
- X File: menus.c
- X
- X This file contains a convenience function to create menus from
- X a structure tree.
- X
- X Version 1: 1/9/92 (Bill James)
- X*********************************************************************/
- X#include <X11/Intrinsic.h>
- X#include <X11/StringDefs.h>
- X#include <Xm/Xm.h>
- X#include <Xm/Separator.h>
- X#include <Xm/PushB.h>
- X#include <Xm/CascadeB.h>
- X#include <Xm/RowColumn.h>
- X#include <Xm/Label.h>
- X#include "menus.h"
- X
- Xvoid xs_create_menu_buttons(title, menu, menulist, nitems)
- Xchar *title;
- XWidget menu;
- Xxs_menu_struct *menulist;
- Xint nitems;
- X{
- XArg wargs[1];
- Xint i;
- XWidgetList buttons;
- Xint separators = 0;
- X buttons = (WidgetList) XtMalloc (nitems * sizeof(Widget));
- X if (title) {
- X XtCreateManagedWidget(title, xmLabelWidgetClass, menu, NULL, 0);
- X XtCreateManagedWidget("separator", xmSeparatorWidgetClass, menu, NULL,0);
- X }
- X for (i = 0; i < nitems; i++) {
- X if (menulist[i].name == NULL) {
- X XtCreateManagedWidget("separator", xmSeparatorWidgetClass,
- X menu, NULL, 0);
- X separators++;
- X }
- X else if (menulist[i].func) {
- X buttons[i-separators] = XtCreateWidget(menulist[i].name,
- X xmPushButtonWidgetClass,
- X menu, NULL, 0);
- X XtAddCallback(buttons[i-separators], XmNactivateCallback,
- X menulist[i].func, menulist[i].data);
- X }
- X else if (!menulist[i].sub_menu)
- X buttons[i-separators] = XtCreateWidget(menulist[i].name,
- X xmLabelWidgetClass,
- X menu, NULL, 0);
- X else {
- X Widget sub_menu;
- X sub_menu = XmCreatePulldownMenu(menu, menulist[i].sub_menu_title,
- X NULL, 0);
- X XtSetArg(wargs[0], XmNsubMenuId, sub_menu);
- X buttons[i-separators] = XtCreateWidget(menulist[i].name,
- X xmCascadeButtonWidgetClass,
- X menu, wargs, 1);
- X xs_create_menu_buttons(menulist[i].sub_menu_title, sub_menu,
- X menulist[i].sub_menu, menulist[i].n_sub_items);
- X }
- X }
- X XtManageChildren(buttons, nitems - separators);
- X}
- END_OF_FILE
- if test 2093 -ne `wc -c <'menus.c'`; then
- echo shar: \"'menus.c'\" unpacked with wrong size!
- fi
- # end of 'menus.c'
- fi
- if test -f 'menus.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'menus.h'\"
- else
- echo shar: Extracting \"'menus.h'\" \(211 characters\)
- sed "s/^X//" >'menus.h' <<'END_OF_FILE'
- Xtypedef struct _menu_struct {
- X char * name;
- X void (*func)();
- X caddr_t data;
- X struct _menu_struct *sub_menu;
- X int n_sub_items;
- X char *sub_menu_title;
- X} xs_menu_struct;
- X
- Xvoid xs_create_menu_buttons();
- END_OF_FILE
- if test 211 -ne `wc -c <'menus.h'`; then
- echo shar: \"'menus.h'\" unpacked with wrong size!
- fi
- # end of 'menus.h'
- fi
- if test -f 'patchlevel.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'patchlevel.h'\"
- else
- echo shar: Extracting \"'patchlevel.h'\" \(25 characters\)
- sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
- X#define PATCHLEVEL "1.0"
- END_OF_FILE
- if test 25 -ne `wc -c <'patchlevel.h'`; then
- echo shar: \"'patchlevel.h'\" unpacked with wrong size!
- fi
- # end of 'patchlevel.h'
- fi
- if test -f 'sun40add.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sun40add.c'\"
- else
- echo shar: Extracting \"'sun40add.c'\" \(470 characters\)
- sed "s/^X//" >'sun40add.c' <<'END_OF_FILE'
- X/*********************************************************************
- X Engarde
- X File: sun40add.c
- X
- X This file is needed by SunOs 4.0x in order to compile correctly with
- X MOTIF libraries compiled with SunOs 4.1x . Do not add this unless
- X necessary.
- X
- X Version 1: 1/9/92 (Bill James)
- X*********************************************************************/
- Xchar tolower(c)
- Xchar c;
- X{
- X return(c - 'A' + 'a');
- X}
- END_OF_FILE
- if test 470 -ne `wc -c <'sun40add.c'`; then
- echo shar: \"'sun40add.c'\" unpacked with wrong size!
- fi
- # end of 'sun40add.c'
- fi
- echo shar: End of archive 2 \(of 2\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked both 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
-