Mercurial > hg > Members > koba > t_dandy
view ppe/Atari.cc @ 28:813f5461daab
collision bug fix.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 28 Dec 2010 15:50:04 +0900 |
parents | 5f1abbe03b9a |
children | 39e643fc4f90 |
line wrap: on
line source
#include "task_base.h" #include "task_object.h" SchedDefineTask(Atari); static int run(SchedTask *smanager, void *rbuf, void *wbuf) { int w = (int)smanager->get_param(0); int h = (int)smanager->get_param(1); int tama_lv1_end = (int)smanager->get_param(2); int tama_lv2_end = (int)smanager->get_param(3); int laser_lv1_end = (int)smanager->get_param(4); CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0); CollisionPropertyPtr property = (CollisionPropertyPtr)smanager->get_input(rbuf, 1); int *bomend = &property->bomend; int *enemycount = &property->enemycount; int infg_level = property->infg_level; stge lg = property->lg; stge infg = property->infg; player jiki = property->jiki; tama1 tlv3 = property->tlv3; tama1 *tama_lv1 = property->tama_lv1; tama2 *tama_lv2 = property->tama_lv2; laser *laser_lv1 = property->laser_lv1; laser *laser_lv2 = property->laser_lv2; laser *laser_lv3 = property->laser_lv3; bomchar *bchar = property->bchar; int i1, ex, ey; int n; ex = p->x; ey = p->y; //自機やられ #ifndef INVISIBLE_MODE if ((ex < jiki.x + 128 / 2) && (ex + w > jiki.x + 128 / 2) && (ey < jiki.y + 128 / 2) && (ey + h > jiki.y + 128 / 2) && jiki.muteki == 0) { Bom(jiki.x + 16, jiki.y + 16, bomend, bchar); jiki.bf = FALSE; jiki.zanki--; jiki.muteki = 120; infg.stg = 0; infg_level--; if (infg_level < 0) infg_level = 0; property->infg_level = infg_level; property->infg = infg; property->jiki = jiki; smanager->swap(); return 0; } #endif if (p->tama == TRUE) goto jumping; for (i1 = 0; i1 < tama_lv1_end + 1; i1++) { if ((tama_lv1[i1].x + 64 + 64 > ex) && (ex + w > tama_lv1[i1].x + 16) && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + h) && (tama_lv1[i1].r != -1)) { tama_lv1[i1].r = -1; p->vit -= TAMALV1P; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->infg = infg; smanager->swap(); return 0; } } if ((tama_lv1[i1].x + 64 > ex) && (ex + w > tama_lv1[i1].x) && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + h) && (tama_lv1[i1].l != -1)) { tama_lv1[i1].l = -1; p->vit -= TAMALV1P; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->infg = infg; smanager->swap(); return 0; } } } for (i1 = 0; i1 < tama_lv2_end + 1; i1++) { if ((tama_lv2[i1].x + 128 + 64 > ex) && (ex + w > tama_lv2[i1].x + 128) && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + h) && (tama_lv2[i1].rr != -1)) { tama_lv2[i1].rr = -1; p->vit -= TAMALV2P; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->infg = infg; smanager->swap(); return 0; } } if ((tama_lv2[i1].x + 64 + 64 > ex) && (ex + w > tama_lv2[i1].x + 16) && (tama_lv2[i1].y - 32 + 192 > ey) && (tama_lv2[i1].y - 32 < ey + h) && (tama_lv2[i1].sr != -1)) { tama_lv2[i1].sr = -1; p->vit -= TAMALV2P; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->infg = infg; smanager->swap(); return 0; } } if ((tama_lv2[i1].x + 64 > ex) && (ex + w > tama_lv2[i1].x) && (tama_lv2[i1].y - 32 + 192 > ey) && (tama_lv2[i1].y - 32 < ey + h) && (tama_lv2[i1].sl != -1)) { tama_lv2[i1].sl = -1; p->vit -= TAMALV2P; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->infg = infg; smanager->swap(); return 0; } } if ((tama_lv2[i1].x - 64 + 64 > ex) && (ex + w > tama_lv2[i1].x - 64) && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + h) && (tama_lv2[i1].ll != -1)) { tama_lv2[i1].ll = -1; p->vit -= TAMALV2P; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->infg = infg; smanager->swap(); return 0; } } } if ((tlv3.r > 0) && (jiki.x < ex + w) && (jiki.x + 128 > ex) && (jiki.y > ey + h)) { p->vit -= TAMALV3P; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->infg = infg; smanager->swap(); return 0; } } jumping: if ((tlv3.r > 0) && (jiki.x < ex + w) && (jiki.x + 128 > ex) && (jiki.y + 128 > ey) && (jiki.y < ey + h)) { p->vit -= TAMALV3P; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->infg = infg; smanager->swap(); return 0; } } /*laser lv1 */ for (i1 = 0; i1 < laser_lv1_end + 1; i1++) { n = laser_lv1[i1].r * 128 / 4096; if ((laser_lv1[i1].x + n > ex) && (ex + w > laser_lv1[i1].x) && (laser_lv1[i1].y + n > ey) && (laser_lv1[i1].y < ey + h) && (laser_lv1[i1].r != -1)) { laser_lv1[i1].r = -1; laser_lv1[i1].y = -1; p->vit -= LASERLV1P; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->infg = infg; smanager->swap(); return 0; } } } /*shield(laser lv2) */ if ((p->tama == TRUE) && (lg.stg > 0) && (laser_lv2[0].x + 128 > ex) && (ex + w > laser_lv2[0].x - 128) && (laser_lv2[0].y + 128 > ey) && (laser_lv2[0].y - 128 < ey + h) && (laser_lv2[0].r != 0)) { p->vit -= LASERLV2P; lg.stg -= 26; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->lg = lg; property->infg = infg; smanager->swap(); return 0; } } /*bomber(laser lv3) */ if (laser_lv3[0].r < 62) { for (i1 = 1; i1 < 128; i1++) { if ((laser_lv3[i1].x + 128 > ex) && (ex + w > laser_lv3[i1].x) && (laser_lv3[i1].y + 128 > ey) && (laser_lv3[i1].y < ey + h) && (laser_lv3[i1].r > 0)) { tama_lv2[i1].rr = -1; p->vit -= LASERLV3P; infg.stg++; if (p->vit <= 0) { infg.stg += 4; Bom(p->x, p->y, bomend, bchar); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->task = DELETE_CHARA; // p->collision = noaction; p->f = FALSE; property->infg = infg; smanager->swap(); return 0; } } } } property->infg = infg; smanager->swap(); return 0; }