Dust particles from tank wheels.
This commit is contained in:
+1
-1
Submodule assets updated: cfda101f67...d013629690
@@ -21,7 +21,7 @@ struct ParticleEmitter : Component
|
|||||||
, LifeTime(0)
|
, LifeTime(0)
|
||||||
, TimeSinceLastSpawn(100)
|
, TimeSinceLastSpawn(100)
|
||||||
, Emitting(false)
|
, Emitting(false)
|
||||||
, Color(glm::vec4(0)) { }
|
, Color(glm::vec4(1)) { }
|
||||||
|
|
||||||
EntityID ParticleTemplate;
|
EntityID ParticleTemplate;
|
||||||
float SpawnFrequency;
|
float SpawnFrequency;
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ void GameWorld::Initialize()
|
|||||||
//Background Music
|
//Background Music
|
||||||
{
|
{
|
||||||
Events::PlayBGM e;
|
Events::PlayBGM e;
|
||||||
e.Resource = "Sounds/BGM/RideoftheValkyries.mp3";
|
e.Resource = "Sounds/SFX/WUB.mp3";
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ void Systems::SoundSystem::Update(double dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
LOG_INFO("Antal emitters i listan: %i", m_Channels.size());
|
//LOG_INFO("Antal emitters i listan: %i", m_Channels.size());
|
||||||
|
|
||||||
for(it = m_Channels.begin(); it != m_Channels.end();)
|
for(it = m_Channels.begin(); it != m_Channels.end();)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,32 @@ void Systems::TankSteeringSystem::Update(double dt)
|
|||||||
|
|
||||||
void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
|
auto pEmitter = m_World->GetComponent<Components::ParticleEmitter>(entity);
|
||||||
|
if(pEmitter)
|
||||||
|
{
|
||||||
|
if(!m_World->GetComponent<Components::TankSteering>(parent))
|
||||||
|
return;
|
||||||
|
auto tankTransform = m_World->GetComponent<Components::Transform>(parent);
|
||||||
|
glm::vec2 velXZ = glm::vec2(tankTransform->Velocity.x, tankTransform->Velocity.z);
|
||||||
|
float speedMPDT = glm::length(velXZ);
|
||||||
|
if(speedMPDT < 1)
|
||||||
|
{
|
||||||
|
pEmitter->Emitting = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pEmitter->Emitting = true;
|
||||||
|
pEmitter->ScaleSpectrum.erase(pEmitter->ScaleSpectrum.begin());
|
||||||
|
float scale = speedMPDT / 20;
|
||||||
|
scale = glm::clamp(scale, 0.3f, 20.f);
|
||||||
|
pEmitter->ScaleSpectrum.push_back(glm::vec3(speedMPDT / 20));
|
||||||
|
float spawnFrequency = 1 / speedMPDT;
|
||||||
|
spawnFrequency = glm::clamp(spawnFrequency, 0.1f, 2.f);
|
||||||
|
pEmitter->SpawnFrequency = 1 / speedMPDT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto tankSteeringComponent = m_World->GetComponent<Components::TankSteering>(entity);
|
auto tankSteeringComponent = m_World->GetComponent<Components::TankSteering>(entity);
|
||||||
if(!tankSteeringComponent)
|
if(!tankSteeringComponent)
|
||||||
return;
|
return;
|
||||||
@@ -147,15 +173,6 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
|
|
||||||
m_TimeSinceLastShot[tankSteeringComponent->Barrel] += dt;
|
m_TimeSinceLastShot[tankSteeringComponent->Barrel] += dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto shot = m_World->GetComponent<Components::TankShell>(entity);
|
|
||||||
// if(shot)
|
|
||||||
// {
|
|
||||||
// if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5)
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
||||||
@@ -194,66 +211,66 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
|||||||
//auto otherTransform = m_World->GetComponent<Components::Transform>(otherEntity);
|
//auto otherTransform = m_World->GetComponent<Components::Transform>(otherEntity);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Events::CreateExplosion e;
|
||||||
|
e.LifeTime = 3;
|
||||||
|
e.ParticleScale.push_back(8);
|
||||||
|
e.ParticlesToSpawn = 20;
|
||||||
|
e.Position = shellTransform->Position;
|
||||||
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||||
|
e.Speed = 3;
|
||||||
|
e.SpreadAngle = glm::pi<float>();
|
||||||
|
e.spritePath = "Textures/Sprites/Smoke1.png";
|
||||||
|
e.Color = glm::vec4(0.6,0.6,0.6,1);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
e.LifeTime = 0.7;
|
||||||
|
e.ParticleScale.push_back(12);
|
||||||
|
e.ParticlesToSpawn = 10;
|
||||||
|
e.Position = shellTransform->Position;
|
||||||
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||||
|
e.Speed = 17;
|
||||||
|
e.SpreadAngle = glm::pi<float>();
|
||||||
|
e.spritePath = "Textures/Sprites/Fire.png";
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
e.LifeTime = 0.2;
|
||||||
|
e.ParticleScale.push_back(1);
|
||||||
|
e.ParticleScale.push_back(15);
|
||||||
|
e.ParticlesToSpawn = 5;
|
||||||
|
e.Position = shellTransform->Position;
|
||||||
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||||
|
e.Speed = 6;
|
||||||
|
e.SpreadAngle = glm::pi<float>();
|
||||||
|
e.spritePath = "Textures/Sprites/Blast1.png";
|
||||||
|
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
|
||||||
// Events::CreateExplosion e;
|
// Events::CreateExplosion e;
|
||||||
// e.LifeTime = 3;
|
// e.LifeTime = 1.5;
|
||||||
// e.ParticleScale.push_back(8);
|
// e.ParticleScale.push_back(1);
|
||||||
|
// e.ParticleScale.push_back(6);
|
||||||
// e.ParticlesToSpawn = 20;
|
// e.ParticlesToSpawn = 20;
|
||||||
// e.Position = shellTransform->Position;
|
// e.Position = shellTransform->Position;
|
||||||
// e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
// e.SpreadAngle = glm::radians<float>(180) / 4;
|
||||||
// e.Speed = 3;
|
// e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
||||||
// e.SpreadAngle = glm::pi<float>();
|
// e.UseGoalVector = true;
|
||||||
// e.spritePath = "Textures/Sprites/Smoke1.png";
|
// e.GoalVelocity = glm::vec3(0,-12,0);
|
||||||
// e.Color = glm::vec4(0.6,0.6,0.6,1);
|
// e.Speed = 12;
|
||||||
|
// e.spritePath = "Textures/Sprites/Splash.png";
|
||||||
|
// e.Color = glm::vec4(5.f,5.f,5.f,1);
|
||||||
|
//
|
||||||
// EventBroker->Publish(e);
|
// EventBroker->Publish(e);
|
||||||
// e.LifeTime = 0.7;
|
// e.LifeTime = 1.5;
|
||||||
// e.ParticleScale.push_back(12);
|
|
||||||
// e.ParticlesToSpawn = 10;
|
|
||||||
// e.Position = shellTransform->Position;
|
|
||||||
// e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
|
||||||
// e.Speed = 17;
|
|
||||||
// e.SpreadAngle = glm::pi<float>();
|
|
||||||
// e.spritePath = "Textures/Sprites/Fire.png";
|
|
||||||
// EventBroker->Publish(e);
|
|
||||||
// e.LifeTime = 0.2;
|
|
||||||
// e.ParticleScale.push_back(1);
|
// e.ParticleScale.push_back(1);
|
||||||
// e.ParticleScale.push_back(15);
|
// e.ParticleScale.push_back(6);
|
||||||
// e.ParticlesToSpawn = 5;
|
// e.ParticlesToSpawn = 20;
|
||||||
// e.Position = shellTransform->Position;
|
// e.Position = shellTransform->Position;
|
||||||
// e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
// e.SpreadAngle = glm::radians<float>(180)/ 4;
|
||||||
// e.Speed = 6;
|
// e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
||||||
// e.SpreadAngle = glm::pi<float>();
|
// e.UseGoalVector = true;
|
||||||
// e.spritePath = "Textures/Sprites/Blast1.png";
|
// e.GoalVelocity = glm::vec3(0,-12,0);
|
||||||
// e.Color = glm::vec4(2, 2, 2, 0.2);
|
// e.Speed = 12;
|
||||||
|
// e.spritePath = "Textures/Sprites/Splash.png";
|
||||||
|
// e.Color = glm::vec4(1.f,1.f,1.f,1);
|
||||||
// EventBroker->Publish(e);
|
// EventBroker->Publish(e);
|
||||||
|
|
||||||
Events::CreateExplosion e;
|
|
||||||
e.LifeTime = 1.5;
|
|
||||||
e.ParticleScale.push_back(1);
|
|
||||||
e.ParticleScale.push_back(6);
|
|
||||||
e.ParticlesToSpawn = 20;
|
|
||||||
e.Position = shellTransform->Position;
|
|
||||||
e.SpreadAngle = glm::radians<float>(180) / 4;
|
|
||||||
e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
|
||||||
e.UseGoalVector = true;
|
|
||||||
e.GoalVelocity = glm::vec3(0,-12,0);
|
|
||||||
e.Speed = 12;
|
|
||||||
e.spritePath = "Textures/Sprites/Splash.png";
|
|
||||||
e.Color = glm::vec4(5.f,5.f,5.f,1);
|
|
||||||
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
e.LifeTime = 1.5;
|
|
||||||
e.ParticleScale.push_back(1);
|
|
||||||
e.ParticleScale.push_back(6);
|
|
||||||
e.ParticlesToSpawn = 20;
|
|
||||||
e.Position = shellTransform->Position;
|
|
||||||
e.SpreadAngle = glm::radians<float>(180)/ 4;
|
|
||||||
e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
|
||||||
e.UseGoalVector = true;
|
|
||||||
e.GoalVelocity = glm::vec3(0,-12,0);
|
|
||||||
e.Speed = 12;
|
|
||||||
e.spritePath = "Textures/Sprites/Splash.png";
|
|
||||||
e.Color = glm::vec4(1.f,1.f,1.f,1);
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Events::PlaySFX e;
|
Events::PlaySFX e;
|
||||||
@@ -431,7 +448,8 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
|||||||
auto health = m_World->AddComponent<Components::Health>(tank);
|
auto health = m_World->AddComponent<Components::Health>(tank);
|
||||||
health->Amount = 100.f;
|
health->Amount = 100.f;
|
||||||
m_World->AddComponent<Components::Listener>(tank);
|
m_World->AddComponent<Components::Listener>(tank);
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto shape = m_World->CreateEntity(tank);
|
auto shape = m_World->CreateEntity(tank);
|
||||||
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
||||||
@@ -565,31 +583,43 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
|||||||
AddTankWheelPair(tank, glm::vec3(-1.68f, wheelOffset, 2.375), 1, false);
|
AddTankWheelPair(tank, glm::vec3(-1.68f, wheelOffset, 2.375), 1, false);
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region DustParticles
|
||||||
|
|
||||||
|
std::vector<glm::vec3> ePos;
|
||||||
|
ePos.push_back(glm::vec3(-2, -1.7, 2.0));
|
||||||
|
ePos.push_back(glm::vec3(2, -1.7, 2.0));
|
||||||
|
ePos.push_back(glm::vec3(2, -1.7, -2.0));
|
||||||
|
ePos.push_back(glm::vec3(-2, -1.7, -2.0));
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
auto entity = m_World->CreateEntity(tank);
|
auto entity = m_World->CreateEntity(tank);
|
||||||
auto transformComponent = m_World->AddComponent<Components::Transform>(entity);
|
auto transformComponent = m_World->AddComponent<Components::Transform>(entity);
|
||||||
transformComponent->Position = glm::vec3(-2, -1.7, 2.0);
|
transformComponent->Position = ePos[i];
|
||||||
transformComponent->Scale = glm::vec3(3, 3, 3);
|
transformComponent->Scale = glm::vec3(3, 3, 3);
|
||||||
transformComponent->Orientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1, 0, 0));
|
transformComponent->Orientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1, 0, 0));
|
||||||
auto emitterComponent = m_World->AddComponent<Components::ParticleEmitter>(entity);
|
auto emitterComponent = m_World->AddComponent<Components::ParticleEmitter>(entity);
|
||||||
emitterComponent->SpawnCount = 2;
|
emitterComponent->SpawnCount = 1;
|
||||||
emitterComponent->SpawnFrequency = 0.005;
|
emitterComponent->SpawnFrequency = 0.1;
|
||||||
emitterComponent->SpreadAngle = glm::pi<float>();
|
emitterComponent->SpreadAngle = glm::pi<float>();
|
||||||
emitterComponent->UseGoalVelocity = false;
|
emitterComponent->UseGoalVelocity = false;
|
||||||
emitterComponent->LifeTime = 0.5;
|
emitterComponent->LifeTime = 0.3;
|
||||||
//emitterComponent->AngularVelocitySpectrum.push_back(glm::pi<float>() / 100);
|
emitterComponent->Speed = 3;
|
||||||
emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
|
emitterComponent->Emitting = true;
|
||||||
m_World->CommitEntity(entity);
|
emitterComponent->Fade = true;
|
||||||
|
emitterComponent->ScaleSpectrum.push_back(glm::vec3(1));
|
||||||
|
//emitterComponent->Color = glm::vec4(1);
|
||||||
auto particleEntity = m_World->CreateEntity(entity);
|
auto particleEntity = m_World->CreateEntity(entity);
|
||||||
auto TEMP = m_World->AddComponent<Components::Transform>(particleEntity);
|
m_World->AddComponent<Components::Template>(particleEntity);
|
||||||
TEMP->Scale = glm::vec3(0);
|
m_World->AddComponent<Components::Transform>(particleEntity);
|
||||||
auto spriteComponent = m_World->AddComponent<Components::Sprite>(particleEntity);
|
auto spriteComponent = m_World->AddComponent<Components::Sprite>(particleEntity);
|
||||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
spriteComponent->SpriteFile = "Textures/Sprites/Dirt.png";
|
||||||
emitterComponent->ParticleTemplate = particleEntity;
|
|
||||||
|
|
||||||
m_World->CommitEntity(particleEntity);
|
m_World->CommitEntity(particleEntity);
|
||||||
|
emitterComponent->ParticleTemplate = particleEntity;
|
||||||
|
m_World->CommitEntity(entity);
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
m_World->CommitEntity(tank);
|
m_World->CommitEntity(tank);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "Events/TankSteer.h"
|
#include "Events/TankSteer.h"
|
||||||
#include "Events/SetVelocity.h"
|
#include "Events/SetVelocity.h"
|
||||||
@@ -23,6 +22,7 @@
|
|||||||
#include "Components/TankShell.h"
|
#include "Components/TankShell.h"
|
||||||
#include "Components/SphereShape.h"
|
#include "Components/SphereShape.h"
|
||||||
#include "Components/Listener.h"
|
#include "Components/Listener.h"
|
||||||
|
#include "Components/SoundEmitter.h"
|
||||||
|
|
||||||
#include "Events/EnableCollisions.h"
|
#include "Events/EnableCollisions.h"
|
||||||
#include "Events/DisableCollisions.h"
|
#include "Events/DisableCollisions.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user