Unittests and demos update
-fixed bug in EntityManager -added better support for non-betterC unittests -added many new unittests -slightly improved JUnit xml output -fixed WASM compile script -added new textures -fixed model texture coordinaes in demos -some minor bug fixes in demo TODO: demos cpu usage in non-betterC mode
This commit is contained in:
parent
46530ff45b
commit
84e04191c8
13 changed files with 453 additions and 51 deletions
|
|
@ -138,6 +138,7 @@ struct CountSystem
|
|||
struct EntitiesData
|
||||
{
|
||||
uint length;
|
||||
const (Entity)[] entity;
|
||||
}
|
||||
|
||||
bool onBegin()
|
||||
|
|
@ -749,7 +750,7 @@ void loadGFX()
|
|||
GfxConfig.materials = Mallocator.makeArray!Material(1);
|
||||
GfxConfig.meshes = Mallocator.makeArray!Mesh(1);
|
||||
|
||||
float[16] vertices = [-0.5,-0.5, 0,0, -0.5,0.5, 0,1, 0.5,-0.5, 1,0, 0.5,0.5, 1,1];
|
||||
float[16] vertices = [-0.5,-0.5, 0,1, -0.5,0.5, 0,0, 0.5,-0.5, 1,1, 0.5,0.5, 1,0];
|
||||
GfxConfig.meshes[0].vertices = Mallocator.makeArray(vertices);
|
||||
ushort[6] indices = [0,1,2,1,2,3];
|
||||
GfxConfig.meshes[0].indices = Mallocator.makeArray(indices);
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ struct Snake
|
|||
|
||||
EntityTemplate* apple_tmpl;
|
||||
EntityTemplate* snake_tmpl;
|
||||
Texture snake_texture;
|
||||
Texture wall_texture;
|
||||
Texture apple_texture;
|
||||
Texture texture;
|
||||
|
||||
bool move_system = true;
|
||||
bool draw_system = true;
|
||||
|
|
@ -85,15 +83,16 @@ struct Snake
|
|||
|
||||
void drawMap()
|
||||
{
|
||||
const float px = 1.0/512.0;
|
||||
foreach(x; 0 .. map_size)
|
||||
{
|
||||
foreach(y; 0 .. map_size)
|
||||
{
|
||||
switch(element(ivec2(x,y)).type)
|
||||
{
|
||||
case MapElement.Type.apple:launcher.renderer.draw(apple_texture, vec2(x*32,y*32), vec2(32,32), vec4(0,0,1,1), 0, 0 , 0);break;
|
||||
case MapElement.Type.snake:launcher.renderer.draw(snake_texture, vec2(x*32,y*32), vec2(32,32), vec4(0,0,1,1), 0, 0 , 0);break;
|
||||
case MapElement.Type.wall:launcher.renderer.draw(wall_texture, vec2(x*32,y*32), vec2(32,32), vec4(0,0,1,1), 0, 0 , 0);break;
|
||||
case MapElement.Type.apple:launcher.renderer.draw(texture, vec2(x*32,y*32), vec2(32,32), vec4(0,32*px,16*px,16*px), 0, 0 , 0);break;
|
||||
case MapElement.Type.snake:launcher.renderer.draw(texture, vec2(x*32,y*32), vec2(32,32), vec4(0,48*px,16*px,16*px), 0, 0 , 0);break;
|
||||
case MapElement.Type.wall:launcher.renderer.draw(texture, vec2(x*32,y*32), vec2(32,32), vec4(0,0,1,1), 0, 0 , 0);break;
|
||||
default:break;
|
||||
}
|
||||
}
|
||||
|
|
@ -444,14 +443,8 @@ void snakeStart()
|
|||
{
|
||||
snake = Mallocator.make!Snake;
|
||||
|
||||
snake.snake_texture.create();
|
||||
snake.snake_texture.load("assets/textures/buckler.png");
|
||||
|
||||
snake.apple_texture.create();
|
||||
snake.apple_texture.load("assets/textures/buckler.png");
|
||||
|
||||
snake.wall_texture.create();
|
||||
snake.wall_texture.load("assets/textures/buckler.png");
|
||||
snake.texture.create();
|
||||
snake.texture.load("assets/textures/atlas.png");
|
||||
|
||||
launcher.manager.beginRegister();
|
||||
|
||||
|
|
@ -503,10 +496,6 @@ void snakeStart()
|
|||
|
||||
void snakeEnd()
|
||||
{
|
||||
snake.wall_texture.destroy();
|
||||
snake.apple_texture.destroy();
|
||||
snake.snake_texture.destroy();
|
||||
|
||||
//launcher.manager.freeTemplate(simple.tmpl);
|
||||
Mallocator.dispose(snake);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ struct SpaceInvaders
|
|||
EntityTemplate* enemy_tmpl;
|
||||
EntityTemplate* ship_tmpl;
|
||||
EntityTemplate* laser_tmpl;
|
||||
Texture enemy_tex;
|
||||
Texture ship_tex;
|
||||
Texture laser_tex;
|
||||
Texture texture;
|
||||
|
||||
bool move_system = true;
|
||||
bool draw_system = true;
|
||||
|
|
@ -111,6 +109,7 @@ struct CTexture
|
|||
mixin ECS.Component;
|
||||
|
||||
Texture tex;
|
||||
vec4 coords = vec4(0,0,0,1);
|
||||
}
|
||||
|
||||
struct CVelocity
|
||||
|
|
@ -214,7 +213,7 @@ struct DrawSystem
|
|||
{
|
||||
foreach(i; 0..data.length)
|
||||
{
|
||||
launcher.renderer.draw(data.textures[i].tex, data.locations[i].value, data.scale[i], vec4(0,0,1,1), 0, 0 , 0);
|
||||
launcher.renderer.draw(data.textures[i].tex, data.locations[i].value, data.scale[i], data.textures[i].coords, 0, 0 , 0);
|
||||
//draw(renderer, data.textures[i].tex, data.locations[i], vec2(32,32), vec4(0,0,1,1));
|
||||
}
|
||||
}
|
||||
|
|
@ -645,13 +644,12 @@ __gshared SpaceInvaders* space_invaders;
|
|||
|
||||
void spaceInvadersStart()
|
||||
{
|
||||
const float px = 1.0/512.0;
|
||||
|
||||
space_invaders = Mallocator.make!SpaceInvaders;
|
||||
|
||||
space_invaders.ship_tex.create();
|
||||
space_invaders.ship_tex.load("assets/textures/buckler.png");
|
||||
|
||||
space_invaders.laser_tex.create();
|
||||
space_invaders.laser_tex.load("assets/textures/buckler.png");
|
||||
space_invaders.texture.create();
|
||||
space_invaders.texture.load("assets/textures/atlas.png");
|
||||
|
||||
launcher.manager.beginRegister();
|
||||
|
||||
|
|
@ -693,7 +691,8 @@ void spaceInvadersStart()
|
|||
space_invaders.ship_tmpl = launcher.manager.allocateTemplate(components);
|
||||
|
||||
CTexture* tex_comp = space_invaders.ship_tmpl.getComponent!CTexture;
|
||||
tex_comp.tex = space_invaders.ship_tex;
|
||||
tex_comp.tex = space_invaders.texture;//ship_tex;
|
||||
tex_comp.coords = vec4(0*px,48*px,16*px,16*px);
|
||||
CLocation* loc_comp = space_invaders.ship_tmpl.getComponent!CLocation;
|
||||
loc_comp.value = vec2(64,64);
|
||||
CLaserWeapon* weapon = space_invaders.ship_tmpl.getComponent!CLaserWeapon;
|
||||
|
|
@ -707,7 +706,8 @@ void spaceInvadersStart()
|
|||
space_invaders.laser_tmpl = launcher.manager.allocateTemplate(components);
|
||||
|
||||
CTexture* tex_comp = space_invaders.laser_tmpl.getComponent!CTexture;
|
||||
tex_comp.tex = space_invaders.laser_tex;
|
||||
tex_comp.tex = space_invaders.texture;//laser_tex;
|
||||
tex_comp.coords = vec4(0*px,48*px,16*px,16*px);
|
||||
CScale* scale_comp = space_invaders.laser_tmpl.getComponent!CScale;
|
||||
scale_comp.value = vec2(4,16);
|
||||
CVelocity* vel_comp = space_invaders.laser_tmpl.getComponent!CVelocity;
|
||||
|
|
@ -724,7 +724,8 @@ void spaceInvadersStart()
|
|||
space_invaders.enemy_tmpl = launcher.manager.allocateTemplate(components);
|
||||
|
||||
CTexture* tex_comp = space_invaders.enemy_tmpl.getComponent!CTexture;
|
||||
tex_comp.tex = space_invaders.ship_tex;
|
||||
tex_comp.tex = space_invaders.texture;//ship_tex;
|
||||
tex_comp.coords = vec4(32*px,32*px,16*px,16*px);
|
||||
CLocation* loc_comp = space_invaders.enemy_tmpl.getComponent!CLocation;
|
||||
loc_comp.value = vec2(64,space_invaders.map_size.y - 64);
|
||||
CShootDirection* shoot_dir_comp = space_invaders.enemy_tmpl.getComponent!CShootDirection;
|
||||
|
|
@ -775,8 +776,6 @@ void spaceInvadersEnd()
|
|||
launcher.manager.getSystem(MovementSystem.system_id).disable();
|
||||
launcher.manager.getSystem(ClampPositionSystem.system_id).disable();
|
||||
|
||||
space_invaders.ship_tex.destroy();
|
||||
|
||||
launcher.manager.freeTemplate(space_invaders.enemy_tmpl);
|
||||
Mallocator.dispose(space_invaders);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue