Demos update
-added some new types to gui manager + some fixes -TexCoordsManager now working (probably) -added CRenderDefault components which makes entities without texcoords possible to draw -makes better way of binding demos to launcher -moved some registration related to rendering to one function (basic components + draw system) -added Sandbox demo (demo which takes all demos to one demo) -extends ParticlesDemo play area -added BirckBreaker demo (WIP) -added special material to additive particles -added whole bunch of rendering code to rendering module -added ability to show filtered entities (blinking)
This commit is contained in:
parent
ef4faf2755
commit
b0b64b965f
12 changed files with 1122 additions and 74 deletions
193
demos/source/demos/brick_breaker.d
Normal file
193
demos/source/demos/brick_breaker.d
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
module demos.brick_breaker;
|
||||
|
||||
import app;
|
||||
|
||||
import bindbc.sdl;
|
||||
|
||||
import bubel.ecs.attributes;
|
||||
import bubel.ecs.core;
|
||||
import bubel.ecs.entity;
|
||||
import bubel.ecs.manager;
|
||||
import bubel.ecs.std;
|
||||
|
||||
import cimgui.cimgui;
|
||||
|
||||
import ecs_utils.gfx.texture;
|
||||
import ecs_utils.math.vector;
|
||||
import ecs_utils.utils;
|
||||
|
||||
import game_core.basic;
|
||||
import game_core.rendering;
|
||||
|
||||
extern(C):
|
||||
|
||||
/*#######################################################################################################################
|
||||
------------------------------------------------ Components ------------------------------------------------------------------
|
||||
#######################################################################################################################*/
|
||||
|
||||
/*struct CLocation
|
||||
{
|
||||
mixin ECS.Component;
|
||||
|
||||
alias location this;
|
||||
|
||||
vec2 location;
|
||||
}*/
|
||||
|
||||
struct CBrick
|
||||
{
|
||||
mixin ECS.Component;
|
||||
}
|
||||
|
||||
struct CPaddle
|
||||
{
|
||||
mixin ECS.Component;
|
||||
}
|
||||
|
||||
struct CBall
|
||||
{
|
||||
mixin ECS.Component;
|
||||
|
||||
ubyte radius;
|
||||
}
|
||||
|
||||
struct CVelocity
|
||||
{
|
||||
mixin ECS.Component;
|
||||
|
||||
alias value this;
|
||||
|
||||
vec2 value;
|
||||
}
|
||||
|
||||
/*#######################################################################################################################
|
||||
------------------------------------------------ Systems ------------------------------------------------------------------
|
||||
#######################################################################################################################*/
|
||||
|
||||
struct MoveSystem
|
||||
{
|
||||
mixin ECS.System!64;
|
||||
|
||||
struct EntitiesData
|
||||
{
|
||||
uint length;
|
||||
CLocation[] location;
|
||||
@readonly CVelocity[] velocity;
|
||||
}
|
||||
|
||||
void onUpdate(EntitiesData data)
|
||||
{
|
||||
foreach(i; 0..data.length)
|
||||
{
|
||||
data.location[i] += data.velocity[i] * launcher.delta_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct BallCollisionSystem
|
||||
{
|
||||
mixin ECS.System!64;
|
||||
|
||||
struct EntitiesData
|
||||
{
|
||||
uint length;
|
||||
CLocation[] location;
|
||||
CVelocity[] velocity;
|
||||
}
|
||||
|
||||
void onUpdate(EntitiesData data)
|
||||
{
|
||||
foreach(i; 0..data.length)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*#######################################################################################################################
|
||||
------------------------------------------------ Functions ------------------------------------------------------------------
|
||||
#######################################################################################################################*/
|
||||
|
||||
struct BrickBreakerDemo
|
||||
{
|
||||
__gshared const (char)* tips = "Brick breaker demo. It's a game about destroying evil bricks.";
|
||||
|
||||
EntityTemplate* tmpl;
|
||||
Texture texture;
|
||||
}
|
||||
|
||||
__gshared BrickBreakerDemo* demo;
|
||||
|
||||
void brickBreakerStart()
|
||||
{
|
||||
demo = Mallocator.make!BrickBreakerDemo;
|
||||
|
||||
launcher.manager.beginRegister();
|
||||
|
||||
registerRenderingModule(launcher.manager);
|
||||
|
||||
launcher.manager.registerComponent!CLocation;
|
||||
launcher.manager.registerComponent!CRotation;
|
||||
launcher.manager.registerComponent!CScale;
|
||||
launcher.manager.registerComponent!CTexCoords;
|
||||
launcher.manager.registerComponent!CTexCoordsIndex;
|
||||
launcher.manager.registerComponent!CVelocity;
|
||||
|
||||
launcher.manager.registerSystem!MoveSystem(-100);
|
||||
launcher.manager.registerSystem!BallCollisionSystem(-99);
|
||||
|
||||
launcher.manager.endRegister();
|
||||
|
||||
demo.texture.create();
|
||||
demo.texture.load("assets/textures/atlas.png");
|
||||
|
||||
launcher.manager.beginRegister();
|
||||
|
||||
launcher.manager.registerComponent!CLocation;
|
||||
|
||||
launcher.manager.endRegister();
|
||||
}
|
||||
|
||||
void brickBreakerEnd()
|
||||
{
|
||||
launcher.manager.getSystem(MoveSystem.system_id).disable();
|
||||
launcher.manager.getSystem(DrawSystem.system_id).disable();
|
||||
|
||||
demo.texture.destroy();
|
||||
|
||||
Mallocator.dispose(demo);
|
||||
}
|
||||
|
||||
void brickBreakerEvent(SDL_Event* event)
|
||||
{
|
||||
}
|
||||
|
||||
bool brickBreakerLoop()
|
||||
{
|
||||
launcher.render_position = (vec2(launcher.window_size.x,launcher.window_size.y)*launcher.scalling - vec2(400,300)) * 0.5;
|
||||
|
||||
launcher.manager.begin();
|
||||
if(launcher.multithreading)
|
||||
{
|
||||
launcher.job_updater.begin();
|
||||
launcher.manager.updateMT();
|
||||
launcher.job_updater.call();
|
||||
}
|
||||
else
|
||||
{
|
||||
launcher.manager.update();
|
||||
}
|
||||
launcher.manager.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DemoCallbacks getBrickBreakerDemo()
|
||||
{
|
||||
DemoCallbacks demo;
|
||||
demo.initialize = &brickBreakerStart;
|
||||
demo.deinitialize = &brickBreakerEnd;
|
||||
demo.loop = &brickBreakerLoop;
|
||||
demo.tips = .demo.tips;
|
||||
return demo;
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ import ecs_utils.math.vector;
|
|||
import ecs_utils.utils;
|
||||
|
||||
import game_core.basic;
|
||||
import game_core.rendering;
|
||||
|
||||
import gui.attributes;
|
||||
|
||||
|
|
@ -115,7 +116,7 @@ struct CParticleLife
|
|||
/*#######################################################################################################################
|
||||
------------------------------------------------ Systems ------------------------------------------------------------------
|
||||
#######################################################################################################################*/
|
||||
|
||||
/*
|
||||
struct DrawSystem
|
||||
{
|
||||
mixin ECS.System!32;
|
||||
|
|
@ -162,7 +163,7 @@ struct DrawSystem
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
struct MoveSystem
|
||||
{
|
||||
|
|
@ -338,10 +339,10 @@ struct PlayAreaSystem
|
|||
{
|
||||
foreach(i; 0..data.length)
|
||||
{
|
||||
if(data.locations[i].x > 400)launcher.manager.removeEntity(data.entity[i].id);
|
||||
else if(data.locations[i].x < 0)launcher.manager.removeEntity(data.entity[i].id);
|
||||
if(data.locations[i].y > 300)launcher.manager.removeEntity(data.entity[i].id);
|
||||
else if(data.locations[i].y < 0)launcher.manager.removeEntity(data.entity[i].id);
|
||||
if(data.locations[i].x > 440)launcher.manager.removeEntity(data.entity[i].id);
|
||||
else if(data.locations[i].x < -40)launcher.manager.removeEntity(data.entity[i].id);
|
||||
if(data.locations[i].y > 340)launcher.manager.removeEntity(data.entity[i].id);
|
||||
else if(data.locations[i].y < -40)launcher.manager.removeEntity(data.entity[i].id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -452,16 +453,24 @@ void particlesStart()
|
|||
|
||||
launcher.manager.beginRegister();
|
||||
|
||||
registerRenderingModule(launcher.manager);
|
||||
|
||||
launcher.manager.registerComponent!CLocation;
|
||||
//launcher.manager.registerComponent!CTexCoords;
|
||||
launcher.manager.registerComponent!CColor;
|
||||
launcher.manager.registerComponent!CVelocity;
|
||||
launcher.manager.registerComponent!CScale;
|
||||
launcher.manager.registerComponent!CTexCoords;
|
||||
launcher.manager.registerComponent!CTexCoordsIndex;
|
||||
launcher.manager.registerComponent!CRotation;
|
||||
launcher.manager.registerComponent!CDepth;
|
||||
launcher.manager.registerComponent!CAttractor;
|
||||
launcher.manager.registerComponent!CDamping;
|
||||
launcher.manager.registerComponent!CGravity;
|
||||
launcher.manager.registerComponent!CVortex;
|
||||
launcher.manager.registerComponent!CParticleLife;
|
||||
launcher.manager.registerComponent!CForceRange;
|
||||
launcher.manager.registerComponent!CMaterialIndex;
|
||||
|
||||
launcher.manager.registerSystem!MoveSystem(0);
|
||||
launcher.manager.registerSystem!DrawSystem(100);
|
||||
|
|
@ -476,6 +485,12 @@ void particlesStart()
|
|||
|
||||
launcher.manager.endRegister();
|
||||
|
||||
DrawSystem* draw_system = launcher.manager.getSystem!DrawSystem;
|
||||
draw_system.default_data.size = vec2(2,2);
|
||||
draw_system.default_data.coords = vec4(246,64,2,2)*px;
|
||||
draw_system.default_data.material_id = 2;
|
||||
draw_system.default_data.texture = particles_demo.texture;
|
||||
|
||||
launcher.gui_manager.addSystem(MoveSystem.system_id,"Move System");
|
||||
launcher.gui_manager.addSystem(DrawSystem.system_id,"Draw System");
|
||||
launcher.gui_manager.addSystem(PlayAreaSystem.system_id,"Play Area System");
|
||||
|
|
@ -498,8 +513,11 @@ void particlesStart()
|
|||
launcher.gui_manager.addComponent(CGravity(),"Gravity");
|
||||
|
||||
EntityTemplate* tmpl;
|
||||
EntityTemplate* base_tmpl = launcher.manager.allocateTemplate([CLocation.component_id, CColor.component_id, CVelocity.component_id, CDamping.component_id].staticArray);
|
||||
EntityTemplate* base_tmpl = launcher.manager.allocateTemplate([CTexCoords.component_id, CLocation.component_id, CColor.component_id, CVelocity.component_id, CDamping.component_id, CScale.component_id, CMaterialIndex.component_id].staticArray);
|
||||
base_tmpl.getComponent!CColor().value = 0xFF251010;
|
||||
base_tmpl.getComponent!CScale().value = vec2(2);
|
||||
base_tmpl.getComponent!CTexCoords().value = vec4(246,64,2,2)*px;
|
||||
base_tmpl.getComponent!CMaterialIndex().value = 2;
|
||||
launcher.gui_manager.addTemplate(base_tmpl,"Particle");
|
||||
// tmpl = launcher.manager.allocateTemplate(base_tmpl);
|
||||
// tmpl.getComponent!CColor().value = 0xFF251010;
|
||||
|
|
@ -515,7 +533,8 @@ void particlesStart()
|
|||
// tmpl = launcher.manager.allocateTemplate(tmpl);
|
||||
// tmpl.getComponent!CDamping().power = 4;
|
||||
// launcher.gui_manager.addTemplate(tmpl,"Particle (damping!)");
|
||||
tmpl = launcher.manager.allocateTemplate([CAttractor.component_id, CLocation.component_id, CForceRange.component_id].staticArray);
|
||||
tmpl = launcher.manager.allocateTemplate([CAttractor.component_id, CLocation.component_id, CForceRange.component_id, CScale.component_id].staticArray);
|
||||
tmpl.getComponent!CScale().value = vec2(4);
|
||||
launcher.gui_manager.addTemplate(tmpl,"Attractor");
|
||||
tmpl = launcher.manager.allocateTemplate(tmpl, [CVortex.component_id].staticArray);
|
||||
launcher.gui_manager.addTemplate(tmpl,"Vortex");
|
||||
|
|
@ -555,4 +574,14 @@ bool particlesLoop()
|
|||
launcher.manager.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DemoCallbacks getParticlesDemo()
|
||||
{
|
||||
DemoCallbacks demo;
|
||||
demo.initialize = &particlesStart;
|
||||
demo.deinitialize = &particlesEnd;
|
||||
demo.loop = &particlesLoop;
|
||||
demo.tips = ParticlesDemo.tips;
|
||||
return demo;
|
||||
}
|
||||
89
demos/source/demos/sandbox.d
Normal file
89
demos/source/demos/sandbox.d
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
module demos.sandbox;
|
||||
|
||||
import bindbc.sdl;
|
||||
|
||||
import demos.simple;
|
||||
import demos.snake;
|
||||
import demos.space_invaders;
|
||||
import demos.particles;
|
||||
|
||||
import game_core.rendering;
|
||||
|
||||
import app;
|
||||
|
||||
import ecs_utils.math.vector;
|
||||
|
||||
extern(C):
|
||||
|
||||
void sandboxStart()
|
||||
{
|
||||
simpleStart();
|
||||
snakeStart();
|
||||
spaceInvadersStart();
|
||||
particlesStart();
|
||||
|
||||
DrawSystem* draw_system = launcher.manager.getSystem!DrawSystem;
|
||||
draw_system.default_data.size = vec2(16,16);
|
||||
draw_system.default_data.coords = vec4(0,48,16,16)*demos.simple.px;
|
||||
draw_system.default_data.material_id = 0;
|
||||
draw_system.default_data.texture = particles_demo.texture;
|
||||
draw_system.default_data.color = 0x80808080;
|
||||
}
|
||||
|
||||
void sandboxEnd()
|
||||
{
|
||||
simpleEnd();
|
||||
snakeEnd();
|
||||
spaceInvadersEnd();
|
||||
particlesEnd();
|
||||
}
|
||||
/*
|
||||
void sandboxEvent(SDL_Event* event)
|
||||
{
|
||||
}*/
|
||||
|
||||
bool sandboxLoop()
|
||||
{
|
||||
launcher.render_position = (vec2(launcher.window_size.x,launcher.window_size.y)*launcher.scalling - vec2(400,300)) * 0.5;
|
||||
|
||||
launcher.manager.begin();
|
||||
|
||||
float delta_time = launcher.delta_time;
|
||||
if(delta_time > 2000)delta_time = 2000;
|
||||
__gshared float time = 0;
|
||||
|
||||
/*if(launcher.getKeyState(SDL_SCANCODE_SPACE))time += delta_time * 3;
|
||||
else */
|
||||
time += delta_time;
|
||||
|
||||
while(time > 100)
|
||||
{
|
||||
time -= 100;
|
||||
|
||||
launcher.manager.update("fixed");
|
||||
}
|
||||
|
||||
if(launcher.multithreading)
|
||||
{
|
||||
launcher.job_updater.begin();
|
||||
launcher.manager.updateMT();
|
||||
launcher.job_updater.call();
|
||||
}
|
||||
else
|
||||
{
|
||||
launcher.manager.update();
|
||||
}
|
||||
launcher.manager.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DemoCallbacks getSanboxDemo()
|
||||
{
|
||||
DemoCallbacks demo;
|
||||
demo.initialize = &sandboxStart;
|
||||
demo.deinitialize = &sandboxEnd;
|
||||
demo.loop = &sandboxLoop;
|
||||
demo.tips = "tips";
|
||||
return demo;
|
||||
}
|
||||
|
|
@ -17,9 +17,12 @@ import ecs_utils.math.vector;
|
|||
import ecs_utils.utils;
|
||||
|
||||
import game_core.basic;
|
||||
import game_core.rendering;
|
||||
|
||||
extern(C):
|
||||
|
||||
enum float px = 1.0/512.0;
|
||||
|
||||
/*#######################################################################################################################
|
||||
------------------------------------------------ Components ------------------------------------------------------------------
|
||||
#######################################################################################################################*/
|
||||
|
|
@ -36,7 +39,7 @@ extern(C):
|
|||
/*#######################################################################################################################
|
||||
------------------------------------------------ Systems ------------------------------------------------------------------
|
||||
#######################################################################################################################*/
|
||||
|
||||
/*
|
||||
struct DrawSystem
|
||||
{
|
||||
mixin ECS.System!32;
|
||||
|
|
@ -66,13 +69,9 @@ struct DrawSystem
|
|||
draw_data.position = data.locations[i];
|
||||
draw_data.depth = cast(ushort)(data.locations[i].y);
|
||||
launcher.renderer.draw(draw_data);
|
||||
//launcher.renderer.draw(simple.texture, data.locations[i], vec2(16,16), vec4(0,0,1,1), cast(ushort)(data.locations[i].y), 0x80808080, 0, 0, 0, data.job_id);
|
||||
// launcher.renderer.draw(data.textures[i].tex, data.locations[i].location, vec2(16,16), vec4(0,0,1,1), 0, 0x80808080, 0, 0, 0, data.job_id);
|
||||
//draw(renderer, data.textures[i].tex, data.locations[i], vec2(32,32), vec4(0,0,1,1));
|
||||
}
|
||||
//if(data.thread_id == 0)launcher.renderer.pushData();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
struct MoveSystem
|
||||
{
|
||||
|
|
@ -113,22 +112,30 @@ void simpleStart()
|
|||
simple = Mallocator.make!Simple;
|
||||
|
||||
simple.texture.create();
|
||||
simple.texture.load("assets/textures/buckler.png");
|
||||
simple.texture.load("assets/textures/atlas.png");
|
||||
|
||||
launcher.manager.beginRegister();
|
||||
|
||||
registerRenderingModule(launcher.manager);
|
||||
|
||||
launcher.manager.registerComponent!CLocation;
|
||||
|
||||
launcher.manager.registerSystem!MoveSystem(0);
|
||||
launcher.manager.registerSystem!DrawSystem(1);
|
||||
// launcher.manager.registerSystem!DrawSystem(1);
|
||||
|
||||
launcher.manager.endRegister();
|
||||
|
||||
DrawSystem* draw_system = launcher.manager.getSystem!DrawSystem;
|
||||
draw_system.default_data.color = 0x80808080;
|
||||
draw_system.default_data.texture = simple.texture;
|
||||
draw_system.default_data.size = vec2(16,16);
|
||||
draw_system.default_data.coords = vec4(0,48,16,16)*px;//vec4(0,0,1,1);
|
||||
|
||||
launcher.gui_manager.addSystem(MoveSystem.system_id,"Move System");
|
||||
launcher.gui_manager.addSystem(MoveSystem.system_id,"Move Up System");
|
||||
launcher.gui_manager.addSystem(DrawSystem.system_id,"Draw System");
|
||||
|
||||
ushort[1] components = [CLocation.component_id];
|
||||
simple.tmpl = launcher.manager.allocateTemplate(components);
|
||||
simple.tmpl = launcher.manager.allocateTemplate([CLocation.component_id, CDrawDefault.component_id].staticArray);
|
||||
//*simple.tmpl.getComponent!CTexCoordsIndex = TexCoordsManager.instance.getCoordIndex(vec4(0,48,16,16)*px);
|
||||
//CLocation* loc_comp = simple.tmpl.getComponent!CLocation;
|
||||
|
||||
launcher.gui_manager.addTemplate(simple.tmpl, "Basic");
|
||||
|
|
@ -186,4 +193,14 @@ bool simpleLoop()
|
|||
launcher.manager.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DemoCallbacks getSimpleDemo()
|
||||
{
|
||||
DemoCallbacks demo;
|
||||
demo.initialize = &simpleStart;
|
||||
demo.deinitialize = &simpleEnd;
|
||||
demo.loop = &simpleLoop;
|
||||
demo.tips = simple.tips;
|
||||
return demo;
|
||||
}
|
||||
|
|
@ -851,6 +851,8 @@ __gshared Snake* snake;
|
|||
|
||||
void snakeStart()
|
||||
{
|
||||
import game_core.rendering;
|
||||
|
||||
snake = Mallocator.make!Snake;
|
||||
|
||||
snake.texture.create();
|
||||
|
|
@ -860,6 +862,8 @@ void snakeStart()
|
|||
|
||||
launcher.manager.registerPass("fixed");
|
||||
|
||||
registerRenderingModule(launcher.manager);
|
||||
|
||||
launcher.manager.registerComponent!CLocation;
|
||||
launcher.manager.registerComponent!CILocation;
|
||||
launcher.manager.registerComponent!CSnake;
|
||||
|
|
@ -983,4 +987,14 @@ bool snakeLoop()
|
|||
launcher.manager.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DemoCallbacks getSnakeDemo()
|
||||
{
|
||||
DemoCallbacks demo;
|
||||
demo.initialize = &snakeStart;
|
||||
demo.deinitialize = &snakeEnd;
|
||||
demo.loop = &snakeLoop;
|
||||
demo.tips = snake.tips;
|
||||
return demo;
|
||||
}
|
||||
|
|
@ -401,8 +401,8 @@ struct CParticleEmitter
|
|||
{
|
||||
mixin ECS.Component;
|
||||
|
||||
vec2 range;
|
||||
vec2 time_range;
|
||||
vec2 range = vec2(0,0);
|
||||
vec2 time_range = vec2(500,1000);
|
||||
///due to multithreading there should be separate template for every thread.
|
||||
///It can be array of tempaltes or (like in this demo) simply index of template;
|
||||
uint tmpl_id;
|
||||
|
|
@ -829,7 +829,7 @@ struct ShipWeaponSystem
|
|||
void create()
|
||||
{
|
||||
tower1_tmpl = launcher.manager.allocateTemplate(
|
||||
[CHitMark.component_id, CHitPoints.component_id, CLocation.component_id,
|
||||
[CColor.component_id, CHitMark.component_id, CHitPoints.component_id, CLocation.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,
|
||||
|
|
@ -959,7 +959,7 @@ struct MoveToParentTargetSystem
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
struct DrawSystem
|
||||
{
|
||||
mixin ECS.System!32;
|
||||
|
|
@ -1088,7 +1088,7 @@ struct DrawSystem
|
|||
}
|
||||
//if(data.thread_id == 0)launcher.renderer.pushData();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
struct CollisionSystem
|
||||
{
|
||||
|
|
@ -1325,7 +1325,7 @@ struct BulletsCollisionSystem
|
|||
uint length;
|
||||
const (Entity)[] entity;
|
||||
@readonly CLocation[] location;
|
||||
@readonly CBullet[] laser;
|
||||
@readonly CBullet[] bullet;
|
||||
@readonly CGuild[] guild;
|
||||
}
|
||||
|
||||
|
|
@ -1336,7 +1336,7 @@ struct BulletsCollisionSystem
|
|||
{
|
||||
if(space_invaders.shoot_grid.test(id, data.location[i], cast(ubyte)(~(1 << data.guild[i].guild))))
|
||||
{
|
||||
launcher.manager.sendEvent(id, EBulletHit(data.entity[i].id,1));
|
||||
launcher.manager.sendEvent(id, EBulletHit(data.entity[i].id,data.bullet[i].damage));
|
||||
//launcher.manager.removeEntity(data.entity[i].id);
|
||||
}
|
||||
}
|
||||
|
|
@ -1631,6 +1631,7 @@ struct HitMarkingSystem
|
|||
{
|
||||
uint length;
|
||||
CHitMark[] mark;
|
||||
CColor[] color;
|
||||
}
|
||||
|
||||
void onUpdate(EntitiesData data)
|
||||
|
|
@ -1640,6 +1641,7 @@ struct HitMarkingSystem
|
|||
//if(data.mark[i] < 10)data.mark[i] = 0;
|
||||
//else data.mark[i] -= 1;
|
||||
data.mark[i] = cast(ubyte)(data.mark[i] * 0.9);
|
||||
data.color[i] = 0x80808080 + 0x01010101 * data.mark[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2339,6 +2341,8 @@ void spaceInvadersStart()
|
|||
|
||||
launcher.manager.registerDependency(ShootGridDependency);
|
||||
|
||||
registerRenderingModule(launcher.manager);
|
||||
|
||||
launcher.manager.registerComponent!CLocation;
|
||||
launcher.manager.registerComponent!CTexCoords;
|
||||
//launcher.manager.registerComponent!CTexture;
|
||||
|
|
@ -2416,6 +2420,10 @@ void spaceInvadersStart()
|
|||
|
||||
launcher.manager.endRegister();
|
||||
|
||||
DrawSystem* draw_system = launcher.manager.getSystem!DrawSystem;
|
||||
draw_system.default_data.color = 0x80808080;
|
||||
draw_system.default_data.texture = space_invaders.texture;
|
||||
|
||||
launcher.gui_manager.addComponent(CInput(),"Input");
|
||||
launcher.gui_manager.addComponent(CShip(),"Ship");
|
||||
launcher.gui_manager.addComponent(CEnemy(),"Enemy");
|
||||
|
|
@ -2482,7 +2490,7 @@ void spaceInvadersStart()
|
|||
//launcher.manager.getSystem(CleanSystem.system_id).disable();
|
||||
{
|
||||
space_invaders.ship_tmpl = launcher.manager.allocateTemplate(
|
||||
[CVelocity.component_id, CHitMark.component_id, CHitPoints.component_id,
|
||||
[CVelocity.component_id, CColor.component_id, CHitMark.component_id, CHitPoints.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,
|
||||
|
|
@ -2517,7 +2525,7 @@ void spaceInvadersStart()
|
|||
|
||||
{
|
||||
boss_tmpl = launcher.manager.allocateTemplate(
|
||||
[CHitMark.component_id, CParts.component_id, CLocation.component_id,
|
||||
[CColor.component_id, CHitMark.component_id, CParts.component_id, CLocation.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,
|
||||
|
|
@ -2540,7 +2548,7 @@ void spaceInvadersStart()
|
|||
|
||||
{
|
||||
tower_tmpl = launcher.manager.allocateTemplate(
|
||||
[CHitMark.component_id, CHitPoints.component_id, CLocation.component_id,
|
||||
[CColor.component_id, CHitMark.component_id, CHitPoints.component_id, CLocation.component_id,
|
||||
CTexCoords.component_id, CScale.component_id, CEnemy.component_id,
|
||||
CShootGrid.component_id, CGuild.component_id, CInit.component_id,
|
||||
CChildren.component_id].staticArray
|
||||
|
|
@ -2554,7 +2562,7 @@ void spaceInvadersStart()
|
|||
|
||||
{
|
||||
space_invaders.enemy_tmpl = launcher.manager.allocateTemplate(
|
||||
[CWeaponLocation.component_id, CHitMark.component_id, CHitPoints.component_id,
|
||||
[CWeaponLocation.component_id, CColor.component_id, CHitMark.component_id, CHitPoints.component_id,
|
||||
CVelocity.component_id, CAutoShoot.component_id, CLocation.component_id,
|
||||
CTexCoords.component_id, CScale.component_id, CWeapon.component_id,
|
||||
CEnemy.component_id, CShootDirection.component_id, CShootGrid.component_id,
|
||||
|
|
@ -2733,4 +2741,14 @@ bool spaceInvadersLoop()
|
|||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DemoCallbacks getSpaceInvadersDemo()
|
||||
{
|
||||
DemoCallbacks demo;
|
||||
demo.initialize = &spaceInvadersStart;
|
||||
demo.deinitialize = &spaceInvadersEnd;
|
||||
demo.loop = &spaceInvadersLoop;
|
||||
demo.tips = space_invaders.tips;
|
||||
return demo;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue