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"
30 #if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM)
32 #include "xpm-pixmap.h"
34 #if defined(USE_PIXMAP)
42 #define GETNB(n) ((1 << (n)) - 1)
43 #define TESTNB(v, n) (((1 << (n)) & v) != 0x00)
44 #define SNB(v, n) ((v) |= (1 << (n)))
45 #define UNSNB(v, n) ((v) &= ~(1 << (n)))
47 #if defined(USE_PIXMAP)
58 #define START ((LRAND() & 1) ? 1 : 3)
61 #define YELLOW (MI_NPIXELS(mi) / 6)
62 #define GREEN (23 * MI_NPIXELS(mi) / 64)
63 #define BLUE (45 * MI_NPIXELS(mi) / 64)
64 #define WHITE (MI_NPIXELS(mi))
71 #define GETFACTOR(x, y) ((x) > (y) ? 1 : ((x) < (y) ? -1 : 0))
72 #define SIGN(x) GETFACTOR((x), 0)
75 typedef struct { int vx, vy; } tracevec_struct;
77 typedef enum { inbox = 0, goingout, randdir, chasing, hiding } GhostState;
78 typedef enum { ps_eating = 0, ps_chasing, ps_hiding, ps_random } PacmanState;
79 typedef enum { GHOST_DANGER, GHOST_EATEN } GameState;
82 unsigned int col, row;
83 unsigned int lastbox, nextcol, nextrow;
97 unsigned int col, row;
98 unsigned int lastbox, nextcol, nextrow;
99 int mouthstage, mouthdirection;
100 int cfactor, rfactor;
106 tracevec_struct trace[TRACEVECS];
117 unsigned short width, height;
118 unsigned short nrows, ncols;
119 short xs, ys, xb, yb;
125 unsigned int nghosts;
126 Pixmap pacmanPixmap[4][MAXMOUTH];
127 Pixmap pacmanMask[4][MAXMOUTH];
128 Pixmap ghostPixmap[4][MAXGDIR][MAXGWAG];
130 char level[LEVHEIGHT * LEVWIDTH];
131 unsigned int wallwidth;
132 unsigned int dotsleft;
133 int spritexs, spriteys, spritedx, spritedy;
136 unsigned int timeleft;
141 extern pacmangamestruct *pacmangames;
142 extern Bool trackmouse;
144 typedef char lev_t[LEVHEIGHT][LEVWIDTH + 1];
146 #endif /* __PACMAN_H__ */