Holy god the windows build better fucking work
[crack-attack.git] / src / LoseBar.cxx
blob51aa39f21d846c2d43ea69fab7975398bf1fa261
1 /*
2 * LoseBar.cxx
3 * Daniel Nelson - 3/1/2
5 * Copyright (C) 2002 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 * Handles the losebar.
28 #include <GL/glut.h>
30 #include "glext.h"
32 using namespace std;
34 #include "Game.h"
35 #include "Creep.h"
36 #include "Displayer.h"
37 #include "LoseBar.h"
39 GLfloat LoseBar::bar;
40 int LoseBar::fade_timer;
41 int LoseBar::state;
43 void LoseBar::initialize ( )
45 bar = 0.0f;
46 fade_timer = 0;
47 state = LB_INACTIVE;
51 void LoseBar::gameStart ( )
53 // at the start of the game, fade to inactive
54 if (state == LB_LOW_ALERT)
55 enterLowToInactiveFade();
56 else if (state == LB_HIGH_ALERT)
57 enterHighToInactiveFade();
60 void LoseBar::timeStep ( )
62 // update state
64 // if we're not on alert
65 if (state
66 & (LB_INACTIVE | LB_FADE_LOW_TO_INACTIVE | LB_FADE_HIGH_TO_INACTIVE)) {
68 // if we're done fading
69 if (state & (LB_FADE_LOW_TO_INACTIVE | LB_FADE_HIGH_TO_INACTIVE)
70 && --fade_timer == 0)
71 state = LB_INACTIVE;
73 // if we should be on alert
74 if (Creep::creep_freeze) {
75 // no check for high alert is needed
76 state = LB_LOW_ALERT;
77 fade_timer = 0;
80 // if we are on low alert
81 } else if (state == LB_LOW_ALERT) {
83 // if we no longer should be on alert
84 if (!Creep::creep_freeze)
85 enterLowToInactiveFade();
87 // if we should enter high alert
88 else if (Creep::loss_alarm <= GC_LOSS_DELAY_ELIMINATION)
89 state = LB_HIGH_ALERT;
91 // if we are on high alert
92 } else if (state == LB_HIGH_ALERT) {
94 // if we no longer should be on alert
95 if (!Creep::creep_freeze)
96 enterHighToInactiveFade();
98 // if we are fading because of a high alert reset
99 } else if (state == LB_FADE_RESET_HIGH) {
100 if (--fade_timer == 0)
101 state = LB_HIGH_ALERT;
104 // calculate the bar value
106 if (state & (LB_LOW_ALERT | LB_HIGH_ALERT))
107 if (state & LB_LOW_ALERT)
108 bar = (GC_LOSS_DELAY - Creep::loss_alarm)
109 * (1.0f / (GLfloat) (GC_LOSS_DELAY - GC_LOSS_DELAY_ELIMINATION));
110 else
111 bar = (GC_LOSS_DELAY_ELIMINATION - Creep::loss_alarm)
112 * (1.0f / (GLfloat) GC_LOSS_DELAY_ELIMINATION);