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.
35 int X::reverse_controls
;
36 int X::invisible_swapper
;
42 Wild
X::wilds
[GC_MAX_WILD_NUMBER
];
43 int X::special_color_count
;
45 const GLfloat
X::light_level_map
[6][3]
46 = { { 0.0f
, 1.0f
, 1.0f
},
51 { 0.5f
, 1.0f
, 0.5f
} };
57 invisible_swapper
= 0;
58 swapper_alpha
= GC_INVISIBLE_MAX_ALPHA
;
64 for (int n
= GC_MAX_WILD_NUMBER
; n
--; )
65 wilds
[n
].active
= false;
67 special_color_count
= 0;
72 // evolve the swapper's invisibleness
73 if (invisible_swapper
!= 0 || swapper_alpha
!= GC_INVISIBLE_MAX_ALPHA
)
74 if (invisible_swapper
!= 0) {
76 // drop the swapper's alpha
77 if (swapper_alpha
> 0)
78 swapper_alpha
-= GC_INVISIBLE_QUICK_DECAY_RATE
;
79 else if (swapper_alpha
> GC_INVISIBLE_MIN_ALPHA
)
82 // there is a chance the swapper's alpha will spike upward
83 if (Random::chanceIn(GC_INVISIBLE_PULSE_CHANCE_IN
)) {
84 swapper_alpha
+= GC_INVISIBLE_PULSE_STRENGTH
;
85 if (swapper_alpha
> GC_INVISIBLE_MAX_ALPHA
)
86 swapper_alpha
= GC_INVISIBLE_MAX_ALPHA
;
89 // raise the swapper's alpha back to normal
93 // evolve the wild blocks' state
94 if (wild_count
!= 0) {
96 for (int n
= 0; c
; n
++)
97 if (wilds
[n
].active
) {
99 if (!--wilds
[n
].alarm
) {
102 wilds
[n
].alarm
= GC_WILD_PERIOD
;
103 if (wilds
[n
].flavor
== 0)
104 wilds
[n
].flavor
= BF_WILD
;
107 if (wilds
[n
].block
->y
!= 0)
108 Grid::requestEliminationCheck(*wilds
[n
].block
);
114 // evolve the crazy lights
115 if (crazy_lights
!= 0 || light_mode
!= -1) {
117 // switch light colors
118 if (!--light_alarm
) {
120 // if craziness continues
121 if (crazy_lights
!= 0) {
122 if (light_mode
!= 11)
127 // odd modes - non-white modes - are longer
128 if (light_mode
& (1 << 0))
129 light_alarm
= GC_CRAZY_LONG_MODE_PERIOD
;
131 light_alarm
= GC_CRAZY_SHORT_MODE_PERIOD
;
140 void X::notifyImpact ( Garbage
&garbage
)
142 * Garbage has impacted. We must check to see if it's flavor has a special
146 // controls are reversed
147 if (garbage
.flavor
== GF_REVERSE_CONTROLS
) {
149 if (invisible_swapper
== 0)
154 // swapper becomes invisible
155 } else if (garbage
.flavor
== GF_INVISIBLE_SWAPPER
) {
157 if (reverse_controls
== 0)
163 } else if (garbage
.flavor
== GF_CRAZY_LIGHTS
) {
165 if (light_mode
== -1) {
166 light_mode
= (Random::number(6) << 1) + 1;
172 void X::notifyShatter ( Garbage
&garbage
)
174 * Garbage has shattered. We must check to see if this effects the special
175 * effects which are occuring.
178 if (garbage
.flavor
== GF_REVERSE_CONTROLS
) {
180 if (reverse_controls
== 0)
181 if (invisible_swapper
== 0)
186 } else if (garbage
.flavor
== GF_INVISIBLE_SWAPPER
) {
188 if (invisible_swapper
== 0)
189 if (reverse_controls
== 0)
194 } else if (garbage
.flavor
== GF_CRAZY_LIGHTS
)
198 void X::modifyHeadlightColor ( GLfloat headlight_color
[3] )
200 * Called by LightManager to allow us the opportunity to modify the headlight
204 assert(crazyLights());
206 GLfloat fade
= light_alarm
* (2.0f
/ (float) GC_CRAZY_LONG_MODE_PERIOD
);
213 headlight_color
[0] = light_level_map
[light_mode
>> 1][0]
214 + fade
* (1.0f
- light_level_map
[light_mode
>> 1][0]);
215 headlight_color
[1] = light_level_map
[light_mode
>> 1][1]
216 + fade
* (1.0f
- light_level_map
[light_mode
>> 1][1]);
217 headlight_color
[2] = light_level_map
[light_mode
>> 1][2]
218 + fade
* (1.0f
- light_level_map
[light_mode
>> 1][2]);