P-button pauses, H-button does 0.3 second HitLag.
This commit is contained in:
@@ -130,31 +130,6 @@ public:
|
|||||||
m_World->ComponentFactory.Register<Components::WaterVolume>();
|
m_World->ComponentFactory.Register<Components::WaterVolume>();
|
||||||
m_World->Initialize();
|
m_World->Initialize();
|
||||||
|
|
||||||
|
|
||||||
//OctoBall
|
|
||||||
{
|
|
||||||
auto ent = m_World->CreateEntity();
|
|
||||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
|
||||||
transform->Position = glm::vec3(-0.f, 0.26f, -10.f);
|
|
||||||
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
|
||||||
transform->Velocity = glm::vec3(0.0f, -10.f, 0.f);
|
|
||||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
|
||||||
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
|
||||||
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
|
||||||
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
|
|
||||||
ball->Speed = 5.f;
|
|
||||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
|
||||||
physics->Static = false;
|
|
||||||
physics->Category = CollisionLayer::Type::Ball;
|
|
||||||
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
|
|
||||||
physics->Calculate = true;
|
|
||||||
|
|
||||||
//auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
|
||||||
//plight->Radius = 2.f;
|
|
||||||
|
|
||||||
m_World->CommitEntity(ent);
|
|
||||||
}
|
|
||||||
|
|
||||||
//PointLightTest
|
//PointLightTest
|
||||||
{
|
{
|
||||||
auto t_Light = m_World->CreateEntity();
|
auto t_Light = m_World->CreateEntity();
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include "Game/EMultiBall.h"
|
#include "Game/EMultiBall.h"
|
||||||
#include "Game/EMultiBallLost.h"
|
#include "Game/EMultiBallLost.h"
|
||||||
#include "Game/EGameOver.h"
|
#include "Game/EGameOver.h"
|
||||||
|
#include "Game/EPause.h"
|
||||||
|
#include "Game/EHitLag.h"
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
@@ -75,6 +77,10 @@ public:
|
|||||||
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
||||||
bool MultiBall() const { return m_MultiBall; }
|
bool MultiBall() const { return m_MultiBall; }
|
||||||
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
|
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
|
||||||
|
bool Pause() const { return m_Pause; }
|
||||||
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
|
bool HitLag() const { return m_HitLag; }
|
||||||
|
void SetHitLag(const bool& hitLag) { m_HitLag = hitLag; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_XMovementMultiplier = 2.f;
|
float m_XMovementMultiplier = 2.f;
|
||||||
@@ -85,6 +91,13 @@ private:
|
|||||||
int m_PastLives = 3;
|
int m_PastLives = 3;
|
||||||
bool m_ReplaceBall = false;
|
bool m_ReplaceBall = false;
|
||||||
bool m_MultiBall = false;
|
bool m_MultiBall = false;
|
||||||
|
bool m_Pause = false;
|
||||||
|
|
||||||
|
bool m_HitLag = false;
|
||||||
|
float m_Time;
|
||||||
|
float m_SlowdownTime;
|
||||||
|
float m_HitLagTimer = 0;
|
||||||
|
float m_HitLagPlacement = 0;
|
||||||
|
|
||||||
EntityID m_Ball;
|
EntityID m_Ball;
|
||||||
|
|
||||||
@@ -92,11 +105,15 @@ private:
|
|||||||
dd::EventRelay<BallSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
|
dd::EventRelay<BallSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
|
||||||
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
||||||
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||||
|
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||||
|
dd::EventRelay<BallSystem, dd::Events::HitLag> m_EHitLag;
|
||||||
|
|
||||||
bool OnLifeLost(const dd::Events::LifeLost &event);
|
bool OnLifeLost(const dd::Events::LifeLost &event);
|
||||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||||
bool OnResetBall(const dd::Events::ResetBall &event);
|
bool OnResetBall(const dd::Events::ResetBall &event);
|
||||||
bool OnMultiBall(const dd::Events::MultiBall &event);
|
bool OnMultiBall(const dd::Events::MultiBall &event);
|
||||||
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
|
bool OnHitLag(const dd::Events::HitLag &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
//
|
||||||
|
// Created by Administrator on 2015-09-30.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_EHITLAG_H
|
||||||
|
#define DAYDREAM_EHITLAG_H
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct HitLag : Event
|
||||||
|
{
|
||||||
|
float Time;
|
||||||
|
std::string Type;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_EHITLAG_H
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-09-30.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_EPAUSE_H
|
||||||
|
#define DAYDREAM_EPAUSE_H
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Pause : Event
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_EPAUSE_H
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "Game/EComboEvent.h"
|
#include "Game/EComboEvent.h"
|
||||||
#include "Game/EMultiBall.h"
|
#include "Game/EMultiBall.h"
|
||||||
#include "Game/EMultiBallLost.h"
|
#include "Game/EMultiBallLost.h"
|
||||||
|
#include "Game/EPause.h"
|
||||||
#include "Game/EGameOver.h"
|
#include "Game/EGameOver.h"
|
||||||
#include "Game/ECreatePowerUp.h"
|
#include "Game/ECreatePowerUp.h"
|
||||||
#include "Game/EPowerUpTaken.h"
|
#include "Game/EPowerUpTaken.h"
|
||||||
@@ -80,6 +81,8 @@ public:
|
|||||||
void SetRestarting(const bool& restarting) { m_Restarting = restarting; }
|
void SetRestarting(const bool& restarting) { m_Restarting = restarting; }
|
||||||
bool Initialized() const { return m_Initialized; }
|
bool Initialized() const { return m_Initialized; }
|
||||||
void SetInitialized(const bool& initialized) { m_Initialized = initialized; }
|
void SetInitialized(const bool& initialized) { m_Initialized = initialized; }
|
||||||
|
bool Pause() const { return m_Pause; }
|
||||||
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
int& MultiBalls() { return m_MultiBalls; }
|
int& MultiBalls() { return m_MultiBalls; }
|
||||||
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
||||||
int& PowerUps() { return m_PowerUps; }
|
int& PowerUps() { return m_PowerUps; }
|
||||||
@@ -103,6 +106,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool m_Restarting = false;
|
bool m_Restarting = false;
|
||||||
bool m_Initialized = false;
|
bool m_Initialized = false;
|
||||||
|
bool m_Pause = false;
|
||||||
int m_MultiBalls = 0;
|
int m_MultiBalls = 0;
|
||||||
int m_PowerUps = 0;
|
int m_PowerUps = 0;
|
||||||
int m_Score = 0;
|
int m_Score = 0;
|
||||||
@@ -120,6 +124,7 @@ private:
|
|||||||
dd::EventRelay<LevelSystem, dd::Events::CreatePowerUp> m_ECreatePowerUp;
|
dd::EventRelay<LevelSystem, dd::Events::CreatePowerUp> m_ECreatePowerUp;
|
||||||
dd::EventRelay<LevelSystem, dd::Events::PowerUpTaken> m_EPowerUpTaken;
|
dd::EventRelay<LevelSystem, dd::Events::PowerUpTaken> m_EPowerUpTaken;
|
||||||
dd::EventRelay<LevelSystem, dd::Events::StageCleared> m_EStageCleared;
|
dd::EventRelay<LevelSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||||
|
dd::EventRelay<LevelSystem, dd::Events::Pause> m_EPause;
|
||||||
|
|
||||||
bool OnContact(const dd::Events::Contact &event);
|
bool OnContact(const dd::Events::Contact &event);
|
||||||
bool OnScoreEvent(const dd::Events::ScoreEvent &event);
|
bool OnScoreEvent(const dd::Events::ScoreEvent &event);
|
||||||
@@ -128,6 +133,7 @@ private:
|
|||||||
bool OnCreatePowerUp(const dd::Events::CreatePowerUp &event);
|
bool OnCreatePowerUp(const dd::Events::CreatePowerUp &event);
|
||||||
bool OnPowerUpTaken(const dd::Events::PowerUpTaken &event);
|
bool OnPowerUpTaken(const dd::Events::PowerUpTaken &event);
|
||||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||||
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
#include "Game/EMultiBall.h"
|
#include "Game/EMultiBall.h"
|
||||||
#include "Game/EPowerUpTaken.h"
|
#include "Game/EPowerUpTaken.h"
|
||||||
#include "Game/EStageCleared.h"
|
#include "Game/EStageCleared.h"
|
||||||
|
#include "Game/EPause.h"
|
||||||
|
#include "Game/EHitLag.h"
|
||||||
|
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
@@ -63,6 +65,9 @@ public:
|
|||||||
Components::Pad* Pad() const { return m_Pad; }
|
Components::Pad* Pad() const { return m_Pad; }
|
||||||
void SetPad(Components::Pad* pad) { m_Pad = pad; }
|
void SetPad(Components::Pad* pad) { m_Pad = pad; }
|
||||||
|
|
||||||
|
bool Pause() const { return m_Pause; }
|
||||||
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EntityID m_Entity = 0;
|
EntityID m_Entity = 0;
|
||||||
glm::vec3 m_Acceleration = glm::vec3(0.f, 0.f, 0.f);
|
glm::vec3 m_Acceleration = glm::vec3(0.f, 0.f, 0.f);
|
||||||
@@ -72,18 +77,21 @@ private:
|
|||||||
Components::Transform* m_Transform;
|
Components::Transform* m_Transform;
|
||||||
Components::Pad* m_Pad;
|
Components::Pad* m_Pad;
|
||||||
|
|
||||||
|
bool m_Pause = false;
|
||||||
|
|
||||||
dd::EventRelay<PadSystem, dd::Events::KeyDown> m_EKeyDown;
|
dd::EventRelay<PadSystem, dd::Events::KeyDown> m_EKeyDown;
|
||||||
dd::EventRelay<PadSystem, dd::Events::KeyUp> m_EKeyUp;
|
dd::EventRelay<PadSystem, dd::Events::KeyUp> m_EKeyUp;
|
||||||
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContact;
|
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContact;
|
||||||
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContactPowerUp;
|
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContactPowerUp;
|
||||||
dd::EventRelay<PadSystem, dd::Events::StageCleared> m_EStageCleared;
|
dd::EventRelay<PadSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||||
|
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
||||||
|
|
||||||
bool OnKeyDown(const dd::Events::KeyDown &event);
|
bool OnKeyDown(const dd::Events::KeyDown &event);
|
||||||
bool OnKeyUp(const dd::Events::KeyUp &event);
|
bool OnKeyUp(const dd::Events::KeyUp &event);
|
||||||
|
|
||||||
bool OnContact(const dd::Events::Contact &event);
|
bool OnContact(const dd::Events::Contact &event);
|
||||||
bool OnContactPowerUp(const dd::Events::Contact &event);
|
bool OnContactPowerUp(const dd::Events::Contact &event);
|
||||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||||
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
|
|
||||||
class PadSteeringInputController;
|
class PadSteeringInputController;
|
||||||
std::array<std::shared_ptr<PadSteeringInputController>, 4> m_PadInputControllers;
|
std::array<std::shared_ptr<PadSteeringInputController>, 4> m_PadInputControllers;
|
||||||
|
|||||||
@@ -3,21 +3,23 @@
|
|||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "Core/CTransform.h"
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "CRectangleShape.h"
|
#include "Core/EventBroker.h"
|
||||||
|
#include "Physics/CRectangleShape.h"
|
||||||
|
#include "Physics/CCircleShape.h"
|
||||||
#include "Physics/CPhysics.h"
|
#include "Physics/CPhysics.h"
|
||||||
#include <Box2D/Box2D.h>
|
#include "Physics/CWaterVolume.h"
|
||||||
#include "Core/CTransform.h"
|
|
||||||
#include "Transform/TransformSystem.h"
|
|
||||||
#include "Physics/EContact.h"
|
#include "Physics/EContact.h"
|
||||||
#include "Physics/ESetImpulse.h"
|
#include "Physics/ESetImpulse.h"
|
||||||
#include "Physics/CCircleShape.h"
|
#include "Game/EPause.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Game/EHitLag.h"
|
||||||
#include "Game/CPad.h"
|
#include "Game/CPad.h"
|
||||||
#include "Physics/CWaterVolume.h"
|
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
|
#include "Transform/TransformSystem.h"
|
||||||
#include "Rendering/CSprite.h"
|
#include "Rendering/CSprite.h"
|
||||||
|
#include <Box2D/Box2D.h>
|
||||||
|
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
@@ -54,11 +56,28 @@ public:
|
|||||||
// Called when an entity is removed
|
// Called when an entity is removed
|
||||||
void OnEntityRemoved(EntityID entity) override;
|
void OnEntityRemoved(EntityID entity) override;
|
||||||
|
|
||||||
|
bool Pause() const { return m_Pause; }
|
||||||
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
|
bool HitLag() const { return m_HitLag; }
|
||||||
|
void SetHitLag(const bool& hitLag) { m_HitLag = hitLag; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
b2Vec2 m_Gravity;
|
b2Vec2 m_Gravity;
|
||||||
b2World* m_PhysicsWorld;
|
b2World* m_PhysicsWorld;
|
||||||
double m_TimeStep;
|
double m_TimeStep;
|
||||||
double m_Accumulator;
|
double m_Accumulator;
|
||||||
|
bool m_Pause = false;
|
||||||
|
|
||||||
|
bool m_HitLag = false;
|
||||||
|
float m_Time;
|
||||||
|
float m_SlowdownTime;
|
||||||
|
float m_HitLagTimer = 0;
|
||||||
|
float m_HitLagPlacement = 0;
|
||||||
|
|
||||||
|
dd::EventRelay<PhysicsSystem, dd::Events::Pause> m_EPause;
|
||||||
|
dd::EventRelay<PhysicsSystem, dd::Events::HitLag> m_EHitLag;
|
||||||
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
|
bool OnHitLag(const dd::Events::HitLag &event);
|
||||||
|
|
||||||
int m_VelocityIterations, m_PositionIterations;
|
int m_VelocityIterations, m_PositionIterations;
|
||||||
|
|
||||||
|
|||||||
@@ -18,26 +18,42 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &BallSystem::OnMultiBallLost);
|
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &BallSystem::OnMultiBallLost);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &BallSystem::OnResetBall);
|
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &BallSystem::OnResetBall);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EHitLag, &BallSystem::OnHitLag);
|
||||||
|
|
||||||
auto ent = m_World->CreateEntity();
|
//OctoBall
|
||||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
{
|
||||||
transform->Position = glm::vec3(-0.f, 50.f, -10.f);
|
auto ent = m_World->CreateEntity();
|
||||||
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||||
transform->Velocity = glm::vec3(0.0f, 0.f, 0.f);
|
transform->Position = glm::vec3(-0.f, 50.26f, -10.f);
|
||||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||||
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||||
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
|
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
||||||
ball->Speed = 5.f;
|
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
|
||||||
std::shared_ptr<Components::Template> ballTemplate = m_World->AddComponent<Components::Template>(ent);
|
ball->Speed = 5.f;
|
||||||
physics->Static = false;
|
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||||
physics->Category = CollisionLayer::Type::Ball;
|
std::shared_ptr<Components::Template> ballTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||||
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
|
physics->Static = false;
|
||||||
physics->Calculate = true;
|
physics->Category = CollisionLayer::Type::Ball;
|
||||||
m_World->CommitEntity(ent);
|
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
|
||||||
|
physics->Calculate = true;
|
||||||
|
|
||||||
SetBall(ent);
|
//auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
||||||
|
//plight->Radius = 2.f;
|
||||||
|
|
||||||
|
m_World->CommitEntity(ent);
|
||||||
|
|
||||||
|
SetBall(ent);
|
||||||
|
|
||||||
|
auto ent2 = CreateBall();
|
||||||
|
auto transform2 = m_World->GetComponent<Components::Transform>(ent2);
|
||||||
|
transform2->Position = glm::vec3(-0.f, 0.26f, -10.f);
|
||||||
|
transform2->Velocity = glm::vec3(0.0f, -10.f, 0.f);
|
||||||
|
|
||||||
|
m_World->CommitEntity(ent2);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < Lives(); i++) {
|
for (int i = 0; i < Lives(); i++) {
|
||||||
CreateLife(i);
|
CreateLife(i);
|
||||||
@@ -52,10 +68,30 @@ void dd::Systems::BallSystem::Update(double dt)
|
|||||||
Events::GameOver e;
|
Events::GameOver e;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if (HitLag()) {
|
||||||
|
m_HitLagTimer += 0.1 * dt;
|
||||||
|
if (Pause()) {
|
||||||
|
if (m_HitLagTimer > 1) {
|
||||||
|
SetPause(false);
|
||||||
|
m_HitLagTimer = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (m_HitLagTimer > m_HitLagPlacement) {
|
||||||
|
SetPause(true);
|
||||||
|
m_HitLagPlacement *= 0.9;
|
||||||
|
m_HitLagTimer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
|
if (Pause()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||||
if (templateCheck != nullptr){ return; }
|
if (templateCheck != nullptr){ return; }
|
||||||
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
|
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
|
||||||
@@ -132,6 +168,29 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::BallSystem::OnPause(const dd::Events::Pause &event)
|
||||||
|
{
|
||||||
|
if (Pause()) {
|
||||||
|
SetPause(false);
|
||||||
|
} else {
|
||||||
|
SetPause(true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::BallSystem::OnHitLag(const dd::Events::HitLag &event)
|
||||||
|
{
|
||||||
|
if (HitLag()) {
|
||||||
|
SetHitLag(false);
|
||||||
|
} else {
|
||||||
|
SetHitLag(true);
|
||||||
|
m_Time = event.Time;
|
||||||
|
m_SlowdownTime = event.SlowdownTime;
|
||||||
|
m_HitLagTimer = m_SlowdownTime;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void dd::Systems::BallSystem::OnEntityCommit(EntityID entity)
|
void dd::Systems::BallSystem::OnEntityCommit(EntityID entity)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ void dd::Systems::LevelSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &LevelSystem::OnMultiBallLost);
|
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &LevelSystem::OnMultiBallLost);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPowerUpTaken, &LevelSystem::OnPowerUpTaken);
|
EVENT_SUBSCRIBE_MEMBER(m_EPowerUpTaken, &LevelSystem::OnPowerUpTaken);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &LevelSystem::OnStageCleared);
|
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &LevelSystem::OnStageCleared);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &LevelSystem::OnPause);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -30,6 +31,9 @@ void dd::Systems::LevelSystem::Update(double dt)
|
|||||||
|
|
||||||
void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
|
if (Pause()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||||
if (templateCheck != nullptr){ return; }
|
if (templateCheck != nullptr){ return; }
|
||||||
|
|
||||||
@@ -71,6 +75,16 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::LevelSystem::OnPause(const dd::Events::Pause &event)
|
||||||
|
{
|
||||||
|
if (Pause()) {
|
||||||
|
SetPause(false);
|
||||||
|
} else {
|
||||||
|
SetPause(true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 spacesBetweenBricks, float spaceToEdge)
|
void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 spacesBetweenBricks, float spaceToEdge)
|
||||||
{
|
{
|
||||||
SetNumberOfBricks(rows * lines);
|
SetNumberOfBricks(rows * lines);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ void dd::Systems::PadSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &PadSystem::OnContact);
|
EVENT_SUBSCRIBE_MEMBER(m_EContact, &PadSystem::OnContact);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EContactPowerUp, &PadSystem::OnContactPowerUp);
|
EVENT_SUBSCRIBE_MEMBER(m_EContactPowerUp, &PadSystem::OnContactPowerUp);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PadSystem::OnStageCleared);
|
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PadSystem::OnStageCleared);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto ent = m_World->CreateEntity();
|
auto ent = m_World->CreateEntity();
|
||||||
@@ -58,6 +59,9 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
|
|
||||||
void dd::Systems::PadSystem::Update(double dt)
|
void dd::Systems::PadSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
|
if (Pause()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Entity() == 0) {
|
if (Entity() == 0) {
|
||||||
for (auto it = m_World->GetEntities()->begin(); it != m_World->GetEntities()->end(); it++) {
|
for (auto it = m_World->GetEntities()->begin(); it != m_World->GetEntities()->end(); it++) {
|
||||||
if (m_World->GetProperty<std::string>(it->first, "Name") == "Pad") {
|
if (m_World->GetProperty<std::string>(it->first, "Name") == "Pad") {
|
||||||
@@ -105,6 +109,16 @@ void dd::Systems::PadSystem::Update(double dt)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::PadSystem::OnPause(const dd::Events::Pause &event)
|
||||||
|
{
|
||||||
|
if (Pause()) {
|
||||||
|
SetPause(false);
|
||||||
|
} else {
|
||||||
|
SetPause(true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
||||||
{
|
{
|
||||||
int val = event.KeyCode;
|
int val = event.KeyCode;
|
||||||
@@ -127,6 +141,18 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
|||||||
Events::MultiBall e;
|
Events::MultiBall e;
|
||||||
e.padTransform = Transform();
|
e.padTransform = Transform();
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
|
} else if (val == GLFW_KEY_P) {
|
||||||
|
Events::Pause e;
|
||||||
|
e.Time = 0;
|
||||||
|
e.SlowdownTime = 0;
|
||||||
|
e.Type = "All";
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
} else if (val == GLFW_KEY_H) {
|
||||||
|
Events::HitLag e;
|
||||||
|
e.Time = 0.3;
|
||||||
|
e.SlowdownTime = 10;
|
||||||
|
e.Type = "All";
|
||||||
|
EventBroker->Publish(e);
|
||||||
} else if (val == GLFW_KEY_D) {
|
} else if (val == GLFW_KEY_D) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ void dd::Systems::PhysicsSystem::Initialize()
|
|||||||
InitializeWater();
|
InitializeWater();
|
||||||
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
|
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EHitLag, &PhysicsSystem::OnHitLag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::PhysicsSystem::InitializeWater()
|
void dd::Systems::PhysicsSystem::InitializeWater()
|
||||||
@@ -60,6 +62,19 @@ bool dd::Systems::PhysicsSystem::SetImpulse(const Events::SetImpulse &event)
|
|||||||
|
|
||||||
void dd::Systems::PhysicsSystem::Update(double dt)
|
void dd::Systems::PhysicsSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
|
if (Pause()) {
|
||||||
|
if (HitLag()) {
|
||||||
|
m_HitLagTimer += dt;
|
||||||
|
std::cout << m_HitLagTimer << std::endl;
|
||||||
|
if (m_HitLagPlacement < m_HitLagTimer) {
|
||||||
|
m_HitLagTimer = 0;
|
||||||
|
SetHitLag(false);
|
||||||
|
Events::Pause e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_Accumulator += dt;
|
m_Accumulator += dt;
|
||||||
while(m_Accumulator >= m_TimeStep)
|
while(m_Accumulator >= m_TimeStep)
|
||||||
@@ -173,6 +188,27 @@ void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, Entity
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::PhysicsSystem::OnPause(const dd::Events::Pause &event)
|
||||||
|
{
|
||||||
|
if (Pause()) {
|
||||||
|
SetPause(false);
|
||||||
|
} else {
|
||||||
|
SetPause(true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::PhysicsSystem::OnHitLag(const dd::Events::HitLag &event)
|
||||||
|
{
|
||||||
|
SetHitLag(true);
|
||||||
|
Events::Pause e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
m_HitLagPlacement = event.Time + 10;
|
||||||
|
m_SlowdownTime = event.SlowdownTime;
|
||||||
|
m_HitLagTimer = m_SlowdownTime;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity)
|
void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity)
|
||||||
{
|
{
|
||||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
|
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
|
||||||
|
|||||||
Reference in New Issue
Block a user