1
0

SPHITSP実装

This commit is contained in:
otya128
2015-08-29 13:07:41 +09:00
parent 7893411842
commit cc3f18ee9a
3 changed files with 55 additions and 7 deletions

View File

@@ -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");

View File

@@ -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

View File

@@ -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;
}