console: Format tabs semi-intelligently
[attac-man.git] / render_ghost.c
blobe0c129511e3d0d2c0ca75f27b86fbc90753de8bc
1 /*
2 Pacman Arena
3 Copyright (C) 2003 Nuno Subtil
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 static const char cvsid[] =
21 "$Id: render_ghost.c,v 1.2 2003/11/30 17:43:55 nsubtil Exp $";
23 #ifdef _WIN32
24 #include <windows.h>
25 #endif
27 #include <SDL.h>
28 #include <GL/gl.h>
29 #include <GL/glu.h>
30 #include <stdio.h>
32 #include "object.h"
33 #include "game.h"
34 #include "ghost.h"
35 #include "screen.h"
36 #include "render.h"
38 #include "player.h"
40 void ghost_render(struct game *game, struct ghost *g)
42 GLfloat blue[] = {0.1, 0.1, 1.0, 1.0};
44 glMatrixMode(GL_MODELVIEW);
45 glLoadIdentity();
47 glEnable(GL_LIGHTING);
48 glShadeModel(GL_SMOOTH);
50 glTranslatef(g->position[X], g->position[Y], g->position[Z]);
51 render_setup_model_direction(g->direction);
53 glEnable(GL_COLOR_MATERIAL);
54 glDisable(GL_BLEND);
55 glDisable(GL_TEXTURE_2D);
56 glEnable(GL_DEPTH_TEST);
57 glDepthMask(GL_TRUE);
59 switch(g->state)
61 case GHOST_STATE_ACTIVE:
62 if(g->tainted && (game->players[0].pill_time > 3.0 ||
63 (int)(game->players[0].pill_time * 4.0) % 2 == 0))
64 render_dlist(&g->model_active[(int)g->current_frame % g->frames_active],
65 blue);
66 else
67 render_dlist(&g->model_active[(int)g->current_frame % g->frames_active],
68 g->color);
69 break;
71 case GHOST_STATE_DYING:
72 if(g->tainted && (game->players[0].pill_time > 3.0 ||
73 (int)(game->players[0].pill_time * 4.0) % 2 == 0))
74 render_dlist(&g->model_dying[(int)g->current_frame % g->frames_dying],
75 blue);
76 else
77 render_dlist(&g->model_dying[(int)g->current_frame % g->frames_dying],
78 g->color);
79 break;
81 case GHOST_STATE_DEAD:
82 render_dlist(&g->model_dead[(int)g->current_frame % g->frames_dead], g->color);
83 break;
85 case GHOST_STATE_RETURNING:
86 render_dlist(&g->model_returning[(int)g->current_frame % g->frames_returning], g->color);
87 break;
89 #if 0
90 glLoadIdentity();
91 glTranslatef(g->position[X], g->position[Y], g->position[Z]);
92 glColor4f(1.0, 1.0, 1.0, 1.0);
93 glBegin(GL_LINES);
95 glVertex3f(0.0, 0.0, 0.0);
96 switch(g->direction)
98 case DIRECTION_LEFT:
99 glVertex3f(-g->time * g->speed, 0.0, 0.0);
100 break;
102 case DIRECTION_RIGHT:
103 glVertex3f(g->time * g->speed, 0.0, 0.0);
104 break;
106 case DIRECTION_UP:
107 glVertex3f(0.0, 0.0, g->time * g->speed);
108 break;
110 case DIRECTION_DOWN:
111 glVertex3f(0.0, 0.0, -g->time * g->speed);
112 break;
115 glEnd();
116 #endif