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.
31 #include "SignManager.h"
34 int SignManager::sign_count
;
35 Sign
SignManager::signs
[DC_MAX_SIGN_NUMBER
];
37 // maximum levels for each sign type
38 const int maximum_levels
[3]
41 // which sign texture contains which signs
42 const int texture_mapping
[3][11]
43 = { { 0, 0, 0, 0, 0, 0, 1, 1, 1 },
44 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
45 { 1, 1, 1, 1, 1, 1, 1, 1, 1 } };
47 // where a sign's subtexture is located
48 const GLfloat subtexture_s_mapping
[3][11]
49 = { { 0.0f
, 0.0f
, DC_SIGN_SMALL_SUBTEX_COORD_S
, DC_SIGN_SMALL_SUBTEX_COORD_S
,
50 2.0f
* DC_SIGN_SMALL_SUBTEX_COORD_S
, 2.0f
* DC_SIGN_SMALL_SUBTEX_COORD_S
,
52 { 0.0f
, 1.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
53 DC_SIGN_LARGE_SUBTEX_COORD_S
, DC_SIGN_LARGE_SUBTEX_COORD_S
,
54 DC_SIGN_LARGE_SUBTEX_COORD_S
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
55 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
56 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
, 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
57 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
, 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
62 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
} };
63 const GLfloat subtexture_t_mapping
[3][11]
64 = { { 0.0f
, DC_SIGN_SMALL_SUBTEX_COORD_T
, 0.0f
, DC_SIGN_SMALL_SUBTEX_COORD_T
,
65 0.0f
, DC_SIGN_SMALL_SUBTEX_COORD_T
, 0.0f
, DC_SIGN_LARGE_SUBTEX_COORD_T
,
66 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
},
67 { 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
, 0.0f
, DC_SIGN_LARGE_SUBTEX_COORD_T
,
68 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
, 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
,
69 0.0f
, DC_SIGN_LARGE_SUBTEX_COORD_T
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
,
70 3.0f
* DC_SIGN_LARGE_SUBTEX_COORD_T
, 0.0f
,
71 DC_SIGN_LARGE_SUBTEX_COORD_T
},
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
, 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
,
76 2.0f
* DC_SIGN_LARGE_SUBTEX_COORD_S
} };
78 void SignManager::initialize ( )
81 for (int n
= DC_MAX_SIGN_NUMBER
; n
--; )
82 signs
[n
].active
= false;
85 void SignManager::createSign ( int x
, int y
, int type
, int level
)
87 if (sign_count
== DC_MAX_SIGN_NUMBER
) return;
90 for (n
= 0; signs
[n
].active
; n
++);
91 Sign
&sign
= signs
[n
];
93 if (type
== ST_MULTIPLIER
) {
96 if (!confirmSignLocation(signs
[n
]))
105 if (!confirmSignLocation(sign
))
106 if (sign
.g_x
< GC_PLAY_WIDTH
- 1)
112 while (!confirmSignLocation(sign
))
115 sign
.x
= sign
.g_x
* DC_GRID_ELEMENT_LENGTH
116 + (DC_PLAY_OFFSET_X
+ DC_SIGN_OFFSET_X
- DC_SIGN_OFFSET_SPREAD
)
117 + (2 * DC_SIGN_OFFSET_SPREAD
) * Random::number();
118 sign
.y
= sign
.g_y
* DC_GRID_ELEMENT_LENGTH
119 + Displayer::play_offset_y
+ (DC_SIGN_OFFSET_Y
- DC_SIGN_OFFSET_SPREAD
)
120 + (2 * DC_SIGN_OFFSET_SPREAD
) * Random::number();
122 if (level
> maximum_levels
[type
])
123 level
= maximum_levels
[type
];
125 sign
.texture
= texture_mapping
[type
][level
];
126 sign
.subtexture_s
= subtexture_s_mapping
[type
][level
];
127 sign
.subtexture_t
= subtexture_t_mapping
[type
][level
];
129 if (type
!= ST_SPECIAL
)
140 void SignManager::timeStep_inline_split_ ( )
143 for (int n
= 0; c
; n
++)
144 if (signs
[n
].active
) {
145 Sign
&sign
= signs
[n
];
148 if (++sign
.life_time
== DC_SIGN_LIFE_TIME
) {
153 if (sign
.life_time
< DC_SIGN_ACCELERATION_TIME
)
154 sign
.y
+= DC_SIGN_ACCELERATION
* sign
.life_time
;
157 sign
.y
+= DC_SIGN_TERMINAL_VELOCITY
;