SpaceShip demo update
-added wave shooted upon death of boss tower -cleanup code a little bit -moved to new entityAdding method -fixed bug with changeing demos
This commit is contained in:
parent
7a0ddf7494
commit
9af1cee60b
8 changed files with 368 additions and 297 deletions
|
|
@ -129,9 +129,10 @@ struct Snake
|
|||
}
|
||||
if(base_pos.x == random_pos.x && base_pos.y == random_pos.y)return;
|
||||
}
|
||||
CILocation* location = apple_tmpl.getComponent!CILocation;
|
||||
*location = random_pos;
|
||||
Entity* apple = launcher.manager.addEntity(apple_tmpl);
|
||||
//CILocation* location = apple_tmpl.getComponent!CILocation;
|
||||
//*location = random_pos;
|
||||
//Entity* apple =
|
||||
launcher.manager.addEntity(apple_tmpl,[CILocation(random_pos).ref_].staticArray);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -366,8 +367,8 @@ struct MoveSystem
|
|||
mixin ECS.System!64;
|
||||
|
||||
EntityTemplate* destroy_template;
|
||||
CLocation* destroy_location;
|
||||
CParticleVector* destroy_vector;
|
||||
//CLocation* destroy_location;
|
||||
//CParticleVector* destroy_vector;
|
||||
|
||||
struct EntitiesData
|
||||
{
|
||||
|
|
@ -381,8 +382,8 @@ struct MoveSystem
|
|||
void setTemplates()
|
||||
{
|
||||
destroy_template = snake.snake_destroy_particle;
|
||||
destroy_location = destroy_template.getComponent!CLocation;
|
||||
destroy_vector = destroy_template.getComponent!CParticleVector;
|
||||
//destroy_location = destroy_template.getComponent!CLocation;
|
||||
//destroy_vector = destroy_template.getComponent!CParticleVector;
|
||||
}
|
||||
|
||||
void moveLocation(ref CILocation location, CMovement.Direction direction)
|
||||
|
|
@ -436,24 +437,26 @@ struct MoveSystem
|
|||
case MapElement.Type.snake:
|
||||
foreach(loc; data.snakes[i].parts)
|
||||
{
|
||||
destroy_location.x = loc.x * 16;
|
||||
destroy_location.y = loc.y * 16;
|
||||
//destroy_location.x = loc.x * 16;
|
||||
//destroy_location.y = loc.y * 16;
|
||||
snake.element(MapElement(MapElement.Type.empty, EntityID()),loc);
|
||||
launcher.manager.addEntity(snake.snake_destroy_particle);
|
||||
launcher.manager.addEntity(snake.snake_destroy_particle,[CLocation(cast(vec2)(loc * 16)).ref_].staticArray);
|
||||
|
||||
CLocation destroy_location;
|
||||
foreach(j;0..10)
|
||||
{
|
||||
destroy_location.x = loc.x * 16 + randomf() * 8 - 4;
|
||||
destroy_location.y = loc.y * 16 + randomf() * 8 - 4;
|
||||
destroy_vector.velocity = vec2(randomf(),randomf())*0.4-0.2;
|
||||
//destroy_vector.velocity = vec2(randomf(),randomf())*0.4-0.2;
|
||||
snake.element(MapElement(MapElement.Type.empty, EntityID()),loc);
|
||||
launcher.manager.addEntity(snake.snake_destroy_particle);
|
||||
launcher.manager.addEntity(snake.snake_destroy_particle, [destroy_location.ref_, CParticleVector(vec2(randomf(),randomf())*0.4-0.2).ref_].staticArray);
|
||||
}
|
||||
|
||||
}
|
||||
destroy_location.x = new_location.x * 16;
|
||||
destroy_location.y = new_location.y * 16;
|
||||
//destroy_location.x = new_location.x * 16;
|
||||
//destroy_location.y = new_location.y * 16;
|
||||
snake.element(MapElement(MapElement.Type.empty, EntityID()),new_location);
|
||||
launcher.manager.addEntity(snake.snake_destroy_particle);
|
||||
launcher.manager.addEntity(snake.snake_destroy_particle,[CLocation(cast(vec2)(new_location * 16)).ref_].staticArray);
|
||||
launcher.manager.removeEntity(data.entities[i].id);
|
||||
break;
|
||||
|
||||
|
|
@ -796,9 +799,9 @@ void snakeStart()
|
|||
{
|
||||
ushort[4] components = [CILocation.component_id, CSnake.component_id, CMovement.component_id, CInput.component_id];
|
||||
snake.snake_tmpl = launcher.manager.allocateTemplate(components);
|
||||
CILocation* loc_comp = snake.snake_tmpl.getComponent!CILocation;
|
||||
*loc_comp = ivec2(2,2);
|
||||
launcher.manager.addEntity(snake.snake_tmpl);
|
||||
//CILocation* loc_comp = snake.snake_tmpl.getComponent!CILocation;
|
||||
//*loc_comp = ivec2(2,2);
|
||||
launcher.manager.addEntity(snake.snake_tmpl,[CILocation(ivec2(2,2)).ref_].staticArray);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -846,15 +849,15 @@ void snakeTool(vec2 position, Tool tool, int size)
|
|||
CLocation* location = tmpl.getComponent!CLocation;
|
||||
if(location)
|
||||
{
|
||||
position.x += (randomf - 0.5) * size;
|
||||
position.y += (randomf - 0.5) * size;
|
||||
position.x += (randomf() - 0.5) * size;
|
||||
position.y += (randomf() - 0.5) * size;
|
||||
*location = position;
|
||||
}
|
||||
CILocation* ilocation = tmpl.getComponent!CILocation;
|
||||
if(ilocation)
|
||||
{
|
||||
position.x += (randomf - 0.5) * size;
|
||||
position.y += (randomf - 0.5) * size;
|
||||
position.x += (randomf() - 0.5) * size;
|
||||
position.y += (randomf() - 0.5) * size;
|
||||
ivec2 ipos;
|
||||
ipos.x = cast(int)(position.x / 16);
|
||||
ipos.y = cast(int)(position.y / 16);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue