1 /* 2 * Garbage.h 3 * Daniel Nelson - 8/24/0 4 * 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. 11 * 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. 16 * 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. 20 * 21 * Daniel Nelson - aluminumangel.org 22 * 174 W. 18th Ave. 23 * Columbus, OH 43210 24 */ 25 26 #ifndef GARBAGE_H 27 #define GARBAGE_H 28 29 #include <GL/glut.h> 30 31 #include "glext.h" 32 33 using namespace std; 34 35 // flavor of garbage 36 #define GF_NORMAL (0) 37 #define GF_GRAY (1) // hard to destroy 38 #define GF_BLACK (2) // very hard to destroy 39 #define GF_WHITE (3) // crazy lights 40 #define GF_COLOR_1 (4) // sprinkling of 1x1's 41 #define GF_COLOR_2 (5) // shatters to normal garbage 42 #define GF_COLOR_3 (6) // invisible swapper 43 #define GF_COLOR_4 (7) // reverse controls 44 #define GF_COLOR_5 (8) // tall garbage 45 #define GF_NUMBER (9) 46 47 // flavor effects 48 #define GF_SHATTER_TO_NORMAL_GARBAGE (GF_COLOR_2) 49 #define GF_REVERSE_CONTROLS (GF_COLOR_4) 50 #define GF_INVISIBLE_SWAPPER (GF_COLOR_3) 51 #define GF_CRAZY_LIGHTS (GF_WHITE) 52 53 // states of garbage 54 #define GS_STATIC (1 << 0) 55 #define GS_FALLING (1 << 1) 56 #define GS_AWAKING (1 << 2) 57 #define GS_SHATTERING (1 << 3) 58 59 class ComboTabulator; 60 61 class Garbage { 62 public: 63 void initializeStatic ( int _x, int _y, int _height, int _width, 64 int _flavor ); 65 void initializeFalling ( int _x, int _y, int _height, int _width, 66 int _flavor ); 67 void initializeAwaking ( int _x, int _y, int _height, int pop_delay, 68 int awake_delay, ComboTabulator *combo, int _pop_color ); 69 void timeStep ( int &l_x, int &l_y ); 70 void startFalling ( ComboTabulator *combo = NULL, bool no_hang = false, 71 bool self_call = false ); 72 void startShattering ( int &s_x, int s_y, int &pop_delay, int awake_delay, 73 ComboTabulator *combo ); 74 considerShattering(Garbage * due_to)75 bool considerShattering ( Garbage *due_to ) 76 /* 77 * The grid is asking us if we should shatter due to the fact that our 78 * neighbor - due_to - is shattering. If due_to is null, we are shattering 79 * because of a neighboring elimination. Parts of the black garbage 80 * algorithm are handled in Grid.cxx 81 */ 82 { 83 if (!due_to) return true; 84 if (flavor == GF_GRAY) 85 if (due_to->flavor == GF_GRAY) 86 return true; 87 else 88 return false; 89 if (flavor == GF_BLACK) 90 if (due_to->flavor == GF_BLACK) 91 return true; 92 else 93 return false; 94 if (due_to->flavor == GF_GRAY) 95 return false; 96 else 97 return true; 98 } 99 100 // free store id 101 int id; 102 103 // block type 104 int flavor; 105 106 // grid position 107 int x, y; 108 109 // garbage dimensions 110 int height, width; 111 112 // find position control; GC_STEPS_PER_GRID number of increments per grid 113 int f_y; 114 115 // garbage state 116 int state; 117 118 // time until awakening 119 int alarm; 120 121 // number of sections popped in awaking garbage 122 int sections_popped; 123 124 // true if we're in an initial fall 125 bool initial_fall; 126 127 // next direction of rotation upon popping 128 int pop_direction; 129 130 // time until pop 131 int pop_alarm; 132 133 // the block color before popping 134 int pop_color; 135 136 private: 137 // combo to pass on upon awakening 138 ComboTabulator *awaking_combo; 139 }; 140 141 #endif 142