This is the doxygen documentation for gtkboard.

.
Main Page   Data Structures   File List   Data Fields   Globals  

pacman.c

Go to the documentation of this file.
00001 /*  This file is a part of gtkboard, a board games system.
00002     Copyright (C) 2003, Arvind Narayanan <arvindn@users.sourceforge.net>
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
00017 
00018 */
00019 #include <stdio.h>
00020 #include <string.h>
00021 #include <assert.h>
00022 #include <stdlib.h>
00023 #include <math.h>
00024 #include <gdk/gdkkeysyms.h>
00025 
00026 #include "game.h"
00027 #include "aaball.h"
00028 
00029 #define PACMAN_CELL_SIZE 25
00030 #define PACMAN_NUM_PIECES 48
00031 
00032 #define PACMAN_BOARD_WID 26
00033 #define PACMAN_BOARD_HEIT 25
00034 
00035 char pacman_colors[6] = {100, 150, 200, 100, 150, 200};
00036 
00037 int * pacman_init_pos = NULL;
00038 
00039 //#define PACMAN_WALL 1
00040 #define PACMAN_FOOD 1
00041 #define PACMAN_POWER 2
00042 #define PACMAN_EMPTY 3
00043 #define PACMAN_IS_EDIBLE(x) (x>=1 && x<=3)
00044 #define PACMAN_PAC_MIN 28
00045 #define PACMAN_PAC_MAX 32
00046 #define PACMAN_PAC_UP 28
00047 #define PACMAN_PAC_DOWN 29
00048 #define PACMAN_PAC_RIGHT 30
00049 #define PACMAN_PAC_LEFT 31
00050 #define PACMAN_IS_PAC(x) ((x) >= PACMAN_PAC_MIN && (x) < PACMAN_PAC_MAX)
00051 //#define PACMAN_GHOST_MASK 4
00052 #define PACMAN_IS_GHOST(x) ((x) >= 4 && x < 20)
00053 #define PACMAN_GET_GHOST(x) ((x)-(x)%4)
00054 #define PACMAN_GET_GHOST_NUM(x) (PACMAN_GET_GHOST(x)/4-1)
00055 /*#define PACMAN_GHOST_INKY 5
00056 #define PACMAN_GHOST_PINKY 6
00057 #define PACMAN_GHOST_BLINKY 7
00058 #define PACMAN_GHOST_SUE 8*/
00059 //#define PACMAN_IS_GHOST(x) ((x) >= PACMAN_GHOST_INKY && (x) <= PACMAN_GHOST_SUE)
00060 
00061 #define PACMAN_WALL_MASK 32
00062 #define PACMAN_WALL_UP    8
00063 #define PACMAN_WALL_DOWN  4
00064 #define PACMAN_WALL_LEFT  2
00065 #define PACMAN_WALL_RIGHT 1
00066 
00067 int pacman_maze[PACMAN_BOARD_HEIT][PACMAN_BOARD_WID] = 
00068 {
00069         {32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32},
00070         {32, 2, 1, 1, 1, 1, 1,32, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,32, 1, 1, 1, 1, 1, 2,32},
00071         {32, 1,32,32,32,32, 1,32, 1,32,32,32,32,32,32,32,32, 1,32, 1,32,32,32,32, 1,32},
00072         {32, 1,32,32,32,32, 1,32, 1,32,32,32,32,32,32,32,32, 1,32, 1,32,32,32,32, 1,32},
00073         {32, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,32},
00074         {32,32,32, 1,32,32, 1,32,32,32,32, 1,32,32, 1,32,32,32,32, 1,32,32, 1,32,32,32},
00075         {32,32,32, 1,32,32, 1, 1, 1, 1, 1, 1,32,32, 1, 1, 1, 1, 1, 1,32,32, 1,32,32,32},
00076         {32, 1, 1, 1,32,32,32,32, 1,32,32,32,32,32,32,32,32, 1,32,32,32,32, 1, 1, 1,32},
00077         {32, 1, 1, 1,32,32,32,32, 1,32,32,32,32,32,32,32,32, 1,32,32,32,32, 1, 1, 1,32},
00078         {32,32,32, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,32,32,32},
00079         {32,32,32, 1,32,32,32,32, 1,32,32,32,32,32,32, 1,32, 1,32,32,32,32, 1,32,32,32},
00080         {32,32,32, 1,32,32,32,32, 1,32, 7, 3,15, 3, 3, 3,32, 1,32,32,32,32, 1,32,32,32},
00081         {32,32,32, 1,32,32, 1, 1, 1,32, 3,11, 3,19, 3, 3,32, 1, 1, 1,32,32, 1,32,32,32},
00082         {32,32,32, 1,32,32, 1,32, 1,32,32,32,32,32,32,32,32, 1,32, 1,32,32, 1,32,32,32},
00083         {32, 1, 1, 1, 1, 1, 1,32, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,32, 1, 1, 1, 1, 1, 1,32},
00084         {32,32,32, 1,32,32,32,32,32,32,32, 1,32,32, 1,32,32,32,32,32,32,32, 1,32,32,32},
00085         {32,32,32, 1, 1, 1, 1, 1, 1, 1, 1, 1,32,32, 1, 1, 1, 1, 1, 1, 1, 1, 1,32,32,32},
00086         {32,32,32, 1,32,32,32,32, 1,32,32,32,32,32,32,32,32, 1,32,32,32,32, 1,32,32,32},
00087         {32,32,32, 1,32,32,32,32, 1,32,32,32,32,32,32,32,32, 1,32,32,32,32, 1,32,32,32},
00088         {32, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,32},
00089         {32, 1,32,32,32, 1,32,32,32,32,32, 1,32,32, 1,32,32,32,32,32, 1,32,32,32, 1,32},
00090         {32, 1,32,32,32, 1,32,32, 1, 1, 1, 1,32,32, 1, 1, 1, 1,32,32, 1,32,32,32, 1,32},
00091         {32, 1,32,32,32, 1,32,32, 1,32,32,32,32,32,32,32,32, 1,32,32, 1,32,32,32, 1,32},
00092         {32, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,32},
00093         {32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32},
00094 };
00095 
00096 static char * brown_square_25_xpm[]=
00097 {
00098 "25 25 2 1",
00099 "  c none",
00100 ". c #443333",
00101 ".........................",
00102 ".........................",
00103 ".........................",
00104 ".........................",
00105 ".........................",
00106 ".........................",
00107 ".........................",
00108 ".........................",
00109 ".........................",
00110 ".........................",
00111 ".........................",
00112 ".........................",
00113 ".........................",
00114 ".........................",
00115 ".........................",
00116 ".........................",
00117 ".........................",
00118 ".........................",
00119 ".........................",
00120 ".........................",
00121 ".........................",
00122 ".........................",
00123 ".........................",
00124 ".........................",
00125 ".........................",
00126 
00127 };
00128 
00129 
00130 void pacman_init ();
00131 
00132 Game Pacman = { PACMAN_CELL_SIZE, PACMAN_BOARD_WID, PACMAN_BOARD_HEIT, 
00133         PACMAN_NUM_PIECES,
00134         pacman_colors,  NULL, NULL, "Pacman", pacman_init};
00135 
00136 
00137 static void pacman_set_init_pos (Pos *pos);
00138 static char ** pacman_get_pixmap (int idx, int color);
00139 static int pacman_getmove_kb (Pos *cur_pos, int key, Player glob_to_play, 
00140                 byte **move, int **);
00141 static int pacman_animate (Pos *pos, byte **movp);
00142 
00143 
00144 void pacman_init ()
00145 {
00146         game_single_player = TRUE;
00147         game_set_init_pos = pacman_set_init_pos;
00148         game_get_pixmap = pacman_get_pixmap;
00149         game_getmove_kb = pacman_getmove_kb;
00150         game_animation_time = 100;
00151         game_animate = pacman_animate;
00152         game_doc_about = 
00153                 "Pacman\n"
00154                 "Single player game\n"
00155                 "Status: Partially implemented (currently unplayable)\n"
00156                 "URL: "GAME_DEFAULT_URL ("pacman");
00157 }
00158 
00159 void pacman_get_cur_pos (byte *pos, int *x, int *y)
00160 {
00161         int i, j;
00162         for (i=0; i<board_wid; i++)
00163                 for (j=0; j<board_heit; j++)
00164                         if (PACMAN_IS_PAC(pos [j * board_wid + i]))
00165                         { *x = i; *y = j; return;
00166                         }
00167 }
00168 
00169 static short dist[PACMAN_BOARD_WID][PACMAN_BOARD_HEIT];
00170 
00171 // FIXME: avoid recursion
00172 void pacman_recursive_dist (byte *pos, int x, int y, int val)
00173 {
00174         if (x < 0 || y < 0 || x >= board_wid || y >= board_heit) return;
00175         if (pos[y * board_wid + x] & PACMAN_WALL_MASK) return;
00176         if (dist[x][y] >= 0 && dist[x][y] < val) return;
00177         dist[x][y] = val;
00178         pacman_recursive_dist (pos, x+1, y, val+1);
00179         pacman_recursive_dist (pos, x-1, y, val+1);
00180         pacman_recursive_dist (pos, x, y+1, val+1);
00181         pacman_recursive_dist (pos, x, y-1, val+1);
00182 }
00183 
00184 void pacman_set_dist (byte *pos)
00185 {
00186         int i, j;
00187         int curx, cury;
00188         pacman_get_cur_pos (pos, &curx, &cury);
00189         for (i=0; i<board_wid; i++)
00190         for (j=0; j<board_heit; j++)
00191                 dist[i][j] = -1;
00192         dist[curx][cury] = 1;
00193         pacman_recursive_dist (pos, curx, cury, 0);
00194 }
00195 
00196 int pacman_animate (Pos *pos, byte **movp)
00197 {
00198         static int count = 0;
00199         static byte move[32];
00200         byte *mp = move;
00201         int curx = -1, cury = -1;
00202         int incx = 0, incy = 0;
00203         int i, j, k, x, y;
00204         int oldboard;
00205         // FIXME: do this using stateful
00206         static int prevx[4] = {0, 0, 0, 0}, prevy[4] = {0, 0, 0, 0};
00207         // make sure the ghosts dont step on each others toes
00208         int taken[4] = {-1, -1, -1, -1}, t=0, gid;
00209         byte *board = pos->board;
00210         pacman_set_dist (board);
00211         for (i=0; i<board_wid; i++)
00212         for (j=0; j<board_heit; j++)
00213         {
00214                 if (!PACMAN_IS_GHOST(board[j * board_wid + i]))
00215                         continue;
00216                 gid = PACMAN_GET_GHOST_NUM(board [j * board_wid + i]);
00217                 for (k=0; k<10; k++)
00218                 {
00219                         int rnd = random()%4;
00220                         switch(rnd)
00221                         {
00222                                 case 0: incx = 0; incy = 1; break;
00223                                 case 1: incx = 0; incy = -1; break;
00224                                 case 2: incx = 1; incy = 0; break;
00225                                 case 3: incx = -1; incy = 0; break;
00226                         }
00227 #if 0
00228                         // make the ghosts move straight as long as boardsible
00229                         if (k < 5 && (incx != prevx[gid] || incy != prevy[gid])) continue;
00230 #endif
00231                         x = i+incx, y = j+incy;
00232                         // make the ghosts head straight for pacman
00233                         if (k < 5 && dist[x][y] > dist[i][j]) continue;
00234                         if (!PACMAN_IS_EDIBLE(board [y * board_wid + x])) continue;
00235                         { int found = 0, s;
00236                         for (s=0; s<t; s++) if (y * board_wid + x == taken[s])
00237                                 found = 1;
00238                         if (found) break;
00239                         }
00240                         prevx[gid] = incx; prevy[gid] = incy;
00241                         taken[t++] = y * board_wid + x;
00242                         *mp++ = i; *mp++ = j; 
00243                         *mp++ = board [j * board_wid + i] - 
00244                                 PACMAN_GET_GHOST (board [j * board_wid + i]);
00245                         *mp++ = x; *mp++ = y; 
00246                         *mp++ = board [y * board_wid + x] +
00247                                 PACMAN_GET_GHOST (board [j * board_wid + i]);
00248                         *movp = move;
00249                         break;
00250                 }
00251         }
00252         pacman_get_cur_pos (board, &curx, &cury);
00253         g_assert (curx >= 0 && cury >= 0);
00254         switch ((oldboard = board [cury * board_wid + curx]))
00255         {
00256                 case PACMAN_PAC_UP: incx = 0; incy = 1; break;
00257                 case PACMAN_PAC_DOWN: incx = 0; incy = -1; break;
00258                 case PACMAN_PAC_RIGHT: incx = 1; incy = 0; break;
00259                 case PACMAN_PAC_LEFT: incx = -1; incy = 0; break;
00260         }
00261         if (incx == 0 && incy == 0)   return -1;
00262         x = curx + incx; y = cury + incy;
00263         if (x >= 0 && y >= 0 && x < board_wid && y < board_heit &&
00264                         !(board [y * board_wid + x] & PACMAN_WALL_MASK))
00265         {
00266                 *mp++ = curx; *mp++ = cury; *mp++ = PACMAN_EMPTY;
00267                 *mp++ = x; *mp++ = y; *mp++ = oldboard; *mp++ = -1;
00268                 *movp = move;
00269         }
00270         *mp = -1;
00271         return mp > move ? 1 : -1;
00272         //return -1;
00273         
00274 
00275 }
00276 
00277 // TODO
00278 int pacman_getmove_kb (Pos *pos, int key, Player glob_to_play, byte **movp, int **rmovp)
00279 {
00280         static byte move[10];
00281         int curx = -1, cury = -1;
00282         int newpos;
00283         pacman_get_cur_pos (pos->board, &curx, &cury);
00284         g_assert (curx >= 0 && cury >= 0);
00285         switch (key)
00286         {
00287                 case GDK_Up: newpos = PACMAN_PAC_UP; break;
00288                 case GDK_Down: newpos = PACMAN_PAC_DOWN; break;
00289                 case GDK_Right: newpos = PACMAN_PAC_RIGHT; break;
00290                 case GDK_Left: newpos = PACMAN_PAC_LEFT; break;
00291                 default: return -1;
00292         }
00293         move[0] = curx; move[1] = cury; 
00294         move[2] = newpos;
00295         move[3] = -1;
00296         *movp = move;
00297         return 1;
00298 }
00299 
00300 void pacman_set_init_pos (Pos *pos)
00301 {
00302         int i, j, k;
00303         int incx[4] = {0, 0, 1, -1};
00304         int incy[4] = {1, -1, 0, 0};
00305         int wallmask[4] = {PACMAN_WALL_UP, PACMAN_WALL_DOWN, 
00306                 PACMAN_WALL_RIGHT, PACMAN_WALL_LEFT};
00307         byte *board = pos->board;
00308         for (i=0; i<board_wid; i++)
00309         for (j=0; j<board_heit; j++)
00310                 board [j * board_wid + i] = pacman_maze[board_heit - 1 - j][i];
00311         for (i=0; i<board_wid; i++)
00312         for (j=0; j<board_heit; j++)
00313         {
00314                 if (board [j * board_wid + i] & PACMAN_WALL_MASK)
00315                 {
00316                         for (k=0; k<4; k++)
00317                         {
00318                                 int x = i + incx[k];
00319                                 int y = j + incy[k];
00320                                 if (x < 0 || y < 0 || x >= board_wid || y>= board_heit)
00321                                         continue;
00322                                 if (board [y * board_wid + x] & PACMAN_WALL_MASK)
00323                                         board [j * board_wid + i] |= wallmask[k];
00324                         }
00325                 }
00326         }
00327 }
00328 
00329 static float get_angle (float x, float y)
00330 {
00331         float ang;
00332         if (x >= 0 && y == 0) return 0;
00333         if (x < 0 && y == 0) return M_PI;
00334         if (x == 0 && y > 0) return M_PI/2;
00335         if (x == 0 && y < 0) return 3 * M_PI/2;
00336         if (x > 0) { ang = atan(y/x); if (ang < 0) ang += 2 * M_PI; return ang;}
00337         return M_PI + atan(y/x);
00338 }
00339 
00340 static char **pacman_pixmap_ghost_gen(char *pixbuf)
00341         // FIXME: ghosts look like flowers :(
00342 {
00343         int i, j;
00344         static char *pixmap[PACMAN_CELL_SIZE+3];
00345         pixmap[0] = "25 25 2 1";
00346         pixmap[1] = "  c none";
00347         pixmap[2] = ". c #dddddd";
00348         for (i=0; i<PACMAN_CELL_SIZE; i++)
00349         {
00350                 pixmap[i+3] = pixbuf + i * (PACMAN_CELL_SIZE+1);
00351                 pixmap[i+3][PACMAN_CELL_SIZE] = 0;
00352         }
00353         for (i=0; i<PACMAN_CELL_SIZE; i++)
00354         for (j=0; j<PACMAN_CELL_SIZE; j++)
00355         {
00356                 int x = i - PACMAN_CELL_SIZE/2, y = j - PACMAN_CELL_SIZE/2;
00357                 float rad = x * x + y * y;
00358                 float val = cos (3 * get_angle (x, y));
00359                 val = val * val * PACMAN_CELL_SIZE * PACMAN_CELL_SIZE/6;
00360                 if (rad - val < PACMAN_CELL_SIZE*PACMAN_CELL_SIZE/10)
00361                         pixmap[i+3][j] = '.';
00362                 else
00363                         pixmap[i+3][j] = ' ';
00364         }
00365         return pixmap;
00366 }
00367 
00368 char ** pacman_pixmap_wall_gen(int idx, char *pixbuf)
00369 {
00370         int i, j;
00371         char **pixmap;
00372         char *colors;
00373         int fg, bg;
00374         if (!(idx & PACMAN_WALL_MASK))
00375                 return NULL;
00376         colors = pacman_colors;
00377         fg = (200 << 16) + 200;
00378         for(i=0, bg=0;i<3;i++) 
00379         { int col = colors[i]; if (col<0) col += 256; bg += col * (1 << (16-8*i));}
00380         pixmap = g_new(char *, PACMAN_CELL_SIZE + 3);
00381         for (i=0; i<3; i++)
00382                 pixmap[i] = brown_square_25_xpm[i];
00383         for (i=0; i<PACMAN_CELL_SIZE; i++)
00384         {
00385                 //pixmap[i+3] = g_new(char, PACMAN_CELL_SIZE+1);
00386                 pixmap[i+3] = pixbuf + i * (PACMAN_CELL_SIZE+1);
00387                 pixmap[i+3][PACMAN_CELL_SIZE] = 0;
00388         }
00389         for (i=0; i<PACMAN_CELL_SIZE; i++)
00390         for (j=0; j<PACMAN_CELL_SIZE; j++)
00391         {
00392                 pixmap[i+3][j] = ' ';
00393                 if ((i >= PACMAN_CELL_SIZE/3 && i < 2*PACMAN_CELL_SIZE/3)
00394                  && (j >= PACMAN_CELL_SIZE/3 && j < 2*PACMAN_CELL_SIZE/3))
00395                         pixmap[i+3][j] = '.';
00396                 if ((i >= PACMAN_CELL_SIZE*2/3)
00397                  && (j >= PACMAN_CELL_SIZE/3 && j < 2*PACMAN_CELL_SIZE/3)
00398                  && idx & PACMAN_WALL_DOWN)
00399                         pixmap[i+3][j] = '.';
00400                 if ((i < PACMAN_CELL_SIZE/3)
00401                  && (j >= PACMAN_CELL_SIZE/3 && j < 2*PACMAN_CELL_SIZE/3)
00402                  && idx & PACMAN_WALL_UP)
00403                         pixmap[i+3][j] = '.';
00404                 if ((i >= PACMAN_CELL_SIZE/3 && i < 2*PACMAN_CELL_SIZE/3)
00405                  && (j >= PACMAN_CELL_SIZE*2/3)
00406                  && idx & PACMAN_WALL_RIGHT)
00407                         pixmap[i+3][j] = '.';
00408                 if ((i >= PACMAN_CELL_SIZE/3 && i < 2*PACMAN_CELL_SIZE/3)
00409                  && (j < PACMAN_CELL_SIZE/3)
00410                  && idx & PACMAN_WALL_LEFT)
00411                         pixmap[i+3][j] = '.';
00412         }
00413         return pixmap;
00414 }
00415 
00416 char ** pacman_pixmap_pac_gen(float dir, float gap, char *pixbuf)
00417 {
00418         char **pixmap;
00419         float ang;
00420         float x0, y0;
00421         int i, j;
00422         pixmap = g_new(char *, 5 + PACMAN_CELL_SIZE);
00423         pixmap[0] = "25 25 4 1";
00424         pixmap[1] = "  c none";
00425         pixmap[2] = "b c black";
00426         pixmap[3] = "y c yellow";
00427         pixmap[4] = "r c red";
00428         ang = dir * M_PI / 2;
00429         x0 = cos(ang);
00430         y0 = sin(ang);
00431         for (i=0; i<PACMAN_CELL_SIZE; i++)
00432         {
00433                 pixmap[i+5] = pixbuf + i * (PACMAN_CELL_SIZE+1);
00434                 pixmap[i+5][PACMAN_CELL_SIZE] = 0;
00435                 for (j=0; j<PACMAN_CELL_SIZE; j++)
00436                 {
00437                         float x, y, tmp;
00438                         pixmap[i+5][j] = ' ';
00439                         x = i - PACMAN_CELL_SIZE/2, y = j - PACMAN_CELL_SIZE/2;
00440                         if (x * x + y * y > PACMAN_CELL_SIZE * PACMAN_CELL_SIZE/6)
00441                                 continue;
00442                         tmp =  sqrt(x*x+y*y);
00443                         if (tmp > 0) {  x /= tmp;       y /= tmp; }
00444                         if (x0 * x + y0 * y < cos (gap * M_PI / 180))
00445                                 pixmap[i+5][j] = 'y';                   
00446                         if (x*x+y*y==0) 
00447                                 pixmap[i+5][j] = 'y';                   
00448                 }
00449         }
00450         return pixmap;
00451 }
00452 
00453 char ** pacman_get_pixmap (int idx, int color)
00454 {
00455         int fg, bg, i;
00456         char *colors;
00457         static char pixbuf[PACMAN_CELL_SIZE*(PACMAN_CELL_SIZE+1)];
00458         if (idx & PACMAN_WALL_MASK)
00459                 return pacman_pixmap_wall_gen(idx, pixbuf);
00460         colors = pacman_colors;
00461         for(i=0, bg=0;i<3;i++) 
00462         { int col = colors[i]; if (col<0) col += 256; bg += col * (1 << (16-8*i));}
00463         if (idx == PACMAN_FOOD)
00464         {
00465                 fg = 200 << 8;
00466                 return pixmap_ball_gen(PACMAN_CELL_SIZE, pixbuf, fg, bg, 4.0, 30.0);
00467         }
00468         else if (idx == PACMAN_EMPTY)
00469         {
00470                 fg = 200 << 8;
00471                 return pixmap_ball_gen(PACMAN_CELL_SIZE, pixbuf, fg, bg, 0, 1);
00472         }       
00473         else if (idx == PACMAN_POWER)
00474         {
00475                 fg = 200 << 16;
00476                 return pixmap_ball_gen(PACMAN_CELL_SIZE, pixbuf, fg, bg, 6.0, 30.0);
00477         }
00478         else if (idx == PACMAN_PAC_UP)
00479         {
00480                 return pacman_pixmap_pac_gen(2, 45, pixbuf);
00481         }
00482         else if (idx == PACMAN_PAC_DOWN)
00483         {
00484                 return pacman_pixmap_pac_gen(0, 45, pixbuf);
00485         }
00486         else if (idx == PACMAN_PAC_RIGHT)
00487         {
00488                 return pacman_pixmap_pac_gen(1, 45, pixbuf);
00489         }
00490         else if (idx == PACMAN_PAC_LEFT)
00491         {
00492                 return pacman_pixmap_pac_gen(3, 45, pixbuf);
00493         }
00494         else if (PACMAN_IS_GHOST(idx))
00495         {
00496                 //fg = 50;
00497                 return pacman_pixmap_ghost_gen (pixbuf);
00498                         //pixmap_ball_gen(PACMAN_CELL_SIZE, pixbuf, fg, bg, 6.0, 24.0);
00499         }
00500         return NULL;
00501 }
00502