2 * Copyright (c) 2002 by Edwin de Jong <mauddib@gmx.net>.
4 * Permission to use, copy, modify, and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted,
6 * provided that the above copyright notice appear in all copies and that
7 * both that copyright notice and this permission notice appear in
8 * supporting documentation.
10 * This file is provided AS IS with no warranties of any kind. The author
11 * shall have no liability with respect to the infringement of copyrights,
12 * trade secrets or any patents by this file or any part thereof. In no
13 * event will the author be liable for any lost revenue or profits or
14 * other special, indirect and consequential damages.
17 * 3-May-2002: Added AI to pacman and ghosts, slowed down ghosts.
18 * 26-Nov-2001: Random level generator added
19 * 01-Nov-2000: Allocation checks
20 * 04-Jun-1997: Compatible with xscreensaver
28 #include "xlockmoreI.h"
33 #define GETNB(n) ((1 << (n)) - 1)
34 #define TESTNB(v, n) (((1 << (n)) & v) != 0x00)
35 #define SNB(v, n) ((v) |= (1 << (n)))
36 #define UNSNB(v, n) ((v) &= ~(1 << (n)))
45 #define START ((LRAND() & 1) ? 1 : 3)
48 #define YELLOW (MI_NPIXELS(mi) / 6)
49 #define GREEN (23 * MI_NPIXELS(mi) / 64)
50 #define BLUE (45 * MI_NPIXELS(mi) / 64)
51 #define WHITE (MI_NPIXELS(mi))
58 #define GETFACTOR(x, y) ((x) > (y) ? 1 : ((x) < (y) ? -1 : 0))
59 #define SIGN(x) GETFACTOR((x), 0)
62 typedef struct { int vx, vy; } tracevec_struct;
64 typedef enum { inbox = 0, goingout, randdir, chasing, hiding } GhostState;
65 typedef enum { ps_eating = 0, ps_chasing, ps_hiding, ps_random } PacmanState;
66 typedef enum { GHOST_DANGER, GHOST_EATEN } GameState;
69 unsigned int col, row;
70 unsigned int lastbox, nextcol, nextrow;
84 unsigned int col, row;
85 unsigned int lastbox, nextcol, nextrow;
86 int mouthstage, mouthdirection;
93 tracevec_struct trace[TRACEVECS];
104 unsigned short width, height;
105 unsigned short nrows, ncols;
106 short xs, ys, xb, yb;
112 unsigned int nghosts;
113 Pixmap pacmanPixmap[4][MAXMOUTH];
114 /* Pixmap ghostPixmap[4][MAXGPOS];*/
115 /* Pixmap ghostPixmap; */
116 Pixmap ghostPixmap[4][MAXGDIR][MAXGWAG];
117 /* Pixmap ghostMask[4][MAXGDIR][MAXGWAG]; */
119 char level[LEVHEIGHT * LEVWIDTH];
120 unsigned int wallwidth;
121 unsigned int dotsleft;
122 int spritexs, spriteys, spritedx, spritedy;
125 unsigned int timeleft;
130 extern pacmangamestruct *pacmangames;
131 extern Bool trackmouse;
133 typedef char lev_t[LEVHEIGHT][LEVWIDTH + 1];
135 #endif /* __PACMAN_H__ */