comparison collision.c @ 0:01387a2e419e

initial version
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 07 Dec 2010 15:39:45 +0900
parents
children 972a7f233b23
comparison
equal deleted inserted replaced
-1:000000000000 0:01387a2e419e
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <SDL.h>
4 #include "SDL_opengl.h"
5 #include "object.h"
6 #include "Character.h"
7 #include "Character_state.h"
8 #include "tokuten.h"
9 #include "collision.h"
10 //#include "atari.h"
11 #include "bom.h"
12 #include "count2.h"
13 #include "sound.h"
14 //#include "Enemy.h"
15 //#include "libps.h"
16 #include "sgoex.h"
17
18 extern SpriteTable sptable[DEFOBJ];
19
20
21 CHARACTER * atari(CHARACTER *p)
22 {
23 int i1, h, w, ex, ey, charno;
24 int n;
25 ex = p->x;
26 ey = p->y;
27 charno = p->charano;
28 w = sptable[charno].w;
29 h = sptable[charno].h;
30 //i2 = playerno;
31
32
33 //自機やられ
34 #ifndef INVISIBLE_MODE
35 if ((ex < jiki.x + 128 / 2) && (ex + w > jiki.x + 128 / 2)
36 && (ey < jiki.y + 128 / 2) && (ey + h > jiki.y + 128 / 2)
37 && jiki.muteki == 0) {
38 //se_voice[0] = SsUtKeyOn(vab[JIKIOUT], 0, 0, 65, 0, 60, 60);
39 Bom(jiki.x + 16, jiki.y + 16);
40 jiki.bf = FALSE;
41 jiki.zanki--;
42 jiki.muteki = 120;
43
44 infg.stg = 0;
45 infg_level--;
46 if (infg_level < 0)
47 infg_level = 0;
48
49 return p;
50 }
51 #endif
52
53 if (p->tama == TRUE)
54 goto jumping;
55 for (i1 = 0; i1 < tama_lv1_end + 1; i1++) {
56
57 if ((tama_lv1[i1].x + 64 + 64 > ex)
58 && (ex + w > tama_lv1[i1].x + 16)
59 && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + h)
60 && (tama_lv1[i1].r != -1)) {
61 tama_lv1[i1].r = -1;
62 p->vit -= TAMALV1P;
63 infg.stg++;
64 if (p->vit <= 0) {
65 infg.stg += 4;
66 Bom(p->x, p->y);
67 enemycount += (p->score *
68 ((infg.stg / 128) + infg_level + 1));
69 p->state = delete_chara;
70 p->collision = noaction;
71 p->f = FALSE;
72 return p;
73 }
74 }
75 if ((tama_lv1[i1].x + 64 > ex) && (ex + w > tama_lv1[i1].x)
76 && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + h)
77 && (tama_lv1[i1].l != -1)) {
78 tama_lv1[i1].l = -1;
79 p->vit -= TAMALV1P;
80 infg.stg++;
81 if (p->vit <= 0) {
82 infg.stg += 4;
83 Bom(p->x, p->y);
84 enemycount += (p->score *
85 ((infg.stg / 128) + infg_level + 1));
86 p->state = delete_chara;
87 p->collision = noaction;
88 p->f = FALSE;
89 return p;
90 }
91 }
92 }
93
94 for (i1 = 0; i1 < tama_lv2_end + 1; i1++) {
95 if ((tama_lv2[i1].x + 128 + 64 > ex)
96 && (ex + w > tama_lv2[i1].x + 128)
97 && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + h)
98 && (tama_lv2[i1].rr != -1)) {
99 tama_lv2[i1].rr = -1;
100 p->vit -= TAMALV2P;
101 infg.stg++;
102 if (p->vit <= 0) {
103 infg.stg += 4;
104 Bom(p->x, p->y);
105 enemycount += (p->score *
106 ((infg.stg / 128) + infg_level + 1));
107 p->state = delete_chara;
108 p->collision = noaction;
109 p->f = FALSE;
110 return p;
111 }
112 }
113
114 if ((tama_lv2[i1].x + 64 + 64 > ex)
115 && (ex + w > tama_lv2[i1].x + 16)
116 && (tama_lv2[i1].y - 32 + 192 > ey)
117 && (tama_lv2[i1].y - 32 < ey + h)
118 && (tama_lv2[i1].sr != -1)) {
119 tama_lv2[i1].sr = -1;
120 p->vit -= TAMALV2P;
121 infg.stg++;
122 if (p->vit <= 0) {
123 infg.stg += 4;
124 Bom(p->x, p->y);
125 enemycount += (p->score *
126 ((infg.stg / 128) + infg_level + 1));
127 p->state = delete_chara;
128 p->collision = noaction;
129 p->f = FALSE;
130 return p;
131 }
132 }
133 if ((tama_lv2[i1].x + 64 > ex) && (ex + w > tama_lv2[i1].x)
134 && (tama_lv2[i1].y - 32 + 192 > ey)
135 && (tama_lv2[i1].y - 32 < ey + h)
136 && (tama_lv2[i1].sl != -1)) {
137 tama_lv2[i1].sl = -1;
138 p->vit -= TAMALV2P;
139 infg.stg++;
140 if (p->vit <= 0) {
141 infg.stg += 4;
142 Bom(p->x, p->y);
143 enemycount += (p->score *
144 ((infg.stg / 128) + infg_level + 1));
145 p->state = delete_chara;
146 p->collision = noaction;
147 p->f = FALSE;
148 return p;
149 }
150 }
151 if ((tama_lv2[i1].x - 64 + 64 > ex)
152 && (ex + w > tama_lv2[i1].x - 64)
153 && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + h)
154 && (tama_lv2[i1].ll != -1)) {
155 tama_lv2[i1].ll = -1;
156 p->vit -= TAMALV2P;
157 infg.stg++;
158 if (p->vit <= 0) {
159 infg.stg += 4;
160 Bom(p->x, p->y);
161 enemycount += (p->score *
162 ((infg.stg / 128) + infg_level + 1));
163 p->state = delete_chara;
164 p->collision = noaction;
165 p->f = FALSE;
166 return p;
167 }
168 }
169 }
170 if ((tlv3[0].r > 0) && (jiki.x < ex + w) && (jiki.x + 128 > ex)
171 && (jiki.y > ey + h)) {
172 p->vit -= TAMALV3P;
173 infg.stg++;
174 if (p->vit <= 0) {
175 infg.stg += 4;
176 Bom(p->x, p->y);
177 enemycount += (p->score *
178 ((infg.stg / 128) + infg_level + 1));
179 p->state = delete_chara;
180 p->collision = noaction;
181 p->f = FALSE;
182 return p;
183 }
184 }
185 jumping:
186 if ((tlv3[0].r > 0) && (jiki.x < ex + w) && (jiki.x + 128 > ex)
187 && (jiki.y + 128 > ey) && (jiki.y < ey + h)) {
188 p->vit -= TAMALV3P;
189 infg.stg++;
190 if (p->vit <= 0) {
191 infg.stg += 4;
192 Bom(p->x, p->y);
193 enemycount += (p->score *
194 ((infg.stg / 128) + infg_level + 1));
195 p->state = delete_chara;
196 p->collision = noaction;
197 p->f = FALSE;
198 return p;
199 }
200 }
201 /*laser lv1 */
202 for (i1 = 0; i1 < laser_lv1_end + 1; i1++) {
203 n = laser_lv1[i1].r * 128 / 4096;
204
205 if ((laser_lv1[i1].x + n > ex) && (ex + w > laser_lv1[i1].x)
206 && (laser_lv1[i1].y + n > ey) && (laser_lv1[i1].y < ey + h)
207 && (laser_lv1[i1].r != -1)) {
208 laser_lv1[i1].r = -1;
209 laser_lv1[i1].y = -1;
210 p->vit -= LASERLV1P;
211 infg.stg++;
212 if (p->vit <= 0) {
213 infg.stg += 4;
214 Bom(p->x, p->y);
215 enemycount += (p->score *
216 ((infg.stg / 128) + infg_level + 1));
217 p->state = delete_chara;
218 p->collision = noaction;
219 p->f = FALSE;
220 return p;
221 }
222 }
223 }
224 /*shield(laser lv2) */
225 if ((p->tama == TRUE) && (lg.stg > 0) &&
226 (laser_lv2[0].x + 128 > ex) && (ex + w > laser_lv2[0].x - 128)
227 && (laser_lv2[0].y + 128 > ey) && (laser_lv2[0].y - 128 < ey + h)
228 && (laser_lv2[0].r != 0)) {
229 p->vit -= LASERLV2P;
230 lg.stg -= 26;
231 infg.stg++;
232 if (p->vit <= 0) {
233 infg.stg += 4;
234 Bom(p->x, p->y);
235 enemycount += (p->score *
236 ((infg.stg / 128) + infg_level + 1));
237 p->state = delete_chara;
238 p->collision = noaction;
239 p->f = FALSE;
240 return p;
241 }
242 }
243 /*bomber(laser lv3) */
244 if (laser_lv3[0].r < 62) {
245 for (i1 = 1; i1 < 128; i1++) {
246 if ((laser_lv3[i1].x + 128 > ex) && (ex + w > laser_lv3[i1].x)
247 && (laser_lv3[i1].y + 128 > ey)
248 && (laser_lv3[i1].y < ey + h)
249 && (laser_lv3[i1].r > 0)) {
250 tama_lv2[i1].rr = -1;
251 p->vit -= LASERLV3P;
252 infg.stg++;
253 if (p->vit <= 0) {
254 infg.stg += 4;
255 Bom(p->x, p->y);
256 enemycount += (p->score *
257 ((infg.stg / 128) + infg_level + 1));
258 p->state = delete_chara;
259 p->collision = noaction;
260 p->f = FALSE;
261 return p;
262 }
263 }
264 }
265 }
266 return p;
267 }