Mercurial > hg > Members > tkaito > task_dandy
view collision.cc @ 25:aa37f220b7a8
add new files, not working.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 24 Nov 2010 19:24:43 +0900 |
parents | |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <SDL.h> #include "collision.h" /*** 当たり判定に使うパラメータや変数の定義 ***/ #if 0 CHARACTER * atari(CHARACTER *p) int i1, h, w, ex, ey, charno; int n; ex = p->x; ey = node->xyz[1]; charno = p->charano; w = sptable[charno].w; h = sptable[charno].h; //i2 = playerno; /*** 自機やられ ただし無敵時間中で無ければという条件付き ***/ void player_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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; } } } //#endif // if (p->tama == TRUE) // goto jumping; // for (i1 = 0; i1 < tama_lv1_end + 1; i1++) { /*** tama_lv1_end になるまで ***/ void collision_01(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } void collision_02(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } /*** tama_lv1_end ここまで ***/ // for (i1 = 0; i1 < tama_lv2_end + 1; i1++) { /*** tama_lv2_end になるまで ***/ void collision_03(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } void collision_04(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } void collision_05(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } void collision_06(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } /*** tama_lv2_end ここまで ***/ void collision_07(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } // jumping: /*** ObjectのtamaフラグがTRUEの場合 ***/ void collision_08(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } /*laser lv1 */ // for (i1 = 0; i1 < laser_lv1_end + 1; i1++) { // n = laser_lv1[i1].r * 128 / 4096; /*** laser_lv1_end になるまで ***/ void collision_09(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } /*** laser_lv1_endここまで ***/ /*shield(laser lv2) */ void collision_10(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } /*bomber(laser lv3) */ void collision_11(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { 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(node->xyz[0], node->xyz[1]); enemycount += (p->score * ((infg.stg / 128) + infg_level + 1)); p->state = delete_chara; p->collision = noaction; p->f = FALSE; } } } } } #endif