Fixed scale issue for power up textures. Added a defaultscale flag. Also removed ugly particleeffect for projectiles.
This commit is contained in:
@@ -30,7 +30,6 @@
|
|||||||
#include "Game/CProjectile.h"
|
#include "Game/CProjectile.h"
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
#include "Rendering/CSprite.h"
|
#include "Rendering/CSprite.h"
|
||||||
#include "Physics/ECreateParticleSequence.h"
|
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ struct ParticleEmitter : public Component
|
|||||||
float Speed = 2.f;
|
float Speed = 2.f;
|
||||||
double LifeTime = 100;
|
double LifeTime = 100;
|
||||||
float RadiusDistribution = 0;
|
float RadiusDistribution = 0;
|
||||||
|
bool DefaultScale = false;
|
||||||
//values to interpolate between.
|
//values to interpolate between.
|
||||||
std::vector<glm::vec3> ScaleValues;
|
std::vector<glm::vec3> ScaleValues;
|
||||||
std::vector<float> AlphaValues;
|
std::vector<float> AlphaValues;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ struct CreateParticleSequence : public Event
|
|||||||
glm::vec4 Color = glm::vec4(0);
|
glm::vec4 Color = glm::vec4(0);
|
||||||
EntityID parent = 0;
|
EntityID parent = 0;
|
||||||
// values to interpolate between.
|
// values to interpolate between.
|
||||||
|
bool DefaultScale = false;
|
||||||
std::vector<glm::vec3> ScaleValues;
|
std::vector<glm::vec3> ScaleValues;
|
||||||
std::vector<float> AlphaValues;
|
std::vector<float> AlphaValues;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "Core/CTemplate.h"
|
#include "Core/CTemplate.h"
|
||||||
#include "Core/CTransform.h"
|
#include "Core/CTransform.h"
|
||||||
#include "Core/CTemplate.h"
|
#include "Core/CTemplate.h"
|
||||||
|
#include "Rendering/Texture.h"
|
||||||
|
|
||||||
#include "Physics/EContact.h"
|
#include "Physics/EContact.h"
|
||||||
#include "Physics/ESetImpulse.h"
|
#include "Physics/ESetImpulse.h"
|
||||||
|
|||||||
@@ -1007,7 +1007,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
|||||||
glm::vec4 p2 = glm::vec4(255.f / 255.f, 81.f / 255.f, 253.f / 255.f, 1.f);
|
glm::vec4 p2 = glm::vec4(255.f / 255.f, 81.f / 255.f, 253.f / 255.f, 1.f);
|
||||||
glm::vec4 p3 = glm::vec4(189.f / 255.f, 0.f / 255.f, 187.f / 255.f, 1.f);
|
glm::vec4 p3 = glm::vec4(189.f / 255.f, 0.f / 255.f, 187.f / 255.f, 1.f);
|
||||||
glm::vec4 p4 = glm::vec4(125.f / 255.f, 0.f / 255.f, 147.f / 255.f, 1.f);
|
glm::vec4 p4 = glm::vec4(125.f / 255.f, 0.f / 255.f, 147.f / 255.f, 1.f);
|
||||||
m_CurrentLevel = 4;
|
|
||||||
if (m_CurrentCluster == 0) {
|
if (m_CurrentCluster == 0) {
|
||||||
if (m_CurrentLevel == 1) {
|
if (m_CurrentLevel == 1) {
|
||||||
level =
|
level =
|
||||||
|
|||||||
@@ -139,27 +139,7 @@ bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButto
|
|||||||
transform->Position = event.Position;
|
transform->Position = event.Position;
|
||||||
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
||||||
m_Shots--;
|
m_Shots--;
|
||||||
Events::CreateParticleSequence e;
|
|
||||||
e.parent = ent;
|
|
||||||
e.EmitterLifeTime = 1.0;
|
|
||||||
e.EmittingAngle = glm::half_pi<float>();
|
|
||||||
e.Spread = 0.f;
|
|
||||||
e.SpawnRate = 0.2;
|
|
||||||
//e.NumberOfTicks = 1;
|
|
||||||
e.ParticleLifeTime = 0.5f;
|
|
||||||
e.ParticlesPerTick = 1;
|
|
||||||
e.Position = event.Position;
|
|
||||||
e.ScaleValues.clear();
|
|
||||||
e.ScaleValues.push_back(glm::vec3(0.1f));
|
|
||||||
e.RadiusDistribution = 0.3;
|
|
||||||
e.ScaleValues.push_back(glm::vec3(0.f, 0.f, 0.2f));
|
|
||||||
e.SpriteFile = "Textures/Particles/FadeBall.png";
|
|
||||||
e.Color = glm::vec4(0, 0, 0, 1);
|
|
||||||
e.AlphaValues.clear();
|
|
||||||
e.AlphaValues.push_back(1.f);
|
|
||||||
e.AlphaValues.push_back(0.f);
|
|
||||||
e.Speed = 20.f;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
if (m_Shots <= 0) {
|
if (m_Shots <= 0) {
|
||||||
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
||||||
m_InkBlaster = false;
|
m_InkBlaster = false;
|
||||||
|
|||||||
@@ -235,7 +235,12 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
|||||||
auto particle = m_World->GetComponent<Components::Particle>(entity);
|
auto particle = m_World->GetComponent<Components::Particle>(entity);
|
||||||
|
|
||||||
transform->Position = glm::vec3(position.x, position.y, transform->Position.z);
|
transform->Position = glm::vec3(position.x, position.y, transform->Position.z);
|
||||||
transform->Scale = particle->Scale;//glm::vec3(particle->Radius * 2.f, particle->Radius * 2.f, 1);
|
EntityID emitter = m_ParticleEmitters.ParticleEmitter[e];
|
||||||
|
auto cEmitter = m_World->GetComponent<Components::ParticleEmitter>(emitter);
|
||||||
|
if (!cEmitter->DefaultScale)
|
||||||
|
{
|
||||||
|
transform->Scale = particle->Scale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +276,7 @@ void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, Entity
|
|||||||
m_World->RemoveEntity(entity);
|
m_World->RemoveEntity(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Update alpha
|
//Update alpha & scale
|
||||||
auto sprite = m_World->GetComponent<Components::Sprite>(entity);
|
auto sprite = m_World->GetComponent<Components::Sprite>(entity);
|
||||||
float timeProgress = particle->TimeLived / (particle->LifeTime - 0.1);
|
float timeProgress = particle->TimeLived / (particle->LifeTime - 0.1);
|
||||||
if (timeProgress > 1) {
|
if (timeProgress > 1) {
|
||||||
@@ -280,7 +285,9 @@ void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, Entity
|
|||||||
auto emitter = m_World->GetComponent<Components::ParticleEmitter>(particle->ParticleSystem);
|
auto emitter = m_World->GetComponent<Components::ParticleEmitter>(particle->ParticleSystem);
|
||||||
if (emitter) {
|
if (emitter) {
|
||||||
sprite->Color.w = ScalarInterpolation(timeProgress, emitter->AlphaValues);
|
sprite->Color.w = ScalarInterpolation(timeProgress, emitter->AlphaValues);
|
||||||
particle->Scale = VectorInterpolation(timeProgress, emitter->ScaleValues);
|
if (!emitter->DefaultScale) {
|
||||||
|
particle->Scale = VectorInterpolation(timeProgress, emitter->ScaleValues);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -719,8 +726,9 @@ bool dd::Systems::PhysicsSystem::CreateParticleSequence(const Events::CreatePart
|
|||||||
particleEmitter->EmittingAngle = event.EmittingAngle;
|
particleEmitter->EmittingAngle = event.EmittingAngle;
|
||||||
particleEmitter->LifeTime = event.EmitterLifeTime;
|
particleEmitter->LifeTime = event.EmitterLifeTime;
|
||||||
particleEmitter->AlphaValues = event.AlphaValues;
|
particleEmitter->AlphaValues = event.AlphaValues;
|
||||||
particleEmitter->ScaleValues = event.ScaleValues;
|
|
||||||
particleEmitter->RadiusDistribution = event.RadiusDistribution;
|
particleEmitter->RadiusDistribution = event.RadiusDistribution;
|
||||||
|
particleEmitter->DefaultScale = event.DefaultScale;
|
||||||
|
particleEmitter->ScaleValues = event.ScaleValues;
|
||||||
{
|
{
|
||||||
//Creating Particle Template
|
//Creating Particle Template
|
||||||
auto particle = m_World->CreateEntity(emitter);
|
auto particle = m_World->CreateEntity(emitter);
|
||||||
@@ -730,10 +738,17 @@ bool dd::Systems::PhysicsSystem::CreateParticleSequence(const Events::CreatePart
|
|||||||
m_World->AddComponent<Components::Template>(particle);
|
m_World->AddComponent<Components::Template>(particle);
|
||||||
particleTransform->Position = emitterTransform->Position;
|
particleTransform->Position = emitterTransform->Position;
|
||||||
sprite->SpriteFile = event.SpriteFile;
|
sprite->SpriteFile = event.SpriteFile;
|
||||||
|
if (particleEmitter->DefaultScale == true)
|
||||||
|
{
|
||||||
|
Texture* texture = ResourceManager::Load<Texture>(event.SpriteFile);
|
||||||
|
particleEmitter->ScaleValues.clear();
|
||||||
|
particleEmitter->ScaleValues.push_back(glm::vec3(texture->Width / 100, texture->Height / 100, 1));
|
||||||
|
|
||||||
|
}
|
||||||
sprite->Color = event.Color;
|
sprite->Color = event.Color;
|
||||||
particleComponent->LifeTime = event.ParticleLifeTime;
|
particleComponent->LifeTime = event.ParticleLifeTime;
|
||||||
particleComponent->Flags = event.Flags;
|
particleComponent->Flags = event.Flags;
|
||||||
particleComponent->Scale = event.ScaleValues[0];
|
particleComponent->Scale = particleEmitter->ScaleValues[0];
|
||||||
particleComponent->ParticleSystem = emitter;
|
particleComponent->ParticleSystem = emitter;
|
||||||
}
|
}
|
||||||
m_World->CommitEntity(emitter);
|
m_World->CommitEntity(emitter);
|
||||||
@@ -834,8 +849,9 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
e.Color = glm::vec4(1.f);
|
e.Color = glm::vec4(1.f);
|
||||||
e.AlphaValues.push_back(1.f);
|
e.AlphaValues.push_back(1.f);
|
||||||
e.AlphaValues.push_back(0.f);
|
e.AlphaValues.push_back(0.f);
|
||||||
e.ScaleValues.push_back(glm::vec3(1.f));
|
e.ScaleValues.push_back(glm::vec3(4));
|
||||||
e.Speed = 0;
|
e.Speed = 0;
|
||||||
|
e.DefaultScale = true;
|
||||||
|
|
||||||
auto PowerFriend = m_World->GetComponent<Components::MultiBallBrick>(entity);
|
auto PowerFriend = m_World->GetComponent<Components::MultiBallBrick>(entity);
|
||||||
auto PowerSaviour = m_World->GetComponent<Components::LifebuoyBrick>(entity);
|
auto PowerSaviour = m_World->GetComponent<Components::LifebuoyBrick>(entity);
|
||||||
@@ -860,6 +876,7 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
e.SpriteFile = "Textures/PowerUps/RealeaseTheKraken.png";
|
e.SpriteFile = "Textures/PowerUps/RealeaseTheKraken.png";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
e.DefaultScale = false;
|
||||||
e.EmitterLifeTime = 4;
|
e.EmitterLifeTime = 4;
|
||||||
e.EmittingAngle = glm::half_pi<float>();
|
e.EmittingAngle = glm::half_pi<float>();
|
||||||
e.Spread = 0.5f;
|
e.Spread = 0.5f;
|
||||||
|
|||||||
Reference in New Issue
Block a user