desktop file ended up in the wrong place.
[crack-attack.git] / src / DrawWinRecord.cxx
blob32e86c66606e9c3f2d32b9d597d437727d147ad6
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 #ifndef _WIN32
31 #else
32 # include <glext.h>
33 #endif
35 using namespace std;
37 #include "Game.h"
38 #include "Displayer.h"
39 #include "WinRecord.h"
41 void Displayer::drawWinRecord ( )
43 glBindTexture(GL_TEXTURE_2D, mote_textures[MT_FIVE_POINTED_STAR]);
45 int n;
46 if (MetaState::mode & CM_SOLO)
47 n = DC_SOLO_STAR_ID + 1;
48 else
49 n = GC_GAMES_PER_MATCH;
50 while (n--) {
51 Star &star = WinRecord::stars[n];
53 glPushMatrix();
55 switch (WinRecord::record[n]) {
57 // game not yet played
58 case GR_NOT_PLAYED:
59 glColor3f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
60 DC_STAR_UNPLAYED_BLUE);
61 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n,
62 DC_STAR_OFFSET_Y, DC_EXTERNAL_OFFSET_Z);
63 glScalef(DC_STAR_SIZE_EQUILIBRIUM, -DC_STAR_SIZE_EQUILIBRIUM, 0.0f);
64 glCallList(sparkle_list);
65 break;
67 // game being played
68 case GR_BEING_PLAYED:
69 glColor3f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
70 DC_STAR_UNPLAYED_BLUE);
71 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n,
72 DC_STAR_OFFSET_Y, DC_EXTERNAL_OFFSET_Z);
73 glRotatef(star.a, 0.0f, 0.0f, 1.0f);
74 glScalef(DC_STAR_SIZE_EQUILIBRIUM, -DC_STAR_SIZE_EQUILIBRIUM, 0.0f);
75 glCallList(sparkle_list);
76 break;
78 // game has been lost
79 case GR_LOST:
80 // star has already faded out
81 if (WinRecord::current_game != n)
82 glColor4f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
83 DC_STAR_UNPLAYED_BLUE, DC_STAR_LOST_ALPHA);
85 // star is fading out
86 else if (Game::time_step < DC_CELEBRATION_TIME) {
87 GLfloat fade
88 = Game::time_step * (1.0f / (GLfloat) DC_CELEBRATION_TIME);
89 fade = Game::sqrt(fade);
90 glColor4f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
91 DC_STAR_UNPLAYED_BLUE, 1.0f - (1.0f - DC_STAR_LOST_ALPHA) * fade);
93 // star has already faded out
94 } else
95 glColor4f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
96 DC_STAR_UNPLAYED_BLUE, DC_STAR_LOST_ALPHA);
98 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n,
99 DC_STAR_OFFSET_Y, DC_EXTERNAL_OFFSET_Z);
100 glRotatef(star.a, 0.0f, 0.0f, 1.0f);
101 glScalef(DC_STAR_SIZE_EQUILIBRIUM, -DC_STAR_SIZE_EQUILIBRIUM, 0.0f);
102 glCallList(sparkle_list);
103 break;
105 // game has been won
106 case GR_WON:
107 // if we need to, draw the old star
108 if (WinRecord::draw_old_star && WinRecord::current_game == n) {
109 glPushMatrix();
110 glColor3f(DC_STAR_UNPLAYED_RED, DC_STAR_UNPLAYED_GREEN,
111 DC_STAR_UNPLAYED_BLUE);
112 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n,
113 DC_STAR_OFFSET_Y, DC_EXTERNAL_OFFSET_Z);
114 glRotatef(WinRecord::old_star_a, 0.0f, 0.0f, 1.0f);
115 glScalef(WinRecord::old_star_size, -WinRecord::old_star_size, 0.0f);
116 glCallList(sparkle_list);
117 glPopMatrix();
120 glColor3f(DC_STAR_WIN_RED, DC_STAR_WIN_GREEN, DC_STAR_WIN_BLUE);
122 // star is static but displaced
123 if (n == WinRecord::displaced_star)
124 if (MetaState::mode & CM_SOLO)
125 glTranslatef(DC_STAR_WIN_OFFSET_X, DC_STAR_WIN_SOLO_OFFSET_Y,
126 DC_EXTERNAL_OFFSET_Z);
127 else
128 glTranslatef(DC_STAR_WIN_OFFSET_X, DC_STAR_WIN_OFFSET_Y,
129 DC_EXTERNAL_OFFSET_Z);
131 // star is in motion
132 else if (n == WinRecord::dynamic_star)
133 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n
134 + WinRecord::win_star_x, DC_STAR_OFFSET_Y + WinRecord::win_star_y,
135 DC_EXTERNAL_OFFSET_Z);
137 // star is at rest in the standard location
138 else
139 glTranslatef(DC_STAR_OFFSET_X + DC_STAR_DISPLACEMENT * n,
140 DC_STAR_OFFSET_Y, DC_EXTERNAL_OFFSET_Z);
142 glRotatef(star.a, 0.0f, 0.0f, 1.0f);
143 glScalef(star.size, -star.size, 0.0f);
144 glCallList(sparkle_list);
145 break;
148 glPopMatrix();
150 if (MetaState::mode & CM_SOLO) break;