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.
33 #include "Displayer.h"
34 #include "LevelLights.h"
35 #include "MetaState.h"
37 #define CS_UNDEFINED (0)
41 const GLfloat ambient
[]
42 = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
44 const GLfloat diffuse
[]
45 = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
47 const GLfloat specular
[]
48 = { 0.8f
, 0.8f
, 0.8f
, 1.0f
};
50 void Displayer::drawLevelLights ( )
54 GLfloat death_flash
= 0.0f
;
57 glColorMaterial(GL_FRONT
, GL_EMISSION
);
59 glMaterialfv(GL_FRONT
, GL_AMBIENT
, ambient
);
60 glMaterialfv(GL_FRONT
, GL_SPECULAR
, specular
);
61 glMaterialfv(GL_FRONT
, GL_DIFFUSE
, diffuse
);
62 glMaterialf(GL_FRONT
, GL_SHININESS
, 2.0f
);
64 for (int set
= 2; set
--; ) {
68 if (set
== LL_LOCAL_LIGHTS
)
69 glTranslatef(DC_LEVEL_LIGHT_LOCAL_OFFSET_X
,
70 DC_PLAY_OFFSET_Y
+ (DC_GRID_ELEMENT_LENGTH
/ 2.0f
), 0.0f
);
72 glTranslatef(DC_LEVEL_LIGHT_OPPONENT_OFFSET_X
,
73 DC_PLAY_OFFSET_Y
+ (DC_GRID_ELEMENT_LENGTH
/ 2.0f
), 0.0f
);
74 glScalef(-1.0f
, 1.0f
, 1.0f
);
77 static int hold_set
= 0;
78 if ((MetaState::mode
& CM_SOLO
) && !(MetaState::mode
& CM_AI
)) {
80 set
= LL_LOCAL_LIGHTS
;
83 color_state
= CS_UNDEFINED
;
85 if (LevelLights::death_flash_alarm
[set
] != -1) {
86 death_flash
= LevelLights::death_flash_alarm
[set
]
87 * (2.0f
/ (GLfloat
) DC_LEVEL_LIGHT_DEATH_FLASH_TIME
);
89 if (death_flash
> 1.0f
) death_flash
= 2.0f
- death_flash
;
92 for (int n
= 0; n
< LL_NUMBER_LEVEL_LIGHTS
; n
++) {
93 LevelLight
&light
= LevelLights::lights
[set
][n
];
94 color
[0] = color
[1] = color
[2] = 0.0f
;
96 if (light
.state
& LS_RED
) {
97 color
[0] = DC_LEVEL_LIGHT_RED
;
98 next_color_state
= CS_RED
;
100 } else if (light
.state
& LS_BLUE
) {
101 color
[2] = DC_LEVEL_LIGHT_BLUE
;
102 next_color_state
= CS_BLUE
;
105 GLfloat fade
= light
.fade_alarm
106 * (1.0f
/ (GLfloat
) DC_LEVEL_LIGHT_FADE_TIME
);
108 if (light
.state
& LS_FADE_TO_RED
) {
109 color
[0] = DC_LEVEL_LIGHT_RED
* Game::sqrt(1.0f
- fade
);
110 color
[2] = DC_LEVEL_LIGHT_BLUE
* Game::sqrt(fade
);
113 color
[0] = DC_LEVEL_LIGHT_RED
* Game::sqrt(fade
);
114 color
[2] = DC_LEVEL_LIGHT_BLUE
* Game::sqrt(1.0f
- fade
);
117 next_color_state
= CS_UNDEFINED
;
120 if (light
.state
& LS_IMPACT_FLASH
) {
121 GLfloat flash
= light
.flash_alarm
122 * (1.0f
/ (GLfloat
) DC_LEVEL_LIGHT_IMPACT_FLASH_TIME
);
124 if (flash
> DC_LEVEL_LIGHT_FLASH_INFLECTION
)
125 flash
= (1.0f
- flash
)
126 * (1.0f
/ (1.0f
- DC_LEVEL_LIGHT_FLASH_INFLECTION
));
128 flash
*= 1.0f
/ DC_LEVEL_LIGHT_FLASH_INFLECTION
;
131 color
[0] += (1.0f
- color
[0]) * flash
;
133 color
[2] += (1.0f
- color
[2]) * flash
;
135 next_color_state
= CS_UNDEFINED
;
138 if (LevelLights::death_flash_alarm
[set
] != -1) {
139 color
[0] += (1.0f
- color
[0]) * death_flash
;
140 color
[1] += (1.0f
- color
[1]) * death_flash
;
141 color
[2] += (1.0f
- color
[2]) * death_flash
;
144 if (next_color_state
!= color_state
|| color_state
== CS_UNDEFINED
) {
146 color_state
= next_color_state
;
149 glTranslatef(0.0f
, DC_GRID_ELEMENT_LENGTH
, 0.0f
);
151 glCallList(level_light_list
);
154 if ((MetaState::mode
& CM_SOLO
) && !(MetaState::mode
& CM_AI
))