Fixes for datatype size on amd64.
[crack-attack.git] / src / DrawWinRecord.cxx
blob5318a995332ca5184c556ed0be2efbd9b1e841cd
1 /*
2 * DrawWinRecord.cxx
3 * Daniel Nelson - 11/5/0
5 * Copyright (C) 2000 Daniel Nelson
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * Daniel Nelson - aluminumangel.org
22 * 174 W. 18th Ave.
23 * Columbus, OH 43210
25 * Draws the little win record stars.
28 #include <GL/glut.h>
30 #include "glext.h"
32 #include "Game.h"
33 #include "Displayer.h"
34 #include "WinRecord.h"
36 void Displayer::drawWinRecord ( )
38 glBindTexture(GL_TEXTURE_2D, mote_textures[MT_FIVE_POINTED_STAR]);
40 int n;
41 if (MetaState::mode & CM_SOLO)
42 n = DC_SOLO_STAR_ID + 1;
43 else
44 n = GC_GAMES_PER_MATCH;
45 while (n--) {
46 Star &star = WinRecord::stars[n];
48 glPushMatrix();
50 switch (WinRecord::record[n]) {
52 // game not yet played
53 case GR_NOT_PLAYED:
54 glColor3f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
55 DC_STAR_UNPLAYED_BLUE);
56 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n,
57 DC_STAR_OFFSET_Y, DC_EXTERNAL_OFFSET_Z);
58 glScalef(DC_STAR_SIZE_EQUILIBRIUM, -DC_STAR_SIZE_EQUILIBRIUM, 0.0f);
59 glCallList(sparkle_list);
60 break;
62 // game being played
63 case GR_BEING_PLAYED:
64 glColor3f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
65 DC_STAR_UNPLAYED_BLUE);
66 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n,
67 DC_STAR_OFFSET_Y, DC_EXTERNAL_OFFSET_Z);
68 glRotatef(star.a, 0.0f, 0.0f, 1.0f);
69 glScalef(DC_STAR_SIZE_EQUILIBRIUM, -DC_STAR_SIZE_EQUILIBRIUM, 0.0f);
70 glCallList(sparkle_list);
71 break;
73 // game has been lost
74 case GR_LOST:
75 // star has already faded out
76 if (WinRecord::current_game != n)
77 glColor4f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
78 DC_STAR_UNPLAYED_BLUE, DC_STAR_LOST_ALPHA);
80 // star is fading out
81 else if (Game::time_step < DC_CELEBRATION_TIME) {
82 GLfloat fade
83 = Game::time_step * (1.0f / (GLfloat) DC_CELEBRATION_TIME);
84 fade = Game::sqrt(fade);
85 glColor4f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
86 DC_STAR_UNPLAYED_BLUE, 1.0f - (1.0f - DC_STAR_LOST_ALPHA) * fade);
88 // star has already faded out
89 } else
90 glColor4f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
91 DC_STAR_UNPLAYED_BLUE, DC_STAR_LOST_ALPHA);
93 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n,
94 DC_STAR_OFFSET_Y, DC_EXTERNAL_OFFSET_Z);
95 glRotatef(star.a, 0.0f, 0.0f, 1.0f);
96 glScalef(DC_STAR_SIZE_EQUILIBRIUM, -DC_STAR_SIZE_EQUILIBRIUM, 0.0f);
97 glCallList(sparkle_list);
98 break;
100 // game has been won
101 case GR_WON:
102 // if we need to, draw the old star
103 if (WinRecord::draw_old_star && WinRecord::current_game == n) {
104 glPushMatrix();
105 glColor3f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
106 DC_STAR_UNPLAYED_BLUE);
107 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n,
108 DC_STAR_OFFSET_Y, DC_EXTERNAL_OFFSET_Z);
109 glRotatef(WinRecord::old_star_a, 0.0f, 0.0f, 1.0f);
110 glScalef(WinRecord::old_star_size, -WinRecord::old_star_size, 0.0f);
111 glCallList(sparkle_list);
112 glPopMatrix();
115 glColor3f(DC_STAR_WIN_RED, DC_STAR_WIN_GREEN, DC_STAR_WIN_BLUE);
117 // star is static but displaced
118 if (n == WinRecord::displaced_star)
119 if (MetaState::mode & CM_SOLO)
120 glTranslatef(DC_STAR_WIN_OFFSET_X, DC_STAR_WIN_SOLO_OFFSET_Y,
121 DC_EXTERNAL_OFFSET_Z);
122 else
123 glTranslatef(DC_STAR_WIN_OFFSET_X, DC_STAR_WIN_OFFSET_Y,
124 DC_EXTERNAL_OFFSET_Z);
126 // star is in motion
127 else if (n == WinRecord::dynamic_star)
128 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n
129 + WinRecord::win_star_x, DC_STAR_OFFSET_Y + WinRecord::win_star_y,
130 DC_EXTERNAL_OFFSET_Z);
132 // star is at rest in the standard location
133 else
134 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n,
135 DC_STAR_OFFSET_Y, DC_EXTERNAL_OFFSET_Z);
137 glRotatef(star.a, 0.0f, 0.0f, 1.0f);
138 glScalef(star.size, -star.size, 0.0f);
139 glCallList(sparkle_list);
140 break;
143 glPopMatrix();
145 if (MetaState::mode & CM_SOLO) break;