Merge remote-tracking branch 'origin/master' into water
Conflicts: src/game/Game/LevelSystem.cpp src/game/Physics/PhysicsSystem.cpp
This commit is contained in:
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
+13
-1
@@ -31,14 +31,15 @@
|
|||||||
//TODO: Remove includes that are only here for the temporary draw solution.
|
//TODO: Remove includes that are only here for the temporary draw solution.
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "CTransform.h"
|
#include "CTransform.h"
|
||||||
|
#include "CTemplate.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Rendering/CModel.h"
|
#include "Rendering/CModel.h"
|
||||||
#include "Rendering/CSprite.h"
|
#include "Rendering/CSprite.h"
|
||||||
#include "CTemplate.h"
|
|
||||||
#include "Rendering/CPointLight.h"
|
#include "Rendering/CPointLight.h"
|
||||||
#include "Transform/TransformSystem.h"
|
#include "Transform/TransformSystem.h"
|
||||||
#include "Sound/SoundSystem.h"
|
#include "Sound/SoundSystem.h"
|
||||||
#include "Sound/CCollisionSound.h"
|
#include "Sound/CCollisionSound.h"
|
||||||
|
|
||||||
#include "Game/LevelSystem.h"
|
#include "Game/LevelSystem.h"
|
||||||
#include "Game/PadSystem.h"
|
#include "Game/PadSystem.h"
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
@@ -46,12 +47,15 @@
|
|||||||
#include "Game/CLifebuoy.h"
|
#include "Game/CLifebuoy.h"
|
||||||
#include "Game/CProjectile.h"
|
#include "Game/CProjectile.h"
|
||||||
#include "Game/CBrick.h"
|
#include "Game/CBrick.h"
|
||||||
|
#include "Game/CStickyAim.h"
|
||||||
#include "Game/BallSystem.h"
|
#include "Game/BallSystem.h"
|
||||||
#include "Game/HitLagSystem.h"
|
#include "Game/HitLagSystem.h"
|
||||||
#include "Game/LifebuoySystem.h"
|
#include "Game/LifebuoySystem.h"
|
||||||
#include "Game/ProjectileSystem.h"
|
#include "Game/ProjectileSystem.h"
|
||||||
#include "Game/Bricks/CPowerUpBrick.h"
|
#include "Game/Bricks/CPowerUpBrick.h"
|
||||||
|
|
||||||
|
#include "Game/BrickComponents.h"
|
||||||
|
|
||||||
#include "Physics/PhysicsSystem.h"
|
#include "Physics/PhysicsSystem.h"
|
||||||
#include "Physics/CPhysics.h"
|
#include "Physics/CPhysics.h"
|
||||||
#include "Physics/CRectangleShape.h"
|
#include "Physics/CRectangleShape.h"
|
||||||
@@ -116,10 +120,18 @@ public:
|
|||||||
m_World->ComponentFactory.Register<Components::Life>();
|
m_World->ComponentFactory.Register<Components::Life>();
|
||||||
m_World->ComponentFactory.Register<Components::Lifebuoy>();
|
m_World->ComponentFactory.Register<Components::Lifebuoy>();
|
||||||
m_World->ComponentFactory.Register<Components::Projectile>();
|
m_World->ComponentFactory.Register<Components::Projectile>();
|
||||||
|
m_World->ComponentFactory.Register<Components::StickyAim>();
|
||||||
|
|
||||||
m_World->ComponentFactory.Register<Components::PowerUp>();
|
m_World->ComponentFactory.Register<Components::PowerUp>();
|
||||||
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
|
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
|
||||||
|
|
||||||
|
m_World->ComponentFactory.Register<Components::StandardBrick>();
|
||||||
|
m_World->ComponentFactory.Register<Components::MultiBallBrick>();
|
||||||
|
m_World->ComponentFactory.Register<Components::LifebuoyBrick>();
|
||||||
|
m_World->ComponentFactory.Register<Components::StickyBrick>();
|
||||||
|
m_World->ComponentFactory.Register<Components::InkBlasterBrick>();
|
||||||
|
m_World->ComponentFactory.Register<Components::KrakenAttackBrick>();
|
||||||
|
|
||||||
m_World->SystemFactory.Register<Systems::LevelSystem>(
|
m_World->SystemFactory.Register<Systems::LevelSystem>(
|
||||||
[this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
|
[this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
|
||||||
m_World->AddSystem<Systems::LevelSystem>();
|
m_World->AddSystem<Systems::LevelSystem>();
|
||||||
|
|||||||
@@ -11,25 +11,29 @@
|
|||||||
#include "Physics/CRectangleShape.h"
|
#include "Physics/CRectangleShape.h"
|
||||||
#include "Physics/EContact.h"
|
#include "Physics/EContact.h"
|
||||||
#include "Rendering/CModel.h"
|
#include "Rendering/CModel.h"
|
||||||
|
#include "Rendering/CSprite.h"
|
||||||
#include "Rendering/CPointLight.h"
|
#include "Rendering/CPointLight.h"
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
#include "Game/CPowerUp.h"
|
#include "Game/CPowerUp.h"
|
||||||
#include "Game/CLife.h"
|
#include "Game/CLife.h"
|
||||||
#include "Game/CBrick.h"
|
#include "Game/CBrick.h"
|
||||||
|
#include "Game/CLifebuoy.h"
|
||||||
#include "Game/ELifeLost.h"
|
#include "Game/ELifeLost.h"
|
||||||
#include "Game/EComboEvent.h"
|
#include "Game/EComboEvent.h"
|
||||||
#include "Game/EResetBall.h"
|
#include "Game/EResetBall.h"
|
||||||
#include "Game/EMultiBall.h"
|
#include "Game/EMultiBall.h"
|
||||||
#include "Game/EMultiBallLost.h"
|
#include "Game/EMultiBallLost.h"
|
||||||
#include "Game/EStickyPad.h"
|
#include "Game/EStickyPad.h"
|
||||||
|
#include "Game/EStickyAttachedToPad.h"
|
||||||
#include "Game/EInkBlaster.h"
|
#include "Game/EInkBlaster.h"
|
||||||
#include "Game/EInkBlasterOver.h"
|
#include "Game/EInkBlasterOver.h"
|
||||||
|
#include "Game/EStageCleared.h"
|
||||||
|
#include "Game/EArrivedAtNewStage.h"
|
||||||
#include "Game/EGameOver.h"
|
#include "Game/EGameOver.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
#include "Game/EHitPad.h"
|
#include "Game/EHitPad.h"
|
||||||
#include "Game/EHitLag.h"
|
#include "Game/EHitLag.h"
|
||||||
#include "Game/EActionButton.h"
|
#include "Game/EActionButton.h"
|
||||||
#include "Game/CLifebuoy.h"
|
|
||||||
#include "Game/ELifebuoyHit.h"
|
#include "Game/ELifebuoyHit.h"
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
@@ -99,8 +103,11 @@ private:
|
|||||||
bool m_Sticky = false;
|
bool m_Sticky = false;
|
||||||
bool m_InkBlaster = false;
|
bool m_InkBlaster = false;
|
||||||
bool m_InkAttached = false;
|
bool m_InkAttached = false;
|
||||||
bool m_BlockedWaiting = false;
|
bool m_InkBlockedWaiting = false;
|
||||||
int m_StickyCounter = 5;
|
bool m_Restarting = false;
|
||||||
|
int m_StickyCounter = 3;
|
||||||
|
|
||||||
|
bool m_StageBlockedWaiting = false;
|
||||||
|
|
||||||
glm::vec3 m_SavedSpeed;
|
glm::vec3 m_SavedSpeed;
|
||||||
bool m_InitializePause = false;
|
bool m_InitializePause = false;
|
||||||
@@ -120,6 +127,8 @@ private:
|
|||||||
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||||
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
||||||
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
||||||
|
dd::EventRelay<BallSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||||
|
dd::EventRelay<BallSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
||||||
|
|
||||||
bool Contact(const Events::Contact &event);
|
bool Contact(const Events::Contact &event);
|
||||||
bool OnLifeLost(const dd::Events::LifeLost &event);
|
bool OnLifeLost(const dd::Events::LifeLost &event);
|
||||||
@@ -131,6 +140,8 @@ private:
|
|||||||
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||||
|
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||||
|
bool OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_CBRICKCOMPONENTS_H
|
||||||
|
#define DAYDREAM_CBRICKCOMPONENTS_H
|
||||||
|
|
||||||
|
#include "Game/CStandardBrick.h"
|
||||||
|
#include "Game/CMultiBallBrick.h"
|
||||||
|
#include "Game/CLifebuoyBrick.h"
|
||||||
|
#include "Game/CStickyBrick.h"
|
||||||
|
#include "Game/CInkBlasterBrick.h"
|
||||||
|
#include "Game/CKrakenAttackBrick.h"
|
||||||
|
|
||||||
|
#endif //DAYDREAM_CBRICKCOMPONENTS_H
|
||||||
@@ -16,8 +16,18 @@ namespace Components
|
|||||||
struct Brick : Component
|
struct Brick : Component
|
||||||
{
|
{
|
||||||
int Score = 50;
|
int Score = 50;
|
||||||
|
//0 = empty, 1 = normal, 2 = multi-brick, 3 = lifebuoy, 4 = sticky, 5 = blaster, 6 = kraken
|
||||||
int Type = 0;
|
int Type = 0;
|
||||||
bool Removed = false;
|
bool Removed = false;
|
||||||
|
|
||||||
|
//What number of types each is.
|
||||||
|
const int EmptyBrickSpace = 0;
|
||||||
|
const int StandardBrick = 1;
|
||||||
|
const int MultiBallBrick = 2;
|
||||||
|
const int LifebuoyBrick = 3;
|
||||||
|
const int StickyBrick = 4;
|
||||||
|
const int InkBlasterBrick = 5;
|
||||||
|
const int KrakenAttackBrick = 6;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_CINKBLASTERBRICK_H
|
||||||
|
#define DAYDREAM_CINKBLASTERBRICK_H
|
||||||
|
|
||||||
|
#include "Core/Component.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct InkBlasterBrick : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_CINKBLASTERBRICK_H
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_CKRAKENATTACKBRICK_H
|
||||||
|
#define DAYDREAM_CKRAKENATTACKBRICK_H
|
||||||
|
|
||||||
|
#include "Core/Component.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct KrakenAttackBrick : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_CKRAKENATTACKBRICK_H
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_CLIFEBUOYBRICK_H
|
||||||
|
#define DAYDREAM_CLIFEBUOYBRICK_H
|
||||||
|
|
||||||
|
#include "Core/Component.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct LifebuoyBrick : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_CLIFEBUOYBRICK_H
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_CMULTIBALLBRICK_H
|
||||||
|
#define DAYDREAM_CMULTIBALLBRICK_H
|
||||||
|
|
||||||
|
#include "Core/Component.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct MultiBallBrick : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_CMULTIBALLBRICK_H
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_CSTANDARDBRICK_H
|
||||||
|
#define DAYDREAM_CSTANDARDBRICK_H
|
||||||
|
|
||||||
|
#include "Core/Component.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct StandardBrick : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_CSTANDARDBRICK_H
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_CSTICKYAIM_H
|
||||||
|
#define DAYDREAM_CSTICKYAIM_H
|
||||||
|
|
||||||
|
#include "Core/Component.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct StickyAim : Component
|
||||||
|
{
|
||||||
|
bool Aiming = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_CSTICKYAIM_H
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_CSTICKYBRICK_H
|
||||||
|
#define DAYDREAM_CSTICKYBRICK_H
|
||||||
|
|
||||||
|
#include "Core/Component.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct StickyBrick : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_CSTICKYBRICK_H
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef EVENTS_EARRIVEDATNEWSTAGE_H__
|
||||||
|
#define EVENTS_EARRIVEDATNEWSTAGE_H__
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct ArrivedAtNewStage : public Event
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_EARRIVEDATNEWSTAGE_H
|
||||||
@@ -16,6 +16,7 @@ namespace Events
|
|||||||
struct InkBlaster : Event
|
struct InkBlaster : Event
|
||||||
{
|
{
|
||||||
Components::Transform* Transform;
|
Components::Transform* Transform;
|
||||||
|
int Shots;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef EVENTS_ESTICKYATTACHEDTOPAD_H__
|
||||||
|
#define EVENTS_ESTICKYATTACHEDTOPAD_H__
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct StickyAttachedToPad : public Event
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_ESTICKYATTACHEDTOPADE_H
|
||||||
@@ -16,6 +16,7 @@ namespace Events
|
|||||||
struct StickyPad : Event
|
struct StickyPad : Event
|
||||||
{
|
{
|
||||||
Components::Transform* Transform;
|
Components::Transform* Transform;
|
||||||
|
int Times;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-16
@@ -26,24 +26,23 @@ public:
|
|||||||
Width = parent->Width;
|
Width = parent->Width;
|
||||||
Height = parent->Height;
|
Height = parent->Height;
|
||||||
|
|
||||||
m_LevelIndicator = new GUI::TextureFrame(this, "HUDLevelIndicator");
|
//m_LevelIndicator = new GUI::TextureFrame(this, "HUDLevelIndicator");
|
||||||
m_LevelIndicator->SetTexture("Textures/GUI/HUD/LevelIndicatorBG.png");
|
//m_LevelIndicator->SetTexture("Textures/GUI/HUD/LevelIndicatorBG.png");
|
||||||
|
|
||||||
m_AreaNumberFrame = new GUI::NumberFrame(m_LevelIndicator, "HUDScoreNumberFrameawdawdwa");
|
//m_AreaNumberFrame = new GUI::NumberFrame(m_LevelIndicator, "HUDScoreNumberFrameawdawdwa");
|
||||||
m_AreaNumberFrame->X = 132;
|
//m_AreaNumberFrame->X = 132;
|
||||||
m_AreaNumberFrame->Y = 19;
|
//m_AreaNumberFrame->Y = 19;
|
||||||
m_AreaNumberFrame->SetNumber(6);
|
//m_AreaNumberFrame->SetNumber(6);
|
||||||
m_StageNumberFrame = new GUI::NumberFrame(m_LevelIndicator, "HUDScoreNumberFrameawdawdwa");
|
//m_StageNumberFrame = new GUI::NumberFrame(m_LevelIndicator, "HUDScoreNumberFrameawdawdwa");
|
||||||
m_StageNumberFrame->X = 165;
|
//m_StageNumberFrame->X = 165;
|
||||||
m_StageNumberFrame->Y = 19;
|
//m_StageNumberFrame->Y = 19;
|
||||||
m_StageNumberFrame->SetNumber(5);
|
//m_StageNumberFrame->SetNumber(5);
|
||||||
|
|
||||||
m_ScoreIndicator = new GUI::TextureFrame(this, "HUDScoreIndicator");
|
//m_ScoreIndicator = new GUI::TextureFrame(this, "HUDScoreIndicator");
|
||||||
m_ScoreIndicator->SetTexture("Textures/GUI/HUD/ScoreIndicatorBG.png");
|
//m_ScoreIndicator->SetTexture("Textures/GUI/HUD/ScoreIndicatorBG.png");
|
||||||
m_ScoreIndicator->SetRight(Right());
|
m_ScoreNumberFrame = new GUI::NumberFrame(this, "HUDScoreNumberFrame");
|
||||||
m_ScoreNumberFrame = new GUI::NumberFrame(m_ScoreIndicator, "HUDScoreNumberFrame");
|
//m_ScoreNumberFrame->X = 15;
|
||||||
m_ScoreNumberFrame->X = 15;
|
m_ScoreNumberFrame->Y = 18;
|
||||||
m_ScoreNumberFrame->Y = 21;
|
|
||||||
|
|
||||||
m_FPSCounter = new GUI::FPSCounter(this, "FPSCounter");
|
m_FPSCounter = new GUI::FPSCounter(this, "FPSCounter");
|
||||||
|
|
||||||
@@ -60,6 +59,11 @@ public:
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_KrakenAttack, &HUD::OnKrakenAttack);
|
EVENT_SUBSCRIBE_MEMBER(m_KrakenAttack, &HUD::OnKrakenAttack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Update(double dt) override
|
||||||
|
{
|
||||||
|
m_ScoreNumberFrame->SetLeft(Width / 2.f - m_ScoreNumberFrame->Width / 2.f);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextureFrame* m_LevelIndicator = nullptr;
|
TextureFrame* m_LevelIndicator = nullptr;
|
||||||
TextureFrame* m_ScoreIndicator = nullptr;
|
TextureFrame* m_ScoreIndicator = nullptr;
|
||||||
|
|||||||
@@ -12,11 +12,15 @@
|
|||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Rendering/CSprite.h"
|
#include "Rendering/CSprite.h"
|
||||||
#include "Rendering/CModel.h"
|
#include "Rendering/CModel.h"
|
||||||
|
|
||||||
#include "Game/CBrick.h"
|
#include "Game/CBrick.h"
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
#include "Game/CLife.h"
|
#include "Game/CLife.h"
|
||||||
#include "Game/CProjectile.h"
|
#include "Game/CProjectile.h"
|
||||||
#include "Game/CPowerUp.h"
|
#include "Game/CPowerUp.h"
|
||||||
|
|
||||||
|
#include "Game/BrickComponents.h"
|
||||||
|
|
||||||
#include "Game/EStageCleared.h"
|
#include "Game/EStageCleared.h"
|
||||||
#include "Game/ELifeLost.h"
|
#include "Game/ELifeLost.h"
|
||||||
#include "Game/EResetBall.h"
|
#include "Game/EResetBall.h"
|
||||||
@@ -34,7 +38,7 @@
|
|||||||
#include "Game/EClusterClear.h"
|
#include "Game/EClusterClear.h"
|
||||||
#include "Game/ECreatePowerUp.h"
|
#include "Game/ECreatePowerUp.h"
|
||||||
#include "Game/EPowerUpTaken.h"
|
#include "Game/EPowerUpTaken.h"
|
||||||
//#include "Game/Bricks/CPowerUpBrick.h"
|
|
||||||
#include "Physics/CPhysics.h"
|
#include "Physics/CPhysics.h"
|
||||||
#include "Physics/CCircleShape.h"
|
#include "Physics/CCircleShape.h"
|
||||||
#include "Physics/CRectangleShape.h"
|
#include "Physics/CRectangleShape.h"
|
||||||
@@ -76,6 +80,7 @@ public:
|
|||||||
void CreateBasicLevel(int, int, glm::vec2, float);
|
void CreateBasicLevel(int, int, glm::vec2, float);
|
||||||
void CreateLevel(int);
|
void CreateLevel(int);
|
||||||
void CreateBrick(int, int, glm::vec2, float, int, int, int, glm::vec4);
|
void CreateBrick(int, int, glm::vec2, float, int, int, int, glm::vec4);
|
||||||
|
void BrickHit(EntityID, EntityID, int);
|
||||||
|
|
||||||
void OnEntityRemoved(EntityID entity);
|
void OnEntityRemoved(EntityID entity);
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,12 @@
|
|||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
#include "Game/CPad.h"
|
#include "Game/CPad.h"
|
||||||
#include "Game/CPowerUp.h"
|
#include "Game/CPowerUp.h"
|
||||||
|
#include "Game/CStickyAim.h"
|
||||||
#include "Game/EResetBall.h"
|
#include "Game/EResetBall.h"
|
||||||
#include "Game/EMultiBall.h"
|
#include "Game/EMultiBall.h"
|
||||||
|
#include "Game/EStickyPad.h"
|
||||||
|
#include "Game/EStickyAttachedToPad.h"
|
||||||
|
#include "Game/EInkBlaster.h"
|
||||||
#include "Game/EKrakenAttack.h"
|
#include "Game/EKrakenAttack.h"
|
||||||
#include "Game/EPowerUpTaken.h"
|
#include "Game/EPowerUpTaken.h"
|
||||||
#include "Game/EStageCleared.h"
|
#include "Game/EStageCleared.h"
|
||||||
@@ -78,12 +82,15 @@ private:
|
|||||||
bool m_ReplaceBall = false;
|
bool m_ReplaceBall = false;
|
||||||
bool m_MultiBall = false;
|
bool m_MultiBall = false;
|
||||||
bool m_KrakenAttack = false;
|
bool m_KrakenAttack = false;
|
||||||
|
bool m_BallStuck = false;
|
||||||
double m_KrakenCharge = 0;
|
double m_KrakenCharge = 0;
|
||||||
double m_KrakenStrength = 0;
|
double m_KrakenStrength = 0;
|
||||||
double m_PlayerStrength = 0;
|
double m_PlayerStrength = 0;
|
||||||
float m_Edge = 2.8f;
|
float m_Edge = 2.8f;
|
||||||
Components::Transform* m_Transform = nullptr;
|
Components::Transform* m_Transform = nullptr;
|
||||||
Components::Pad* m_Pad = nullptr;
|
Components::Pad* m_Pad = nullptr;
|
||||||
|
std::shared_ptr<Components::Transform> m_StickTransform;
|
||||||
|
std::shared_ptr<Components::StickyAim> m_StickyAim;
|
||||||
|
|
||||||
bool m_Pause = false;
|
bool m_Pause = false;
|
||||||
|
|
||||||
@@ -94,6 +101,8 @@ private:
|
|||||||
dd::EventRelay<PadSystem, dd::Events::StageCleared> m_EStageCleared;
|
dd::EventRelay<PadSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||||
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
||||||
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||||
|
dd::EventRelay<PadSystem, dd::Events::StickyPad> m_EStickyPad;
|
||||||
|
dd::EventRelay<PadSystem, dd::Events::StickyAttachedToPad> m_EStickyAttachedToPad;
|
||||||
dd::EventRelay<PadSystem, dd::Events::ActionButton> m_EActionButton;
|
dd::EventRelay<PadSystem, dd::Events::ActionButton> m_EActionButton;
|
||||||
|
|
||||||
bool OnKeyDown(const dd::Events::KeyDown &event);
|
bool OnKeyDown(const dd::Events::KeyDown &event);
|
||||||
@@ -103,6 +112,8 @@ private:
|
|||||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||||
|
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||||
|
bool OnStickyAttachedToPad(const dd::Events::StickyAttachedToPad &event);
|
||||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||||
|
|
||||||
class PadSteeringInputController;
|
class PadSteeringInputController;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ struct ParticleEmitter : public Component
|
|||||||
float Spread = 0.f;
|
float Spread = 0.f;
|
||||||
float Speed = 2.f;
|
float Speed = 2.f;
|
||||||
double LifeTime = 100;
|
double LifeTime = 100;
|
||||||
|
float RadiusDistribution = 0;
|
||||||
|
|
||||||
//values to interpolate between.
|
//values to interpolate between.
|
||||||
std::vector<float> RadiusValues;
|
std::vector<float> RadiusValues;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ struct CreateParticleSequence : public Event
|
|||||||
float Spread = 1.f;
|
float Spread = 1.f;
|
||||||
float EmittingAngle = 0.f;
|
float EmittingAngle = 0.f;
|
||||||
float MaxCount = 0;
|
float MaxCount = 0;
|
||||||
|
float RadiusDistribution = 0;
|
||||||
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.
|
||||||
|
|||||||
@@ -25,12 +25,15 @@
|
|||||||
#include "Physics/CCircleShape.h"
|
#include "Physics/CCircleShape.h"
|
||||||
#include "Physics/CParticleEmitter.h"
|
#include "Physics/CParticleEmitter.h"
|
||||||
|
|
||||||
|
#include "Game/BrickComponents.h"
|
||||||
|
|
||||||
#include "Transform/TransformSystem.h"
|
#include "Transform/TransformSystem.h"
|
||||||
#include "Transform/TransformSystem.h"
|
#include "Transform/TransformSystem.h"
|
||||||
|
|
||||||
#include "CRectangleShape.h"
|
#include "CRectangleShape.h"
|
||||||
|
|
||||||
#include "Game/EStageCleared.h"
|
#include "Game/EStageCleared.h"
|
||||||
|
#include "Game/EArrivedAtNewStage.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
#include "Game/CPad.h"
|
#include "Game/CPad.h"
|
||||||
#include "Game/CBrick.h"
|
#include "Game/CBrick.h"
|
||||||
|
|||||||
@@ -23,12 +23,14 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
|
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &BallSystem::OnStageCleared);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EArrivedAtNewStage, &BallSystem::OnArrivedToNewStage);
|
||||||
|
|
||||||
//OctoBall
|
//OctoBall
|
||||||
{
|
{
|
||||||
auto ent = m_World->CreateEntity();
|
auto ent = m_World->CreateEntity();
|
||||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||||
transform->Position = glm::vec3(-0.f, 50.26f, -10.f);
|
transform->Position = glm::vec3(0.f, 0.26f, -10.f);
|
||||||
transform->Scale = glm::vec3(0.3f, 0.3f, 0.3f);
|
transform->Scale = glm::vec3(0.3f, 0.3f, 0.3f);
|
||||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||||
@@ -117,6 +119,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
|
|
||||||
if (ballComponent->Waiting) {
|
if (ballComponent->Waiting) {
|
||||||
if (!m_Waiting) {
|
if (!m_Waiting) {
|
||||||
|
m_Restarting = false;
|
||||||
ballComponent->Waiting = false;
|
ballComponent->Waiting = false;
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
|
transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
|
||||||
@@ -155,7 +158,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
m_World->RemoveEntity(entity);
|
m_World->RemoveEntity(entity);
|
||||||
Events::MultiBallLost e;
|
Events::MultiBallLost e;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
} else if (Lives() == PastLives()) {
|
} else if (Lives() == PastLives() && !m_Restarting) {
|
||||||
Events::ResetBall be;
|
Events::ResetBall be;
|
||||||
EventBroker->Publish(be);
|
EventBroker->Publish(be);
|
||||||
Events::LifeLost e;
|
Events::LifeLost e;
|
||||||
@@ -193,11 +196,14 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ballComponent != nullptr) {
|
if (ballComponent != nullptr) {
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
if (!ballComponent->Sticky)
|
||||||
glm::vec2 dir = glm::normalize(glm::vec2(transform->Velocity.x, transform->Velocity.y));
|
{
|
||||||
glm::vec2 up = glm::vec2(0.f, 1.f);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
|
glm::vec2 dir = glm::normalize(glm::vec2(transform->Velocity.x, transform->Velocity.y));
|
||||||
transform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f));
|
glm::vec2 up = glm::vec2(0.f, 1.f);
|
||||||
|
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
|
||||||
|
transform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +293,7 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
|||||||
if (!m_InkAttached) {
|
if (!m_InkAttached) {
|
||||||
m_InkAttached = true;
|
m_InkAttached = true;
|
||||||
m_Waiting = true;
|
m_Waiting = true;
|
||||||
m_BlockedWaiting = true;
|
m_InkBlockedWaiting = true;
|
||||||
ballComponent->Sticky = true;
|
ballComponent->Sticky = true;
|
||||||
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
||||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||||
@@ -300,6 +306,8 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
|||||||
ballComponent->StickyPlacement = ballTransform->Position - padTransform->Position;
|
ballComponent->StickyPlacement = ballTransform->Position - padTransform->Position;
|
||||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||||
ballTransform->Velocity *= -1;
|
ballTransform->Velocity *= -1;
|
||||||
|
Events::StickyAttachedToPad e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +446,6 @@ bool dd::Systems::BallSystem::OnMultiBall(const dd::Events::MultiBall &event)
|
|||||||
bool dd::Systems::BallSystem::OnStickyPad(const dd::Events::StickyPad &event)
|
bool dd::Systems::BallSystem::OnStickyPad(const dd::Events::StickyPad &event)
|
||||||
{
|
{
|
||||||
m_Sticky = true;
|
m_Sticky = true;
|
||||||
m_StickyCounter = 5;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,8 +462,7 @@ bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver
|
|||||||
|
|
||||||
m_InkBlaster = false;
|
m_InkBlaster = false;
|
||||||
m_InkAttached = false;
|
m_InkAttached = false;
|
||||||
m_BlockedWaiting = false;
|
m_InkBlockedWaiting = false;
|
||||||
m_Sticky = true;
|
|
||||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(0.f, 1.f, 0.f)) * ballComponent->Speed;
|
ballComponent->SavedSpeed = glm::normalize(glm::vec3(0.f, 1.f, 0.f)) * ballComponent->Speed;
|
||||||
m_Waiting = false;
|
m_Waiting = false;
|
||||||
transform->Velocity = glm::normalize(glm::vec3(0.f, 1, 0.f)) * ballComponent->Speed;
|
transform->Velocity = glm::normalize(glm::vec3(0.f, 1, 0.f)) * ballComponent->Speed;
|
||||||
@@ -465,9 +471,24 @@ bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver
|
|||||||
|
|
||||||
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||||
{
|
{
|
||||||
if (!m_BlockedWaiting) {
|
if (!m_StageBlockedWaiting) {
|
||||||
m_Waiting = false;
|
if (!m_InkBlockedWaiting) {
|
||||||
|
m_Waiting = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::BallSystem::OnStageCleared(const dd::Events::StageCleared &event)
|
||||||
|
{
|
||||||
|
m_Restarting = true;
|
||||||
|
m_StageBlockedWaiting = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::BallSystem::OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event)
|
||||||
|
{
|
||||||
|
m_StageBlockedWaiting = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+114
-103
@@ -78,7 +78,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
//Removes bricks that falls out of the stage.
|
//Removes bricks that falls out of the stage.
|
||||||
if (transform->Position.y < -10) {
|
if (transform->Position.y < -10) {
|
||||||
if (brick->Type == StandardBrick) {
|
/*if (brick->Type == StandardBrick) {
|
||||||
} else if (brick->Type == MultiBallBrick) {
|
} else if (brick->Type == MultiBallBrick) {
|
||||||
Events::MultiBall e;
|
Events::MultiBall e;
|
||||||
e.padTransform = transform;
|
e.padTransform = transform;
|
||||||
@@ -99,7 +99,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
e.KrakenStrength = 0.1;
|
e.KrakenStrength = 0.1;
|
||||||
e.PlayerStrength = 0.05;
|
e.PlayerStrength = 0.05;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}*/
|
||||||
m_LooseBricks--;
|
m_LooseBricks--;
|
||||||
m_World->RemoveEntity(entity);
|
m_World->RemoveEntity(entity);
|
||||||
}
|
}
|
||||||
@@ -200,21 +200,28 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
|
|||||||
auto cBrick = m_World->GetComponent<Components::Brick>(brick);
|
auto cBrick = m_World->GetComponent<Components::Brick>(brick);
|
||||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||||
if (typeInt == StandardBrick) {
|
if (typeInt == StandardBrick) {
|
||||||
|
cBrick->Type = StandardBrick;
|
||||||
|
auto type = m_World->AddComponent<Components::StandardBrick>(brick);
|
||||||
model->Color = colorVec;
|
model->Color = colorVec;
|
||||||
} else if (typeInt == MultiBallBrick) {
|
} else if (typeInt == MultiBallBrick) {
|
||||||
cBrick->Type = MultiBallBrick;
|
cBrick->Type = MultiBallBrick;
|
||||||
|
auto type = m_World->AddComponent<Components::MultiBallBrick>(brick);
|
||||||
model->ModelFile = "Models/Brick/IceBrick.obj";
|
model->ModelFile = "Models/Brick/IceBrick.obj";
|
||||||
} else if (typeInt == LifebuoyBrick) {
|
} else if (typeInt == LifebuoyBrick) {
|
||||||
cBrick->Type = LifebuoyBrick;
|
cBrick->Type = LifebuoyBrick;
|
||||||
|
auto type = m_World->AddComponent<Components::LifebuoyBrick>(brick);
|
||||||
model->ModelFile = "Models/Brick/LifeBuoyBrick.obj";
|
model->ModelFile = "Models/Brick/LifeBuoyBrick.obj";
|
||||||
} else if (typeInt == StickyBrick) {
|
} else if (typeInt == StickyBrick) {
|
||||||
cBrick->Type = StickyBrick;
|
cBrick->Type = StickyBrick;
|
||||||
|
auto type = m_World->AddComponent<Components::StickyBrick>(brick);
|
||||||
model->ModelFile = "Models/Brick/StickyBrick.obj";
|
model->ModelFile = "Models/Brick/StickyBrick.obj";
|
||||||
} else if (typeInt == InkBlasterBrick) {
|
} else if (typeInt == InkBlasterBrick) {
|
||||||
cBrick->Type = InkBlasterBrick;
|
cBrick->Type = InkBlasterBrick;
|
||||||
|
auto type = m_World->AddComponent<Components::InkBlasterBrick>(brick);
|
||||||
model->Color = glm::vec4(0.1f, 0.1f, 0.1f, 1.0f);
|
model->Color = glm::vec4(0.1f, 0.1f, 0.1f, 1.0f);
|
||||||
} else if (typeInt == KrakenAttackBrick) {
|
} else if (typeInt == KrakenAttackBrick) {
|
||||||
cBrick->Type = KrakenAttackBrick;
|
cBrick->Type = KrakenAttackBrick;
|
||||||
|
auto type = m_World->AddComponent<Components::KrakenAttackBrick>(brick);
|
||||||
model->Color = glm::vec4(0.f, 0.5f, 1.0f, .0f);
|
model->Color = glm::vec4(0.f, 0.5f, 1.0f, .0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,119 +284,123 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
if (entityShot != 0) {
|
if (entityShot != 0) {
|
||||||
// For when a brick gets shot.
|
// For when a brick gets shot.
|
||||||
brick->Removed = true;
|
brick->Removed = true;
|
||||||
|
|
||||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
|
|
||||||
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
|
||||||
physicsComponent->GravityScale = 1.f;
|
|
||||||
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
|
||||||
|
|
||||||
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
|
|
||||||
auto transformComponentShot = m_World->GetComponent<Components::Transform>(entityShot);
|
|
||||||
auto brickModel = m_World->GetComponent<Components::Model>(entityBrick);
|
|
||||||
|
|
||||||
Events::SetImpulse e;
|
|
||||||
e.Entity = entityBrick;
|
|
||||||
|
|
||||||
glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentShot->Position.x - transformComponentBrick->Position.x) / 4),
|
|
||||||
transformComponentBrick->Position.y + ((transformComponentShot->Position.y - transformComponentBrick->Position.y) / 4));
|
|
||||||
|
|
||||||
e.Impulse = glm::normalize(point)*5.f;
|
|
||||||
e.Point = point;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
|
|
||||||
|
|
||||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
|
||||||
Events::ScoreEvent es;
|
|
||||||
es.Score = brick->Score;
|
|
||||||
EventBroker->Publish(es);
|
|
||||||
|
|
||||||
m_World->RemoveEntity(entityShot);
|
m_World->RemoveEntity(entityShot);
|
||||||
|
BrickHit(entityShot, entityBrick, 1);
|
||||||
Events::CreateParticleSequence ep;
|
|
||||||
ep.parent = entityBrick;
|
|
||||||
ep.EmitterLifeTime = 1.f;
|
|
||||||
ep.ParticleLifeTime = 1.5f;
|
|
||||||
ep.ParticlesPerTick = 1;
|
|
||||||
ep.SpawnRate = 0.2;
|
|
||||||
ep.EmittingAngle = glm::half_pi<float>();
|
|
||||||
ep.Spread = 1.5f;
|
|
||||||
ep.Position = transformComponentBrick->Position;
|
|
||||||
//ep.Radius = 0.05;
|
//ep.Radius = 0.05;
|
||||||
ep.SpriteFile = "Textures/Particles/FadeBall.png";
|
|
||||||
ep.Color = brickModel->Color + glm::vec4(0.3f);
|
|
||||||
ep.AlphaValues.push_back(1.f);
|
|
||||||
ep.AlphaValues.push_back(0.f);
|
|
||||||
ep.RadiusValues.push_back(0.05);
|
|
||||||
ep.Speed = 50;
|
|
||||||
EventBroker->Publish(ep);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Restarting() && !brick->Removed) {
|
if (!Restarting() && !brick->Removed) {
|
||||||
brick->Removed = true;
|
brick->Removed = true;
|
||||||
// Hit brick with ball code.
|
|
||||||
ball->Combo += 1;
|
// Hit brick with ball code.
|
||||||
Events::ComboEvent ec;
|
ball->Combo += 1;
|
||||||
ec.Combo = ball->Combo;
|
Events::ComboEvent ec;
|
||||||
ec.Ball = entityBall;
|
ec.Combo = ball->Combo;
|
||||||
EventBroker->Publish(ec);
|
ec.Ball = entityBall;
|
||||||
|
EventBroker->Publish(ec);
|
||||||
|
|
||||||
auto ballTransform = m_World->GetComponent<Components::Transform>(entityBall);
|
BrickHit(entityBall, entityBrick, ball->Combo);
|
||||||
|
|
||||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
|
|
||||||
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
|
||||||
physicsComponent->GravityScale = 1.f;
|
|
||||||
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
|
||||||
|
|
||||||
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
|
|
||||||
auto transformComponentBall = m_World->GetComponent<Components::Transform>(entityBall);
|
|
||||||
auto brickModel = m_World->GetComponent<Components::Model>(entityBrick);
|
|
||||||
|
|
||||||
Events::SetImpulse e;
|
|
||||||
e.Entity = entityBrick;
|
|
||||||
|
|
||||||
glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentBall->Position.x - transformComponentBrick->Position.x )/4),
|
|
||||||
transformComponentBrick->Position.y + ((transformComponentBall->Position.y - transformComponentBrick->Position.y)/4));
|
|
||||||
|
|
||||||
e.Impulse = glm::normalize(point)*5.f;///2.f;
|
|
||||||
e.Point = point;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
//TODO: Bricks dont collide with walls D=
|
|
||||||
|
|
||||||
|
|
||||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
|
||||||
Events::ScoreEvent es;
|
|
||||||
es.Score = brick->Score * ball->Combo;
|
|
||||||
EventBroker->Publish(es);
|
|
||||||
|
|
||||||
Events::CreateParticleSequence ep;
|
|
||||||
ep.parent = entityBrick;
|
|
||||||
ep.EmitterLifeTime = 1.f;
|
|
||||||
ep.ParticleLifeTime = 1.5f;
|
|
||||||
ep.ParticlesPerTick = 1;
|
|
||||||
ep.SpawnRate = 0.2;
|
|
||||||
ep.EmittingAngle = glm::half_pi<float>();
|
|
||||||
ep.Spread = 1.5f;
|
|
||||||
ep.Position = transformComponentBrick->Position;
|
|
||||||
//ep.Radius = 0.05;
|
|
||||||
ep.SpriteFile = "Textures/Particles/FadeBall.png";
|
|
||||||
ep.Color = brickModel->Color + glm::vec4(0.3f);
|
|
||||||
ep.AlphaValues.push_back(1.f);
|
|
||||||
ep.AlphaValues.push_back(0.f);
|
|
||||||
ep.RadiusValues.push_back(0.05f);
|
|
||||||
ep.Speed = 50;
|
|
||||||
EventBroker->Publish(ep);
|
|
||||||
|
|
||||||
//std::cout << "Combo: " << ball->Combo << std::endl;
|
|
||||||
//std::cout << NumberOfBricks() << std::endl;
|
|
||||||
//std::cout << "Brick Score: " << brick->Score << std::endl;
|
|
||||||
//std::cout << "Score: " << Score() << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dd::Systems::LevelSystem::BrickHit(EntityID entityHitter, EntityID entityBrick, int combo)
|
||||||
|
{
|
||||||
|
auto brick = m_World->GetComponent<Components::Brick>(entityBrick);
|
||||||
|
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
|
||||||
|
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
||||||
|
physicsComponent->GravityScale = 1.f;
|
||||||
|
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
||||||
|
|
||||||
|
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
|
||||||
|
auto transformComponentHitter = m_World->GetComponent<Components::Transform>(entityHitter);
|
||||||
|
auto brickModel = m_World->GetComponent<Components::Model>(entityBrick);
|
||||||
|
|
||||||
|
// Check if the brick is any kind of special.
|
||||||
|
auto multi = m_World->GetComponent<Components::MultiBallBrick>(entityBrick);
|
||||||
|
if (multi != nullptr) {
|
||||||
|
Events::MultiBall e;
|
||||||
|
e.padTransform = transformComponentBrick;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto buoy = m_World->GetComponent<Components::LifebuoyBrick>(entityBrick);
|
||||||
|
if (buoy != nullptr) {
|
||||||
|
Events::Lifebuoy e;
|
||||||
|
e.Transform = transformComponentBrick;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto sticky = m_World->GetComponent<Components::StickyBrick>(entityBrick);
|
||||||
|
if (sticky != nullptr) {
|
||||||
|
Events::StickyPad e;
|
||||||
|
e.Transform = transformComponentBrick;
|
||||||
|
e.Times = 3;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto ink = m_World->GetComponent<Components::InkBlasterBrick>(entityBrick);
|
||||||
|
if (ink != nullptr) {
|
||||||
|
Events::InkBlaster e;
|
||||||
|
e.Transform = transformComponentBrick;
|
||||||
|
e.Shots = 5;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto kraken = m_World->GetComponent<Components::KrakenAttackBrick>(entityBrick);
|
||||||
|
if (kraken != nullptr) {
|
||||||
|
Events::KrakenAttack e;
|
||||||
|
e.ChargeUpdate = 0;
|
||||||
|
e.KrakenStrength = 0.1;
|
||||||
|
e.PlayerStrength = 0.05;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Events::SetImpulse e;
|
||||||
|
e.Entity = entityBrick;
|
||||||
|
|
||||||
|
glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentHitter->Position.x - transformComponentBrick->Position.x) / 4),
|
||||||
|
transformComponentBrick->Position.y + ((transformComponentHitter->Position.y - transformComponentBrick->Position.y) / 4));
|
||||||
|
|
||||||
|
e.Impulse = glm::normalize(point)*5.f;
|
||||||
|
e.Point = point;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
|
||||||
|
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||||
|
Events::ScoreEvent es;
|
||||||
|
es.Score = brick->Score * combo;
|
||||||
|
EventBroker->Publish(es);
|
||||||
|
|
||||||
|
Events::CreateParticleSequence ep;
|
||||||
|
ep.parent = entityBrick;
|
||||||
|
ep.EmitterLifeTime = 1.f;
|
||||||
|
ep.ParticleLifeTime = 1.5f;
|
||||||
|
ep.ParticlesPerTick = 1;
|
||||||
|
ep.SpawnRate = 0.2;
|
||||||
|
ep.EmittingAngle = glm::half_pi<float>();
|
||||||
|
ep.Spread = 1.5f;
|
||||||
|
ep.Position = transformComponentBrick->Position;
|
||||||
|
//ep.Radius = 0.05;
|
||||||
|
ep.SpriteFile = "Textures/Particles/FadeBall.png";
|
||||||
|
ep.Color = brickModel->Color + glm::vec4(0.3f);
|
||||||
|
ep.AlphaValues.push_back(1.f);
|
||||||
|
ep.AlphaValues.push_back(0.f);
|
||||||
|
ep.RadiusValues.push_back(0.05f);
|
||||||
|
ep.RadiusDistribution = 0.05;
|
||||||
|
ep.Speed = 50;
|
||||||
|
EventBroker->Publish(ep);
|
||||||
|
}
|
||||||
|
|
||||||
bool dd::Systems::LevelSystem::OnScoreEvent(const dd::Events::ScoreEvent &event)
|
bool dd::Systems::LevelSystem::OnScoreEvent(const dd::Events::ScoreEvent &event)
|
||||||
{
|
{
|
||||||
SetScore(Score() += event.Score);
|
SetScore(Score() += event.Score);
|
||||||
@@ -663,14 +674,14 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
|||||||
1, 4, 1, 1, 1, 3, 1,
|
1, 4, 1, 1, 1, 3, 1,
|
||||||
0, 1, 0, 1, 0, 1, 0,
|
0, 1, 0, 1, 0, 1, 0,
|
||||||
0, 1, 0, 1, 0, 1, 0,
|
0, 1, 0, 1, 0, 1, 0,
|
||||||
1, 5, 1, 1, 1, 2, 1,
|
1, 5, 1, 6, 1, 2, 1,
|
||||||
0, 1, 0, 0, 0, 1, 0};
|
0, 1, 0, 0, 0, 1, 0};
|
||||||
color =
|
color =
|
||||||
{w, p3, w, w, w, r, w,
|
{w, p3, w, w, w, r, w,
|
||||||
p2, w, p1, g, w, w, w,
|
p2, w, p1, g, w, w, w,
|
||||||
w, p4, w, g, w, r, w,
|
w, p4, w, g, w, r, w,
|
||||||
w, br, w, g, w, lb1, w,
|
w, br, w, g, w, lb1, w,
|
||||||
y, w, y, g, b, w, b,
|
y, w, y, d, b, w, b,
|
||||||
w, br, w, w, w, lb1, w};
|
w, br, w, w, w, lb1, w};
|
||||||
}
|
}
|
||||||
} else if (m_CurrentCluster == 3) {
|
} else if (m_CurrentCluster == 3) {
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ void dd::Systems::PadSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PadSystem::OnStageCleared);
|
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PadSystem::OnStageCleared);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack);
|
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &PadSystem::OnStickyPad);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EStickyAttachedToPad, &PadSystem::OnStickyAttachedToPad);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &PadSystem::OnActionButton);
|
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &PadSystem::OnActionButton);
|
||||||
//EVENT_SUBSCRIBE_MEMBER(m_EBindKey, &PadSystem::OnBindKey);
|
//EVENT_SUBSCRIBE_MEMBER(m_EBindKey, &PadSystem::OnBindKey);
|
||||||
|
|
||||||
@@ -53,6 +55,23 @@ void dd::Systems::PadSystem::Initialize()
|
|||||||
|
|
||||||
SetEdge(3.2 - (ctransform->Scale.x / 2));
|
SetEdge(3.2 - (ctransform->Scale.x / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Stick
|
||||||
|
{
|
||||||
|
auto ent = m_World->CreateEntity();
|
||||||
|
m_World->SetProperty(ent, "Name", "Stick");
|
||||||
|
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||||
|
transform->Position = glm::vec3(30.f, 0.f, -10.f);
|
||||||
|
transform->Scale = glm::vec3(0.1f, 25.f, 0.1f);
|
||||||
|
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
|
||||||
|
sprite->SpriteFile = "Models/Brick/White.png";
|
||||||
|
sprite->Color = glm::vec4(0.f, 0.5f, 0.f, 0.5f);
|
||||||
|
std::shared_ptr<Components::StickyAim> sticky = m_World->AddComponent<Components::StickyAim>(ent);
|
||||||
|
m_World->CommitEntity(ent);
|
||||||
|
|
||||||
|
m_StickTransform = transform;
|
||||||
|
m_StickyAim = sticky;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
@@ -63,9 +82,18 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
auto ball = m_World->GetComponent<Components::Ball>(entity);
|
auto ball = m_World->GetComponent<Components::Ball>(entity);
|
||||||
if (ball != nullptr) {
|
if (ball != nullptr) {
|
||||||
if (ball->Sticky) {
|
if (ball->Sticky) {
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto ballTransform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
transform->Position = Transform()->Position;
|
ballTransform->Position = Transform()->Position;
|
||||||
transform->Position += ball->StickyPlacement;
|
ballTransform->Position += ball->StickyPlacement;
|
||||||
|
glm::vec2 dir = glm::normalize(glm::vec2(ball->SavedSpeed.x, ball->SavedSpeed.y));
|
||||||
|
glm::vec2 up = glm::vec2(0.f, 1.f);
|
||||||
|
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
|
||||||
|
ballTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f));
|
||||||
|
m_StickTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, 1.f));
|
||||||
|
m_StickTransform->Position = ballTransform->Position;
|
||||||
|
}
|
||||||
|
if (!m_StickyAim->Aiming) {
|
||||||
|
m_StickTransform->Position = glm::vec3(30.f, 0.f, 0.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,7 +209,15 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
|
|||||||
} else if (val == GLFW_KEY_S) {
|
} else if (val == GLFW_KEY_S) {
|
||||||
Events::StageCleared e;
|
Events::StageCleared e;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
} else if (val == GLFW_KEY_K) {
|
} else if (val == GLFW_KEY_Y) {
|
||||||
|
Events::StickyPad e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else if (val == GLFW_KEY_I) {
|
||||||
|
Events::InkBlaster e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else if (val == GLFW_KEY_K) {
|
||||||
Events::KrakenAttack e;
|
Events::KrakenAttack e;
|
||||||
e.ChargeUpdate = 0;
|
e.ChargeUpdate = 0;
|
||||||
e.KrakenStrength = 0.1;
|
e.KrakenStrength = 0.1;
|
||||||
@@ -333,6 +369,17 @@ bool dd::Systems::PadSystem::OnKrakenAttack(const dd::Events::KrakenAttack &even
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::PadSystem::OnStickyPad(const dd::Events::StickyPad &event)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::PadSystem::OnStickyAttachedToPad(const dd::Events::StickyAttachedToPad &event)
|
||||||
|
{
|
||||||
|
m_StickyAim->Aiming = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool dd::Systems::PadSystem::OnActionButton(const dd::Events::ActionButton &event)
|
bool dd::Systems::PadSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||||
{
|
{
|
||||||
if (m_KrakenAttack) {
|
if (m_KrakenAttack) {
|
||||||
@@ -344,6 +391,7 @@ bool dd::Systems::PadSystem::OnActionButton(const dd::Events::ActionButton &even
|
|||||||
e.PlayerStrength = 0;
|
e.PlayerStrength = 0;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
m_StickyAim->Aiming = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ bool dd::Systems::ProjectileSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
||||||
{
|
{
|
||||||
m_InkBlaster = true;
|
m_InkBlaster = true;
|
||||||
m_Shots = 5;
|
m_Shots = event.Shots;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
|||||||
if (m_DistanceTravelled > 12.f) {
|
if (m_DistanceTravelled > 12.f) {
|
||||||
m_DistanceTravelled = 0;
|
m_DistanceTravelled = 0;
|
||||||
m_Travelling = false;
|
m_Travelling = false;
|
||||||
|
Events::ArrivedAtNewStage e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DistanceTravelled += 6.0f * dt;
|
m_DistanceTravelled += 6.0f * dt;
|
||||||
@@ -297,7 +299,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->Radius = ScalarInterpolation(timeProgress, emitter->RadiusValues);
|
if (emitter->RadiusValues.size() >= 1) {
|
||||||
|
particle->Radius = ScalarInterpolation(timeProgress, emitter->RadiusValues);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,24 +550,40 @@ void dd::Systems::PhysicsSystem::UpdateParticleEmitters(double dt)
|
|||||||
particleDef.flags = particleTemplate->Flags;
|
particleDef.flags = particleTemplate->Flags;
|
||||||
//particleDef.color TODO: Implement this if we want color mixing and shit.
|
//particleDef.color TODO: Implement this if we want color mixing and shit.
|
||||||
particleDef.lifetime = particleTemplate->LifeTime;
|
particleDef.lifetime = particleTemplate->LifeTime;
|
||||||
float eAngle = emitter->EmittingAngle;
|
|
||||||
|
//random angle
|
||||||
|
float eAngle = emitter->EmittingAngle;
|
||||||
float halfSpread = emitter->Spread / 2;
|
float halfSpread = emitter->Spread / 2;
|
||||||
|
|
||||||
std::uniform_real_distribution<float> dis(eAngle - halfSpread, eAngle + halfSpread);
|
std::uniform_real_distribution<float> dis(eAngle - halfSpread, eAngle + halfSpread);
|
||||||
float pAngle = dis(gen);
|
float pAngle = dis(gen);
|
||||||
|
|
||||||
|
//Using angle to determine velocity
|
||||||
std::uniform_real_distribution<float> dis2(0.3, 1.5);
|
std::uniform_real_distribution<float> dis2(0.3, 1.5);
|
||||||
float speedMultiplier = dis2(gen);
|
float speedMultiplier = dis2(gen);
|
||||||
glm::vec2 unitVec = glm::normalize(glm::vec2(glm::cos(pAngle), glm::sin(pAngle)));
|
glm::vec2 unitVec = glm::normalize(glm::vec2(glm::cos(pAngle), glm::sin(pAngle)));
|
||||||
glm::vec2 vel = unitVec * emitter->Speed * (float)dt * speedMultiplier * 0.5f;
|
glm::vec2 vel = unitVec * emitter->Speed * (float)dt * speedMultiplier;
|
||||||
particleDef.velocity = b2Vec2(vel.x, vel.y);
|
particleDef.velocity = b2Vec2(vel.x, vel.y);
|
||||||
|
|
||||||
|
//position
|
||||||
particleDef.position = b2Vec2(emitterTransform->Position.x, emitterTransform->Position.y);
|
particleDef.position = b2Vec2(emitterTransform->Position.x, emitterTransform->Position.y);
|
||||||
|
|
||||||
|
|
||||||
auto particle = m_World->CloneEntity(pt, 0);
|
auto particle = m_World->CloneEntity(pt, 0);
|
||||||
m_World->RemoveComponent<Components::Template>(particle);
|
m_World->RemoveComponent<Components::Template>(particle);
|
||||||
auto particleTransform = m_World->GetComponent<Components::Transform>(particle);
|
auto particleTransform = m_World->GetComponent<Components::Transform>(particle);
|
||||||
|
auto particleComponent = m_World->GetComponent<Components::Particle>(particle);
|
||||||
|
|
||||||
|
float radius = emitter->RadiusValues[0];
|
||||||
|
if (emitter->RadiusDistribution != 0) {
|
||||||
|
float halfRadius = emitter->RadiusDistribution / 2;
|
||||||
|
std::uniform_real_distribution<float> dis3(radius - halfRadius, radius + halfRadius);
|
||||||
|
radius = dis3(gen);
|
||||||
|
//emitter->RadiusValues[0] = radius;
|
||||||
|
}
|
||||||
|
//particleTransform->Scale = glm::vec3(radius * 2, radius * 2, 1);
|
||||||
|
particleComponent->Radius = radius;
|
||||||
|
|
||||||
|
//Random z-value
|
||||||
std::uniform_real_distribution<float> dist(0, 1);
|
std::uniform_real_distribution<float> dist(0, 1);
|
||||||
float zDistribution = dist(gen);
|
float zDistribution = dist(gen);
|
||||||
particleTransform->Position = glm::vec3(emitterTransform->Position.x, emitterTransform->Position.y, -9.5f + zDistribution);
|
particleTransform->Position = glm::vec3(emitterTransform->Position.x, emitterTransform->Position.y, -9.5f + zDistribution);
|
||||||
@@ -640,6 +660,7 @@ bool dd::Systems::PhysicsSystem::CreateParticleSequence(const Events::CreatePart
|
|||||||
particleEmitter->LifeTime = event.EmitterLifeTime;
|
particleEmitter->LifeTime = event.EmitterLifeTime;
|
||||||
particleEmitter->AlphaValues = event.AlphaValues;
|
particleEmitter->AlphaValues = event.AlphaValues;
|
||||||
particleEmitter->RadiusValues = event.RadiusValues;
|
particleEmitter->RadiusValues = event.RadiusValues;
|
||||||
|
particleEmitter->RadiusDistribution = event.RadiusDistribution;
|
||||||
{
|
{
|
||||||
//Creating Particle Template
|
//Creating Particle Template
|
||||||
auto particle = m_World->CreateEntity(emitter);
|
auto particle = m_World->CreateEntity(emitter);
|
||||||
@@ -716,10 +737,12 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
{
|
{
|
||||||
//Check if it is a brick colliding with ball
|
//Check if it is a brick colliding with ball
|
||||||
auto brick = m_World->GetComponent<Components::Brick>(event.Entity1);
|
auto brick = m_World->GetComponent<Components::Brick>(event.Entity1);
|
||||||
|
EntityID entity = event.Entity1;
|
||||||
Components::Model* model;
|
Components::Model* model;
|
||||||
auto ball = m_World->GetComponent<Components::Ball>(event.Entity2);
|
auto ball = m_World->GetComponent<Components::Ball>(event.Entity2);
|
||||||
if (!brick) {
|
if (!brick) {
|
||||||
brick = m_World->GetComponent<Components::Brick>(event.Entity2);
|
brick = m_World->GetComponent<Components::Brick>(event.Entity2);
|
||||||
|
EntityID entity = event.Entity2;
|
||||||
if (!brick) {
|
if (!brick) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -737,24 +760,59 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
|
|
||||||
model = m_World->GetComponent<Components::Model>(event.Entity1);
|
model = m_World->GetComponent<Components::Model>(event.Entity1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Spawn a particle when a brick collides with somthing
|
||||||
Events::CreateParticleSequence e;
|
Events::CreateParticleSequence e;
|
||||||
e.EmitterLifeTime = 4;
|
e.EmitterLifeTime = 3;
|
||||||
//- glm::atan(event.Normal.x, event.Normal.y
|
|
||||||
e.EmittingAngle = glm::half_pi<float>();
|
e.EmittingAngle = glm::half_pi<float>();
|
||||||
e.Spread = 0.5f;
|
e.Spread = 0.f;
|
||||||
e.NumberOfTicks = 1;
|
e.NumberOfTicks = 1;
|
||||||
e.ParticleLifeTime = 1.f;
|
e.ParticleLifeTime = 1.f;
|
||||||
e.ParticlesPerTick = 15;
|
e.ParticlesPerTick = 1;
|
||||||
e.Position = glm::vec3(event.IntersectionPoint.x, event.IntersectionPoint.y, -10);
|
e.Position = glm::vec3(event.IntersectionPoint.x, event.IntersectionPoint.y, -7);
|
||||||
e.RadiusValues.push_back(0.2);
|
e.Color = glm::vec4(1.f);
|
||||||
e.RadiusValues.push_back(1);
|
|
||||||
e.SpriteFile = "Textures/Particles/Cloud_Particle.png";
|
|
||||||
e.Color = model->Color + glm::vec4(0.5f);
|
|
||||||
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.Speed = 100;
|
e.Speed = 0;
|
||||||
|
|
||||||
|
auto PowerFriend = m_World->GetComponent<Components::MultiBallBrick>(entity);
|
||||||
|
auto PowerSaviour = m_World->GetComponent<Components::LifebuoyBrick>(entity);
|
||||||
|
auto PowerSticky = m_World->GetComponent<Components::StickyBrick>(entity);
|
||||||
|
auto PowerInkBlaster = m_World->GetComponent<Components::InkBlasterBrick>(entity);
|
||||||
|
auto PowerKraken = m_World->GetComponent<Components::KrakenAttackBrick>(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<float>();
|
||||||
|
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.RadiusValues.push_back(0.2);
|
||||||
|
e.RadiusValues.push_back(1);
|
||||||
|
e.SpriteFile = "Textures/Particles/Cloud_Particle.png";
|
||||||
|
e.Color = model->Color + glm::vec4(0.5f);
|
||||||
|
e.AlphaValues.push_back(1.f);
|
||||||
|
e.AlphaValues.push_back(0.f);
|
||||||
|
e.Speed = 100;
|
||||||
|
}
|
||||||
|
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user