3 * Daniel Nelson - 9/14/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 * Handles all the little reward signs.
28 #include "SignManager.h"
33 int SignManager::sign_count
;
34 Sign
SignManager::signs
[DC_MAX_SIGN_NUMBER
];
36 // maximum levels for each sign type
37 const int maximum_levels
[3]
40 // which sign texture contains which signs
41 const int texture_mapping
[3][11]
42 = { { 0, 0, 0, 0, 0, 0, 1, 1, 1 },
43 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
44 { 1, 1, 1, 1, 1, 1, 1, 1, 1 } };
46 // where a sign's subtexture is located
47 const GLfloat subtexture_s_mapping
[3][11]
48 = { { 0.0f
, 0.0f
, DC_SIGN_SMALL_SUBTEX_COORD_S
, DC_SIGN_SMALL_SUBTEX_COORD_S
,
49 2.0f
* DC_SIGN_SMALL_SUBTEX_COORD_S
, 2.0f
* DC_SIGN_SMALL_SUBTEX_COORD_S
,
51 { 0.0f
, 1.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
52 DC_SIGN_LARGE_SUBTEX_COORD_S
, DC_SIGN_LARGE_SUBTEX_COORD_S
,
53 DC_SIGN_LARGE_SUBTEX_COORD_S
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
54 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
55 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
56 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
},
57 { 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
58 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
59 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
60 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
61 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
} };
62 const GLfloat subtexture_t_mapping
[3][11]
63 = { { 0.0f
, DC_SIGN_SMALL_SUBTEX_COORD_T
, 0.0f
, DC_SIGN_SMALL_SUBTEX_COORD_T
,
64 0.0f
, DC_SIGN_SMALL_SUBTEX_COORD_T
, 0.0f
, DC_SIGN_LARGE_SUBTEX_COORD_T
,
65 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
},
66 { 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
, 0.0f
, DC_SIGN_LARGE_SUBTEX_COORD_T
,
67 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
, 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
,
68 0.0f
, DC_SIGN_LARGE_SUBTEX_COORD_T
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
,
69 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
, 0.0f
,
70 DC_SIGN_LARGE_SUBTEX_COORD_T
},
71 { 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
72 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
73 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
74 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
75 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
} };
77 void SignManager::initialize ( )
80 for (int n
= DC_MAX_SIGN_NUMBER
; n
--; )
81 signs
[n
].active
= false;
84 void SignManager::createSign ( int x
, int y
, int type
, int level
)
86 if (sign_count
== DC_MAX_SIGN_NUMBER
) return;
89 for (n
= 0; signs
[n
].active
; n
++);
90 Sign
&sign
= signs
[n
];
92 if (type
== ST_MULTIPLIER
) {
95 if (!confirmSignLocation(signs
[n
]))
104 if (!confirmSignLocation(sign
))
105 if (sign
.g_x
< GC_PLAY_WIDTH
- 1)
111 while (!confirmSignLocation(sign
))
114 sign
.x
= sign
.g_x
* DC_GRID_ELEMENT_LENGTH
115 + (DC_PLAY_OFFSET_X
+ DC_SIGN_OFFSET_X
- DC_SIGN_OFFSET_SPREAD
)
116 + (2 * DC_SIGN_OFFSET_SPREAD
) * Random::number();
117 sign
.y
= sign
.g_y
* DC_GRID_ELEMENT_LENGTH
118 + Displayer::play_offset_y
+ (DC_SIGN_OFFSET_Y
- DC_SIGN_OFFSET_SPREAD
)
119 + (2 * DC_SIGN_OFFSET_SPREAD
) * Random::number();
121 if (level
> maximum_levels
[type
])
122 level
= maximum_levels
[type
];
124 sign
.texture
= texture_mapping
[type
][level
];
125 sign
.subtexture_s
= subtexture_s_mapping
[type
][level
];
126 sign
.subtexture_t
= subtexture_t_mapping
[type
][level
];
128 if (type
!= ST_SPECIAL
)
139 void SignManager::timeStep_inline_split_ ( )
142 for (int n
= 0; c
; n
++)
143 if (signs
[n
].active
) {
144 Sign
&sign
= signs
[n
];
147 if (++sign
.life_time
== DC_SIGN_LIFE_TIME
) {
152 if (sign
.life_time
< DC_SIGN_ACCELERATION_TIME
)
153 sign
.y
+= DC_SIGN_ACCELERATION
* sign
.life_time
;
156 sign
.y
+= DC_SIGN_TERMINAL_VELOCITY
;