Really low graphics patch thanks to Stephan Beyer
[crack-attack.git] / src / X.h
blob40cbe53d3ee2bfc378aa0ef38aa4086be93f1b89
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 #ifndef _WIN32
33 #else
34 # include <glext.h>
35 #endif
37 using namespace std;
39 #include "Game.h"
40 #include "Random.h"
41 #include "Garbage.h"
42 #include "Block.h"
44 class Wild {
45 public:
46 bool active;
47 int flavor;
48 int alarm;
49 Block *block;
52 /* static */ class X {
53 public:
54 static void gameStart ( );
55 static void timeStep ( );
56 static void modifyHeadlightColor ( GLfloat headlight_color[3] );
57 static void notifyImpact ( Garbage &garbage );
58 static void notifyShatter ( Garbage &garbage );
60 static inline bool reverseControls ( )
62 return reverse_controls != 0;
65 static inline bool invisibleSwapper ( )
67 return swapper_alpha != GC_INVISIBLE_MAX_ALPHA;
70 static inline bool needDrawSwapper ( )
72 return swapper_alpha > 0;
75 static inline GLfloat swapperAlpha ( )
77 assert(needDrawSwapper());
78 return swapper_alpha * (1.0f / (float) GC_INVISIBLE_MAX_ALPHA);
81 static inline bool crazyLights ( )
83 return light_mode != -1 && (light_mode & (1 << 0));
86 static inline bool wildActive ( )
88 return wild_count != 0;
91 static inline bool wildAllowed ( )
93 return wild_count != GC_MAX_WILD_NUMBER;
96 static inline void activateWild ( Block &block )
98 assert(wildAllowed());
100 int n;
101 for (n = 0; wilds[n].active; n++);
103 block.X = n;
105 wilds[n].active = true;
106 wilds[n].block = &block;
107 wilds[n].flavor = Random::number(BF_WILD + 1);
108 wilds[n].alarm = 180;
110 wild_count++;
113 static inline int wildFlavor ( Block &block )
115 assert(block.flavor == BF_WILD);
117 if (wilds[block.X].alarm >= GC_WILD_POLYMORPH_PERIOD)
118 return wilds[block.X].flavor;
119 else
120 return BF_WILD;
123 static inline Wild &wild ( Block &block )
125 assert(block.flavor == BF_WILD);
127 return wilds[block.X];
130 static inline void deactivateWild ( Block &block )
132 assert(block.flavor == BF_WILD);
134 wilds[block.X].active = false;
135 wild_count--;
138 static inline bool specialColorActive ( )
140 return special_color_count != 0;
143 static inline bool specialColorAllowed ( )
145 return special_color_count != GC_MAX_SPECIAL_COLOR_NUMBER;
148 static inline void activateSpecialColor ( Block &block )
150 assert(specialColorAllowed());
152 // sloppy but effective way of insuring each special color block's gleam
153 // is distinct
154 block.X = Random::number2((1 << 20));
155 special_color_count++;
158 static inline void deactivateSpecialColor ( )
160 special_color_count--;
163 static int reverse_controls;
164 static int invisible_swapper;
165 static int crazy_lights;
167 static int swapper_alpha;
169 static int light_mode;
170 static int light_alarm;
171 static const GLfloat light_level_map[6][3];
173 static int wild_count;
174 static Wild wilds[GC_MAX_WILD_NUMBER];
176 static int special_color_count;
179 #endif