Object loading patch
[crack-attack.git] / src / X.h
blobfc053b51dda7cf12ff45dfef11d71ca8ce3ab720
1 /*
2 * X.h
3 * Daniel Nelson - 8/24/0
5 * Copyright (C) 2000 Daniel Nelson
6 *
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
22 * 174 W. 18th Ave.
23 * Columbus, OH 43210
26 #ifndef X_H
27 #define X_H
29 #include <GL/glut.h>
30 #include <cassert>
32 #include "glext.h"
34 using namespace std;
36 #include "Game.h"
37 #include "Random.h"
38 #include "Garbage.h"
39 #include "Block.h"
41 class Wild {
42 public:
43 bool active;
44 int flavor;
45 int alarm;
46 Block *block;
49 /* static */ class X {
50 public:
51 static void gameStart ( );
52 static void timeStep ( );
53 static void modifyHeadlightColor ( GLfloat headlight_color[3] );
54 static void notifyImpact ( Garbage &garbage );
55 static void notifyShatter ( Garbage &garbage );
57 static inline bool reverseControls ( )
59 return reverse_controls != 0;
62 static inline bool invisibleSwapper ( )
64 return swapper_alpha != GC_INVISIBLE_MAX_ALPHA;
67 static inline bool needDrawSwapper ( )
69 return swapper_alpha > 0;
72 static inline GLfloat swapperAlpha ( )
74 assert(needDrawSwapper());
75 return swapper_alpha * (1.0f / (float) GC_INVISIBLE_MAX_ALPHA);
78 static inline bool crazyLights ( )
80 return light_mode != -1 && (light_mode & (1 << 0));
83 static inline bool wildActive ( )
85 return wild_count != 0;
88 static inline bool wildAllowed ( )
90 return wild_count != GC_MAX_WILD_NUMBER;
93 static inline void activateWild ( Block &block )
95 assert(wildAllowed());
97 int n;
98 for (n = 0; wilds[n].active; n++);
100 block.X = n;
102 wilds[n].active = true;
103 wilds[n].block = &block;
104 wilds[n].flavor = Random::number(BF_WILD + 1);
105 wilds[n].alarm = 180;
107 wild_count++;
110 static inline int wildFlavor ( Block &block )
112 assert(block.flavor == BF_WILD);
114 if (wilds[block.X].alarm >= GC_WILD_POLYMORPH_PERIOD)
115 return wilds[block.X].flavor;
116 else
117 return BF_WILD;
120 static inline Wild &wild ( Block &block )
122 assert(block.flavor == BF_WILD);
124 return wilds[block.X];
127 static inline void deactivateWild ( Block &block )
129 assert(block.flavor == BF_WILD);
131 wilds[block.X].active = false;
132 wild_count--;
135 static inline bool specialColorActive ( )
137 return special_color_count != 0;
140 static inline bool specialColorAllowed ( )
142 return special_color_count != GC_MAX_SPECIAL_COLOR_NUMBER;
145 static inline void activateSpecialColor ( Block &block )
147 assert(specialColorAllowed());
149 // sloppy but effective way of insuring each special color block's gleam
150 // is distinct
151 block.X = Random::number2((1 << 20));
152 special_color_count++;
155 static inline void deactivateSpecialColor ( )
157 special_color_count--;
160 static int reverse_controls;
161 static int invisible_swapper;
162 static int crazy_lights;
164 static int swapper_alpha;
166 static int light_mode;
167 static int light_alarm;
168 static const GLfloat light_level_map[6][3];
170 static int wild_count;
171 static Wild wilds[GC_MAX_WILD_NUMBER];
173 static int special_color_count;
176 #endif