3 * Daniel Nelson - 11/11/0
5 * Copyright (C) 2000 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 * Holds the X-treme state.
36 int X::reverse_controls
;
37 int X::invisible_swapper
;
43 Wild
X::wilds
[GC_MAX_WILD_NUMBER
];
44 int X::special_color_count
;
46 const GLfloat
X::light_level_map
[6][3]
47 = { { 0.0f
, 1.0f
, 1.0f
},
52 { 0.5f
, 1.0f
, 0.5f
} };
58 invisible_swapper
= 0;
59 swapper_alpha
= GC_INVISIBLE_MAX_ALPHA
;
65 for (int n
= GC_MAX_WILD_NUMBER
; n
--; )
66 wilds
[n
].active
= false;
68 special_color_count
= 0;
73 // evolve the swapper's invisibleness
74 if (invisible_swapper
!= 0 || swapper_alpha
!= GC_INVISIBLE_MAX_ALPHA
)
75 if (invisible_swapper
!= 0) {
77 // drop the swapper's alpha
78 if (swapper_alpha
> 0)
79 swapper_alpha
-= GC_INVISIBLE_QUICK_DECAY_RATE
;
80 else if (swapper_alpha
> GC_INVISIBLE_MIN_ALPHA
)
83 // there is a chance the swapper's alpha will spike upward
84 if (Random::chanceIn(GC_INVISIBLE_PULSE_CHANCE_IN
)) {
85 swapper_alpha
+= GC_INVISIBLE_PULSE_STRENGTH
;
86 if (swapper_alpha
> GC_INVISIBLE_MAX_ALPHA
)
87 swapper_alpha
= GC_INVISIBLE_MAX_ALPHA
;
90 // raise the swapper's alpha back to normal
94 // evolve the wild blocks' state
95 if (wild_count
!= 0) {
97 for (int n
= 0; c
; n
++)
98 if (wilds
[n
].active
) {
100 if (!--wilds
[n
].alarm
) {
103 wilds
[n
].alarm
= GC_WILD_PERIOD
;
104 if (wilds
[n
].flavor
== 0)
105 wilds
[n
].flavor
= BF_WILD
;
108 if (wilds
[n
].block
->y
!= 0)
109 Grid::requestEliminationCheck(*wilds
[n
].block
);
115 // evolve the crazy lights
116 if (crazy_lights
!= 0 || light_mode
!= -1) {
118 // switch light colors
119 if (!--light_alarm
) {
121 // if craziness continues
122 if (crazy_lights
!= 0) {
123 if (light_mode
!= 11)
128 // odd modes - non-white modes - are longer
129 if (light_mode
& (1 << 0))
130 light_alarm
= GC_CRAZY_LONG_MODE_PERIOD
;
132 light_alarm
= GC_CRAZY_SHORT_MODE_PERIOD
;
141 void X::notifyImpact ( Garbage
&garbage
)
143 * Garbage has impacted. We must check to see if it's flavor has a special
147 // controls are reversed
148 if (garbage
.flavor
== GF_REVERSE_CONTROLS
) {
150 if (invisible_swapper
== 0)
155 // swapper becomes invisible
156 } else if (garbage
.flavor
== GF_INVISIBLE_SWAPPER
) {
158 if (reverse_controls
== 0)
164 } else if (garbage
.flavor
== GF_CRAZY_LIGHTS
) {
166 if (light_mode
== -1) {
167 light_mode
= (Random::number(6) << 1) + 1;
173 void X::notifyShatter ( Garbage
&garbage
)
175 * Garbage has shattered. We must check to see if this effects the special
176 * effects which are occuring.
179 if (garbage
.flavor
== GF_REVERSE_CONTROLS
) {
181 if (reverse_controls
== 0)
182 if (invisible_swapper
== 0)
187 } else if (garbage
.flavor
== GF_INVISIBLE_SWAPPER
) {
189 if (invisible_swapper
== 0)
190 if (reverse_controls
== 0)
195 } else if (garbage
.flavor
== GF_CRAZY_LIGHTS
)
199 void X::modifyHeadlightColor ( GLfloat headlight_color
[3] )
201 * Called by LightManager to allow us the opportunity to modify the headlight
205 assert(crazyLights());
207 GLfloat fade
= light_alarm
* (2.0f
/ (float) GC_CRAZY_LONG_MODE_PERIOD
);
214 headlight_color
[0] = light_level_map
[light_mode
>> 1][0]
215 + fade
* (1.0f
- light_level_map
[light_mode
>> 1][0]);
216 headlight_color
[1] = light_level_map
[light_mode
>> 1][1]
217 + fade
* (1.0f
- light_level_map
[light_mode
>> 1][1]);
218 headlight_color
[2] = light_level_map
[light_mode
>> 1][2]
219 + fade
* (1.0f
- light_level_map
[light_mode
>> 1][2]);