1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Copyright (c) 2002 by Edwin de Jong <mauddib@gmx.net>.
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation for any purpose and without fee is hereby granted,
7 * provided that the above copyright notice appear in all copies and that
8 * both that copyright notice and this permission notice appear in
9 * supporting documentation.
11 * This file is provided AS IS with no warranties of any kind. The author
12 * shall have no liability with respect to the infringement of copyrights,
13 * trade secrets or any patents by this file or any part thereof. In no
14 * event will the author be liable for any lost revenue or profits or
15 * other special, indirect and consequential damages.
18 * 3-May-2002: Added AI to pacman and ghosts, slowed down ghosts.
19 * 26-Nov-2001: Random level generator added
20 * 01-Nov-2000: Allocation checks
21 * 04-Jun-1997: Compatible with xscreensaver
29 #include "xlockmoreI.h"
31 #if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM)
33 #include "xpm-pixmap.h"
35 #if defined(USE_PIXMAP)
43 #define GETNB(n) ((1 << (n)) - 1)
44 #define TESTNB(v, n) (((1 << (n)) & v) != 0x00)
45 #define SNB(v, n) ((v) |= (1 << (n)))
46 #define UNSNB(v, n) ((v) &= ~(1 << (n)))
48 #if defined(USE_PIXMAP)
60 #define START ((LRAND() & 1) ? 1 : 3)
63 #define YELLOW (MI_NPIXELS(mi) / 6)
64 #define GREEN (23 * MI_NPIXELS(mi) / 64)
65 #define BLUE (45 * MI_NPIXELS(mi) / 64)
66 #define WHITE (MI_NPIXELS(mi))
73 #define GETFACTOR(x, y) ((x) > (y) ? 1 : ((x) < (y) ? -1 : 0))
74 #define SIGN(x) GETFACTOR((x), 0)
76 #define PAC_DEATH_FRAMES 8
78 #define GHOST_TRACE ( LEVWIDTH * LEVHEIGHT )
86 { inbox = 0, goingout, randdir, chasing, hiding, goingin } GhostState;
88 { ps_eating = 0, ps_chasing, ps_hiding, ps_random, ps_dieing } PacmanState;
90 { GHOST_DANGER, GHOST_EATEN } GameState;
94 volatile unsigned int col, row;
95 unsigned int lastbox, nextcol, nextrow;
100 volatile int timeleft;
107 tracevec_struct trace[GHOST_TRACE];
109 volatile int home_count;
110 tracevec_struct way_home[GHOST_TRACE];
111 volatile int wait_pos; /* a cycle before calculating the position */
112 #if 0 /* Used for debugging */
117 #if 0 /* Used for debugging */
118 char last_stat[1024];
125 unsigned int col, row;
126 unsigned int lastbox, nextcol, nextrow;
127 int mouthstage, mouthdirection;
128 int cfactor, rfactor;
134 tracevec_struct trace[TRACEVECS];
148 unsigned short width, height;
149 unsigned short nrows, ncols;
150 short xs, ys, xb, yb;
156 unsigned int nghosts;
157 Pixmap pacmanPixmap[4][MAXMOUTH];
158 Pixmap pacmanMask[4][MAXMOUTH];
159 Pixmap pacman_ds[PAC_DEATH_FRAMES]; /* pacman death sequence */
160 Pixmap pacman_ds_mask[PAC_DEATH_FRAMES];
161 Pixmap ghostPixmap[4][MAXGDIR][MAXGWAG];
163 Pixmap s_ghostPixmap[MAXGFLASH][MAXGWAG]; /* Scared ghost Pixmaps */
164 Pixmap ghostEyes[MAXGDIR];
165 char level[LEVHEIGHT * LEVWIDTH];
166 unsigned int wallwidth;
167 unsigned int dotsleft;
168 int spritexs, spriteys, spritedx, spritedy;
171 unsigned int timeleft;
176 extern pacmangamestruct *pacmangames;
177 extern Bool trackmouse;
179 typedef char lev_t[LEVHEIGHT][LEVWIDTH + 1];
181 #define NUM_BONUS_DOTS 4
183 #endif /* __PACMAN_H__ */