comparison 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
comparison
equal deleted inserted replaced
3:deb7e09824a4 4:bb2fbe78c7cd
7 #include "Character_state.h" 7 #include "Character_state.h"
8 #include "tokuten.h" 8 #include "tokuten.h"
9 #include "collision.h" 9 #include "collision.h"
10 //#include "atari.h" 10 //#include "atari.h"
11 #include "bom.h" 11 #include "bom.h"
12 #include "count2.h" 12 #include "count.h"
13 #include "sound.h" 13 #include "sound.h"
14 //#include "Enemy.h" 14 //#include "Enemy.h"
15 //#include "libps.h" 15 //#include "libps.h"
16 #include "sgoex.h" 16 #include "sgoex.h"
17 17
18 #include "SceneGraph.h"
19 #include "S_Dandy.h"
20
18 extern SpriteTable sptable[DEFOBJ]; 21 extern SpriteTable sptable[DEFOBJ];
19 22
20 void 23 void
21 nocollision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, 24 nocollision(SceneGraphPtr node, int screen_w, int screen_h,
22 SceneGraphPtr tree){} 25 SceneGraphPtr tree){}
23 26
24 /*** 当たり判定に使うパラメータや変数の定義 ***/ 27 void
25 #if 0 28 delete_chara(SceneGraphPtr node, void *sgroot_, int w, int h,
26 CHARACTER * atari(CHARACTER *p)
27
28 int i1, h, w, ex, ey, charno;
29 int n;
30 ex = p->x;
31 ey = node->xyz[1];
32 charno = p->charano;
33 w = sptable[charno].w;
34 h = sptable[charno].h;
35 //i2 = playerno;
36 #endif
37
38
39 //#ifndef INVISIBLE_MODE
40
41 /*** 自機やられ ただし無敵時間中で無ければという条件付き ***/
42 void
43 player_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
44 SceneGraphPtr tree)
45 {
46 if ((ex < jiki.x + 128 / 2) && (ex + w > jiki.x + 128 / 2)
47 && (ey < jiki.y + 128 / 2) && (ey + h > jiki.y + 128 / 2)
48 && jiki.muteki == 0) {
49 //se_voice[0] = SsUtKeyOn(vab[JIKIOUT], 0, 0, 65, 0, 60, 60);
50 Bom(jiki.x + 16, jiki.y + 16);
51 jiki.bf = FALSE;
52 jiki.zanki--;
53 jiki.muteki = 120;
54
55 infg.stg = 0;
56 infg_level--;
57 if (infg_level < 0) {
58 infg_level = 0;
59 }
60 }
61 }
62
63 //#endif
64
65 // if (p->tama == TRUE)
66 // goto jumping;
67
68 // for (i1 = 0; i1 < tama_lv1_end + 1; i1++) {
69
70 /*** tama_lv1_end になるまで ***/
71 void
72 collision_01(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
73 SceneGraphPtr tree) 29 SceneGraphPtr tree)
74 { 30 {
75 if ((tama_lv1[i1].x + 64 + 64 > ex) 31 node->remove();
76 && (ex + w > tama_lv1[i1].x + 16)
77 && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + h)
78 && (tama_lv1[i1].r != -1)) {
79 tama_lv1[i1].r = -1;
80 p->vit -= TAMALV1P;
81 infg.stg++;
82 if (p->vit <= 0) {
83 infg.stg += 4;
84 Bom(node->xyz[0], node->xyz[1]);
85 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1));
86 p->state = delete_chara;
87 p->collision = noaction;
88 p->f = FALSE;
89 }
90 }
91 } 32 }
92 33
93 void 34 void
94 collision_02(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, 35 title_collision(SceneGraphPtr node, void *sgroot_, int w, int h,
95 SceneGraphPtr tree) 36 SceneGraphPtr tree)
96 { 37 {
97 if ((tama_lv1[i1].x + 64 > ex) && (ex + w > tama_lv1[i1].x) 38 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
98 && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + h) 39 Pad *pad = sgroot->getController();
99 && (tama_lv1[i1].l != -1)) { 40
100 tama_lv1[i1].l = -1; 41 if (pad->start.isPush() && pad->start.isHold()) {
101 p->vit -= TAMALV1P; 42 jiki.bf = TRUE;
102 infg.stg++; 43
103 if (p->vit <= 0) { 44 SoundStop();
104 infg.stg += 4; 45 SoundPlay(0);
105 Bom(node->xyz[0], node->xyz[1]); 46
106 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); 47 gamef = 1;
107 p->state = delete_chara; 48
108 p->collision = noaction; 49 // node->remove();
109 p->f = FALSE; 50 }
110 } 51
111 } 52 if ((pad->start.isPush() && pad->start.isHold()) &&
53 (pad->select.isPush() && pad->select.isHold())) {
54
55 gamef = 0;
56 }
57
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 */
112 } 75 }
113 /*** tama_lv1_end ここまで ***/ 76
114 77 void
115 // for (i1 = 0; i1 < tama_lv2_end + 1; i1++) { 78 subtitle_collision(SceneGraphPtr node, void *sgroot_, int w, int h,
116 79 SceneGraphPtr tree)
117 /*** tama_lv2_end になるまで ***/
118 void
119 collision_03(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
120 SceneGraphPtr tree)
121 { 80 {
122 if ((tama_lv2[i1].x + 128 + 64 > ex) 81 if(gamef) {
123 && (ex + w > tama_lv2[i1].x + 128) 82 node->remove();
124 && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + h) 83 }
125 && (tama_lv2[i1].rr != -1)) {
126 tama_lv2[i1].rr = -1;
127 p->vit -= TAMALV2P;
128 infg.stg++;
129 if (p->vit <= 0) {
130 infg.stg += 4;
131 Bom(node->xyz[0], node->xyz[1]);
132 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1));
133 p->state = delete_chara;
134 p->collision = noaction;
135 p->f = FALSE;
136 }
137 }
138 } 84 }
139 85
140 void 86 void
141 collision_04(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, 87 atari(SceneGraphPtr node, void *sgroot_, int w, int h,
142 SceneGraphPtr tree) 88 SceneGraphPtr tree)
143 { 89 {
144 if ((tama_lv2[i1].x + 64 + 64 > ex) 90 int i1, height, width, ex, ey, charno;
145 && (ex + w > tama_lv2[i1].x + 16) 91 int n;
146 && (tama_lv2[i1].y - 32 + 192 > ey) 92
147 && (tama_lv2[i1].y - 32 < ey + h) 93 SpriteTable *p;
148 && (tama_lv2[i1].sr != -1)) { 94
149 tama_lv2[i1].sr = -1; 95 ex = node->xyz[0];
150 p->vit -= TAMALV2P; 96 ey = node->xyz[1];
151 infg.stg++; 97 charno = node->stack_xyz[0];
152 if (p->vit <= 0) { 98
153 infg.stg += 4; 99 p = &sptable[charno];
154 Bom(node->xyz[0], node->xyz[1]); 100 width = p->w;
155 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); 101 height = p->h;
156 p->state = delete_chara; 102 //i2 = playerno;
157 p->collision = noaction; 103
158 p->f = FALSE; 104
159 } 105 //自機やられ
160 } 106 #ifndef INVISIBLE_MODE
161 } 107 if ((ex < jiki.x + 128 / 2) && (ex + width > jiki.x + 128 / 2)
162 108 && (ey < jiki.y + 128 / 2) && (ey + height > jiki.y + 128 / 2)
163 void 109 && jiki.muteki == 0) {
164 collision_05(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, 110 //se_voice[0] = SsUtKeyOn(vab[JIKIOUT], 0, 0, 65, 0, 60, 60);
165 SceneGraphPtr tree) 111 Bom(jiki.x + 16, jiki.y + 16);
166 { 112 jiki.bf = FALSE;
167 if ((tama_lv2[i1].x + 64 > ex) && (ex + w > tama_lv2[i1].x) 113 jiki.zanki--;
168 && (tama_lv2[i1].y - 32 + 192 > ey) 114 jiki.muteki = 120;
169 && (tama_lv2[i1].y - 32 < ey + h) 115
170 && (tama_lv2[i1].sl != -1)) { 116 infg.stg = 0;
171 tama_lv2[i1].sl = -1; 117 infg_level--;
172 p->vit -= TAMALV2P; 118 if (infg_level < 0)
173 infg.stg++; 119 infg_level = 0;
174 if (p->vit <= 0) { 120 }
175 infg.stg += 4; 121 #endif
176 Bom(node->xyz[0], node->xyz[1]); 122
177 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); 123 if (p->tama == TRUE)
178 p->state = delete_chara; 124 goto jumping;
179 p->collision = noaction; 125 for (i1 = 0; i1 < tama_lv1_end + 1; i1++) {
180 p->f = FALSE; 126
181 } 127 if ((tama_lv1[i1].x + 64 + 64 > ex)
182 } 128 && (ex + width > tama_lv1[i1].x + 16)
183 } 129 && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + height)
184 130 && (tama_lv1[i1].r != -1)) {
185 void 131 tama_lv1[i1].r = -1;
186 collision_06(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, 132 p->vit -= TAMALV1P;
187 SceneGraphPtr tree) 133 infg.stg++;
188 { 134 if (p->vit <= 0) {
189 if ((tama_lv2[i1].x - 64 + 64 > ex) 135 infg.stg += 4;
190 && (ex + w > tama_lv2[i1].x - 64) 136 Bom(p->x, p->y);
191 && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + h) 137 enemycount += (p->score *
192 && (tama_lv2[i1].ll != -1)) { 138 ((infg.stg / 128) + infg_level + 1));
193 tama_lv2[i1].ll = -1; 139
194 p->vit -= TAMALV2P; 140 node->set_move_collision(noaction, delete_chara);
195 infg.stg++; 141 p->f = FALSE;
196 if (p->vit <= 0) { 142 }
197 infg.stg += 4; 143 }
198 Bom(node->xyz[0], node->xyz[1]); 144 if ((tama_lv1[i1].x + 64 > ex) && (ex + width > tama_lv1[i1].x)
199 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); 145 && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + height)
200 p->state = delete_chara; 146 && (tama_lv1[i1].l != -1)) {
201 p->collision = noaction; 147 tama_lv1[i1].l = -1;
202 p->f = FALSE; 148 p->vit -= TAMALV1P;
203 } 149 infg.stg++;
204 } 150 if (p->vit <= 0) {
205 } 151 infg.stg += 4;
206 152 Bom(p->x, p->y);
207 /*** tama_lv2_end ここまで ***/ 153 enemycount += (p->score *
208 154 ((infg.stg / 128) + infg_level + 1));
209 void 155 node->set_move_collision(noaction, delete_chara);
210 collision_07(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, 156 p->f = FALSE;
211 SceneGraphPtr tree) 157 }
212 { 158 }
213 if ((tlv3[0].r > 0) && (jiki.x < ex + w) && (jiki.x + 128 > ex) 159 }
214 && (jiki.y > ey + h)) { 160
215 p->vit -= TAMALV3P; 161 for (i1 = 0; i1 < tama_lv2_end + 1; i1++) {
216 infg.stg++; 162 if ((tama_lv2[i1].x + 128 + 64 > ex)
217 if (p->vit <= 0) { 163 && (ex + width > tama_lv2[i1].x + 128)
218 infg.stg += 4; 164 && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + height)
219 Bom(node->xyz[0], node->xyz[1]); 165 && (tama_lv2[i1].rr != -1)) {
220 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); 166 tama_lv2[i1].rr = -1;
221 p->state = delete_chara; 167 p->vit -= TAMALV2P;
222 p->collision = noaction; 168 infg.stg++;
223 p->f = FALSE; 169 if (p->vit <= 0) {
224 } 170 infg.stg += 4;
225 } 171 Bom(p->x, p->y);
226 } 172 enemycount += (p->score *
227 173 ((infg.stg / 128) + infg_level + 1));
228 // jumping: 174 node->set_move_collision(noaction, delete_chara);
229 175 p->f = FALSE;
230 /*** ObjectのtamaフラグがTRUEの場合 ***/ 176 }
231 177 }
232 void 178
233 collision_08(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, 179 if ((tama_lv2[i1].x + 64 + 64 > ex)
234 SceneGraphPtr tree) 180 && (ex + width > tama_lv2[i1].x + 16)
235 { 181 && (tama_lv2[i1].y - 32 + 192 > ey)
236 if ((tlv3[0].r > 0) && (jiki.x < ex + w) && (jiki.x + 128 > ex) 182 && (tama_lv2[i1].y - 32 < ey + height)
237 && (jiki.y + 128 > ey) && (jiki.y < ey + h)) { 183 && (tama_lv2[i1].sr != -1)) {
238 p->vit -= TAMALV3P; 184 tama_lv2[i1].sr = -1;
239 infg.stg++; 185 p->vit -= TAMALV2P;
240 if (p->vit <= 0) { 186 infg.stg++;
241 infg.stg += 4; 187 if (p->vit <= 0) {
242 Bom(node->xyz[0], node->xyz[1]); 188 infg.stg += 4;
243 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); 189 Bom(p->x, p->y);
244 p->state = delete_chara; 190 enemycount += (p->score *
245 p->collision = noaction; 191 ((infg.stg / 128) + infg_level + 1));
246 p->f = FALSE; 192 node->set_move_collision(noaction, delete_chara);
247 } 193 p->f = FALSE;
248 } 194 }
249 } 195 }
250 196 if ((tama_lv2[i1].x + 64 > ex) && (ex + width > tama_lv2[i1].x)
251 /*laser lv1 */ 197 && (tama_lv2[i1].y - 32 + 192 > ey)
252 // for (i1 = 0; i1 < laser_lv1_end + 1; i1++) { 198 && (tama_lv2[i1].y - 32 < ey + height)
253 // n = laser_lv1[i1].r * 128 / 4096; 199 && (tama_lv2[i1].sl != -1)) {
254 200 tama_lv2[i1].sl = -1;
255 /*** laser_lv1_end になるまで ***/ 201 p->vit -= TAMALV2P;
256 202 infg.stg++;
257 void 203 if (p->vit <= 0) {
258 collision_09(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, 204 infg.stg += 4;
259 SceneGraphPtr tree) 205 Bom(p->x, p->y);
260 { 206 enemycount += (p->score *
261 if ((laser_lv1[i1].x + n > ex) && (ex + w > laser_lv1[i1].x) 207 ((infg.stg / 128) + infg_level + 1));
262 && (laser_lv1[i1].y + n > ey) && (laser_lv1[i1].y < ey + h) 208 node->set_move_collision(noaction, delete_chara);
263 && (laser_lv1[i1].r != -1)) { 209 p->f = FALSE;
264 laser_lv1[i1].r = -1; 210 }
265 laser_lv1[i1].y = -1; 211 }
266 p->vit -= LASERLV1P; 212 if ((tama_lv2[i1].x - 64 + 64 > ex)
267 infg.stg++; 213 && (ex + width > tama_lv2[i1].x - 64)
268 if (p->vit <= 0) { 214 && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + height)
269 infg.stg += 4; 215 && (tama_lv2[i1].ll != -1)) {
270 Bom(node->xyz[0], node->xyz[1]); 216 tama_lv2[i1].ll = -1;
271 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); 217 p->vit -= TAMALV2P;
272 p->state = delete_chara; 218 infg.stg++;
273 p->collision = noaction; 219 if (p->vit <= 0) {
274 p->f = FALSE; 220 infg.stg += 4;
275 } 221 Bom(p->x, p->y);
276 } 222 enemycount += (p->score *
277 } 223 ((infg.stg / 128) + infg_level + 1));
278 /*** laser_lv1_endここまで ***/ 224 node->set_move_collision(noaction, delete_chara);
279 225 p->f = FALSE;
280 /*shield(laser lv2) */ 226 }
281 void 227 }
282 collision_10(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, 228 }
283 SceneGraphPtr tree) 229 if ((tlv3[0].r > 0) && (jiki.x < ex + width) && (jiki.x + 128 > ex)
284 { 230 && (jiki.y > ey + height)) {
285 if ((p->tama == TRUE) && (lg.stg > 0) && 231 p->vit -= TAMALV3P;
286 (laser_lv2[0].x + 128 > ex) && (ex + w > laser_lv2[0].x - 128)
287 && (laser_lv2[0].y + 128 > ey) && (laser_lv2[0].y - 128 < ey + h)
288 && (laser_lv2[0].r != 0)) {
289 p->vit -= LASERLV2P;
290 lg.stg -= 26;
291 infg.stg++;
292 if (p->vit <= 0) {
293 infg.stg += 4;
294 Bom(node->xyz[0], node->xyz[1]);
295 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1));
296 p->state = delete_chara;
297 p->collision = noaction;
298 p->f = FALSE;
299 }
300 }
301 }
302
303 /*bomber(laser lv3) */
304 void
305 collision_11(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
306 SceneGraphPtr tree)
307 {
308 if (laser_lv3[0].r < 62) {
309 for (i1 = 1; i1 < 128; i1++) {
310 if ((laser_lv3[i1].x + 128 > ex) && (ex + w > laser_lv3[i1].x)
311 && (laser_lv3[i1].y + 128 > ey)
312 && (laser_lv3[i1].y < ey + h)
313 && (laser_lv3[i1].r > 0)) {
314 tama_lv2[i1].rr = -1;
315 p->vit -= LASERLV3P;
316 infg.stg++; 232 infg.stg++;
317 if (p->vit <= 0) { 233 if (p->vit <= 0) {
318 infg.stg += 4; 234 infg.stg += 4;
319 Bom(node->xyz[0], node->xyz[1]); 235 Bom(p->x, p->y);
320 enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); 236 enemycount += (p->score *
321 p->state = delete_chara; 237 ((infg.stg / 128) + infg_level + 1));
322 p->collision = noaction; 238 node->set_move_collision(noaction, delete_chara);
323 p->f = FALSE; 239 p->f = FALSE;
324 } 240 }
325 } 241 }
326 } 242 jumping:
327 } 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;
259
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 }
314 }
328 } 315 }