Scroll to next stage works!
This commit is contained in:
@@ -143,6 +143,7 @@ public:
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(-3.f, 6.f, -5.f);
|
||||
transform->Sticky = true;
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 20.f;
|
||||
pl->Diffuse = glm::vec3(0.8f, 0.7f, 0.05f);
|
||||
@@ -154,6 +155,7 @@ public:
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(3.f, -5.f, -5.f);
|
||||
transform->Sticky = true;
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 15.f;
|
||||
pl->Diffuse = glm::vec3(0.1f, 0.5f, 0.8f);
|
||||
@@ -171,19 +173,19 @@ public:
|
||||
transform->Sticky = false;
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(1.f, 0.f, 0.f, 0.3f);
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
}
|
||||
/*{
|
||||
{
|
||||
auto t_halfPipe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
|
||||
transform->Position = glm::vec3(0.f, 6.f, -15.f);
|
||||
transform->Position = glm::vec3(0.f, 34.6f, -15.f);
|
||||
transform->Scale = glm::vec3(6.f, 6.f, 10.f);
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(1.f, 0.f, 0.f, 0.3f);
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
}*/
|
||||
}
|
||||
|
||||
//Background
|
||||
{
|
||||
@@ -240,6 +242,7 @@ public:
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -5.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.f, 1.5f, 1.f);
|
||||
transform->Sticky = true;
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
|
||||
@@ -9,14 +9,18 @@
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct StageCleared : Event
|
||||
{
|
||||
int StageCleared = 0;
|
||||
int ClearedStage = 0;
|
||||
int StageCluster = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ESTAGECLEARED_H
|
||||
|
||||
@@ -66,8 +66,8 @@ public:
|
||||
void Initialize() override;
|
||||
|
||||
void CreateBasicLevel(int, int, glm::vec2, float);
|
||||
void CreateLevel();
|
||||
void CreateBrick(int, int, glm::vec2, float, int, int);
|
||||
void CreateLevel(int);
|
||||
void CreateBrick(int, int, glm::vec2, float, int, int, int);
|
||||
|
||||
void OnEntityRemoved(EntityID entity);
|
||||
|
||||
|
||||
@@ -9,27 +9,33 @@
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "CRectangleShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CParticle.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CParticleEmitter.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CBall.h"
|
||||
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
|
||||
#include "CRectangleShape.h"
|
||||
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CBall.h"
|
||||
|
||||
#include "Rendering/CSprite.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -95,6 +101,10 @@ namespace dd
|
||||
bool SetImpulse(const Events::SetImpulse &event);
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::Pause> m_EPause;
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool m_Travelling = false;
|
||||
float m_Timer = 0;
|
||||
|
||||
//TODO: Fill struct with info needed.
|
||||
struct ParticleEmitter
|
||||
|
||||
@@ -49,7 +49,7 @@ void dd::Systems::LevelSystem::Update(double dt)
|
||||
{
|
||||
if (!m_Initialized) {
|
||||
GetNextLevel();
|
||||
CreateLevel();
|
||||
CreateLevel(0);
|
||||
m_Initialized = true;
|
||||
}
|
||||
}
|
||||
@@ -67,8 +67,8 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
if (model != nullptr) {
|
||||
if (model->ModelFile == "Models/Test/halfpipe/Halfpipe.obj") {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform->Position.y <= -12) {
|
||||
transform->Position.y = 12;
|
||||
if (transform->Position.y <= -34.6) {
|
||||
transform->Position.y = 34.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
if (NumberOfBricks() <= 0 && m_LooseBricks <= 0 && !Restarting()) {
|
||||
if (MultiBalls() <= 0 && PowerUps() <= 0) {
|
||||
Events::StageCleared ec;
|
||||
ec.StageCleared = m_CurrentLevel;
|
||||
ec.ClearedStage = m_CurrentLevel;
|
||||
ec.StageCluster = m_CurrentCluster;
|
||||
EventBroker->Publish(ec);
|
||||
} else {
|
||||
@@ -139,7 +139,7 @@ void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 s
|
||||
for (int i = 0; i < rows; i++) {
|
||||
num--;
|
||||
for (int j = 0; j < Lines(); j++) {
|
||||
CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, num, 1);
|
||||
CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, 0, num, 1);
|
||||
}
|
||||
if (num == 1)
|
||||
num = Lines();
|
||||
@@ -150,7 +150,7 @@ void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 s
|
||||
return;
|
||||
}
|
||||
|
||||
void dd::Systems::LevelSystem::CreateLevel()
|
||||
void dd::Systems::LevelSystem::CreateLevel(int aboveBasicLevel)
|
||||
{
|
||||
std::cout << "Loading level: " << m_CurrentLevel << std::endl;
|
||||
SetNumberOfBricks(Rows() * Lines());
|
||||
@@ -160,7 +160,7 @@ void dd::Systems::LevelSystem::CreateLevel()
|
||||
for (int i = 0; i < Rows(); i++) {
|
||||
num--;
|
||||
for (int j = 0; j < Lines(); j++) {
|
||||
CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), num, m_Bricks[getter]);
|
||||
CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), aboveBasicLevel, num, m_Bricks[getter]);
|
||||
getter++;
|
||||
}
|
||||
if (num == 1) {
|
||||
@@ -171,7 +171,7 @@ void dd::Systems::LevelSystem::CreateLevel()
|
||||
SetRestarting(false);
|
||||
}
|
||||
|
||||
void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int num, int typeInt)
|
||||
void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int aboveLevel, int num, int typeInt)
|
||||
{
|
||||
if (typeInt == EmptyBrickSpace) {
|
||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||
@@ -191,7 +191,7 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
|
||||
}
|
||||
float x = line * spacesBetweenBricks.x;
|
||||
float y = row * spacesBetweenBricks.y;
|
||||
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y , -10.f);
|
||||
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y + aboveLevel, -10.f);
|
||||
cBrick->Score = 10 * num;
|
||||
return;
|
||||
}
|
||||
@@ -352,7 +352,7 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev
|
||||
m_CurrentLevel++;
|
||||
if (m_CurrentLevel < 6) {
|
||||
GetNextLevel();
|
||||
CreateLevel();
|
||||
CreateLevel(12);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -16,6 +16,7 @@ void dd::Systems::PhysicsSystem::Initialize()
|
||||
InitializeWater();
|
||||
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PhysicsSystem::OnStageCleared);
|
||||
}
|
||||
|
||||
void dd::Systems::PhysicsSystem::InitializeWater()
|
||||
@@ -141,10 +142,17 @@ void dd::Systems::PhysicsSystem::SyncBodiesWithEntities()
|
||||
|
||||
void dd::Systems::PhysicsSystem::Update(double dt)
|
||||
{
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Travelling) {
|
||||
m_Timer += dt;
|
||||
if (m_Timer >= 2) {
|
||||
m_Timer = 0;
|
||||
m_Travelling = false;
|
||||
}
|
||||
}
|
||||
m_Accumulator += dt;
|
||||
|
||||
while(m_Accumulator >= m_TimeStep)
|
||||
@@ -194,13 +202,19 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
||||
|
||||
void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform != nullptr) {
|
||||
if (transform->Sticky == true) {
|
||||
return;
|
||||
}
|
||||
transform->Position.y -= 1.0f * dt;
|
||||
}
|
||||
if (m_Travelling) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform != nullptr) {
|
||||
if (transform->Sticky == true) {
|
||||
return;
|
||||
}
|
||||
transform->Position.y -= 6.0f * dt;
|
||||
/*auto brick = m_World->GetComponent<Components::Brick>(entity);
|
||||
if (brick != nullptr) {
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::PhysicsSystem::OnPause(const dd::Events::Pause &event)
|
||||
@@ -269,6 +283,13 @@ void dd::Systems::PhysicsSystem::OnEntityRemoved(EntityID entity)
|
||||
}
|
||||
|
||||
|
||||
bool dd::Systems::PhysicsSystem::OnStageCleared(const dd::Events::StageCleared &event)
|
||||
{
|
||||
m_Travelling = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void dd::Systems::PhysicsSystem::CreateBody(EntityID entity)
|
||||
{
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
|
||||
|
||||
Reference in New Issue
Block a user