3 * Daniel Nelson - 10/13/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 * Draws the cute level lights.
35 #include "Displayer.h"
36 #include "LevelLights.h"
37 #include "MetaState.h"
39 #define CS_UNDEFINED (0)
43 const GLfloat ambient
[]
44 = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
46 const GLfloat diffuse
[]
47 = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
49 const GLfloat specular
[]
50 = { 0.8f
, 0.8f
, 0.8f
, 1.0f
};
52 void Displayer::drawLevelLights ( )
56 GLfloat death_flash
= 0.0f
;
59 glColorMaterial(GL_FRONT
, GL_EMISSION
);
61 glMaterialfv(GL_FRONT
, GL_AMBIENT
, ambient
);
62 glMaterialfv(GL_FRONT
, GL_SPECULAR
, specular
);
63 glMaterialfv(GL_FRONT
, GL_DIFFUSE
, diffuse
);
64 glMaterialf(GL_FRONT
, GL_SHININESS
, 2.0f
);
66 for (int set
= 2; set
--; ) {
70 if (set
== LL_LOCAL_LIGHTS
)
71 glTranslatef(DC_LEVEL_LIGHT_LOCAL_OFFSET_X
,
72 DC_PLAY_OFFSET_Y
+ (DC_GRID_ELEMENT_LENGTH
/ 2.0f
), 0.0f
);
74 glTranslatef(DC_LEVEL_LIGHT_OPPONENT_OFFSET_X
,
75 DC_PLAY_OFFSET_Y
+ (DC_GRID_ELEMENT_LENGTH
/ 2.0f
), 0.0f
);
76 glScalef(-1.0f
, 1.0f
, 1.0f
);
79 static int hold_set
= 0;
80 if ((MetaState::mode
& CM_SOLO
) && !(MetaState::mode
& CM_AI
)) {
82 set
= LL_LOCAL_LIGHTS
;
85 color_state
= CS_UNDEFINED
;
87 if (LevelLights::death_flash_alarm
[set
] != -1) {
88 death_flash
= LevelLights::death_flash_alarm
[set
]
89 * (2.0f
/ (GLfloat
) DC_LEVEL_LIGHT_DEATH_FLASH_TIME
);
91 if (death_flash
> 1.0f
) death_flash
= 2.0f
- death_flash
;
94 for (int n
= 0; n
< LL_NUMBER_LEVEL_LIGHTS
; n
++) {
95 LevelLight
&light
= LevelLights::lights
[set
][n
];
96 color
[0] = color
[1] = color
[2] = 0.0f
;
98 if (light
.state
& LS_RED
) {
99 color
[0] = DC_LEVEL_LIGHT_RED
;
100 next_color_state
= CS_RED
;
102 } else if (light
.state
& LS_BLUE
) {
103 color
[2] = DC_LEVEL_LIGHT_BLUE
;
104 next_color_state
= CS_BLUE
;
107 GLfloat fade
= light
.fade_alarm
108 * (1.0f
/ (GLfloat
) DC_LEVEL_LIGHT_FADE_TIME
);
110 if (light
.state
& LS_FADE_TO_RED
) {
111 color
[0] = DC_LEVEL_LIGHT_RED
* Game::sqrt(1.0f
- fade
);
112 color
[2] = DC_LEVEL_LIGHT_BLUE
* Game::sqrt(fade
);
115 color
[0] = DC_LEVEL_LIGHT_RED
* Game::sqrt(fade
);
116 color
[2] = DC_LEVEL_LIGHT_BLUE
* Game::sqrt(1.0f
- fade
);
119 next_color_state
= CS_UNDEFINED
;
122 if (light
.state
& LS_IMPACT_FLASH
) {
123 GLfloat flash
= light
.flash_alarm
124 * (1.0f
/ (GLfloat
) DC_LEVEL_LIGHT_IMPACT_FLASH_TIME
);
126 if (flash
> DC_LEVEL_LIGHT_FLASH_INFLECTION
)
127 flash
= (1.0f
- flash
)
128 * (1.0f
/ (1.0f
- DC_LEVEL_LIGHT_FLASH_INFLECTION
));
130 flash
*= 1.0f
/ DC_LEVEL_LIGHT_FLASH_INFLECTION
;
133 color
[0] += (1.0f
- color
[0]) * flash
;
135 color
[2] += (1.0f
- color
[2]) * flash
;
137 next_color_state
= CS_UNDEFINED
;
140 if (LevelLights::death_flash_alarm
[set
] != -1) {
141 color
[0] += (1.0f
- color
[0]) * death_flash
;
142 color
[1] += (1.0f
- color
[1]) * death_flash
;
143 color
[2] += (1.0f
- color
[2]) * death_flash
;
146 if (next_color_state
!= color_state
|| color_state
== CS_UNDEFINED
) {
148 color_state
= next_color_state
;
151 glTranslatef(0.0f
, DC_GRID_ELEMENT_LENGTH
, 0.0f
);
153 glCallList(level_light_list
);
156 if ((MetaState::mode
& CM_SOLO
) && !(MetaState::mode
& CM_AI
))