From 52e2ce567ac1eee1761a240851307635af86ecab Mon Sep 17 00:00:00 2001 From: tleety Date: Mon, 12 Oct 2015 16:48:04 +0200 Subject: [PATCH 1/2] Power up sprites now show when you hit powerup bricks --- .../PowerUps/{Friend.png => Friends.png} | Bin .../{Ink Blaster.png => InkBlaster.png} | Bin include/Game/CBrick.h | 1 + include/Physics/PhysicsSystem.h | 1 + src/game/Game/LevelSystem.cpp | 2 +- src/game/Physics/PhysicsSystem.cpp | 48 ++++++++++++++---- 6 files changed, 42 insertions(+), 10 deletions(-) rename assets/Textures/PowerUps/{Friend.png => Friends.png} (100%) rename assets/Textures/PowerUps/{Ink Blaster.png => InkBlaster.png} (100%) diff --git a/assets/Textures/PowerUps/Friend.png b/assets/Textures/PowerUps/Friends.png similarity index 100% rename from assets/Textures/PowerUps/Friend.png rename to assets/Textures/PowerUps/Friends.png diff --git a/assets/Textures/PowerUps/Ink Blaster.png b/assets/Textures/PowerUps/InkBlaster.png similarity index 100% rename from assets/Textures/PowerUps/Ink Blaster.png rename to assets/Textures/PowerUps/InkBlaster.png diff --git a/include/Game/CBrick.h b/include/Game/CBrick.h index f55734a..611db9e 100644 --- a/include/Game/CBrick.h +++ b/include/Game/CBrick.h @@ -16,6 +16,7 @@ namespace Components struct Brick : Component { int Score = 50; + //0 = empty, 1 = normal, 2 = multi-brick, 3 = lifebuoy, 4 = sticky, 5 = blaster, 6 = kraken int Type = 0; bool Removed = false; }; diff --git a/include/Physics/PhysicsSystem.h b/include/Physics/PhysicsSystem.h index ec5b618..1efa09d 100755 --- a/include/Physics/PhysicsSystem.h +++ b/include/Physics/PhysicsSystem.h @@ -24,6 +24,7 @@ #include "Physics/ECreateParticleSequence.h" #include "Physics/CCircleShape.h" #include "Physics/CParticleEmitter.h" +#include "Game/Bricks/CPowerUpBrick.h" #include "Transform/TransformSystem.h" #include "Transform/TransformSystem.h" diff --git a/src/game/Game/LevelSystem.cpp b/src/game/Game/LevelSystem.cpp index 93f6c93..b25cb26 100755 --- a/src/game/Game/LevelSystem.cpp +++ b/src/game/Game/LevelSystem.cpp @@ -598,7 +598,7 @@ void dd::Systems::LevelSystem::GetNextLevel() 1, 0, 1, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 0, 0, 0, 0, 0, 0}; + 2, 3, 4, 5, 6, 0, 0}; color = {w, w, w, w, w, w, w, lb4, lb4, lb4, lb4, lb4, lb4, lb4, diff --git a/src/game/Physics/PhysicsSystem.cpp b/src/game/Physics/PhysicsSystem.cpp index 94778d1..1d12b90 100755 --- a/src/game/Physics/PhysicsSystem.cpp +++ b/src/game/Physics/PhysicsSystem.cpp @@ -702,21 +702,51 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event) else { model = m_World->GetComponent(event.Entity1); } + + //Spawn a particle when a brick collides with somthing Events::CreateParticleSequence e; - e.EmitterLifeTime = 4; - //- glm::atan(event.Normal.x, event.Normal.y + + + e.EmitterLifeTime = 3; e.EmittingAngle = glm::half_pi(); - e.Spread = 0.5f; + e.Spread = 0.f; e.NumberOfTicks = 1; e.ParticleLifeTime = 1.f; - e.ParticlesPerTick = 15; - e.Position = glm::vec3(event.IntersectionPoint.x, event.IntersectionPoint.y, -10); - e.Radius = 0.2f; - e.SpriteFile = "Textures/Particles/Cloud_Particle.png"; - e.Color = model->Color + glm::vec4(0.5f); - e.Speed = 100; + e.ParticlesPerTick = 1; + e.Position = glm::vec3(event.IntersectionPoint.x, event.IntersectionPoint.y, -7); + e.Color = glm::vec4(1.f); + e.Radius = 1.f; + e.Speed = 0; + + if (brick->Type == 1 || brick->Type == 0) + { + e.EmitterLifeTime = 4; + e.EmittingAngle = glm::half_pi(); + e.Spread = 0.5f; + e.NumberOfTicks = 1; + e.ParticleLifeTime = 1.f; + e.ParticlesPerTick = 15; + e.Position = glm::vec3(event.IntersectionPoint.x, event.IntersectionPoint.y, -10); + e.Radius = 0.2f; + e.SpriteFile = "Textures/Particles/Cloud_Particle.png"; + e.Color = model->Color + glm::vec4(0.5f); + e.Speed = 100; + } else if (brick->Type == 2) { + e.SpriteFile = "Textures/PowerUps/Friends.png"; + } else if (brick->Type == 3) { + e.SpriteFile = "Textures/PowerUps/Saviour.png"; + } else if (brick->Type == 4) { + e.SpriteFile = "Textures/PowerUps/Sticky.png"; + } else if (brick->Type == 5) { + e.SpriteFile = "Textures/PowerUps/InkBlaster.png"; + } else if (brick->Type == 6) { + e.SpriteFile = "Textures/PowerUps/RealeaseTheKraken.png"; + } + EventBroker->Publish(e); return true; + + } From cd64531307e5ac4e0a9847fcd08e1422e2938784 Mon Sep 17 00:00:00 2001 From: tleety Date: Mon, 12 Oct 2015 17:18:44 +0200 Subject: [PATCH 2/2] Merged with master and fixed some small variable things --- include/Physics/PhysicsSystem.h | 3 ++- src/game/Game/LevelSystem.cpp | 2 +- src/game/Physics/PhysicsSystem.cpp | 36 ++++++++++++++++++------------ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/include/Physics/PhysicsSystem.h b/include/Physics/PhysicsSystem.h index 1efa09d..510fb42 100755 --- a/include/Physics/PhysicsSystem.h +++ b/include/Physics/PhysicsSystem.h @@ -24,7 +24,8 @@ #include "Physics/ECreateParticleSequence.h" #include "Physics/CCircleShape.h" #include "Physics/CParticleEmitter.h" -#include "Game/Bricks/CPowerUpBrick.h" + +#include "Game/BrickComponents.h" #include "Transform/TransformSystem.h" #include "Transform/TransformSystem.h" diff --git a/src/game/Game/LevelSystem.cpp b/src/game/Game/LevelSystem.cpp index de18b4a..700c4e0 100755 --- a/src/game/Game/LevelSystem.cpp +++ b/src/game/Game/LevelSystem.cpp @@ -605,7 +605,7 @@ void dd::Systems::LevelSystem::GetNextLevel() 1, 0, 1, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 2, 3, 4, 5, 6, 0, 0}; + 0, 0, 0, 0, 0, 0, 0}; color = {w, w, w, w, w, w, w, lb4, lb4, lb4, lb4, lb4, lb4, lb4, diff --git a/src/game/Physics/PhysicsSystem.cpp b/src/game/Physics/PhysicsSystem.cpp index 1d12b90..44923da 100755 --- a/src/game/Physics/PhysicsSystem.cpp +++ b/src/game/Physics/PhysicsSystem.cpp @@ -688,10 +688,12 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event) { //Check if it is a brick colliding auto brick = m_World->GetComponent(event.Entity1); + EntityID entity = event.Entity1; Components::Model* model; if (!brick) { brick = m_World->GetComponent(event.Entity2); + EntityID entity = event.Entity2; if (!brick) { return false; } @@ -717,9 +719,25 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event) e.Color = glm::vec4(1.f); e.Radius = 1.f; e.Speed = 0; - - if (brick->Type == 1 || brick->Type == 0) - { + + auto PowerFriend = m_World->GetComponent(entity); + auto PowerSaviour = m_World->GetComponent(entity); + auto PowerSticky = m_World->GetComponent(entity); + auto PowerInkBlaster = m_World->GetComponent(entity); + auto PowerKraken = m_World->GetComponent(entity); + + if (PowerFriend) { + e.SpriteFile = "Textures/PowerUps/Friends.png"; + } else if (PowerSaviour) { + e.SpriteFile = "Textures/PowerUps/Saviour.png"; + } else if (PowerSticky) { + e.SpriteFile = "Textures/PowerUps/Sticky.png"; + } else if (PowerInkBlaster){ + e.SpriteFile = "Textures/PowerUps/InkBlaster.png"; + } else if (PowerKraken) { + e.SpriteFile = "Textures/PowerUps/RealeaseTheKraken.png"; + } + else { e.EmitterLifeTime = 4; e.EmittingAngle = glm::half_pi(); e.Spread = 0.5f; @@ -731,18 +749,8 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event) e.SpriteFile = "Textures/Particles/Cloud_Particle.png"; e.Color = model->Color + glm::vec4(0.5f); e.Speed = 100; - } else if (brick->Type == 2) { - e.SpriteFile = "Textures/PowerUps/Friends.png"; - } else if (brick->Type == 3) { - e.SpriteFile = "Textures/PowerUps/Saviour.png"; - } else if (brick->Type == 4) { - e.SpriteFile = "Textures/PowerUps/Sticky.png"; - } else if (brick->Type == 5) { - e.SpriteFile = "Textures/PowerUps/InkBlaster.png"; - } else if (brick->Type == 6) { - e.SpriteFile = "Textures/PowerUps/RealeaseTheKraken.png"; } - + EventBroker->Publish(e); return true;