1
|
1 #include "collision.h"
|
|
2 #include "tobject.h"
|
|
3
|
|
4 SchedDefineTask(Atari);
|
|
5
|
|
6 /*
|
|
7 CHARACTER *
|
|
8 noaction(CHARACTER *p)
|
|
9 {
|
|
10 p->state = noaction;
|
|
11 return p;
|
|
12 }
|
|
13
|
|
14 CHARACTER *
|
|
15 delete_chara(CHARACTER *p)
|
|
16 {
|
|
17 CHARACTER *parent = p;
|
|
18 p->f = FALSE;
|
|
19 p->state = noaction;
|
|
20 p->collision = noaction;
|
|
21 return parent;
|
|
22 }
|
|
23 */
|
|
24
|
|
25 void
|
|
26 Bom(int x, int y, int bomend, bomchar *bchar)
|
|
27 {
|
|
28 int i;
|
|
29 bomend++;
|
|
30 if (bomend > 49) {
|
|
31 bomend = 49;
|
|
32 return;
|
|
33 }
|
|
34
|
|
35 i = bomend;
|
|
36 bchar[i].x = x;
|
|
37 bchar[i].y = y;
|
|
38 bchar[i].no = 0;
|
|
39 bchar[i].f = 0;
|
|
40 return;
|
|
41 }
|
|
42
|
|
43 static int
|
|
44 run(SchedTask *smanager, void *rbuf, void *wbuf)
|
|
45 {
|
|
46 int w = (int)smanager->get_param(0);
|
|
47 int h = (int)smanager->get_param(1);
|
|
48 int enemycount = (int)smanager->get_param(2);
|
|
49 int bomend = (int)smanager->get_param(3);
|
|
50 int tama_lv1_end = (int)smanager->get_param(4);
|
|
51 int tama_lv2_end = (int)smanager->get_param(5);
|
|
52 int laser_lv1_end = (int)smanager->get_param(6);
|
|
53 int infg_level = (int)smanager->get_param(7);
|
|
54
|
|
55 player *jiki = (player *)smanager->get_input(rbuf, 0);
|
|
56 tama1 *tama_lv1 = (tama1 *)smanager->get_input(rbuf, 1);
|
|
57 tama2 *tama_lv2 = (tama2 *)smanager->get_input(rbuf, 2);
|
|
58 tama1 *tlv3 = (tama1 *)smanager->get_input(rbuf, 3);
|
|
59 laser *laser_lv1 = (laser *)smanager->get_input(rbuf, 4);
|
|
60 laser *laser_lv2 = (laser *)smanager->get_input(rbuf, 5);
|
|
61 laser *laser_lv3 = (laser *)smanager->get_input(rbuf, 6);
|
|
62 bomchar *bchar = (bomchar *)smanager->get_input(rbuf, 7);
|
|
63 CHARACTER *p = (CHARACTER *)smanager->get_input(rbuf, 8);
|
|
64 stge lg = *(stge *)smanager->get_input(rbuf, 9);
|
|
65 stge infg = *(stge *)smanager->get_input(rbuf, 10);
|
|
66
|
|
67 int i1, ex, ey;
|
|
68 int n;
|
|
69 ex = p->x;
|
|
70 ey = p->y;
|
|
71
|
|
72
|
|
73
|
|
74 //自機やられ
|
|
75 #ifndef INVISIBLE_MODE
|
|
76 if ((ex < jiki->x + 128 / 2) && (ex + w > jiki->x + 128 / 2)
|
|
77 && (ey < jiki->y + 128 / 2) && (ey + h > jiki->y + 128 / 2)
|
|
78 && jiki->muteki == 0) {
|
|
79 Bom(jiki->x + 16, jiki->y + 16, bomend, bchar);
|
|
80 jiki->bf = FALSE;
|
|
81 jiki->zanki--;
|
|
82 jiki->muteki = 120;
|
|
83
|
|
84 infg.stg = 0;
|
|
85 infg_level--;
|
|
86 if (infg_level < 0)
|
|
87 infg_level = 0;
|
|
88
|
|
89 return 0;
|
|
90 }
|
|
91 #endif
|
|
92
|
|
93 if (p->tama == TRUE)
|
|
94 goto jumping;
|
|
95 for (i1 = 0; i1 < tama_lv1_end + 1; i1++) {
|
|
96
|
|
97 if ((tama_lv1[i1].x + 64 + 64 > ex)
|
|
98 && (ex + w > tama_lv1[i1].x + 16)
|
|
99 && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + h)
|
|
100 && (tama_lv1[i1].r != -1)) {
|
|
101 tama_lv1[i1].r = -1;
|
|
102 p->vit -= TAMALV1P;
|
|
103 infg.stg++;
|
|
104 if (p->vit <= 0) {
|
|
105 infg.stg += 4;
|
|
106 Bom(p->x, p->y, bomend, bchar);
|
|
107 enemycount += (p->score *
|
|
108 ((infg.stg / 128) + infg_level + 1));
|
|
109 p->state = delete_chara;
|
|
110 p->collision = noaction;
|
|
111 p->f = FALSE;
|
|
112 return 0;
|
|
113 }
|
|
114 }
|
|
115 if ((tama_lv1[i1].x + 64 > ex) && (ex + w > tama_lv1[i1].x)
|
|
116 && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + h)
|
|
117 && (tama_lv1[i1].l != -1)) {
|
|
118 tama_lv1[i1].l = -1;
|
|
119 p->vit -= TAMALV1P;
|
|
120 infg.stg++;
|
|
121 if (p->vit <= 0) {
|
|
122 infg.stg += 4;
|
|
123 Bom(p->x, p->y, bomend, bchar);
|
|
124 enemycount += (p->score *
|
|
125 ((infg.stg / 128) + infg_level + 1));
|
|
126 p->state = delete_chara;
|
|
127 p->collision = noaction;
|
|
128 p->f = FALSE;
|
|
129 return 0;
|
|
130 }
|
|
131 }
|
|
132 }
|
|
133
|
|
134 for (i1 = 0; i1 < tama_lv2_end + 1; i1++) {
|
|
135 if ((tama_lv2[i1].x + 128 + 64 > ex)
|
|
136 && (ex + w > tama_lv2[i1].x + 128)
|
|
137 && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + h)
|
|
138 && (tama_lv2[i1].rr != -1)) {
|
|
139 tama_lv2[i1].rr = -1;
|
|
140 p->vit -= TAMALV2P;
|
|
141 infg.stg++;
|
|
142 if (p->vit <= 0) {
|
|
143 infg.stg += 4;
|
|
144 Bom(p->x, p->y, bomend, bchar);
|
|
145 enemycount += (p->score *
|
|
146 ((infg.stg / 128) + infg_level + 1));
|
|
147 p->state = delete_chara;
|
|
148 p->collision = noaction;
|
|
149 p->f = FALSE;
|
|
150 return 0;
|
|
151 }
|
|
152 }
|
|
153
|
|
154 if ((tama_lv2[i1].x + 64 + 64 > ex)
|
|
155 && (ex + w > tama_lv2[i1].x + 16)
|
|
156 && (tama_lv2[i1].y - 32 + 192 > ey)
|
|
157 && (tama_lv2[i1].y - 32 < ey + h)
|
|
158 && (tama_lv2[i1].sr != -1)) {
|
|
159 tama_lv2[i1].sr = -1;
|
|
160 p->vit -= TAMALV2P;
|
|
161 infg.stg++;
|
|
162 if (p->vit <= 0) {
|
|
163 infg.stg += 4;
|
|
164 Bom(p->x, p->y, bomend, bchar);
|
|
165 enemycount += (p->score *
|
|
166 ((infg.stg / 128) + infg_level + 1));
|
|
167 p->state = delete_chara;
|
|
168 p->collision = noaction;
|
|
169 p->f = FALSE;
|
|
170 return 0;
|
|
171 }
|
|
172 }
|
|
173 if ((tama_lv2[i1].x + 64 > ex) && (ex + w > tama_lv2[i1].x)
|
|
174 && (tama_lv2[i1].y - 32 + 192 > ey)
|
|
175 && (tama_lv2[i1].y - 32 < ey + h)
|
|
176 && (tama_lv2[i1].sl != -1)) {
|
|
177 tama_lv2[i1].sl = -1;
|
|
178 p->vit -= TAMALV2P;
|
|
179 infg.stg++;
|
|
180 if (p->vit <= 0) {
|
|
181 infg.stg += 4;
|
|
182 Bom(p->x, p->y, bomend, bchar);
|
|
183 enemycount += (p->score *
|
|
184 ((infg.stg / 128) + infg_level + 1));
|
|
185 p->state = delete_chara;
|
|
186 p->collision = noaction;
|
|
187 p->f = FALSE;
|
|
188 return 0;
|
|
189 }
|
|
190 }
|
|
191 if ((tama_lv2[i1].x - 64 + 64 > ex)
|
|
192 && (ex + w > tama_lv2[i1].x - 64)
|
|
193 && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + h)
|
|
194 && (tama_lv2[i1].ll != -1)) {
|
|
195 tama_lv2[i1].ll = -1;
|
|
196 p->vit -= TAMALV2P;
|
|
197 infg.stg++;
|
|
198 if (p->vit <= 0) {
|
|
199 infg.stg += 4;
|
|
200 Bom(p->x, p->y, bomend, bchar);
|
|
201 enemycount += (p->score *
|
|
202 ((infg.stg / 128) + infg_level + 1));
|
|
203 p->state = delete_chara;
|
|
204 p->collision = noaction;
|
|
205 p->f = FALSE;
|
|
206 return 0;
|
|
207 }
|
|
208 }
|
|
209 }
|
|
210 if ((tlv3[0].r > 0) && (jiki->x < ex + w) && (jiki->x + 128 > ex)
|
|
211 && (jiki->y > ey + h)) {
|
|
212 p->vit -= TAMALV3P;
|
|
213 infg.stg++;
|
|
214 if (p->vit <= 0) {
|
|
215 infg.stg += 4;
|
|
216 Bom(p->x, p->y, bomend, bchar);
|
|
217 enemycount += (p->score *
|
|
218 ((infg.stg / 128) + infg_level + 1));
|
|
219 p->state = delete_chara;
|
|
220 p->collision = noaction;
|
|
221 p->f = FALSE;
|
|
222 return 0;
|
|
223 }
|
|
224 }
|
|
225 jumping:
|
|
226 if ((tlv3[0].r > 0) && (jiki->x < ex + w) && (jiki->x + 128 > ex)
|
|
227 && (jiki->y + 128 > ey) && (jiki->y < ey + h)) {
|
|
228 p->vit -= TAMALV3P;
|
|
229 infg.stg++;
|
|
230 if (p->vit <= 0) {
|
|
231 infg.stg += 4;
|
|
232 Bom(p->x, p->y, bomend, bchar);
|
|
233 enemycount += (p->score *
|
|
234 ((infg.stg / 128) + infg_level + 1));
|
|
235 p->state = delete_chara;
|
|
236 p->collision = noaction;
|
|
237 p->f = FALSE;
|
|
238 return 0;
|
|
239 }
|
|
240 }
|
|
241 /*laser lv1 */
|
|
242 for (i1 = 0; i1 < laser_lv1_end + 1; i1++) {
|
|
243 n = laser_lv1[i1].r * 128 / 4096;
|
|
244
|
|
245 if ((laser_lv1[i1].x + n > ex) && (ex + w > laser_lv1[i1].x)
|
|
246 && (laser_lv1[i1].y + n > ey) && (laser_lv1[i1].y < ey + h)
|
|
247 && (laser_lv1[i1].r != -1)) {
|
|
248 laser_lv1[i1].r = -1;
|
|
249 laser_lv1[i1].y = -1;
|
|
250 p->vit -= LASERLV1P;
|
|
251 infg.stg++;
|
|
252 if (p->vit <= 0) {
|
|
253 infg.stg += 4;
|
|
254 Bom(p->x, p->y, bomend, bchar);
|
|
255 enemycount += (p->score *
|
|
256 ((infg.stg / 128) + infg_level + 1));
|
|
257 p->state = delete_chara;
|
|
258 p->collision = noaction;
|
|
259 p->f = FALSE;
|
|
260 return 0;
|
|
261 }
|
|
262 }
|
|
263 }
|
|
264 /*shield(laser lv2) */
|
|
265 if ((p->tama == TRUE) && (lg.stg > 0) &&
|
|
266 (laser_lv2[0].x + 128 > ex) && (ex + w > laser_lv2[0].x - 128)
|
|
267 && (laser_lv2[0].y + 128 > ey) && (laser_lv2[0].y - 128 < ey + h)
|
|
268 && (laser_lv2[0].r != 0)) {
|
|
269 p->vit -= LASERLV2P;
|
|
270 lg.stg -= 26;
|
|
271 infg.stg++;
|
|
272 if (p->vit <= 0) {
|
|
273 infg.stg += 4;
|
|
274 Bom(p->x, p->y, bomend, bchar);
|
|
275 enemycount += (p->score *
|
|
276 ((infg.stg / 128) + infg_level + 1));
|
|
277 p->state = delete_chara;
|
|
278 p->collision = noaction;
|
|
279 p->f = FALSE;
|
|
280 return 0;
|
|
281 }
|
|
282 }
|
|
283 /*bomber(laser lv3) */
|
|
284 if (laser_lv3[0].r < 62) {
|
|
285 for (i1 = 1; i1 < 128; i1++) {
|
|
286 if ((laser_lv3[i1].x + 128 > ex) && (ex + w > laser_lv3[i1].x)
|
|
287 && (laser_lv3[i1].y + 128 > ey)
|
|
288 && (laser_lv3[i1].y < ey + h)
|
|
289 && (laser_lv3[i1].r > 0)) {
|
|
290 tama_lv2[i1].rr = -1;
|
|
291 p->vit -= LASERLV3P;
|
|
292 infg.stg++;
|
|
293 if (p->vit <= 0) {
|
|
294 infg.stg += 4;
|
|
295 Bom(p->x, p->y, bomend, bchar);
|
|
296 enemycount += (p->score *
|
|
297 ((infg.stg / 128) + infg_level + 1));
|
|
298 p->state = delete_chara;
|
|
299 p->collision = noaction;
|
|
300 p->f = FALSE;
|
|
301 return 0;
|
|
302 }
|
|
303 }
|
|
304 }
|
|
305 }
|
|
306 smanager->swap();
|
|
307 return 0;
|
|
308 }
|