diff --git a/include/Game/BallSystem.h b/include/Game/BallSystem.h index b6d312a..d4faa03 100644 --- a/include/Game/BallSystem.h +++ b/include/Game/BallSystem.h @@ -1,152 +1,152 @@ -#ifndef DAYDREAM_BALLSYSTEM_H -#define DAYDREAM_BALLSYSTEM_H - -#include "Core/System.h" -#include "Core/World.h" -#include "Core/EventBroker.h" -#include "Core/CTransform.h" -#include "Core/CTemplate.h" -#include "Physics/CPhysics.h" -#include "Physics/CCircleShape.h" -#include "Physics/CRectangleShape.h" -#include "Physics/EContact.h" -#include "Rendering/CModel.h" -#include "Rendering/CSprite.h" -#include "Rendering/CPointLight.h" -#include "Game/CBall.h" -#include "Game/CPowerUp.h" -#include "Game/CLife.h" -#include "Game/CBrick.h" -#include "Game/CLifebuoy.h" -#include "Game/ELifeLost.h" -#include "Game/EComboEvent.h" -#include "Game/EResetBall.h" -#include "Game/EMultiBall.h" -#include "Game/EMultiBallLost.h" -#include "Game/EStickyPad.h" -#include "Game/EStickyAttachedToPad.h" -#include "Game/EInkBlaster.h" -#include "Game/EInkBlasterOver.h" -#include "Game/EStageCleared.h" -#include "Game/EArrivedAtNewStage.h" -#include "Game/EGameOver.h" -#include "Game/EPause.h" -#include "Game/EHitPad.h" -#include "Game/EHitLag.h" +#ifndef DAYDREAM_BALLSYSTEM_H +#define DAYDREAM_BALLSYSTEM_H + +#include "Core/System.h" +#include "Core/World.h" +#include "Core/EventBroker.h" +#include "Core/CTransform.h" +#include "Core/CTemplate.h" +#include "Physics/CPhysics.h" +#include "Physics/CCircleShape.h" +#include "Physics/CRectangleShape.h" +#include "Physics/EContact.h" +#include "Rendering/CModel.h" +#include "Rendering/CSprite.h" +#include "Rendering/CPointLight.h" +#include "Game/CBall.h" +#include "Game/CPowerUp.h" +#include "Game/CLife.h" +#include "Game/CBrick.h" +#include "Game/CLifebuoy.h" +#include "Game/ELifeLost.h" +#include "Game/EComboEvent.h" +#include "Game/EResetBall.h" +#include "Game/EMultiBall.h" +#include "Game/EMultiBallLost.h" +#include "Game/EStickyPad.h" +#include "Game/EStickyAttachedToPad.h" +#include "Game/EInkBlaster.h" +#include "Game/EInkBlasterOver.h" +#include "Game/EStageCleared.h" +#include "Game/EArrivedAtNewStage.h" +#include "Game/EGameOver.h" +#include "Game/EPause.h" +#include "Game/EHitPad.h" +#include "Game/EHitLag.h" #include "Game/EActionButton.h" -#include "Game/ELifebuoyHit.h" -#include "Physics/ECreateParticleSequence.h" - -namespace dd -{ - -namespace Systems -{ - -class BallSystem : public System -{ -public: - BallSystem(World *world, std::shared_ptr eventBroker) - : System(world, eventBroker) { } - - ~BallSystem(); - - - - void RegisterComponents(ComponentFactory *cf) override; - - void Initialize() override; - - // Called once per system every tick - void Update(double dt) override; - - // Called once for every entity in the world every tick - void UpdateEntity(double dt, EntityID entity, EntityID parent) override; - - // Called when components are committed to an entity - void OnEntityCommit(EntityID entity) override; - - // Called when an entity is removed - void OnEntityRemoved(EntityID entity) override; - - EntityID CreateBall(); - void CreateLife(int); - EntityID Ball() { return m_Ball; }; - void SetBall(const EntityID& ball) { m_Ball = ball; } - - float& XMovementMultiplier() { return m_XMovementMultiplier; } - void SetXMovementMultiplier(const float& xMovementMultiplier) { m_XMovementMultiplier = xMovementMultiplier; } - float& EdgeX() { return m_EdgeX; } - void SetEdgeX(const float& edgeX) { m_EdgeX = edgeX; } - float& EdgeY() { return m_EdgeY; } - void SetEdgeY(const float& edgeY) { m_EdgeY = edgeY; } - int& MultiBalls() { return m_MultiBalls; } - void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; } - int& Lives() { return m_Lives; } - void SetLives(const int& lives) { m_Lives = lives; } - int& PastLives() { return m_PastLives; } - void SetPastLives(const int& pastLives) { m_PastLives = pastLives; } - bool ReplaceBall() const { return m_ReplaceBall; } - void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; } - bool IsPaused() const { return m_Pause; } - void SetPause(const bool& pause) { m_Pause = pause; } - -private: - float m_XMovementMultiplier = 2.f; - float m_EdgeX = 3.2f; - float m_EdgeY = 5.2f; - int m_MultiBalls = 0; - int m_Lives = 3; - int m_PastLives = 3; - bool m_ReplaceBall = false; - bool m_Pause = false; - bool m_Waiting = true; - bool m_Sticky = false; - bool m_InkBlaster = false; - bool m_InkAttached = false; - bool m_InkBlockedWaiting = false; - bool m_Restarting = false; - int m_StickyCounter = 3; - - bool m_StageBlockedWaiting = false; - - glm::vec3 m_SavedSpeed; - bool m_InitializePause = false; - - EntityID m_Ball; - - std::unordered_map> m_Contacts; - void ResolveContacts(); - - dd::EventRelay m_ELifeLost; - dd::EventRelay m_EMultiBallLost; - dd::EventRelay m_EResetBall; - dd::EventRelay m_EMultiBall; - dd::EventRelay m_EStickyPad; - dd::EventRelay m_EInkBlaster; - dd::EventRelay m_EInkBlasterOver; - dd::EventRelay m_EPause; - dd::EventRelay m_Contact; - dd::EventRelay m_EActionButton; - dd::EventRelay m_EStageCleared; - dd::EventRelay m_EArrivedAtNewStage; - - bool Contact(const Events::Contact &event); - bool OnLifeLost(const dd::Events::LifeLost &event); - bool OnMultiBallLost(const dd::Events::MultiBallLost &event); - bool OnResetBall(const dd::Events::ResetBall &event); - bool OnMultiBall(const dd::Events::MultiBall &event); - bool OnStickyPad(const dd::Events::StickyPad &event); - bool OnInkBlaster(const dd::Events::InkBlaster &event); - bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event); - bool OnPause(const dd::Events::Pause &event); - bool OnActionButton(const dd::Events::ActionButton &event); - bool OnStageCleared(const dd::Events::StageCleared &event); - bool OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event); -}; - -} - -} - -#endif +#include "Game/ELifebuoyHit.h" +#include "Physics/ECreateParticleSequence.h" + +namespace dd +{ + +namespace Systems +{ + +class BallSystem : public System +{ +public: + BallSystem(World *world, std::shared_ptr eventBroker) + : System(world, eventBroker) { } + + ~BallSystem(); + + + + void RegisterComponents(ComponentFactory *cf) override; + + void Initialize() override; + + // Called once per system every tick + void Update(double dt) override; + + // Called once for every entity in the world every tick + void UpdateEntity(double dt, EntityID entity, EntityID parent) override; + + // Called when components are committed to an entity + void OnEntityCommit(EntityID entity) override; + + // Called when an entity is removed + void OnEntityRemoved(EntityID entity) override; + + EntityID CreateBall(); + void CreateLife(int); + EntityID Ball() { return m_Ball; }; + void SetBall(const EntityID& ball) { m_Ball = ball; } + + float& XMovementMultiplier() { return m_XMovementMultiplier; } + void SetXMovementMultiplier(const float& xMovementMultiplier) { m_XMovementMultiplier = xMovementMultiplier; } + float& EdgeX() { return m_EdgeX; } + void SetEdgeX(const float& edgeX) { m_EdgeX = edgeX; } + float& EdgeY() { return m_EdgeY; } + void SetEdgeY(const float& edgeY) { m_EdgeY = edgeY; } + int& MultiBalls() { return m_MultiBalls; } + void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; } + int& Lives() { return m_Lives; } + void SetLives(const int& lives) { m_Lives = lives; } + int& PastLives() { return m_PastLives; } + void SetPastLives(const int& pastLives) { m_PastLives = pastLives; } + bool ReplaceBall() const { return m_ReplaceBall; } + void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; } + bool IsPaused() const { return m_Pause; } + void SetPause(const bool& pause) { m_Pause = pause; } + +private: + float m_XMovementMultiplier = 2.f; + float m_EdgeX = 3.2f; + float m_EdgeY = 5.2f; + int m_MultiBalls = 0; + int m_Lives = 3; + int m_PastLives = 3; + bool m_ReplaceBall = false; + bool m_Pause = false; + bool m_Waiting = true; + bool m_Sticky = false; + bool m_InkBlaster = false; + bool m_InkAttached = false; + bool m_InkBlockedWaiting = false; + bool m_Restarting = false; + int m_StickyCounter = 3; + + bool m_StageBlockedWaiting = false; + + glm::vec3 m_SavedSpeed; + bool m_InitializePause = false; + + EntityID m_Ball; + + std::unordered_map> m_Contacts; + void ResolveContacts(); + + dd::EventRelay m_ELifeLost; + dd::EventRelay m_EMultiBallLost; + dd::EventRelay m_EResetBall; + dd::EventRelay m_EMultiBall; + dd::EventRelay m_EStickyPad; + dd::EventRelay m_EInkBlaster; + dd::EventRelay m_EInkBlasterOver; + dd::EventRelay m_EPause; + dd::EventRelay m_Contact; + dd::EventRelay m_EActionButton; + dd::EventRelay m_EStageCleared; + dd::EventRelay m_EArrivedAtNewStage; + + bool Contact(const Events::Contact &event); + bool OnLifeLost(const dd::Events::LifeLost &event); + bool OnMultiBallLost(const dd::Events::MultiBallLost &event); + bool OnResetBall(const dd::Events::ResetBall &event); + bool OnMultiBall(const dd::Events::MultiBall &event); + bool OnStickyPad(const dd::Events::StickyPad &event); + bool OnInkBlaster(const dd::Events::InkBlaster &event); + bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event); + bool OnPause(const dd::Events::Pause &event); + bool OnActionButton(const dd::Events::ActionButton &event); + bool OnStageCleared(const dd::Events::StageCleared &event); + bool OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event); +}; + +} + +} + +#endif diff --git a/src/game/Game/BallSystem.cpp b/src/game/Game/BallSystem.cpp index 4088aed..b2a0301 100644 --- a/src/game/Game/BallSystem.cpp +++ b/src/game/Game/BallSystem.cpp @@ -289,7 +289,7 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event) float y = glm::cos((abs(x) / (1.6f)) * glm::pi() / 2.f) + 1.f; //When a combo is more than 2 create a particle showing it. - if (ballComponent->Combo >= 1){ + if (ballComponent->Combo >= 2){ Events::CreateParticleSequence particleEvent; @@ -311,10 +311,10 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event) if (ballComponent->Combo <= 9) { particleEvent.SpriteFile = "Textures/Combo/Combo00" + std::to_string(ballComponent->Combo) + ".png"; - } else if (ballComponent->Combo <= 99) { + } else if (ballComponent->Combo <= 42) { particleEvent.SpriteFile = "Textures/Combo/Combo0" + std::to_string(ballComponent->Combo) + ".png"; } else { - particleEvent.SpriteFile = "Textures/Combo/Combo" + std::to_string(ballComponent->Combo) + ".png"; + particleEvent.SpriteFile = "Textures/Combo/Combo043.png"; } EventBroker->Publish(particleEvent); } @@ -322,7 +322,7 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event) - ballComponent->Combo = 0; + ballComponent->Combo = 56; if (!ballComponent->Waiting) { if (m_InkBlaster) { if (!m_InkAttached) {