Mercurial > hg > Game > S_Dandy
view src/collision.cc @ 4:bb2fbe78c7cd
moving title scene.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 07 Dec 2010 18:37:43 +0900 |
parents | deb7e09824a4 |
children |
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 "atari.h" #include "bom.h" #include "count.h" #include "sound.h" //#include "Enemy.h" //#include "libps.h" #include "sgoex.h" #include "SceneGraph.h" #include "S_Dandy.h" extern SpriteTable sptable[DEFOBJ]; void nocollision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree){} void delete_chara(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree) { node->remove(); } void title_collision(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; Pad *pad = sgroot->getController(); if (pad->start.isPush() && pad->start.isHold()) { jiki.bf = TRUE; SoundStop(); SoundPlay(0); gamef = 1; // node->remove(); } if ((pad->start.isPush() && pad->start.isHold()) && (pad->select.isPush() && pad->select.isHold())) { gamef = 0; } /* タイトルの move if (pad[0].st > 1) { jiki.bf = TRUE; // CdPlay(1,&cdp[0],0); SoundStop(); SoundPlay(0); gamef = 1; pad[0].st = 1; return; } if ((pad[0].se > 0) && (pad[0].st > 0)) { gamef = 0; break; } */ } void subtitle_collision(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree) { if(gamef) { node->remove(); } } void atari(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree) { int i1, height, width, ex, ey, charno; int n; SpriteTable *p; ex = node->xyz[0]; ey = node->xyz[1]; charno = node->stack_xyz[0]; p = &sptable[charno]; width = p->w; height = p->h; //i2 = playerno; //自機やられ #ifndef INVISIBLE_MODE if ((ex < jiki.x + 128 / 2) && (ex + width > jiki.x + 128 / 2) && (ey < jiki.y + 128 / 2) && (ey + height > 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++) { if ((tama_lv1[i1].x + 64 + 64 > ex) && (ex + width > tama_lv1[i1].x + 16) && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + height) && (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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } if ((tama_lv1[i1].x + 64 > ex) && (ex + width > tama_lv1[i1].x) && (tama_lv1[i1].y + 128 > ey) && (tama_lv1[i1].y < ey + height) && (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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } } for (i1 = 0; i1 < tama_lv2_end + 1; i1++) { if ((tama_lv2[i1].x + 128 + 64 > ex) && (ex + width > tama_lv2[i1].x + 128) && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + height) && (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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } if ((tama_lv2[i1].x + 64 + 64 > ex) && (ex + width > tama_lv2[i1].x + 16) && (tama_lv2[i1].y - 32 + 192 > ey) && (tama_lv2[i1].y - 32 < ey + height) && (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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } if ((tama_lv2[i1].x + 64 > ex) && (ex + width > tama_lv2[i1].x) && (tama_lv2[i1].y - 32 + 192 > ey) && (tama_lv2[i1].y - 32 < ey + height) && (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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } if ((tama_lv2[i1].x - 64 + 64 > ex) && (ex + width > tama_lv2[i1].x - 64) && (tama_lv2[i1].y + 192 > ey) && (tama_lv2[i1].y < ey + height) && (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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } } if ((tlv3[0].r > 0) && (jiki.x < ex + width) && (jiki.x + 128 > ex) && (jiki.y > ey + height)) { 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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } jumping: if ((tlv3[0].r > 0) && (jiki.x < ex + width) && (jiki.x + 128 > ex) && (jiki.y + 128 > ey) && (jiki.y < ey + height)) { 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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } /*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 + width > laser_lv1[i1].x) && (laser_lv1[i1].y + n > ey) && (laser_lv1[i1].y < ey + height) && (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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } } /*shield(laser lv2) */ if ((p->tama == TRUE) && (lg.stg > 0) && (laser_lv2[0].x + 128 > ex) && (ex + width > laser_lv2[0].x - 128) && (laser_lv2[0].y + 128 > ey) && (laser_lv2[0].y - 128 < ey + height) && (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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } /*bomber(laser lv3) */ if (laser_lv3[0].r < 62) { for (i1 = 1; i1 < 128; i1++) { if ((laser_lv3[i1].x + 128 > ex) && (ex + width > laser_lv3[i1].x) && (laser_lv3[i1].y + 128 > ey) && (laser_lv3[i1].y < ey + height) && (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)); node->set_move_collision(noaction, delete_chara); p->f = FALSE; } } } } }