Demos update (SpaceInvaders demo)

-added new sprites
-added new functions to vectors
-fixed rendering rotated sprites
-small performance improvement and some bug fixes
-added animations support
-bullets get initial velocity from parent
-added partiles for fire from gun and explosion of enemies
This commit is contained in:
Mergul 2020-05-19 20:27:18 +02:00
parent 6c3c803d1e
commit 0b924ae77c
7 changed files with 411 additions and 34 deletions

View file

@ -535,12 +535,30 @@ struct Renderer
verts[item_id*28] = cast(short)(((GfxConfig.meshes[mesh_id].vertices[0] * coss + GfxConfig.meshes[mesh_id].vertices[1] * sinn) * size.x + pos.x) * 8191);
verts[item_id*28+1] = cast(short)(((GfxConfig.meshes[mesh_id].vertices[1] * coss - GfxConfig.meshes[mesh_id].vertices[0] * sinn) * size.y + pos.y) * 8191);
verts[item_id*28+2] = cast(short)((GfxConfig.meshes[mesh_id].vertices[2] * coords.z + coords.x)*32767);
verts[item_id*28+3] = cast(short)((GfxConfig.meshes[mesh_id].vertices[3] * coords.w + coords.y)*32767);
memcpy(verts.ptr+item_id*28+4,mem.ptr,6);
verts[item_id*28+7] = cast(short)(((GfxConfig.meshes[mesh_id].vertices[4] * coss + GfxConfig.meshes[mesh_id].vertices[5] * sinn) * size.x + pos.x) * 8191);
verts[item_id*28+8] = cast(short)(((GfxConfig.meshes[mesh_id].vertices[5] * coss - GfxConfig.meshes[mesh_id].vertices[4] * sinn) * size.y + pos.y) * 8191);
verts[item_id*28+9] = cast(short)((GfxConfig.meshes[mesh_id].vertices[6] * coords.z + coords.x)*32767);
verts[item_id*28+10] = cast(short)((GfxConfig.meshes[mesh_id].vertices[7] * coords.w + coords.y)*32767);
memcpy(verts.ptr+item_id*28+11,mem.ptr,6);
verts[item_id*28+14] = cast(short)(((GfxConfig.meshes[mesh_id].vertices[8] * coss + GfxConfig.meshes[mesh_id].vertices[9] * sinn) * size.x + pos.x) * 8191);
verts[item_id*28+15] = cast(short)(((GfxConfig.meshes[mesh_id].vertices[9] * coss - GfxConfig.meshes[mesh_id].vertices[8] * sinn) * size.y + pos.y) * 8191);
verts[item_id*28+16] = cast(short)((GfxConfig.meshes[mesh_id].vertices[10] * coords.z + coords.x)*32767);
verts[item_id*28+17] = cast(short)((GfxConfig.meshes[mesh_id].vertices[11] * coords.w + coords.y)*32767);
memcpy(verts.ptr+item_id*28+18,mem.ptr,6);
verts[item_id*28+21] = cast(short)(((GfxConfig.meshes[mesh_id].vertices[12] * coss + GfxConfig.meshes[mesh_id].vertices[13] * sinn) * size.x + pos.x) * 8191);
verts[item_id*28+22] = cast(short)(((GfxConfig.meshes[mesh_id].vertices[13] * coss - GfxConfig.meshes[mesh_id].vertices[12] * sinn) * size.y + pos.y) * 8191);
verts[item_id*28+23] = cast(short)((GfxConfig.meshes[mesh_id].vertices[14] * coords.z + coords.x)*32767);
verts[item_id*28+24] = cast(short)((GfxConfig.meshes[mesh_id].vertices[15] * coords.w + coords.y)*32767);
memcpy(verts.ptr+item_id*28+25,mem.ptr,6);
}
/*verts[item_id*28+2] = cast(short)((GfxConfig.meshes[mesh_id].vertices[2] * coords.z + coords.x)*32767);

View file

@ -2,6 +2,18 @@ module ecs_utils.math.vector;
struct vec2
{
this(float v) @nogc nothrow
{
x = v;
y = v;
}
this(float x, float y) @nogc nothrow
{
this.x = x;
this.y = y;
}
union
{
struct
@ -75,6 +87,22 @@ struct vec4
float[4] data;
}
this(float v) @nogc nothrow
{
x = v;
y = v;
z = v;
w = v;
}
this(float x, float y, float z, float w) @nogc nothrow
{
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
vec4 opBinary(string op)(float v)
{
static if (op == "+") return vec4(x + v, y + v, z + v, w + v);
@ -96,6 +124,18 @@ struct ivec2
}
int[2] data;
}
this(int v) @nogc nothrow
{
x = v;
y = v;
}
this(int x, int y) @nogc nothrow
{
this.x = x;
this.y = y;
}
ivec2 opBinary(string op, T)(T v)
{
@ -125,4 +165,20 @@ struct ivec4
}
int[4] data;
}
this(int v) @nogc nothrow
{
x = v;
y = v;
z = v;
w = v;
}
this(int x, int y, int z, int w) @nogc nothrow
{
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
}