Mercurial > hg > Game > S_Dandy
annotate src/collision.cc @ 4:bb2fbe78c7cd
moving title scene.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 07 Dec 2010 18:37:43 +0900 |
parents | deb7e09824a4 |
children |
rev | line source |
---|---|
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 #include <stdio.h> |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 #include <stdlib.h> |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 #include <SDL.h> |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 #include "SDL_opengl.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 #include "object.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 #include "Character.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 #include "Character_state.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 #include "tokuten.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 #include "collision.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 //#include "atari.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 #include "bom.h" |
4 | 12 #include "count.h" |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 #include "sound.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 //#include "Enemy.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 //#include "libps.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 #include "sgoex.h" |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 |
4 | 18 #include "SceneGraph.h" |
19 #include "S_Dandy.h" | |
20 | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 extern SpriteTable sptable[DEFOBJ]; |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 void |
4 | 24 nocollision(SceneGraphPtr node, int screen_w, int screen_h, |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 SceneGraphPtr tree){} |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 void |
4 | 28 delete_chara(SceneGraphPtr node, void *sgroot_, int w, int h, |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 SceneGraphPtr tree) |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 { |
4 | 31 node->remove(); |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 } |
4 | 33 |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 void |
4 | 35 title_collision(SceneGraphPtr node, void *sgroot_, int w, int h, |
36 SceneGraphPtr tree) | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 { |
4 | 38 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
39 Pad *pad = sgroot->getController(); | |
40 | |
41 if (pad->start.isPush() && pad->start.isHold()) { | |
42 jiki.bf = TRUE; | |
43 | |
44 SoundStop(); | |
45 SoundPlay(0); | |
46 | |
47 gamef = 1; | |
48 | |
49 // node->remove(); | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 } |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 |
4 | 52 if ((pad->start.isPush() && pad->start.isHold()) && |
53 (pad->select.isPush() && pad->select.isHold())) { | |
54 | |
55 gamef = 0; | |
56 } | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 |
4 | 58 /* タイトルの move |
59 if (pad[0].st > 1) { | |
60 jiki.bf = TRUE; | |
61 | |
62 // CdPlay(1,&cdp[0],0); | |
63 SoundStop(); | |
64 SoundPlay(0); | |
65 | |
66 gamef = 1; | |
67 pad[0].st = 1; | |
68 return; | |
69 } | |
70 if ((pad[0].se > 0) && (pad[0].st > 0)) { | |
71 gamef = 0; | |
72 break; | |
73 } | |
74 */ | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 } |
4 | 76 |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77 void |
4 | 78 subtitle_collision(SceneGraphPtr node, void *sgroot_, int w, int h, |
79 SceneGraphPtr tree) | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
80 { |
4 | 81 if(gamef) { |
82 node->remove(); | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83 } |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
84 } |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85 |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86 void |
4 | 87 atari(SceneGraphPtr node, void *sgroot_, int w, int h, |
88 SceneGraphPtr tree) | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
89 { |
4 | 90 int i1, height, width, ex, ey, charno; |
91 int n; | |
92 | |
93 SpriteTable *p; | |
94 | |
95 ex = node->xyz[0]; | |
96 ey = node->xyz[1]; | |
97 charno = node->stack_xyz[0]; | |
98 | |
99 p = &sptable[charno]; | |
100 width = p->w; | |
101 height = p->h; | |
102 //i2 = playerno; | |
103 | |
104 | |
105 //自機やられ | |
106 #ifndef INVISIBLE_MODE | |
107 if ((ex < jiki.x + 128 / 2) && (ex + width > jiki.x + 128 / 2) | |
108 && (ey < jiki.y + 128 / 2) && (ey + height > jiki.y + 128 / 2) | |
109 && jiki.muteki == 0) { | |
110 //se_voice[0] = SsUtKeyOn(vab[JIKIOUT], 0, 0, 65, 0, 60, 60); | |
111 Bom(jiki.x + 16, jiki.y + 16); | |
112 jiki.bf = FALSE; | |
113 jiki.zanki--; | |
114 jiki.muteki = 120; | |
115 | |
116 infg.stg = 0; | |
117 infg_level--; | |
118 if (infg_level < 0) | |
119 infg_level = 0; | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 } |
4 | 121 #endif |
122 | |
123 if (p->tama == TRUE) | |
124 goto jumping; | |
125 for (i1 = 0; i1 < tama_lv1_end + 1; i1++) { | |
126 | |
127 if ((tama_lv1[i1].x + 64 + 64 > ex) | |
128 && (ex + width > tama_lv1[i1].x + 16) | |
129 && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + height) | |
130 && (tama_lv1[i1].r != -1)) { | |
131 tama_lv1[i1].r = -1; | |
132 p->vit -= TAMALV1P; | |
133 infg.stg++; | |
134 if (p->vit <= 0) { | |
135 infg.stg += 4; | |
136 Bom(p->x, p->y); | |
137 enemycount += (p->score * | |
138 ((infg.stg / 128) + infg_level + 1)); | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 |
4 | 140 node->set_move_collision(noaction, delete_chara); |
141 p->f = FALSE; | |
142 } | |
143 } | |
144 if ((tama_lv1[i1].x + 64 > ex) && (ex + width > tama_lv1[i1].x) | |
145 && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + height) | |
146 && (tama_lv1[i1].l != -1)) { | |
147 tama_lv1[i1].l = -1; | |
148 p->vit -= TAMALV1P; | |
149 infg.stg++; | |
150 if (p->vit <= 0) { | |
151 infg.stg += 4; | |
152 Bom(p->x, p->y); | |
153 enemycount += (p->score * | |
154 ((infg.stg / 128) + infg_level + 1)); | |
155 node->set_move_collision(noaction, delete_chara); | |
156 p->f = FALSE; | |
157 } | |
158 } | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
159 } |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 |
4 | 161 for (i1 = 0; i1 < tama_lv2_end + 1; i1++) { |
162 if ((tama_lv2[i1].x + 128 + 64 > ex) | |
163 && (ex + width > tama_lv2[i1].x + 128) | |
164 && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + height) | |
165 && (tama_lv2[i1].rr != -1)) { | |
166 tama_lv2[i1].rr = -1; | |
167 p->vit -= TAMALV2P; | |
168 infg.stg++; | |
169 if (p->vit <= 0) { | |
170 infg.stg += 4; | |
171 Bom(p->x, p->y); | |
172 enemycount += (p->score * | |
173 ((infg.stg / 128) + infg_level + 1)); | |
174 node->set_move_collision(noaction, delete_chara); | |
175 p->f = FALSE; | |
176 } | |
177 } | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
178 |
4 | 179 if ((tama_lv2[i1].x + 64 + 64 > ex) |
180 && (ex + width > tama_lv2[i1].x + 16) | |
181 && (tama_lv2[i1].y - 32 + 192 > ey) | |
182 && (tama_lv2[i1].y - 32 < ey + height) | |
183 && (tama_lv2[i1].sr != -1)) { | |
184 tama_lv2[i1].sr = -1; | |
185 p->vit -= TAMALV2P; | |
186 infg.stg++; | |
187 if (p->vit <= 0) { | |
188 infg.stg += 4; | |
189 Bom(p->x, p->y); | |
190 enemycount += (p->score * | |
191 ((infg.stg / 128) + infg_level + 1)); | |
192 node->set_move_collision(noaction, delete_chara); | |
193 p->f = FALSE; | |
194 } | |
195 } | |
196 if ((tama_lv2[i1].x + 64 > ex) && (ex + width > tama_lv2[i1].x) | |
197 && (tama_lv2[i1].y - 32 + 192 > ey) | |
198 && (tama_lv2[i1].y - 32 < ey + height) | |
199 && (tama_lv2[i1].sl != -1)) { | |
200 tama_lv2[i1].sl = -1; | |
201 p->vit -= TAMALV2P; | |
202 infg.stg++; | |
203 if (p->vit <= 0) { | |
204 infg.stg += 4; | |
205 Bom(p->x, p->y); | |
206 enemycount += (p->score * | |
207 ((infg.stg / 128) + infg_level + 1)); | |
208 node->set_move_collision(noaction, delete_chara); | |
209 p->f = FALSE; | |
210 } | |
211 } | |
212 if ((tama_lv2[i1].x - 64 + 64 > ex) | |
213 && (ex + width > tama_lv2[i1].x - 64) | |
214 && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + height) | |
215 && (tama_lv2[i1].ll != -1)) { | |
216 tama_lv2[i1].ll = -1; | |
217 p->vit -= TAMALV2P; | |
218 infg.stg++; | |
219 if (p->vit <= 0) { | |
220 infg.stg += 4; | |
221 Bom(p->x, p->y); | |
222 enemycount += (p->score * | |
223 ((infg.stg / 128) + infg_level + 1)); | |
224 node->set_move_collision(noaction, delete_chara); | |
225 p->f = FALSE; | |
226 } | |
227 } | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 } |
4 | 229 if ((tlv3[0].r > 0) && (jiki.x < ex + width) && (jiki.x + 128 > ex) |
230 && (jiki.y > ey + height)) { | |
231 p->vit -= TAMALV3P; | |
232 infg.stg++; | |
233 if (p->vit <= 0) { | |
234 infg.stg += 4; | |
235 Bom(p->x, p->y); | |
236 enemycount += (p->score * | |
237 ((infg.stg / 128) + infg_level + 1)); | |
238 node->set_move_collision(noaction, delete_chara); | |
239 p->f = FALSE; | |
240 } | |
241 } | |
242 jumping: | |
243 if ((tlv3[0].r > 0) && (jiki.x < ex + width) && (jiki.x + 128 > ex) | |
244 && (jiki.y + 128 > ey) && (jiki.y < ey + height)) { | |
245 p->vit -= TAMALV3P; | |
246 infg.stg++; | |
247 if (p->vit <= 0) { | |
248 infg.stg += 4; | |
249 Bom(p->x, p->y); | |
250 enemycount += (p->score * | |
251 ((infg.stg / 128) + infg_level + 1)); | |
252 node->set_move_collision(noaction, delete_chara); | |
253 p->f = FALSE; | |
254 } | |
255 } | |
256 /*laser lv1 */ | |
257 for (i1 = 0; i1 < laser_lv1_end + 1; i1++) { | |
258 n = laser_lv1[i1].r * 128 / 4096; | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
259 |
4 | 260 if ((laser_lv1[i1].x + n > ex) && (ex + width > laser_lv1[i1].x) |
261 && (laser_lv1[i1].y + n > ey) && (laser_lv1[i1].y < ey + height) | |
262 && (laser_lv1[i1].r != -1)) { | |
263 laser_lv1[i1].r = -1; | |
264 laser_lv1[i1].y = -1; | |
265 p->vit -= LASERLV1P; | |
266 infg.stg++; | |
267 if (p->vit <= 0) { | |
268 infg.stg += 4; | |
269 Bom(p->x, p->y); | |
270 enemycount += (p->score * | |
271 ((infg.stg / 128) + infg_level + 1)); | |
272 node->set_move_collision(noaction, delete_chara); | |
273 p->f = FALSE; | |
274 } | |
275 } | |
276 } | |
277 /*shield(laser lv2) */ | |
278 if ((p->tama == TRUE) && (lg.stg > 0) && | |
279 (laser_lv2[0].x + 128 > ex) && (ex + width > laser_lv2[0].x - 128) | |
280 && (laser_lv2[0].y + 128 > ey) && (laser_lv2[0].y - 128 < ey + height) | |
281 && (laser_lv2[0].r != 0)) { | |
282 p->vit -= LASERLV2P; | |
283 lg.stg -= 26; | |
284 infg.stg++; | |
285 if (p->vit <= 0) { | |
286 infg.stg += 4; | |
287 Bom(p->x, p->y); | |
288 enemycount += (p->score * | |
289 ((infg.stg / 128) + infg_level + 1)); | |
290 node->set_move_collision(noaction, delete_chara); | |
291 p->f = FALSE; | |
292 } | |
293 } | |
294 /*bomber(laser lv3) */ | |
295 if (laser_lv3[0].r < 62) { | |
296 for (i1 = 1; i1 < 128; i1++) { | |
297 if ((laser_lv3[i1].x + 128 > ex) && (ex + width > laser_lv3[i1].x) | |
298 && (laser_lv3[i1].y + 128 > ey) | |
299 && (laser_lv3[i1].y < ey + height) | |
300 && (laser_lv3[i1].r > 0)) { | |
301 tama_lv2[i1].rr = -1; | |
302 p->vit -= LASERLV3P; | |
303 infg.stg++; | |
304 if (p->vit <= 0) { | |
305 infg.stg += 4; | |
306 Bom(p->x, p->y); | |
307 enemycount += (p->score * | |
308 ((infg.stg / 128) + infg_level + 1)); | |
309 node->set_move_collision(noaction, delete_chara); | |
310 p->f = FALSE; | |
311 } | |
312 } | |
313 } | |
3
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
314 } |
deb7e09824a4
add 'src' directory and 'xml' directory.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
315 } |