Merge branch 'master' of github.com:teamfisk/AgileBreakOut
This commit is contained in:
+28
-4
@@ -34,9 +34,11 @@
|
||||
#include "CTemplate.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Input/InputSystem.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CPointLight.h"
|
||||
#include "Rendering/CCamera.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Sound/SoundSystem.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
@@ -67,6 +69,7 @@
|
||||
|
||||
#include "Game/BrickComponents.h"
|
||||
|
||||
#include "Game/ScreenShakeSystem.h"
|
||||
#include "Game/EScreenShake.h"
|
||||
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
@@ -147,6 +150,7 @@ public:
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Sprite>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Camera>();
|
||||
m_World->ComponentFactory.Register<Components::RectangleShape>();
|
||||
m_World->ComponentFactory.Register<Components::Physics>();
|
||||
m_World->ComponentFactory.Register<Components::Ball>();
|
||||
@@ -173,6 +177,9 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::InkBlasterBrick>();
|
||||
m_World->ComponentFactory.Register<Components::KrakenAttackBrick>();
|
||||
|
||||
//m_World->SystemFactory.Register<Systems::InputSystem>(
|
||||
// [this]() { return new Systems::InputSystem(m_World.get(), m_EventBroker); });
|
||||
//m_World->AddSystem<Systems::InputSystem>();
|
||||
m_World->SystemFactory.Register<Systems::LevelSystem>(
|
||||
[this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::LevelSystem>();
|
||||
@@ -209,6 +216,9 @@ public:
|
||||
m_World->SystemFactory.Register<Systems::LifeSystem>(
|
||||
[this]() { return new Systems::LifeSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::LifeSystem>();
|
||||
m_World->SystemFactory.Register<Systems::ScreenShakeSystem>(
|
||||
[this]() { return new Systems::ScreenShakeSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::ScreenShakeSystem>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
@@ -251,9 +261,10 @@ public:
|
||||
m_LastTime = currentTime;
|
||||
|
||||
// Update input
|
||||
m_EventBroker->Swap();
|
||||
m_InputManager->Update(dt);
|
||||
// Swap event queues to get fresh input data in the read queue
|
||||
//m_EventBroker->Swap();
|
||||
//m_EventBroker->Process<Systems::InputSystem>();
|
||||
m_EventBroker->Swap();
|
||||
|
||||
//ResourceManager::Update();
|
||||
if (m_GameIsRunning) {
|
||||
@@ -271,8 +282,6 @@ public:
|
||||
TEMPAddToRenderQueue();
|
||||
}
|
||||
|
||||
std::unique_ptr<dd::Camera> defaultCamera = nullptr;
|
||||
|
||||
// Render scene
|
||||
//TODO send renderqueue to draw.
|
||||
m_Renderer->Draw(m_RendererQueue);
|
||||
@@ -280,6 +289,7 @@ public:
|
||||
m_EventBroker->Process<Engine>();
|
||||
// Swap event queues
|
||||
m_EventBroker->Swap();
|
||||
m_EventBroker->Clear();
|
||||
|
||||
glfwPollEvents();
|
||||
}
|
||||
@@ -292,6 +302,20 @@ public:
|
||||
{
|
||||
if (!m_TransformSystem)
|
||||
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
||||
|
||||
// HACK: How do we handle multiple cameras? Maybe view and projection matrices in render queue...
|
||||
auto cameras = m_World->GetComponentsOfType<Components::Camera>();
|
||||
if (cameras != nullptr) {
|
||||
for (auto& component : *cameras) {
|
||||
auto camera = static_cast<Components::Camera*>(component.get());
|
||||
auto transform = m_World->GetComponent<Components::Transform>(camera->Entity);
|
||||
m_Renderer->Camera()->SetPosition(transform->Position);
|
||||
m_Renderer->Camera()->SetOrientation(transform->Orientation);
|
||||
m_Renderer->Camera()->SetFOV(camera->FOV);
|
||||
m_Renderer->Camera()->SetNearClip(camera->NearClip);
|
||||
m_Renderer->Camera()->SetFarClip(camera->FarClip);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &pair : *m_World->GetEntities())
|
||||
{
|
||||
|
||||
@@ -121,6 +121,7 @@ public:
|
||||
int Process();
|
||||
int Process(std::string contextTypeName);
|
||||
void Swap();
|
||||
void Clear();
|
||||
void Unsubscribe(BaseEventRelay &relay);
|
||||
|
||||
private:
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include "Sound/EPlaySound.h"
|
||||
#include "Rendering/EAnimationComplete.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -145,6 +146,7 @@ private:
|
||||
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
dd::EventRelay<BallSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<BallSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
||||
dd::EventRelay<BallSystem, dd::Events::AnimationComplete> m_EAnimationComplete;
|
||||
|
||||
bool Contact(const Events::Contact &event);
|
||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||
@@ -160,6 +162,7 @@ private:
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||
bool OnAnimationComplete(const dd::Events::AnimationComplete &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ struct Ball : Component
|
||||
bool Waiting = true;
|
||||
bool InkBlaster = false;
|
||||
bool Sticky = false;
|
||||
bool Loaded = false;
|
||||
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
|
||||
glm::vec3 SavedSpeed = glm::vec3(0, 1, 0);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Components
|
||||
|
||||
struct Kraken : Component {
|
||||
|
||||
int MaxHealth = 30;
|
||||
int MaxHealth = 18;
|
||||
int Health = MaxHealth;
|
||||
int CurrentAction = 3;
|
||||
float RetreatSpeed = 0.2;
|
||||
|
||||
@@ -20,6 +20,7 @@ struct BrickGenerating : Event
|
||||
int TargetLine;
|
||||
int Set;
|
||||
int SetCluster;
|
||||
int Speed = 6;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace Events
|
||||
|
||||
struct ScreenShake : Event
|
||||
{
|
||||
float Time;
|
||||
int Intensity;
|
||||
float TimeTakenToCoolDown;
|
||||
float Time = 1.f;
|
||||
float Intensity = 1.f;
|
||||
float TimeTakenToCoolDown = 1.f;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "Game/CKraken.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/EScreenShake.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include "Rendering/CAnimation.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
@@ -67,6 +68,7 @@ private:
|
||||
bool m_KrakenBattle = false;
|
||||
bool m_KrakenHasArrived = false;
|
||||
bool m_ReturnToIdle = false;
|
||||
bool m_RandomKraken = false;
|
||||
EntityID m_KrakenTemplate;
|
||||
std::string m_Action = "Idle";
|
||||
int m_NumberOfActions;
|
||||
@@ -76,6 +78,9 @@ private:
|
||||
float m_KrakenCurrentSecondsToAction = 15;
|
||||
const int Idle = 1;
|
||||
|
||||
int m_Set = 0;
|
||||
int m_SetCluster = 0;
|
||||
|
||||
std::array<int, 42> m_Bricks;
|
||||
std::array<int, 42> m_Colors;
|
||||
|
||||
@@ -98,6 +103,7 @@ private:
|
||||
bool OnBrickGenerating(const dd::Events::BrickGenerating &event);
|
||||
bool OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||
void GetBrickSet();
|
||||
void CreateBloodEffect(glm::vec3);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Rendering/CPointLight.h"
|
||||
#include "Rendering/CCamera.h"
|
||||
|
||||
#include "Transform/EMove.h"
|
||||
|
||||
@@ -59,6 +60,7 @@
|
||||
#include "Game/EKrakenAppear.h"
|
||||
#include "Game/EKrakenDefeated.h"
|
||||
#include "Game/EBrickGenerating.h"
|
||||
#include "Game/EBreakAllBricks.h"
|
||||
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
@@ -101,7 +103,7 @@ public:
|
||||
void CreateBasicLevel(int, int, glm::vec2, float);
|
||||
void CreateLevel(int);
|
||||
EntityID CreateBrick(int, int, glm::vec2, float, int, int, int, glm::vec4);
|
||||
void BrickHit(EntityID, EntityID, int);
|
||||
void BrickHit(EntityID, EntityID, int, bool);
|
||||
|
||||
void OnEntityRemoved(EntityID entity);
|
||||
|
||||
@@ -180,6 +182,7 @@ private:
|
||||
bool m_BrickGenerating = false;
|
||||
dd::Events::BrickGenerating m_BrickGeneratingEvent;
|
||||
|
||||
bool m_KrakenBattle = false;
|
||||
bool m_BreakAllBricks = false;
|
||||
|
||||
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
|
||||
@@ -194,6 +197,7 @@ private:
|
||||
dd::EventRelay<LevelSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<LevelSystem, dd::Events::HitPad> m_EHitPad;
|
||||
dd::EventRelay<LevelSystem, dd::Events::BrickGenerating> m_EBrickGenerating;
|
||||
dd::EventRelay<LevelSystem, dd::Events::BreakAllBricks> m_EBreakAllBricks;
|
||||
dd::EventRelay<LevelSystem, dd::Events::KrakenDefeated> m_EKrakenDefeated;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
@@ -209,6 +213,7 @@ private:
|
||||
bool OnHitPad(const dd::Events::HitPad &event);
|
||||
bool OnBrickGenerating(const dd::Events::BrickGenerating &event);
|
||||
bool BrickGenerating(const dd::Events::BrickGenerating &event);
|
||||
bool OnBreakAllBricks(const dd::Events::BreakAllBricks &event);
|
||||
void GetBrickSet(int Set, int SetCluster);
|
||||
bool OnKrakenDefeated(const dd::Events::KrakenDefeated &event);
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@ public:
|
||||
private:
|
||||
bool m_Pause = false;
|
||||
EntityID m_Template;
|
||||
Events::Lifebuoy m_SavedEvent;
|
||||
bool m_Lifebuoy = false;
|
||||
float m_Timer;
|
||||
float m_WaitingTime = 0.4;
|
||||
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Pause> m_EPause;
|
||||
@@ -58,6 +62,7 @@ private:
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnLifebuoy(const dd::Events::Lifebuoy &event);
|
||||
bool Lifebuoy(const dd::Events::Lifebuoy &event);
|
||||
bool OnLifebuoyHit(const dd::Events::LifebuoyHit &event);
|
||||
|
||||
struct LifebuoyInfo
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "Rendering/CAnimation.h"
|
||||
|
||||
#include "Game/EBrickGenerating.h"
|
||||
#include "Game/EBreakAllBricks.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CAnimation.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -60,7 +61,7 @@ private:
|
||||
int m_Shots = 0;
|
||||
float m_InkBlasterSpeed = 5;
|
||||
EntityID m_InkBlastTemplate;
|
||||
EntityID m_AttachedSquid;
|
||||
EntityID m_AttachedSquid = 0;
|
||||
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Pause> m_EPause;
|
||||
|
||||
@@ -26,6 +26,8 @@ struct ParticleEmitter : public Component
|
||||
//values to interpolate between.
|
||||
std::vector<glm::vec3> ScaleValues;
|
||||
std::vector<float> AlphaValues;
|
||||
std::vector<glm::vec3> VelocityValues;
|
||||
|
||||
|
||||
//System variables
|
||||
float GravityScale = 1.0f;
|
||||
|
||||
@@ -29,6 +29,7 @@ struct CreateParticleSequence : public Event
|
||||
bool DefaultScale = false;
|
||||
std::vector<glm::vec3> ScaleValues;
|
||||
std::vector<float> AlphaValues;
|
||||
std::vector<glm::vec3> VelocityValues;
|
||||
|
||||
//Particle
|
||||
std::string SpriteFile = "";
|
||||
|
||||
@@ -37,8 +37,8 @@ public:
|
||||
void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; }
|
||||
bool VSYNC() const { return m_VSYNC; }
|
||||
void SetVSYNC(bool vsync) { m_VSYNC = vsync; }
|
||||
const dd::Camera* Camera() const { return m_Camera; }
|
||||
void SetCamera(const dd::Camera* camera)
|
||||
dd::Camera* Camera() const { return m_Camera; }
|
||||
void SetCamera(dd::Camera* camera)
|
||||
{
|
||||
if (camera == nullptr) {
|
||||
m_Camera = m_DefaultCamera.get();
|
||||
@@ -55,7 +55,7 @@ protected:
|
||||
bool m_Fullscreen = false;
|
||||
bool m_VSYNC = false;
|
||||
std::unique_ptr<dd::Camera> m_DefaultCamera = nullptr;
|
||||
const dd::Camera* m_Camera = nullptr;
|
||||
dd::Camera* m_Camera = nullptr;
|
||||
GLFWwindow* m_Window = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,14 +30,9 @@ namespace Components
|
||||
|
||||
struct Camera : Component
|
||||
{
|
||||
Camera()
|
||||
: FOV(glm::radians(45.f))
|
||||
, NearClip(0.1f)
|
||||
, FarClip(100.f) { }
|
||||
|
||||
float FOV;
|
||||
float NearClip;
|
||||
float FarClip;
|
||||
float FOV = glm::radians(45.f);
|
||||
float NearClip = 0.01f;
|
||||
float FarClip = 100.f;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace dd
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct AnimationComplete
|
||||
struct AnimationComplete : Event
|
||||
{
|
||||
EntityID Entity;
|
||||
std::string Animation;
|
||||
|
||||
@@ -43,7 +43,6 @@ class Renderer : public BaseRenderer
|
||||
public:
|
||||
void Initialize() override;
|
||||
void Draw(RenderQueueCollection& rq) override;
|
||||
void PlaceCamera(glm::vec3 position);
|
||||
|
||||
private:
|
||||
int m_GLVersion[2];
|
||||
@@ -97,12 +96,6 @@ private:
|
||||
void DrawWater(RenderQueue &objects);
|
||||
void DrawGUI(RenderQueue& rq);
|
||||
void DebugKeys();
|
||||
|
||||
dd::EventRelay<Renderer, dd::Events::ScreenShake> m_EScreenShake;
|
||||
bool OnScreenShake(dd::Events::ScreenShake &event);
|
||||
bool m_ScreenShake = false;
|
||||
float m_ShakeIntensity = 0;
|
||||
float m_ShakeTimer = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user