home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / engarde / part02 < prev    next >
Encoding:
Internet Message Format  |  1992-02-04  |  10.3 KB

  1. Path: uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  2. From: wjames@Jupiter.SAIC.Com (Bill James x6167)
  3. Newsgroups: comp.sources.x
  4. Subject: v16i041: engarde - an X/MOTIF strategy game, Part02/02
  5. Message-ID: <1992Feb5.145740.20795@msi.com>
  6. Date: 5 Feb 92 14:57:40 GMT
  7. References: <csx-16i040-engarde@uunet.UU.NET>
  8. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  9. Organization: Molecular Simulations, Inc.
  10. Lines: 311
  11. Approved: dcmartin@msi.com
  12. Originator: dcmartin@fascet
  13.  
  14. Submitted-by: Bill James x6167 <wjames@Jupiter.SAIC.Com>
  15. Posting-number: Volume 16, Issue 41
  16. Archive-name: engarde/part02
  17.  
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  21. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  22. # If this archive is complete, you will see the following message at the end:
  23. #        "End of archive 2 (of 2)."
  24. # Contents:  Makefile board.h engarde.RULES patchlevel.h sun40add.c
  25. #   xboard.h
  26. # Wrapped by dcmartin@fascet on Fri Jan 24 08:36:43 1992
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'Makefile'\"
  30. else
  31. echo shar: Extracting \"'Makefile'\" \(550 characters\)
  32. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  33. XINCDIR = -I/usr/include/X11/Motif1.0
  34. XLIBS = -lXm -lXt -lX11 
  35. XLIBDIR = -L/usr/lib/X11/Motif1.0 -L/usr/lib
  36. XCFLAGS = -D_NO_PROTO $(INCDIR) -O
  37. XLFLAGS = -s
  38. X
  39. X# Use this for SunOs 4.0x, if the MOTIF libraries were compiled with 4.1x
  40. XTOBJS = engarde.o board.o xboard.o menus.o sun40add.o
  41. X
  42. X# Use this for SunOs 4.1x 
  43. X# TOBJS = engarde.o board.o xboard.o menus.o 
  44. X
  45. X
  46. Xengarde: $(TOBJS)
  47. X    cc -o engarde $(LFLAGS) $(LIBDIR) $(TOBJS) $(LIBS)
  48. X
  49. Xboard.o: board.h xboard.h
  50. Xxboard.o: board.h xboard.h menus.h
  51. Xengarde.o: board.h xboard.h bitmaps.h help.h
  52. Xmenus.o: menus.h
  53. END_OF_FILE
  54. if test 550 -ne `wc -c <'Makefile'`; then
  55.     echo shar: \"'Makefile'\" unpacked with wrong size!
  56. fi
  57. # end of 'Makefile'
  58. fi
  59. if test -f 'board.h' -a "${1}" != "-c" ; then 
  60.   echo shar: Will not clobber existing file \"'board.h'\"
  61. else
  62. echo shar: Extracting \"'board.h'\" \(750 characters\)
  63. sed "s/^X//" >'board.h' <<'END_OF_FILE'
  64. X#define POSITIVE    1
  65. X#define NEGATIVE    -1
  66. X#define UNCHARGED    0
  67. X#define BOARD_WIDTH    6
  68. X#define BOARD_HEIGHT    6
  69. X#define PIECE_BLACK    1
  70. X#define PIECE_WHITE    0
  71. X#define PIECE_ROUND    0
  72. X#define PIECE_SQUARE    1
  73. X#define NPIECES        6
  74. X
  75. X#define MIN2(x,y)    (((x)<(y))? (x):(y))
  76. X
  77. Xstruct _PieceType {
  78. X   int color;
  79. X   int type;
  80. X};
  81. Xtypedef struct _PieceType PieceType;
  82. X
  83. Xstruct _SideType {
  84. X   PieceType *p[6];
  85. X};
  86. Xtypedef struct _SideType SideType;
  87. X
  88. Xvoid FlipPiece();
  89. X
  90. Xstruct _BoardType {
  91. X   char **magnets;
  92. X   PieceType ***pieces;
  93. X   int height, width;
  94. X};
  95. Xtypedef struct _BoardType BoardType;
  96. X
  97. Xvoid Magnetize();
  98. Xvoid KillBoard();
  99. Xvoid InitBoard();
  100. XPieceType * GetPiece();
  101. Xint GetPolarity();
  102. Xint MovePiece();
  103. Xvoid BoardShuffle();
  104. Xint SumSet();
  105. Xint CheckWinner();
  106. Xvoid Randomize();
  107. END_OF_FILE
  108. if test 750 -ne `wc -c <'board.h'`; then
  109.     echo shar: \"'board.h'\" unpacked with wrong size!
  110. fi
  111. # end of 'board.h'
  112. fi
  113. if test -f 'engarde.RULES' -a "${1}" != "-c" ; then 
  114.   echo shar: Will not clobber existing file \"'engarde.RULES'\"
  115. else
  116. echo shar: Extracting \"'engarde.RULES'\" \(3657 characters\)
  117. sed "s/^X//" >'engarde.RULES' <<'END_OF_FILE'
  118. X
  119. X                             ENGARDE v1.0
  120. X--------------------------------------------------------------------------
  121. X      A game written for X11R4 with OSF/MOTIF widgets by Bill James.
  122. X--------------------------------------------------------------------------
  123. X
  124. XOBJECT:
  125. X
  126. XTo have 4 pieces in a row, column, diagonal that are all of one player's 
  127. Xcolor, that player is to be considered the winner.
  128. X
  129. X
  130. XDESIGNATIONS:
  131. X
  132. X -  The center set of squares is know as the "grid".
  133. X -  The single columns to the right and left of the grid are
  134. X      called "side-bars", possible preceded by a "left" or "right".
  135. X -  The squares and circles are called "pieces", with the unfilled
  136. X      piece being "white", and the filled piece being "black".
  137. X
  138. X
  139. XCHARACTERISTICS OF THE BOARD:
  140. X
  141. X    Each piece is to be considered a magnet with one pole painted 
  142. Xwhite, and the other painted black.  A piece is considered to be
  143. Xwhite if the white side is face up, else it is black.  On circular 
  144. Xpieces the positive side is painted white, while on the squares it 
  145. Xis the negative side.  The grid is also merely a set of magnetized 
  146. Xsquares, with either the positive or negative side facing upwards.
  147. XThe grid also contains spaces that are not magnets at all, but are 
  148. Xmerely null spots, and do not affect the pieces at all.  
  149. X
  150. XExamples:
  151. XSample Grid :
  152. X    
  153. X   + + - + O -     + = positive grid face up
  154. X   - - + - + -     - = negative grid face up
  155. X   O - + - - +     O = null grid space
  156. X   + + - + + -
  157. X   - + + O - -
  158. X   - - - - + +
  159. X
  160. XEvery new game, the board shuffles it's magnets to form a new
  161. Xgrid.
  162. X
  163. XWhen a player moves a piece onto the grid, the magnetic interactions
  164. Xcause the piece to show the color painted on the magnet side with
  165. Xthe same polarity as the grid place.  e.g. when a piece moves on
  166. Xa positive grid place, the positive side of the magnet is repulsed, 
  167. Xand is therefore face up.
  168. X
  169. X  Before Move          After Move Piece is:
  170. X   Piece is:      When moved onto grid with magnet:
  171. X--------------------------------------------------
  172. X| Shape | Color ||| Positive | Negative |  Null  |
  173. X--------------------------------------------------
  174. X|  SQU  |  Wh   |||    Bl    |    Wh    |   Wh   |   
  175. X|  SQU  |  Bl   |||    Bl    |    Wh    |   Bl   |
  176. X|  CIR  |  Wh   |||    Wh    |    Bl    |   Wh   |
  177. X|  CIR  |  Bl   |||    Wh    |    Bl    |   Bl   |
  178. X--------------------------------------------------
  179. X
  180. XRULES OF MOVEMENT:
  181. X
  182. XThe arrows to either side of the message box designate whose turn it is.
  183. XThis player has the following options:
  184. X
  185. X1.  The player may take a piece from his side-bar and place it
  186. X    on any space on the center grid where there is no other piece.
  187. X
  188. X2.  The player may move any piece that is currently on the grid
  189. X    EXCEPT the last piece moved to another spot guided by these rules:
  190. X    2a.  Piece cannot move to occupied place.
  191. X    2b.  Piece may only move in one direction.
  192. X    2c.  Piece cannot move more than 2 spaces in a single direction,
  193. X           either Up, Down, Left, Right, or the Diagonals.
  194. X    2d.  Piece may only be moved 2 spaces in a direction if the first
  195. X           space in that direction is occupied (it jumps the first piece).
  196. X    2e.  Piece may not be placed back onto side-bar.
  197. X    
  198. X
  199. XSTRATEGY HINTS:
  200. X
  201. X - Try to save a piece on your side-bar, being able to place it anywhere
  202. X      on the grid may save your neck.
  203. X
  204. X - Try to keep track of what polarity the grid locations are as you find
  205. X      them out, they won't change until the next game.
  206. X
  207. X - Don't forget about the null spaces.  If a piece keeps the same color
  208. X      when it moves, a null space is always a possibility.
  209. X
  210. X----------------------------------------------------------------------------
  211. END_OF_FILE
  212. if test 3657 -ne `wc -c <'engarde.RULES'`; then
  213.     echo shar: \"'engarde.RULES'\" unpacked with wrong size!
  214. fi
  215. # end of 'engarde.RULES'
  216. fi
  217. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  218.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  219. else
  220. echo shar: Extracting \"'patchlevel.h'\" \(25 characters\)
  221. sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  222. X#define PATCHLEVEL    "1.0"
  223. END_OF_FILE
  224. if test 25 -ne `wc -c <'patchlevel.h'`; then
  225.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  226. fi
  227. # end of 'patchlevel.h'
  228. fi
  229. if test -f 'sun40add.c' -a "${1}" != "-c" ; then 
  230.   echo shar: Will not clobber existing file \"'sun40add.c'\"
  231. else
  232. echo shar: Extracting \"'sun40add.c'\" \(470 characters\)
  233. sed "s/^X//" >'sun40add.c' <<'END_OF_FILE'
  234. X/*********************************************************************
  235. X                                Engarde
  236. X                           File: sun40add.c
  237. X
  238. X  This file is needed by SunOs 4.0x in order to compile correctly with
  239. X  MOTIF libraries compiled with SunOs 4.1x .  Do not add this unless
  240. X  necessary.
  241. X
  242. X  Version 1:  1/9/92  (Bill James)
  243. X*********************************************************************/
  244. Xchar tolower(c)
  245. Xchar c;
  246. X{
  247. X   return(c - 'A' + 'a');
  248. X}
  249. END_OF_FILE
  250. if test 470 -ne `wc -c <'sun40add.c'`; then
  251.     echo shar: \"'sun40add.c'\" unpacked with wrong size!
  252. fi
  253. # end of 'sun40add.c'
  254. fi
  255. if test -f 'xboard.h' -a "${1}" != "-c" ; then 
  256.   echo shar: Will not clobber existing file \"'xboard.h'\"
  257. else
  258. echo shar: Extracting \"'xboard.h'\" \(1062 characters\)
  259. sed "s/^X//" >'xboard.h' <<'END_OF_FILE'
  260. X#define DRAWLEFTSIDE    10
  261. X#define DRAWRIGHTSIDE    11
  262. X#define STR_BAD_MOVE    "Cannot move there."
  263. X#define STR_BAD_SELECT  "Space is Empty."
  264. X#define STR_RIGHT_WIN    "The Right Side WINS!!"
  265. X#define STR_LEFT_WIN    "The Left Side WINS!!"
  266. X#define STR_MOVE_LAST    "Cannot move piece last moved by other player."
  267. X#define STR_SIDE_MOVE   "Cannot move piece back on side bars."
  268. X#define STR_WRONG_SIDE  "Cannot move piece from other player's side bar."
  269. X#define STR_FAR_MOVE    "Cannot move piece that far."
  270. X#define STR_MUST_JUMP   "Cannot move piece 2 spaces without a jump."
  271. X#define STR_SAME_DIR    "Must move piece 1 or 2 in same direction."
  272. X
  273. X#define ABS(x)    (((x)<0)? (-1*(x)):(x))
  274. X#define SGN(x)    (((x)<0)? -1:(((x) == 0)? 0:1))
  275. X
  276. Xstruct _Pt {
  277. X  int x;
  278. X  int y;
  279. X};
  280. Xtypedef struct _Pt Pt;
  281. X
  282. Xvoid DrawGame();
  283. Xvoid DrawRect();
  284. Xvoid DrawSpace();
  285. Xvoid GetXVals();
  286. Xvoid ResizeGame();
  287. Xvoid DrawPiece();
  288. Xvoid ButtonPress1();
  289. Xvoid MvPiece();
  290. XPieceType * DGetPiece();
  291. Xint CheckMove();
  292. Xvoid ResetBoard();
  293. Xvoid ChangeTurn();
  294. Xvoid ShowHelp();
  295. Xvoid CloseHelp();
  296. Xvoid ShowAbout();
  297. Xvoid CloseAbout();
  298. END_OF_FILE
  299. if test 1062 -ne `wc -c <'xboard.h'`; then
  300.     echo shar: \"'xboard.h'\" unpacked with wrong size!
  301. fi
  302. # end of 'xboard.h'
  303. fi
  304. echo shar: End of archive 2 \(of 2\).
  305. cp /dev/null ark2isdone
  306. MISSING=""
  307. for I in 1 2 ; do
  308.     if test ! -f ark${I}isdone ; then
  309.     MISSING="${MISSING} ${I}"
  310.     fi
  311. done
  312. if test "${MISSING}" = "" ; then
  313.     echo You have unpacked both archives.
  314.     rm -f ark[1-9]isdone
  315. else
  316.     echo You still need to unpack the following archives:
  317.     echo "        " ${MISSING}
  318. fi
  319. ##  End of shell archive.
  320. exit 0
  321. -- 
  322. Molecular Simulations, Inc.             mail: dcmartin@msi.com
  323. 796 N. Pastoria Avenue                  uucp: uunet!dcmartin
  324. Sunnyvale, California 94086             at&t: 408/522-9236
  325.