Mercurial > hg > Members > koba > t_dandy
view collision.c @ 14:c7e7971a76d0
fix.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 16 Dec 2010 15:29:43 +0900 |
parents | b4c797eee72a |
children | 2c85322348cf |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <SDL.h> #include "SDL_opengl.h" #include "object.h" #include "Character.h" #include "Character_state.h" #include "tokuten.h" #include "collision.h" #include "bom.h" #include "count2.h" #include "sound.h" #include "sgoex.h" extern SpriteTable sptable[DEFOBJ]; CHARACTER * atari(CHARACTER *p) { int i1, h, w, ex, ey, charno; int n; ex = p->x; ey = p->y; charno = p->charano; w = sptable[charno].w; h = sptable[charno].h; //i2 = playerno; //自機やられ #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) { //se_voice[0] = SsUtKeyOn(vab[JIKIOUT], 0, 0, 65, 0, 60, 60); Bom(jiki.x + 16, jiki.y + 16); jiki.bf = FALSE; jiki.zanki--; jiki.muteki = 120; infg.stg = 0; infg_level--; if (infg_level < 0) infg_level = 0; return p; } #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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } 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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } } 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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } 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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } 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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } 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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } } if ((tlv3[0].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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } jumping: if ((tlv3[0].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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } /*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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } } /*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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } /*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); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; return p; } } } } return p; }