From cc3f18ee9a1e322710d8fd1a79ffc24d094e4fb4 Mon Sep 17 00:00:00 2001 From: otya128 Date: Sat, 29 Aug 2015 13:07:41 +0900 Subject: [PATCH] =?UTF-8?q?SPHITSP=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SMILEBASIC/builtinfunctions.d | 31 +++++++++++++++++++++++++++++++ SMILEBASIC/petitcomputer.d | 4 ++-- SMILEBASIC/sprite.d | 27 ++++++++++++++++++++++----- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index 6cf9c06..89c74f7 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -656,6 +656,37 @@ class BuiltinFunction { p.sprite.spunlink(id); } + static void SPCOL(PetitComputer p, int id, DefaultValue!(int, false) scale) + { + scale.setDefaultValue(true); + p.sprite.spcol(id, cast(bool)scale); + } + static void SPCOL(PetitComputer p, int id, DefaultValue!int scale, int mask) + { + scale.setDefaultValue(true); + p.sprite.spcol(id, cast(bool)scale, mask); + } + static void SPCOL(PetitComputer p, int id, int x, int y, int w, int h, int scale) + { + p.sprite.spcol(id, cast(short)x, cast(short)y, cast(ushort)w, cast(ushort)h, cast(bool)scale, -1); + } + static void SPCOL(PetitComputer p, int id, int x, int y, int w, int h, DefaultValue!int scale, int mask) + { + scale.setDefaultValue(true); + p.sprite.spcol(id, cast(short)x, cast(short)y, cast(ushort)w, cast(ushort)h, cast(bool)scale, mask); + } + static int SPHITSP(PetitComputer p, int id) + { + return p.sprite.sphitsp(id); + } + static int SPHITSP(PetitComputer p, int id, int min) + { + return p.sprite.sphitsp(id, min, 511);//? + } + static int SPHITSP(PetitComputer p, int id, int min, int max) + { + return p.sprite.sphitsp(id, min, max); + } static void BGMSTOP(PetitComputer p) { writeln("NOTIMPL:BGMSTOP"); diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index 61c78e8..1a25c46 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -1031,11 +1031,11 @@ class PetitComputer { parser = new Parser( //readText("./SYS/GAME6TALK.TXT").to!wstring - readText("./SYS/GAME4SHOOTER.TXT").to!wstring + //readText("./SYS/GAME4SHOOTER.TXT").to!wstring //readText("./SYS/GAME2RPG.TXT").to!wstring //readText("./SYS/GAME1DOTRC.TXT").to!wstring //readText(input("LOAD PROGRAM:", true).to!string).to!wstring - //readText("./SYS/EX8TECDEMO.TXT").to!wstring + readText("./SYS/EX8TECDEMO.TXT").to!wstring //readText("./SYS/EX1TEXT.TXT").to!wstring //readText("FIZZBUZZ.TXT").to!wstring //readText("TEST.TXT").to!wstring diff --git a/SMILEBASIC/sprite.d b/SMILEBASIC/sprite.d index bc89258..f26c825 100644 --- a/SMILEBASIC/sprite.d +++ b/SMILEBASIC/sprite.d @@ -149,8 +149,8 @@ struct SpriteCollision { if(sp.define && sp.col.mask & mask) { - auto x = (sp.linkx + sp.homex + sp.col.sx); - auto y = (sp.linky + sp.homey + sp.col.sy); + int x = (sp.linkx + sp.homex + sp.col.sx); + int y = (sp.linky + sp.homey + sp.col.sy); return detection(x, y, cast(int)(sp.w * sp.scalex), cast(int)(sp.h * sp.scaley)); } return false; @@ -160,10 +160,20 @@ struct SpriteCollision //(x,y,w,h)と判定 bool detection(int x, int y, int w, int h) { - auto x2 = (data.linkx + data.homex + sx); - auto y2 = (data.linky + data.homey + sy); - if(x <= x2 && y <= y2 && x + w > x2 + data.w * data.scalex && y + h > y2 + data.h * data.scaley) + int x2 = (data.linkx + data.homex + sx); + int y2 = (data.linky + data.homey + sy); + if(x <= x2 && y <= y2 && x + w >= x2 && y + h >= y2) return true; + int w2 = cast(int)(data.w * data.scalex); + int h2 = cast(int)(data.h * data.scaley); + if(x <= x2 + w2 && y <= y2 + h2 && x + w >= x2 + w2 && y + h >= y2 + h2) + return true; + if(x <= x2 + w2 && y <= y2 && x + w >= x2 + w2 && y + h >= y2) + return true; + if(x <= x2 && y <= y2 + h2 && x + w >= x2 && y + h >= y2 + h2) + return true; + //if(x2 <= x && y2 <= y && x2 + (data.w * data.scalex) >= x && y + (data.h * data.scaley) >= y) + // return true; return false; } } @@ -699,6 +709,8 @@ class Sprite id = spid(id); sprites[id].x = x; sprites[id].y = y; + sprites[id].linkx = cast(int)(x + (sprites[id].parent ? sprites[id].parent.linkx : 0)); + sprites[id].linky = cast(int)(y + (sprites[id].parent ? sprites[id].parent.linky : 0)); } void spofs(int id, double x, double y, int z) { @@ -706,6 +718,8 @@ class Sprite sprites[id].x = x; sprites[id].y = y; sprites[id].z = z; + sprites[id].linkx = cast(int)(x + (sprites[id].parent ? sprites[id].parent.linkx : 0)); + sprites[id].linky = cast(int)(y + (sprites[id].parent ? sprites[id].parent.linky : 0)); zChange = true; } void getspofs(int id, out double x, out double y, out int z) @@ -849,6 +863,7 @@ class Sprite void spcol(int id, short sx, short sy, ushort w, ushort h, bool scale, int mask) { id = spid(id); + sprites[id].col.data = &sprites[id]; sprites[id].col.sx = sx; sprites[id].col.sy = sy; sprites[id].col.w = w; @@ -896,6 +911,8 @@ class Sprite { for(; start <= end; start++) { + //自分を除外すべきか? + if(id == start) continue;//???? if(sprites[id].col.detection(sprites[start])) return start; }