Make common draw system, moved some components to basic components and fixed bug with GUI for signed short integers

This commit is contained in:
Mergul 2020-06-12 20:51:05 +02:00
parent 3a7a5b2a21
commit d733bb514c
5 changed files with 326 additions and 86 deletions

View file

@ -35,13 +35,6 @@ private enum float px = 1.0/512.0;
alias location this;
vec2 location;
}*/
struct CTexCoords
{
mixin ECS.Component;
vec4 value;
}
struct CColor
@ -53,6 +46,13 @@ struct CColor
@GUIColor uint value = uint.max;
}
struct CTexCoords
{
mixin ECS.Component;
vec4 value;
}*/
struct CVelocity
{
mixin ECS.Component;
@ -453,7 +453,7 @@ void particlesStart()
launcher.manager.beginRegister();
launcher.manager.registerComponent!CLocation;
launcher.manager.registerComponent!CTexCoords;
//launcher.manager.registerComponent!CTexCoords;
launcher.manager.registerComponent!CColor;
launcher.manager.registerComponent!CVelocity;
launcher.manager.registerComponent!CAttractor;

View file

@ -17,6 +17,7 @@ import ecs_utils.math.vector;
import ecs_utils.utils;
import game_core.basic;
import game_core.rendering;
//import std.math : PI;
@ -122,7 +123,7 @@ enum Direction : byte
alias value this;
vec2 value = vec2(0);
}*/
}
struct CScale
{
@ -134,13 +135,13 @@ struct CScale
vec2 value = vec2(16,16);
}
struct CColliderScale
struct CDepth
{
mixin ECS.Component;
alias value this;
alias depth this;
vec2 value = vec2(16,16);
short depth;
}
struct CRotation
@ -160,6 +161,15 @@ struct CTexture
//Texture tex;
uint id;
vec4 coords = vec4(0,0,0,1);
}*/
struct CColliderScale
{
mixin ECS.Component;
alias value this;
vec2 value = vec2(16,16);
}
struct CVelocity
@ -255,15 +265,6 @@ struct CSideMove
byte group = -1;
}
struct CDepth
{
mixin ECS.Component;
alias depth this;
short depth;
}
struct CShootGrid
{
mixin ECS.Component;
@ -754,11 +755,11 @@ struct ShipWeaponSystem
CDepth* depth = entity.getComponent!CDepth;
EntityID[2] weapons;
weapon_tmpl.getComponent!CTargetParent().parent = entity.id;
if(depth)weapon_tmpl.getComponent!CDepth().depth = cast(short)(depth.depth - 1);
else weapon_tmpl.getComponent!CDepth().depth = -1;
if(depth)weapon_tmpl.getComponent!CDepth().value = cast(short)(depth.value - 1);
else weapon_tmpl.getComponent!CDepth().value = -1;
top_tmpl.getComponent!CTargetParent().parent = entity.id;
if(depth)top_tmpl.getComponent!CDepth().depth = cast(short)(depth.depth - 2);
else top_tmpl.getComponent!CDepth().depth = -2;
if(depth)top_tmpl.getComponent!CDepth().value = cast(short)(depth.value - 2);
else top_tmpl.getComponent!CDepth().value = -2;
weapons[0] = launcher.manager.addEntity(weapon_tmpl).id;
weapons[1] = launcher.manager.addEntity(top_tmpl).id;
@ -771,7 +772,7 @@ struct ShipWeaponSystem
[CWeapon.component_id, CLocation.component_id, CShootDirection.component_id,
CTargetParent.component_id, CGuild.component_id, CVelocity.component_id,
CAutoShoot.component_id, CTarget.component_id, CTargetPlayerShip.component_id,
CRotation.component_id, CScale.component_id, CTexture.component_id,
CRotation.component_id, CScale.component_id, CTexCoords.component_id,
CDepth.component_id, CWeaponLocation.component_id].staticArray);
*weapon_tmpl.getComponent!CWeapon = CWeapon(0,CWeapon.Type.laser,3);
weapon_tmpl.getComponent!CTargetParent().rel_pos = vec2(0,0);
@ -779,17 +780,17 @@ struct ShipWeaponSystem
weapon_tmpl.getComponent!CScale().value = vec2(4,16);
//weapon_tmpl.getComponent!CWeapon().level = 1;
*weapon_tmpl.getComponent!CWeapon() = CWeapon(0,CWeapon.Type.canon,1);
weapon_tmpl.getComponent!CDepth().depth = -1;
weapon_tmpl.getComponent!CTexture().coords = vec4(136,96,4,16)*px;
weapon_tmpl.getComponent!CDepth().value = -1;
weapon_tmpl.getComponent!CTexCoords().value = vec4(136,96,4,16)*px;
weapon_tmpl.getComponent!CWeaponLocation().rel_pos = vec2(0,12);
top_tmpl = launcher.manager.allocateTemplate(
[CLocation.component_id, CTargetParent.component_id, CScale.component_id,
CTexture.component_id, CDepth.component_id].staticArray);
CTexCoords.component_id, CDepth.component_id].staticArray);
top_tmpl.getComponent!CTargetParent().rel_pos = vec2(0,1);
top_tmpl.getComponent!CScale().value = vec2(10,11);
top_tmpl.getComponent!CDepth().depth = -2;
top_tmpl.getComponent!CTexture().coords = vec4(112,96,10,11)*px;
top_tmpl.getComponent!CDepth().value = -2;
top_tmpl.getComponent!CTexCoords().value = vec4(112,96,10,11)*px;
}
@ -829,21 +830,23 @@ struct ShipWeaponSystem
{
tower1_tmpl = launcher.manager.allocateTemplate(
[CHitMark.component_id, CHitPoints.component_id, CLocation.component_id,
CTexture.component_id, CScale.component_id, CEnemy.component_id,
CTexCoords.component_id, CScale.component_id, CEnemy.component_id,
CShootGrid.component_id, CGuild.component_id, CInit.component_id,
CChildren.component_id, CDepth.component_id, CTargetParent.component_id,
CSpawnUponDeath.component_id, CShootWaveUponDeath.component_id].staticArray
);
CTexture* tex_comp = tower1_tmpl.getComponent!CTexture;
/*CTexCoords* tex_comp = tower1_tmpl.getComponent!CTexCoords;
//tex_comp.tex = space_invaders.texture;//ship_tex;
tex_comp.coords = vec4(96*px,96*px,16*px,16*px);
CLocation* loc_comp = tower1_tmpl.getComponent!CLocation;
loc_comp.value = vec2(64,space_invaders.map_size.y - 16);
loc_comp.value = vec2(64,space_invaders.map_size.y - 16);*/
tower1_tmpl.getComponent!CTexCoords().value = vec4(96*px,96*px,16*px,16*px);
tower1_tmpl.getComponent!CLocation().value = vec2(64,space_invaders.map_size.y - 16);
tower1_tmpl.getComponent!CGuild().guild = 1;
tower1_tmpl.getComponent!CInit().type = CInit.Type.tower;
tower1_tmpl.getComponent!CHitPoints().value = 10;
tower1_tmpl.getComponent!CDepth().depth = -2;
tower1_tmpl.getComponent!CDepth().value = -2;
tower1_tmpl.getComponent!CShootWaveUponDeath().bullet_type = CWeapon.Type.canon;
tower1_tmpl.getComponent!CTargetParent().rel_pos = vec2(-33,2);
@ -851,11 +854,11 @@ struct ShipWeaponSystem
tower2_tmpl.getComponent!CTargetParent().rel_pos = vec2(33,2);
tower3_tmpl = launcher.manager.allocateTemplate(tower1_tmpl);
tower3_tmpl.getComponent!CDepth().depth = 0;
tower3_tmpl.getComponent!CDepth().value = 0;
tower3_tmpl.getComponent!CTargetParent().rel_pos = vec2(-40,-15);
tower4_tmpl = launcher.manager.allocateTemplate(tower1_tmpl);
tower4_tmpl.getComponent!CDepth().depth = 0;
tower4_tmpl.getComponent!CDepth().value = 0;
tower4_tmpl.getComponent!CTargetParent().rel_pos = vec2(40,-15);
}
@ -966,7 +969,7 @@ struct DrawSystem
uint length;
//uint thread_id;
uint job_id;
@readonly CTexture[] textures;
@readonly CTexCoords[] textures;
@readonly CLocation[] locations;
@readonly CScale[] scale;
@readonly @optional CRotation[] rotation;
@ -992,7 +995,7 @@ struct DrawSystem
{
draw_data.color = 0x80808080 + 0x01010101 * data.hit_mark[i];
draw_data.depth = cast(short)(data.locations[i].y);
draw_data.coords = data.textures[i].coords;
draw_data.coords = data.textures[i].value;
draw_data.size = data.scale[i];
draw_data.position = data.locations[i];
launcher.renderer.draw(draw_data);
@ -1005,7 +1008,7 @@ struct DrawSystem
{
draw_data.depth = cast(short)(data.locations[i].y);
draw_data.angle = data.rotation[i];
draw_data.coords = data.textures[i].coords;
draw_data.coords = data.textures[i].value;
draw_data.size = data.scale[i];
draw_data.position = data.locations[i];
launcher.renderer.draw(draw_data);
@ -1017,7 +1020,7 @@ struct DrawSystem
foreach(i; 0..data.length)
{
draw_data.depth = cast(short)(data.locations[i].y);
draw_data.coords = data.textures[i].coords;
draw_data.coords = data.textures[i].value;
draw_data.size = data.scale[i];
draw_data.position = data.locations[i];
launcher.renderer.draw(draw_data);
@ -1036,7 +1039,7 @@ struct DrawSystem
draw_data.color = 0x80808080 + 0x01010101 * data.hit_mark[i];
draw_data.angle = data.rotation[i];
draw_data.depth = cast(short)(data.depth[i] * 8 + data.locations[i].y);
draw_data.coords = data.textures[i].coords;
draw_data.coords = data.textures[i].value;
draw_data.size = data.scale[i];
draw_data.position = data.locations[i];
launcher.renderer.draw(draw_data);
@ -1049,7 +1052,7 @@ struct DrawSystem
{
draw_data.color = 0x80808080 + 0x01010101 * data.hit_mark[i];
draw_data.depth = cast(short)(data.depth[i] * 8 + data.locations[i].y);
draw_data.coords = data.textures[i].coords;
draw_data.coords = data.textures[i].value;
draw_data.size = data.scale[i];
draw_data.position = data.locations[i];
launcher.renderer.draw(draw_data);
@ -1063,7 +1066,7 @@ struct DrawSystem
{
draw_data.angle = data.rotation[i];
draw_data.depth = cast(short)(data.depth[i] * 8 + data.locations[i].y);
draw_data.coords = data.textures[i].coords;
draw_data.coords = data.textures[i].value;
draw_data.size = data.scale[i];
draw_data.position = data.locations[i];
launcher.renderer.draw(draw_data);
@ -1075,7 +1078,7 @@ struct DrawSystem
foreach(i; 0..data.length)
{
draw_data.depth = cast(short)(data.depth[i] * 8 + data.locations[i].y);
draw_data.coords = data.textures[i].coords;
draw_data.coords = data.textures[i].value;
draw_data.size = data.scale[i];
draw_data.position = data.locations[i];
launcher.renderer.draw(draw_data);
@ -1138,31 +1141,31 @@ struct ShootingSystem
void onCreate()
{
/*bullet_tmpl[0] = launcher.manager.allocateTemplate(
[CLocation.component_id, CTexture.component_id, CVelocity.component_id,
[CLocation.component_id, CTexCoords.component_id, CVelocity.component_id,
CScale.component_id, CBullet.component_id, CGuild.component_id].staticArray
);
bullet_tmpl[0].getComponent!CTexture().coords = vec4(0,24,2,8)*px;
bullet_tmpl[0].getComponent!CTexCoords().value = vec4(0,24,2,8)*px;
bullet_tmpl[0].getComponent!CScale().value = vec2(2,8);
bullet_tmpl[1] = launcher.manager.allocateTemplate(bullet_tmpl[0]);
bullet_tmpl[2] = launcher.manager.allocateTemplate(bullet_tmpl[0]);
bullet_tmpl[2].getComponent!CTexture().coords = vec4(64,32,8,16)*px;
bullet_tmpl[2].getComponent!CTexCoords().value = vec4(64,32,8,16)*px;
bullet_tmpl[2].getComponent!CScale().value = vec2(8,16);
bullet_tmpl[3] = launcher.manager.allocateTemplate(bullet_tmpl[0]);
bullet_tmpl[3].getComponent!CTexture().coords = vec4(56,32,2,2)*px;
bullet_tmpl[3].getComponent!CTexCoords().value = vec4(56,32,2,2)*px;
bullet_tmpl[3].getComponent!CScale().value = vec2(2,2);
// bullet_tmpl[3].getComponent!CTexture().coords = vec4(48,32,8,8)*px;
// bullet_tmpl[3].getComponent!CTexCoords().value = vec4(48,32,8,8)*px;
// bullet_tmpl[3].getComponent!CScale().value = vec2(8,8);
bullet_tmpl[4] = launcher.manager.allocateTemplate(bullet_tmpl[0]);*/
fire_tmpl = launcher.manager.allocateTemplate(
[CLocation.component_id, CTexture.component_id, CScale.component_id,
[CLocation.component_id, CTexCoords.component_id, CScale.component_id,
CAnimation.component_id, CParticle.component_id, CRotation.component_id,
CVelocity.component_id, CDamping.component_id].staticArray
);
fire_tmpl.getComponent!CTexture().coords = vec4(96,64,8,16)*px;
fire_tmpl.getComponent!CTexCoords().value = vec4(96,64,8,16)*px;
fire_tmpl.getComponent!CScale().value = vec2(8,16);
fire_tmpl.getComponent!(CParticle).life = 300;
*fire_tmpl.getComponent!(CAnimation) = CAnimation(fire_frames, 0, 3);
@ -1364,7 +1367,7 @@ struct ParticleEmittingSystem
void onCreate()
{
templates[0] = launcher.manager.allocateTemplate(
[CLocation.component_id, CTexture.component_id, CScale.component_id,
[CLocation.component_id, CTexCoords.component_id, CScale.component_id,
CAnimation.component_id, CParticle.component_id, CRotation.component_id,
CVelocity.component_id, CDamping.component_id, CDepth.component_id].staticArray);
*templates[0].getComponent!CAnimation() = CAnimation(flashes,0,2);
@ -1400,7 +1403,7 @@ struct ParticleEmittingSystem
if(data.depth)
{
depth.depth = data.depth[i];
depth.value = data.depth[i];
}
launcher.manager.addEntity(templates[0],[data.location[i].ref_,velocity.ref_,depth.ref_].staticArray);
@ -1659,18 +1662,18 @@ struct HitPointsSystem
void onCreate()
{
upgrade_tmpl = launcher.manager.allocateTemplate(
[CVelocity.component_id, CLocation.component_id, CTexture.component_id,
[CVelocity.component_id, CLocation.component_id, CTexCoords.component_id,
CScale.component_id, CUpgrade.component_id, CAnimation.component_id,
CAnimationLooped.component_id].staticArray);
//tex_comp.tex = space_invaders.texture;//ship_tex;
upgrade_tmpl.getComponent!CTexture().coords = vec4(0*px,32*px,16*px,16*px);
upgrade_tmpl.getComponent!CTexCoords().value = vec4(0*px,32*px,16*px,16*px);
*upgrade_tmpl.getComponent!CAnimation = CAnimation(upgrade_laser_frames, 0, 1);
upgrade_tmpl.getComponent!CVelocity().value = vec2(0,-0.1);
explosion_tmpl = launcher.manager.allocateTemplate(
[CDepth.component_id, CParticle.component_id, CLocation.component_id,
CTexture.component_id, CScale.component_id, CAnimation.component_id].staticArray);
//explosion_tmpl.getComponent!(CTexture).tex = space_invaders.texture;
CTexCoords.component_id, CScale.component_id, CAnimation.component_id].staticArray);
//explosion_tmpl.getComponent!(CTexCoords).tex = space_invaders.texture;
*explosion_tmpl.getComponent!CAnimation = CAnimation(explosion_laser_frames, 0, 1.333);
explosion_tmpl.getComponent!(CParticle).life = 600;
*explosion_tmpl.getComponent!CDepth = -1;
@ -2005,7 +2008,8 @@ struct AnimationSystem
{
uint length;
CAnimation[] animation;
CTexture[] texture;
//CTexture[] texture;
CTexCoords[] texcoords;
@optional @readonly CAnimationLooped[] looped;
}
@ -2020,7 +2024,7 @@ struct AnimationSystem
while(cast(uint)data.animation[i].time >= data.animation[i].frames.length)data.animation[i].time -= cast(float)data.animation[i].frames.length;
if(cast(uint)(data.animation[i].time) >= data.animation[i].frames.length)assert(0);
uint index = cast(uint)(data.animation[i].time);
if(index < data.animation[i].frames.length)data.texture[i].coords = data.animation[i].frames[index];
if(index < data.animation[i].frames.length)data.texcoords[i].value = data.animation[i].frames[index];
}
}
else
@ -2030,7 +2034,7 @@ struct AnimationSystem
data.animation[i].time += dt * data.animation[i].speed;
if(cast(uint)data.animation[i].time >= data.animation[i].frames.length)data.animation[i].time = data.animation[i].frames.length - 0.9;
uint index = cast(uint)(data.animation[i].time);
if(index < data.animation[i].frames.length)data.texture[i].coords = data.animation[i].frames[index];
if(index < data.animation[i].frames.length)data.texcoords[i].value = data.animation[i].frames[index];
}
}
@ -2241,7 +2245,7 @@ struct InputMovementSystem
//components are treated as required by default
//CLocation[] locations;
CVelocity[] velocity;
CTexture[] textures;
//CTexture[] textures;
}
/**
@ -2336,7 +2340,8 @@ void spaceInvadersStart()
launcher.manager.registerDependency(ShootGridDependency);
launcher.manager.registerComponent!CLocation;
launcher.manager.registerComponent!CTexture;
launcher.manager.registerComponent!CTexCoords;
//launcher.manager.registerComponent!CTexture;
launcher.manager.registerComponent!CInput;
launcher.manager.registerComponent!CShip;
launcher.manager.registerComponent!CEnemy;
@ -2478,12 +2483,12 @@ void spaceInvadersStart()
{
space_invaders.ship_tmpl = launcher.manager.allocateTemplate(
[CVelocity.component_id, CHitMark.component_id, CHitPoints.component_id,
CLocation.component_id, CTexture.component_id, CInput.component_id,
CLocation.component_id, CTexCoords.component_id, CInput.component_id,
CShip.component_id, CScale.component_id, CColliderScale.component_id,
CShootDirection.component_id, CShootGrid.component_id, CGuild.component_id,
CDamping.component_id, CChildren.component_id, CInit.component_id].staticArray
);
space_invaders.ship_tmpl.getComponent!CTexture().coords = vec4(0,80,48,32)*px;
space_invaders.ship_tmpl.getComponent!CTexCoords().value = vec4(0,80,48,32)*px;
space_invaders.ship_tmpl.getComponent!CScale().value = vec2(48,32);
space_invaders.ship_tmpl.getComponent!CHitPoints().value = 1000;
space_invaders.ship_tmpl.getComponent!CDamping().value = 7;
@ -2494,10 +2499,10 @@ void spaceInvadersStart()
}
{
ushort[6] components = [CLocation.component_id, CTexture.component_id, CVelocity.component_id, CScale.component_id, CBullet.component_id, CGuild.component_id];
ushort[6] components = [CLocation.component_id, CTexCoords.component_id, CVelocity.component_id, CScale.component_id, CBullet.component_id, CGuild.component_id];
space_invaders.laser_tmpl = launcher.manager.allocateTemplate(components);
space_invaders.laser_tmpl.getComponent!CTexture().coords = vec4(0,24,2,8)*px;
space_invaders.laser_tmpl.getComponent!CTexCoords().value = vec4(0,24,2,8)*px;
space_invaders.laser_tmpl.getComponent!CScale().value = vec2(2,8);
space_invaders.laser_tmpl.getComponent!CVelocity().value = vec2(0,1);
}
@ -2513,7 +2518,7 @@ void spaceInvadersStart()
{
boss_tmpl = launcher.manager.allocateTemplate(
[CHitMark.component_id, CParts.component_id, CLocation.component_id,
CTexture.component_id, CScale.component_id, CEnemy.component_id,
CTexCoords.component_id, CScale.component_id, CEnemy.component_id,
CBoss.component_id, CGuild.component_id, CInit.component_id,
CChildren.component_id, CSideMove.component_id, CVelocity.component_id,
CDepth.component_id].staticArray
@ -2524,11 +2529,11 @@ void spaceInvadersStart()
//tex_comp.coords = vec4(128*px,0*px,96*px,48*px);
//CLocation* loc_comp = boss_tmpl.getComponent!CLocation;
//loc_comp.value = vec2(64,space_invaders.map_size.y - 16);
boss_tmpl.getComponent!CTexture().coords = vec4(128,0,96,48)*px;
boss_tmpl.getComponent!CTexCoords().value = vec4(128,0,96,48)*px;
boss_tmpl.getComponent!CGuild().guild = 1;
boss_tmpl.getComponent!CInit().type = CInit.Type.boss;
boss_tmpl.getComponent!CScale().value = vec2(96,48);
boss_tmpl.getComponent!CDepth().depth = -1;
boss_tmpl.getComponent!CDepth().value = -1;
boss_tmpl.getComponent!CParts().count = 4;
boss_tmpl.getComponent!CVelocity().value = vec2(0.05,0);
}
@ -2536,12 +2541,12 @@ void spaceInvadersStart()
{
tower_tmpl = launcher.manager.allocateTemplate(
[CHitMark.component_id, CHitPoints.component_id, CLocation.component_id,
CTexture.component_id, CScale.component_id, CEnemy.component_id,
CTexCoords.component_id, CScale.component_id, CEnemy.component_id,
CShootGrid.component_id, CGuild.component_id, CInit.component_id,
CChildren.component_id].staticArray
);
tower_tmpl.getComponent!CTexture().coords = vec4(96,96,16,16)*px;
tower_tmpl.getComponent!CTexCoords().value = vec4(96,96,16,16)*px;
tower_tmpl.getComponent!CGuild().guild = 1;
tower_tmpl.getComponent!CInit().type = CInit.Type.tower;
tower_tmpl.getComponent!CHitPoints().value = 10;
@ -2551,12 +2556,12 @@ void spaceInvadersStart()
space_invaders.enemy_tmpl = launcher.manager.allocateTemplate(
[CWeaponLocation.component_id, CHitMark.component_id, CHitPoints.component_id,
CVelocity.component_id, CAutoShoot.component_id, CLocation.component_id,
CTexture.component_id, CScale.component_id, CWeapon.component_id,
CTexCoords.component_id, CScale.component_id, CWeapon.component_id,
CEnemy.component_id, CShootDirection.component_id, CShootGrid.component_id,
CGuild.component_id].staticArray
);
space_invaders.enemy_tmpl.getComponent!CTexture().coords = vec4(32,32,16,16)*px;
space_invaders.enemy_tmpl.getComponent!CTexCoords().value = vec4(32,32,16,16)*px;
space_invaders.enemy_tmpl.getComponent!CShootDirection().direction = Direction.down;
space_invaders.enemy_tmpl.getComponent!CVelocity().value = vec2(0.1,0);
space_invaders.enemy_tmpl.getComponent!CGuild().guild = 1;
@ -2588,8 +2593,8 @@ void spaceInvadersStart()
EntityTemplate* upgrade_tmpl;
{
upgrade_tmpl = launcher.manager.allocateTemplate([CVelocity.component_id, CLocation.component_id, CTexture.component_id, CScale.component_id, CUpgrade.component_id, CAnimationLooped.component_id, CAnimation.component_id].staticArray);
upgrade_tmpl.getComponent!CTexture().coords = vec4(0,32,16,16)*px;
upgrade_tmpl = launcher.manager.allocateTemplate([CVelocity.component_id, CLocation.component_id, CTexCoords.component_id, CScale.component_id, CUpgrade.component_id, CAnimationLooped.component_id, CAnimation.component_id].staticArray);
upgrade_tmpl.getComponent!CTexCoords().value = vec4(0,32,16,16)*px;
upgrade_tmpl.getComponent!CVelocity().value = vec2(0,-0.1);
*upgrade_tmpl.getComponent!CAnimation = CAnimation(HitPointsSystem.upgrade_laser_frames, 0, 0.75);
}
@ -2600,20 +2605,20 @@ void spaceInvadersStart()
grouped_tmpl = launcher.manager.allocateTemplate(grouped_id);
space_invaders.bullet_tmpl[0] = launcher.manager.allocateTemplate(
[CLocation.component_id, CTexture.component_id, CVelocity.component_id,
[CLocation.component_id, CTexCoords.component_id, CVelocity.component_id,
CScale.component_id, CBullet.component_id, CGuild.component_id].staticArray
);
space_invaders.bullet_tmpl[0].getComponent!CTexture().coords = vec4(0,24,2,8)*px;
space_invaders.bullet_tmpl[0].getComponent!CTexCoords().value = vec4(0,24,2,8)*px;
space_invaders.bullet_tmpl[0].getComponent!CScale().value = vec2(2,8);
space_invaders.bullet_tmpl[1] = launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[0]);
space_invaders.bullet_tmpl[2] = launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[0]);
space_invaders.bullet_tmpl[2].getComponent!CTexture().coords = vec4(64,32,8,16)*px;
space_invaders.bullet_tmpl[2].getComponent!CTexCoords().value = vec4(64,32,8,16)*px;
space_invaders.bullet_tmpl[2].getComponent!CScale().value = vec2(8,16);
space_invaders.bullet_tmpl[3] = launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[0]);
space_invaders.bullet_tmpl[3].getComponent!CTexture().coords = vec4(56,32,2,2)*px;
space_invaders.bullet_tmpl[3].getComponent!CTexCoords().value = vec4(56,32,2,2)*px;
space_invaders.bullet_tmpl[3].getComponent!CScale().value = vec2(2,2);
// bullet_tmpl[3].getComponent!CTexture().coords = vec4(48,32,8,8)*px;
// bullet_tmpl[3].getComponent!CTexCoords().value = vec4(48,32,8,8)*px;
// bullet_tmpl[3].getComponent!CScale().value = vec2(8,8);
space_invaders.bullet_tmpl[4] = launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[0]);