diff ppe/Atari.cc @ 2:6382d8f6a973

not working.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Tue, 14 Dec 2010 00:54:07 +0900
parents
children a87dd72ce1b3
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ppe/Atari.cc	Tue Dec 14 00:54:07 2010 +0900
@@ -0,0 +1,311 @@
+#include "Atari.h"
+#include "tobject.h"
+#include "Func.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 enemycount = (int)smanager->get_param(2);
+    int bomend = (int)smanager->get_param(3);
+    int tama_lv1_end = (int)smanager->get_param(4);
+    int tama_lv2_end = (int)smanager->get_param(5);
+    int laser_lv1_end = (int)smanager->get_param(6);
+    int infg_level = (int)smanager->get_param(7);
+
+    CollisionPropertyPtr property
+	= (CollisionPropertyPtr)smanager->get_input(rbuf, 0);
+
+    player *jiki = &property->jiki;
+    CHARACTER *p = &property->p;
+    tama1 *tlv3 = &property->tlv3;
+    stge lg = property->lg;
+    stge infg = property->infg;
+
+    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 = infg;
+	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->state = 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->state = 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->state = 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->state = 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->state = 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->state = delete_chara;
+		p->collision = noaction;
+		p->f = FALSE;
+
+		property->infg = infg;
+		smanager->swap();
+		return 0;
+	    }
+	}
+    }
+    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, bomend, bchar);
+	    enemycount += (p->score *
+			   ((infg.stg / 128) + infg_level + 1));
+	    p->state = delete_chara;
+	    p->collision = noaction;
+	    p->f = FALSE;
+
+	    property->infg = infg;
+	    smanager->swap();
+	    return 0;
+	}
+    }
+  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, bomend, bchar);
+	    enemycount += (p->score *
+			   ((infg.stg / 128) + infg_level + 1));
+	    p->state = 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->state = 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->state = 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->state = delete_chara;
+		    p->collision = noaction;
+		    p->f = FALSE;
+
+		    property->infg = infg;
+		    smanager->swap();
+		    return 0;
+		}
+	    }
+	}
+    }
+    property->infg = infg;
+    smanager->swap();
+    return 0;
+}