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"
39 int LoseBar::fade_timer
;
42 void LoseBar::initialize ( )
50 void LoseBar::gameStart ( )
52 // at the start of the game, fade to inactive
53 if (state
== LB_LOW_ALERT
)
54 enterLowToInactiveFade();
55 else if (state
== LB_HIGH_ALERT
)
56 enterHighToInactiveFade();
59 void LoseBar::timeStep ( )
63 // if we're not on alert
65 & (LB_INACTIVE
| LB_FADE_LOW_TO_INACTIVE
| LB_FADE_HIGH_TO_INACTIVE
)) {
67 // if we're done fading
68 if (state
& (LB_FADE_LOW_TO_INACTIVE
| LB_FADE_HIGH_TO_INACTIVE
)
72 // if we should be on alert
73 if (Creep::creep_freeze
) {
74 // no check for high alert is needed
79 // if we are on low alert
80 } else if (state
== LB_LOW_ALERT
) {
82 // if we no longer should be on alert
83 if (!Creep::creep_freeze
)
84 enterLowToInactiveFade();
86 // if we should enter high alert
87 else if (Creep::loss_alarm
<= GC_LOSS_DELAY_ELIMINATION
)
88 state
= LB_HIGH_ALERT
;
90 // if we are on high alert
91 } else if (state
== LB_HIGH_ALERT
) {
93 // if we no longer should be on alert
94 if (!Creep::creep_freeze
)
95 enterHighToInactiveFade();
97 // if we are fading because of a high alert reset
98 } else if (state
== LB_FADE_RESET_HIGH
) {
99 if (--fade_timer
== 0)
100 state
= LB_HIGH_ALERT
;
103 // calculate the bar value
105 if (state
& (LB_LOW_ALERT
| LB_HIGH_ALERT
))
106 if (state
& LB_LOW_ALERT
)
107 bar
= (GC_LOSS_DELAY
- Creep::loss_alarm
)
108 * (1.0f
/ (GLfloat
) (GC_LOSS_DELAY
- GC_LOSS_DELAY_ELIMINATION
));
110 bar
= (GC_LOSS_DELAY_ELIMINATION
- Creep::loss_alarm
)
111 * (1.0f
/ (GLfloat
) GC_LOSS_DELAY_ELIMINATION
);