# define MODE_pacman
# define DEFAULTS "*delay: 10000 \n" \
"*size: 0 \n" \
- "*ncolors: 6 \n"
+ "*ncolors: 6 \n" \
+ "*fpsTop: true \n" \
+ "*fpsSolid: true \n" \
+
# define UNIFORM_COLORS
# define BRIGHT_COLORS
-# define reshape_pacman 0
# define pacman_handle_event 0
# include "xlockmore.h" /* in xscreensaver distribution */
# include <assert.h>
};
static argtype vars[] = {
- {&trackmouse, "trackmouse", "TrackMouse", DEF_TRACKMOUSE, t_Bool}
+ {&pacman_trackmouse, "trackmouse", "TrackMouse", DEF_TRACKMOUSE, t_Bool}
};
static OptionStruct desc[] = {
#endif
-Bool trackmouse;
-pacmangamestruct *pacmangames = (pacmangamestruct *) NULL;
+Bool pacman_trackmouse;
+pacmangamestruct *pacman_games = (pacmangamestruct *) NULL;
static void repopulate (ModeInfo * mi);
static void drawlevel (ModeInfo * mi);
static void
reset_level (ModeInfo * mi, int n, int pac_init)
{
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
unsigned int ghost;
MI_CLEARWINDOW (mi);
pp->ghosts[ghost].delta.y = 0;
pp->ghosts[ghost].flash_scared = False;
pp->ghosts[ghost].wait_pos = False;
- ghost_update (pp, &(pp->ghosts[ghost]));
+ pacman_ghost_update (pp, &(pp->ghosts[ghost]));
}
- pac_update (mi, pp, &(pp->pacman));
+ pacman_update (mi, pp, &(pp->pacman));
}
static int
Display *display = MI_DISPLAY (mi);
Window window = MI_WINDOW (mi);
unsigned int ghost;
- int alldead;
if (pp->pacman.aistate == ps_dieing) return;
- alldead = 1;
for (ghost = 0; ghost < pp->nghosts; ghost++) {
/* The ghost have to be scared before you can kill them */
}
continue;
}
-
- alldead = 0;
}
-
-
}
/* Resets state of ghosts + pacman. Creates a new level, draws that level. */
static void
repopulate (ModeInfo * mi)
{
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
pp->pacman.deaths = 0;
- reset_level (mi, createnewlevel (pp), True);
+ reset_level (mi, pacman_createnewlevel (pp), True);
check_death (mi, pp);
}
setwallcolor (ModeInfo * mi)
{
Display *display = MI_DISPLAY (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
if (MI_NPIXELS (mi) > 2)
XSetForeground (display, pp->stippledGC, MI_PIXEL (mi, BLUE));
setdotcolor (ModeInfo * mi)
{
Display *display = MI_DISPLAY (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
XSetForeground (display, pp->stippledGC, MI_WHITE_PIXEL (mi));
}
cleardotcolor (ModeInfo * mi)
{
Display *display = MI_DISPLAY (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
XSetForeground (display, pp->stippledGC, MI_BLACK_PIXEL (mi));
}
{
Display *display = MI_DISPLAY (mi);
Window window = MI_WINDOW (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
XFontStruct *font = NULL;
char *f_name = "-*-utopia-*-r-*-*-*-600-*-*-p-*-*-*";
char *s = NULL;
{
Display *display = MI_DISPLAY (mi);
Window window = MI_WINDOW (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
XFontStruct *font = NULL;
char *f_name = "-*-utopia-*-r-*-*-*-600-*-*-p-*-*-*";
char *s = NULL;
{
Display *display = MI_DISPLAY (mi);
Window window = MI_WINDOW (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
int h = MI_HEIGHT (mi);
int w = MI_WIDTH (mi);
int y = 0;
{
Display *display = MI_DISPLAY (mi);
Window window = MI_WINDOW (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
XFontStruct *font = NULL;
char *f_name = "-*-utopia-*-r-*-*-*-600-*-*-p-*-*-*";
static void
print_pac_stats ( ModeInfo *mi, pacmanstruct *pac )
{
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
char s[1024];
sprintf (s, "Pacman, Deaths: %d", pac->deaths );
switch ( pac->aistate ){
static void
dot_rc_to_pixel (ModeInfo * mi, int *x, int *y)
{
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
*x = (pp->xs * *x) +
(pp->xs / 2) - (pp->xs > 32 ? (pp->xs / 16) : 1) + pp->xb;
*y = (pp->ys * *y) +
static void
dot_width_height (ModeInfo *mi, int *w, int *h)
{
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
if (pp->xs > 32){
*w = *h = (pp->xs / 32 );
}else {
static void
drawlevel (ModeInfo * mi)
{
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
unsigned int x, y;
for (y = 0; y < LEVHEIGHT; y++)
{
Display *display = MI_DISPLAY (mi);
Window window = MI_WINDOW (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
unsigned int dir = 0;
int old_mask_dir = 0;
int old_mask_mouth = 0;
pp->pacman.oldcf = pp->pacman.cf;
pp->pacman.oldrf = pp->pacman.rf;
}
- old_mask_dir = dir;
- old_mask_mouth = pp->pm_mouth;
}
#if 0
{
Display *display = MI_DISPLAY (mi);
Window window = MI_WINDOW (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
#define MAX_WAG_COUNT 50
unsigned int dir = 0;
unsigned int fs = 0; /*flash scared*/
{
Display *display = MI_DISPLAY (mi);
Window window = MI_WINDOW (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
unsigned int dir;
pp->pacman.cf = pp->pacman.col * pp->xs + pp->pacman.delta.x *
{
Display *display = MI_DISPLAY (mi);
Window window = MI_WINDOW (mi);
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
pp->ghosts[ghost].cf =
pp->ghosts[ghost].col * pp->xs + pp->ghosts[ghost].delta.x *
{
int ghost = 0;
int ret = False;
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
dot_rc_to_pixel (mi, &x, &y);
for (ghost = 0; ghost < pp->nghosts; ghost++) {
if ((pp->ghosts[ghost].cf <= x
flash_bonus_dots (ModeInfo * mi)
{
#define MAX_FLASH_COUNT 25
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
int i, x, y;
for (i = 0; i < NUM_BONUS_DOTS; i++) {
- if (!bonus_dot_eaten (pp, i)) {
- bonus_dot_pos (pp, i, &x, &y);
+ if (!pacman_bonus_dot_eaten (pp, i)) {
+ pacman_bonus_dot_pos (pp, i, &x, &y);
if (ghost_over (mi, x, y))
continue;
if (pp->bd_on)
*/
unsigned int ret = 0;
int idx = 0;
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
- if (is_bonus_dot (pp, pp->pacman.col, pp->pacman.row, &idx)) {
- ret = !bonus_dot_eaten (pp, idx);
- eat_bonus_dot (pp, idx);
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+ if (pacman_is_bonus_dot (pp, pp->pacman.col, pp->pacman.row, &idx)) {
+ ret = !pacman_bonus_dot_eaten (pp, idx);
+ pacman_eat_bonus_dot (pp, idx);
}
return ret;
}
ghost_scared (ModeInfo * mi)
{
unsigned int ghost;
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
for (ghost = 0; ghost < pp->nghosts; ghost++) {
if (pp->ghosts[ghost].aistate == goingin ||
pp->ghosts[ghost].aistate == goingout ||
ghost_not_scared (ModeInfo * mi)
{
unsigned int ghost;
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
for (ghost = 0; ghost < pp->nghosts; ghost++){
if (pp->ghosts[ghost].aistate == goingin ||
pp->ghosts[ghost].aistate == goingout ||
ghost_flash_scared (ModeInfo * mi)
{
unsigned int ghost;
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
for (ghost = 0; ghost < pp->nghosts; ghost++)
pp->ghosts[ghost].flash_scared = !pp->ghosts[ghost].flash_scared;
}
#define START_FLASH 200
#define FLASH_COUNT 25
- pacmangamestruct *pp = &pacmangames[MI_SCREEN (mi)];
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
unsigned int ghost;
#if 0
draw_grid (mi);
int dir, mouth;
#endif
- if (pacmangames == NULL) {
- if ((pacmangames = (pacmangamestruct *)
+ if (pacman_games == NULL) {
+ if ((pacman_games = (pacmangamestruct *)
calloc ((size_t) MI_NUM_SCREENS (mi),
sizeof (pacmangamestruct))) == NULL)
return;
}
- pp = &pacmangames[MI_SCREEN (mi)];
+ pp = &pacman_games[MI_SCREEN (mi)];
pp->width = (unsigned short) MI_WIDTH (mi);
pp->height = (unsigned short) MI_HEIGHT (mi);
pp->spriteys = MAX (pp->ys + (pp->ys >> 1) - 1, 1);
pp->spritedx = (pp->xs - pp->spritexs) >> 1;
pp->spritedy = (pp->ys - pp->spriteys) >> 1;
- pp->old_pac_state = chasing;
+ pp->old_pac_state = ps_chasing;
if (!pp->stippledGC) {
gcv.foreground = MI_BLACK_PIXEL (mi);
unsigned int g;
pacmangamestruct *pp;
- if (pacmangames == NULL)
+ if (pacman_games == NULL)
return;
- pp = &pacmangames[MI_SCREEN (mi)];
+ pp = &pacman_games[MI_SCREEN (mi)];
if (pp->ghosts == NULL)
return;
pp->pacman.delta.y += pp->pacman.err.y != 0 ? pp->incy : 0;
if (pp->pacman.delta.x >= pp->xs && pp->pacman.delta.y >= pp->ys) {
- pac_update (mi, pp, &(pp->pacman));
+ pacman_update (mi, pp, &(pp->pacman));
check_death (mi, pp);
pp->pacman.delta.x = pp->incx;
pp->pacman.delta.y = pp->incy;
if (pp->ghosts[g].delta.x >= pp->xs &&
pp->ghosts[g].delta.y >= pp->ys) {
- ghost_update (pp, &(pp->ghosts[g]));
+ pacman_ghost_update (pp, &(pp->ghosts[g]));
pp->ghosts[g].delta.x = pp->incx;
pp->ghosts[g].delta.y = pp->incy;
}
ENTRYPOINT void
release_pacman (ModeInfo * mi)
{
- if (pacmangames != NULL) {
+ if (pacman_games != NULL) {
int screen;
for (screen = 0; screen < MI_NUM_SCREENS (mi); screen++)
- free_pacman (MI_DISPLAY (mi), &pacmangames[screen]);
- free (pacmangames);
- pacmangames = (pacmangamestruct *) NULL;
+ free_pacman (MI_DISPLAY (mi), &pacman_games[screen]);
+ free (pacman_games);
+ pacman_games = (pacmangamestruct *) NULL;
}
}
pacman_tick (mi);
}
+ENTRYPOINT void
+reshape_pacman(ModeInfo * mi, int width, int height)
+{
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+ pp->width = width;
+ pp->height = height;
+ MI_CLEARWINDOW (mi);
+ /* repopulate (mi); */
+ drawlevel (mi);
+}
+
#ifndef STANDALONE
/* Callback to change level. */
ENTRYPOINT void