3 * Daniel Nelson - 3/1/2
5 * Copyright (C) 2002 Daniel Nelson
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
25 * Handles the losebar.
36 #include "Displayer.h"
40 int LoseBar::fade_timer
;
43 void LoseBar::initialize ( )
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 ( )
64 // if we're not on alert
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
)
73 // if we should be on alert
74 if (Creep::creep_freeze
) {
75 // no check for high alert is needed
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
));
111 bar
= (GC_LOSS_DELAY_ELIMINATION
- Creep::loss_alarm
)
112 * (1.0f
/ (GLfloat
) GC_LOSS_DELAY_ELIMINATION
);