Merge remote-tracking branch 'origin/LevelSystemAndSuch' into Physics

Conflicts:
	include/Core/Engine.h
	include/Physics/PhysicsSystem.h
	src/game/Game/BallSystem.cpp
	src/game/Game/LevelSystem.cpp
	src/game/Physics/PhysicsSystem.cpp
This commit is contained in:
viktorljung
2015-10-06 16:13:17 +02:00
17 changed files with 640 additions and 175 deletions
+4 -27
View File
@@ -45,6 +45,7 @@
#include "Game/CPad.h"
#include "Game/CBrick.h"
#include "Game/BallSystem.h"
#include "Game/HitLagSystem.h"
#include "Game/Bricks/CPowerUpBrick.h"
#include "Physics/PhysicsSystem.h"
@@ -122,6 +123,9 @@ public:
m_World->SystemFactory.Register<Systems::BallSystem>(
[this]() { return new Systems::BallSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::BallSystem>();
m_World->SystemFactory.Register<Systems::HitLagSystem>(
[this]() { return new Systems::HitLagSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::HitLagSystem>();
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::PhysicsSystem>();
@@ -134,33 +138,6 @@ public:
m_World->ComponentFactory.Register<Components::ParticleEmitter>();
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.25f, 0.25f, 0.25f);
transform->Velocity = glm::vec3(0.0f, -10.f, 0.f);
auto model = m_World->AddComponent<Components::Model>(ent);
model->ModelFile = "Models/Test/Ball/Sid.obj";
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
circleShape->Radius = 0.25f;
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->CollisionType = CollisionType::Type::Dynamic;
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
{
auto t_Light = m_World->CreateEntity();
+14
View File
@@ -8,18 +8,23 @@
#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/CPointLight.h"
#include "Game/CBall.h"
#include "Game/CPowerUp.h"
#include "Game/CLife.h"
#include "Game/CBrick.h"
#include "Game/ELifeLost.h"
#include "Game/EComboEvent.h"
#include "Game/EResetBall.h"
#include "Game/EMultiBall.h"
#include "Game/EMultiBallLost.h"
#include "Game/EGameOver.h"
#include "Game/EPause.h"
#include "Game/EHitPad.h"
#include "Game/EHitLag.h"
namespace dd
{
@@ -75,6 +80,8 @@ public:
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
bool MultiBall() const { return m_MultiBall; }
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
bool IsPaused() const { return m_Pause; }
void SetPause(const bool& pause) { m_Pause = pause; }
private:
float m_XMovementMultiplier = 2.f;
@@ -85,6 +92,11 @@ private:
int m_PastLives = 3;
bool m_ReplaceBall = false;
bool m_MultiBall = false;
bool m_Pause = false;
EntityID m_LastCollision = 999999;
glm::vec3 m_SavedSpeed;
bool m_InitializePause = false;
EntityID m_Ball;
@@ -92,11 +104,13 @@ private:
dd::EventRelay<BallSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
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 OnPause(const dd::Events::Pause &event);
};
}
+2
View File
@@ -18,6 +18,8 @@ struct Ball : Component
int Number = 0;
float Speed = 5.f;
int Combo = 0;
bool Paused = false;
glm::vec3 SavedSpeed = glm::vec3(0, 0, 0);
};
}
-2
View File
@@ -15,8 +15,6 @@ namespace Components
struct Brick : Component
{
int Points = 10;
int Hits = 1;
int Score = 50;
bool Removed = false;
};
-3
View File
@@ -17,9 +17,6 @@ namespace Components
struct Pad : Component
{
int Lives;
int Points;
float SlowdownModifier = 5.f;
float AccelerationSpeed = 40.f;
float MaxSpeed = 5.f;
+26
View File
@@ -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
+21
View File
@@ -0,0 +1,21 @@
//
// Created by Administrator on 2015-10-05.
//
#ifndef DAYDREAM_EHITPAD_H
#define DAYDREAM_EHITPAD_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct HitPad : Event
{
};
}
}
#endif //DAYDREAM_EHITPAD_H
+25
View File
@@ -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
{
std::string Type;
};
}
}
#endif //DAYDREAM_EPAUSE_H
+91
View File
@@ -0,0 +1,91 @@
//
// Created by Adniklastrator on 2015-09-30.
//
#ifndef DAYDREAM_HITLAGSYSTEM_H
#define DAYDREAM_HITLAGSYSTEM_H
#include "Core/System.h"
#include "Core/CTransform.h"
#include "Core/CTemplate.h"
#include "Core/EventBroker.h"
#include "Core/World.h"
#include "Rendering/CSprite.h"
#include "Rendering/CModel.h"
#include "Game/CBrick.h"
#include "Game/CBall.h"
#include "Game/CLife.h"
#include "Game/CPowerUp.h"
#include "Game/EStageCleared.h"
#include "Game/ELifeLost.h"
#include "Game/EResetBall.h"
#include "Game/EScoreEvent.h"
#include "Game/EComboEvent.h"
#include "Game/EMultiBall.h"
#include "Game/EMultiBallLost.h"
#include "Game/EPause.h"
#include "Game/EHitLag.h"
#include "Game/EGameOver.h"
#include "Game/ECreatePowerUp.h"
#include "Game/EPowerUpTaken.h"
#include "Game/Bricks/CPowerUpBrick.h"
#include "Physics/CPhysics.h"
#include "Physics/CCircleShape.h"
#include "Physics/CRectangleShape.h"
#include "Physics/ESetImpulse.h"
#include "Physics/EContact.h"
#include "Sound/CCollisionSound.h"
#include "Game/PadSystem.h"
#include <fstream>
#include <iostream>
namespace dd
{
namespace Systems
{
class HitLagSystem : public System
{
public:
HitLagSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker)
{ }
void Initialize() override;
void Update(double dt) override;
void FlipPause();
bool IsPaused() 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; }
float& HitLagDuration() { return m_HitLagDuration; }
void SetHitLagDuration(const float& hitLagDuration) { m_HitLagDuration = hitLagDuration; }
float& HitLagTimer() { return m_HitLagTimer; }
void SetHitLagTimer(const float& hitLagTimer) { m_HitLagTimer = hitLagTimer; }
std::string& CurrentType() { return m_CurrentType; }
void SetCurrentType(const std::string& currentType) { m_CurrentType = currentType; }
private:
bool m_Pause;
bool m_HitLag;
float m_HitLagDuration;
float m_HitLagTimer;
std::string m_CurrentType;
dd::EventRelay<HitLagSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<HitLagSystem, dd::Events::HitLag> m_EHitLag;
bool OnPause(const dd::Events::Pause &event);
bool OnHitLag(const dd::Events::HitLag &event);
};
}
}
#endif //DAYDREAM_HITLAGSYSTEM_H
+28 -11
View File
@@ -21,8 +21,10 @@
#include "Game/EResetBall.h"
#include "Game/EScoreEvent.h"
#include "Game/EComboEvent.h"
#include "Game/EHitPad.h"
#include "Game/EMultiBall.h"
#include "Game/EMultiBallLost.h"
#include "Game/EPause.h"
#include "Game/EGameOver.h"
#include "Game/ECreatePowerUp.h"
#include "Game/EPowerUpTaken.h"
@@ -44,15 +46,15 @@ namespace Systems
{
// Me trying things out.
class Level
/*class Level
{
public:
int levelRows;
int levelLines;
int levelSpaceBetweenBricks;
int levelSpaceToEdge;
int bricks[];
};
int levelRows = 6;
int levelLines = 7;
glm::vec2 levelSpaceBetweenBricks = glm::vec2(1, 0.4);
float levelSpaceToEdge = 0.25f;
std::array<int, 42> bricks;
};*/
class LevelSystem : public System
{
@@ -64,10 +66,8 @@ public:
void Initialize() override;
void CreateBasicLevel(int, int, glm::vec2, float);
void SaveLevel(int, int, glm::vec2, int); // Shouldn't be here, but I'm experimenting.
void LoadLevel(char[20]);
void CreateBrick(int, int, glm::vec2, float, int);
void ProcessCollision();
void CreateLevel();
void CreateBrick(int, int, glm::vec2, float, int, int);
void OnEntityRemoved(EntityID entity);
@@ -80,6 +80,8 @@ public:
void SetRestarting(const bool& restarting) { m_Restarting = restarting; }
bool Initialized() const { return m_Initialized; }
void SetInitialized(const bool& initialized) { m_Initialized = initialized; }
bool IsPaused() const { return m_Pause; }
void SetPause(const bool& pause) { m_Pause = pause; }
int& MultiBalls() { return m_MultiBalls; }
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
int& PowerUps() { return m_PowerUps; }
@@ -101,8 +103,13 @@ public:
void SetNotResettingTheStage(const float& notResettingTheStage) { m_NotResettingTheStage = notResettingTheStage; }
private:
bool m_Cleared = false;
bool m_Restarting = false;
bool m_Initialized = false;
bool m_Pause = false;
int m_LooseBricks = 0;
int m_CurrentCluster = 2;
int m_CurrentLevel = 1;
int m_MultiBalls = 0;
int m_PowerUps = 0;
int m_Score = 0;
@@ -113,6 +120,10 @@ private:
glm::vec2 m_SpaceBetweenBricks = glm::vec2(1, 0.4);
float m_NotResettingTheStage = 5.f;
EntityID m_BrickTemplate;
std::array<int, 42> m_Bricks;
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
dd::EventRelay<LevelSystem, dd::Events::MultiBall> m_EMultiBall;
@@ -120,6 +131,8 @@ private:
dd::EventRelay<LevelSystem, dd::Events::CreatePowerUp> m_ECreatePowerUp;
dd::EventRelay<LevelSystem, dd::Events::PowerUpTaken> m_EPowerUpTaken;
dd::EventRelay<LevelSystem, dd::Events::StageCleared> m_EStageCleared;
dd::EventRelay<LevelSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<LevelSystem, dd::Events::HitPad> m_EHitPad;
bool OnContact(const dd::Events::Contact &event);
bool OnScoreEvent(const dd::Events::ScoreEvent &event);
@@ -128,6 +141,10 @@ private:
bool OnCreatePowerUp(const dd::Events::CreatePowerUp &event);
bool OnPowerUpTaken(const dd::Events::PowerUpTaken &event);
bool OnStageCleared(const dd::Events::StageCleared &event);
bool OnPause(const dd::Events::Pause &event);
bool OnHitPad(const dd::Events::HitPad &event);
void GetNextLevel();
};
}
+9 -1
View File
@@ -28,6 +28,8 @@
#include "Game/EMultiBall.h"
#include "Game/EPowerUpTaken.h"
#include "Game/EStageCleared.h"
#include "Game/EPause.h"
#include "Game/EHitLag.h"
namespace dd
@@ -63,6 +65,9 @@ public:
Components::Pad* Pad() const { return m_Pad; }
void SetPad(Components::Pad* pad) { m_Pad = pad; }
bool IsPaused() const { return m_Pause; }
void SetPause(const bool& pause) { m_Pause = pause; }
private:
EntityID m_Entity = 0;
glm::vec3 m_Acceleration = glm::vec3(0.f, 0.f, 0.f);
@@ -74,18 +79,21 @@ private:
Components::Transform* m_Transform = nullptr;
Components::Pad* m_Pad = nullptr;
bool m_Pause = false;
dd::EventRelay<PadSystem, dd::Events::KeyDown> m_EKeyDown;
dd::EventRelay<PadSystem, dd::Events::KeyUp> m_EKeyUp;
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContactPowerUp;
dd::EventRelay<PadSystem, dd::Events::StageCleared> m_EStageCleared;
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
bool OnKeyDown(const dd::Events::KeyDown &event);
bool OnKeyUp(const dd::Events::KeyUp &event);
bool OnContact(const dd::Events::Contact &event);
bool OnContactPowerUp(const dd::Events::Contact &event);
bool OnStageCleared(const dd::Events::StageCleared &event);
bool OnPause(const dd::Events::Pause &event);
class PadSteeringInputController;
std::array<std::shared_ptr<PadSteeringInputController>, 4> m_PadInputControllers;
+3
View File
@@ -29,6 +29,7 @@
#include "Transform/TransformSystem.h"
#include "Rendering/CSprite.h"
#include "Core/CTemplate.h"
#include "Game/EPause.h"
namespace dd
{
@@ -92,6 +93,8 @@ namespace dd
EventRelay<PhysicsSystem, Events::SetImpulse> m_SetImpulse;
bool SetImpulse(const Events::SetImpulse &event);
dd::EventRelay<PhysicsSystem, dd::Events::Pause> m_EPause;
bool OnPause(const dd::Events::Pause &event);
//TODO: Fill struct with info needed.
struct ParticleEmitter