スプライトの属性を実装.
This commit is contained in:
@@ -1,3 +1,16 @@
|
|||||||
|
FOR I=0TO 511'-500
|
||||||
|
SPSET I,I'304'-I+304
|
||||||
|
SPOFS I, (I*16) MOD 400, FLOOR((I*16)/400)*16
|
||||||
|
'SPOFS I, 100,100
|
||||||
|
NEXT
|
||||||
|
WHILE TRUE
|
||||||
|
WEND
|
||||||
|
WHILE TRUE
|
||||||
|
FOR I=0TO 511
|
||||||
|
SPOFS I, RND(400), RND(240)
|
||||||
|
GPSET RND(400), RND(240), -1
|
||||||
|
NEXT
|
||||||
|
WEND
|
||||||
DIM ARRY[10]
|
DIM ARRY[10]
|
||||||
?ARRY[0],FORMAT$("%D",100)
|
?ARRY[0],FORMAT$("%D",100)
|
||||||
GOSUB@A
|
GOSUB@A
|
||||||
|
|||||||
@@ -341,6 +341,9 @@ class BuiltinFunction
|
|||||||
{
|
{
|
||||||
return sqrt(a1);
|
return sqrt(a1);
|
||||||
}
|
}
|
||||||
|
static void TALK(wstring a1)
|
||||||
|
{
|
||||||
|
}
|
||||||
//alias void function(PetitComputer, Value[], Value[]) BuiltinFunc;
|
//alias void function(PetitComputer, Value[], Value[]) BuiltinFunc;
|
||||||
static BuiltinFunction[wstring] builtinFunctions;
|
static BuiltinFunction[wstring] builtinFunctions;
|
||||||
static this()
|
static this()
|
||||||
|
|||||||
@@ -674,11 +674,12 @@ class PetitComputer
|
|||||||
auto startTicks = SDL_GetTicks();
|
auto startTicks = SDL_GetTicks();
|
||||||
//とりあえず
|
//とりあえず
|
||||||
auto parser = new Parser(
|
auto parser = new Parser(
|
||||||
readText("./SYS/GAME1DOTRC.TXT").to!wstring
|
//readText("./SYS/GAME6TALK.TXT").to!wstring
|
||||||
|
//readText("./SYS/GAME1DOTRC.TXT").to!wstring
|
||||||
//readText(input("LOAD PROGRAM:", true).to!string).to!wstring
|
//readText(input("LOAD PROGRAM:", true).to!string).to!wstring
|
||||||
//readText("./SYS/EX1TEXT.TXT").to!wstring
|
//readText("./SYS/EX1TEXT.TXT").to!wstring
|
||||||
//readText("FIZZBUZZ.TXT").to!wstring
|
//readText("FIZZBUZZ.TXT").to!wstring
|
||||||
//readText("TEST.TXT").to!wstring
|
readText("TEST.TXT").to!wstring
|
||||||
/*"?ABS(-1)
|
/*"?ABS(-1)
|
||||||
LOCATE 0,10
|
LOCATE 0,10
|
||||||
COLOR 5
|
COLOR 5
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import derelict.sdl2.sdl;
|
|||||||
import derelict.opengl3.gl;
|
import derelict.opengl3.gl;
|
||||||
enum SpriteAttr
|
enum SpriteAttr
|
||||||
{
|
{
|
||||||
show = 1,
|
show = 0b00001,
|
||||||
rotate90 = 2,
|
rotate90 = 0b00010,
|
||||||
rotate180 = 4,
|
rotate180 = 0b00100,
|
||||||
rotate270 = 8,
|
rotate270 = 0b00110,
|
||||||
|
hflip = 0b01000,//yoko
|
||||||
|
vflip = 0b10000,//tate
|
||||||
}
|
}
|
||||||
enum SpriteAnimTarget
|
enum SpriteAnimTarget
|
||||||
{
|
{
|
||||||
@@ -188,6 +190,7 @@ class Sprite
|
|||||||
SpriteDef[] SPDEFTable;
|
SpriteDef[] SPDEFTable;
|
||||||
SpriteData[] sprites;
|
SpriteData[] sprites;
|
||||||
PetitComputer petitcom;
|
PetitComputer petitcom;
|
||||||
|
string spdefTableFile = "spdef.csv";
|
||||||
void initUVTable()
|
void initUVTable()
|
||||||
{
|
{
|
||||||
SPDEFTable = new SpriteDef[4096];
|
SPDEFTable = new SpriteDef[4096];
|
||||||
@@ -198,6 +201,18 @@ class Sprite
|
|||||||
}
|
}
|
||||||
SPDEFTable[4095] = SpriteDef(192, 480, 96, 32, 48, 16, SpriteAttr.show);
|
SPDEFTable[4095] = SpriteDef(192, 480, 96, 32, 48, 16, SpriteAttr.show);
|
||||||
//UVTable[] = SDL_Rect(192, 480, 96, 32);
|
//UVTable[] = SDL_Rect(192, 480, 96, 32);
|
||||||
|
import std.csv;
|
||||||
|
import std.typecons;//I X Y W H HX HY ATTR
|
||||||
|
import std.file;
|
||||||
|
import std.stdio;
|
||||||
|
import std.algorithm;
|
||||||
|
auto file = File(spdefTableFile, "r");
|
||||||
|
file.readln();//一行読み飛ばす
|
||||||
|
auto csv = file.byLine.joiner("\n").csvReader!(Tuple!(int, "I", int, "X" ,int, "Y", int, "W", int, "H", int, "HX", int, "HY", int, "ATTR"));
|
||||||
|
foreach(record; csv)
|
||||||
|
{
|
||||||
|
SPDEFTable[record.I] = SpriteDef(record.X, record.Y, record.W, record.H, record.HX, record.HY, cast(SpriteAttr)record.ATTR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this(PetitComputer petitcom)
|
this(PetitComputer petitcom)
|
||||||
{
|
{
|
||||||
@@ -251,14 +266,16 @@ class Sprite
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool lll;
|
bool lll;
|
||||||
|
double d = 0;
|
||||||
|
import std.algorithm;
|
||||||
void render()
|
void render()
|
||||||
{
|
{
|
||||||
auto texture = petitcom.GRP[petitcom.sppage].glTexture;
|
auto texture = petitcom.GRP[petitcom.sppage].glTexture;
|
||||||
float z = -0.01f;
|
float z = -0.01f;
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glBegin(GL_QUADS);
|
// glDisable(GL_TEXTURE_2D);
|
||||||
foreach(ref sprite; sprites)
|
foreach(i,ref sprite; sprites)
|
||||||
{
|
{
|
||||||
//定義されてたら動かす
|
//定義されてたら動かす
|
||||||
if(sprite.define)
|
if(sprite.define)
|
||||||
@@ -267,24 +284,94 @@ class Sprite
|
|||||||
}
|
}
|
||||||
if(sprite.attr & SpriteAttr.show)
|
if(sprite.attr & SpriteAttr.show)
|
||||||
{
|
{
|
||||||
glColor3f(1.0, 1.0, 1.0);
|
glLoadIdentity();
|
||||||
int x = cast(int)sprite.x - sprite.homex;
|
int x = cast(int)sprite.x - sprite.homex;
|
||||||
int y = cast(int)sprite.y - sprite.homey;
|
int y = cast(int)sprite.y - sprite.homey;
|
||||||
int x2 = cast(int)x + sprite.w;//-1
|
int w = sprite.w;
|
||||||
int y2 = cast(int)y + sprite.h;
|
int h = sprite.h;
|
||||||
|
if((sprite.attr & SpriteAttr.rotate90) == SpriteAttr.rotate90)
|
||||||
|
{
|
||||||
|
swap(w, h);
|
||||||
|
}
|
||||||
|
int x2 = cast(int)x + w;//-1
|
||||||
|
int y2 = cast(int)y + h;
|
||||||
|
int u = cast(int)sprite.u;
|
||||||
|
int v = cast(int)sprite.v;
|
||||||
int u2 = cast(int)sprite.u + sprite.w;//-1
|
int u2 = cast(int)sprite.u + sprite.w;//-1
|
||||||
int v2 = cast(int)sprite.v + sprite.h;
|
int v2 = cast(int)sprite.v + sprite.h;
|
||||||
glTexCoord2f(sprite.u / 512f - 1 , v2 / 512f - 1);
|
int flipx = 1, flipy = 1, flipx2 = x, flipy2 = y;
|
||||||
glVertex3f(x / 200f - 1, 1 - y2 / 120f, z);
|
if(sprite.attr & SpriteAttr.hflip)
|
||||||
glTexCoord2f(sprite.u / 512f - 1, sprite.v / 512f - 1);
|
{
|
||||||
glVertex3f(x / 200f - 1, 1 - y / 120f, z);
|
flipx = -1;
|
||||||
glTexCoord2f(u2 / 512f - 1, sprite.v / 512f - 1);
|
flipx2 = x2;
|
||||||
glVertex3f(x2 / 200f - 1, 1 - y / 120f, z);
|
|
||||||
glTexCoord2f(u2 / 512f - 1, v2 / 512f - 1);
|
|
||||||
glVertex3f(x2 / 200f - 1, 1 - y2 / 120f, z);
|
|
||||||
}
|
}
|
||||||
|
if(sprite.attr & SpriteAttr.hflip)
|
||||||
|
{
|
||||||
|
flipy = -1;
|
||||||
|
flipy2 = y2;
|
||||||
|
}
|
||||||
|
glTranslatef((flipx2) / 200f - 1,1 - ((flipy2) / 120f), z);
|
||||||
|
glRotatef(d, 0.0f, 0.0f, 1.0f );
|
||||||
|
glScalef(flipx, flipy, 1f);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glColor3f(1.0, 1.0, 1.0);
|
||||||
|
if(sprite.attr == SpriteAttr.show)
|
||||||
|
{
|
||||||
|
//d+=0.01;
|
||||||
|
glTexCoord2f(u / 512f - 1, v / 512f - 1);
|
||||||
|
glVertex3f(0, 0, z);//1
|
||||||
|
glTexCoord2f(u / 512f - 1 , v2 / 512f - 1);
|
||||||
|
glVertex3f(0, -(sprite.h / 120f), z);//2
|
||||||
|
glTexCoord2f(u2 / 512f - 1, v2 / 512f - 1);
|
||||||
|
glVertex3f(sprite.w / 200f, -(sprite.h / 120f), z);//3
|
||||||
|
glTexCoord2f(u2 / 512f - 1, v / 512f - 1);
|
||||||
|
glVertex3f(sprite.w / 200f, 0, z);//4
|
||||||
|
glEnd();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if((sprite.attr & SpriteAttr.rotate270) == SpriteAttr.rotate270)
|
||||||
|
{
|
||||||
|
glTexCoord2f(u2 / 512f - 1, v / 512f - 1);//3
|
||||||
|
glVertex3f(0, 0, z);//1
|
||||||
|
glTexCoord2f(u / 512f - 1, v / 512f - 1);//1
|
||||||
|
glVertex3f(0, -(h / 120f), z);//
|
||||||
|
glTexCoord2f(u / 512f - 1 , v2 / 512f - 1);//2
|
||||||
|
glVertex3f(w / 200f, -(h / 120f), z);//3
|
||||||
|
glTexCoord2f(u2 / 512f - 1, v2 / 512f - 1);//4
|
||||||
|
glVertex3f(w / 200f, 0, z);//4
|
||||||
|
glEnd();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if((sprite.attr & SpriteAttr.rotate90) == SpriteAttr.rotate90)
|
||||||
|
{
|
||||||
|
glTexCoord2f(u / 512f - 1 , v2 / 512f - 1);//2
|
||||||
|
glVertex3f(0, 0, z);//1
|
||||||
|
glTexCoord2f(u2 / 512f - 1, v2 / 512f - 1);//3
|
||||||
|
glVertex3f(0, -(h / 120f), z);//2
|
||||||
|
glTexCoord2f(u2 / 512f - 1, v / 512f - 1);//4
|
||||||
|
glVertex3f(w / 200f, -(h / 120f), z);//3
|
||||||
|
glTexCoord2f(u / 512f - 1, v / 512f - 1);//1
|
||||||
|
glVertex3f(w / 200f, 0, z);//4
|
||||||
|
glEnd();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if((sprite.attr & SpriteAttr.rotate180) == SpriteAttr.rotate180)
|
||||||
|
{
|
||||||
|
glTexCoord2f(u2 / 512f - 1, v2 / 512f - 1);//4
|
||||||
|
glVertex3f(0, 0, z);//1
|
||||||
|
glTexCoord2f(u2 / 512f - 1, v / 512f - 1);//3
|
||||||
|
glVertex3f(0, -(h / 120f), z);//2
|
||||||
|
glTexCoord2f(u / 512f - 1, v / 512f - 1);//1
|
||||||
|
glVertex3f(w / 200f, -(h / 120f), z);//3
|
||||||
|
glTexCoord2f(u / 512f - 1 , v2 / 512f - 1);//2
|
||||||
|
glVertex3f(w / 200f, 0, z);//4
|
||||||
|
glEnd();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void spset(int id, int defno)
|
void spset(int id, int defno)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user