Implemented Combos which multiply score. Adjusted pad a bit.
This commit is contained in:
@@ -150,8 +150,8 @@ public:
|
|||||||
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
|
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
|
||||||
physics->Calculate = true;
|
physics->Calculate = true;
|
||||||
|
|
||||||
auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
//auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
||||||
plight->Radius = 2.f;
|
//plight->Radius = 2.f;
|
||||||
|
|
||||||
m_World->CommitEntity(ent);
|
m_World->CommitEntity(ent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Core/CTransform.h"
|
#include "Core/CTransform.h"
|
||||||
|
#include "Core/CTemplate.h"
|
||||||
#include "Physics/CPhysics.h"
|
#include "Physics/CPhysics.h"
|
||||||
#include "Physics/CCircleShape.h"
|
#include "Physics/CCircleShape.h"
|
||||||
#include "Physics/EContact.h"
|
#include "Physics/EContact.h"
|
||||||
@@ -12,17 +13,22 @@
|
|||||||
#include "Rendering/CPointLight.h"
|
#include "Rendering/CPointLight.h"
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
#include "Game/CPowerUp.h"
|
#include "Game/CPowerUp.h"
|
||||||
|
#include "Game/CLife.h"
|
||||||
#include "Game/ELifeLost.h"
|
#include "Game/ELifeLost.h"
|
||||||
|
#include "Game/EComboEvent.h"
|
||||||
#include "Game/EResetBall.h"
|
#include "Game/EResetBall.h"
|
||||||
#include "Game/EMultiBall.h"
|
#include "Game/EMultiBall.h"
|
||||||
#include "Game/EMultiBallLost.h"
|
#include "Game/EMultiBallLost.h"
|
||||||
#include "Game/EGameOver.h"
|
#include "Game/EGameOver.h"
|
||||||
|
|
||||||
namespace dd {
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
namespace Systems {
|
namespace Systems
|
||||||
|
{
|
||||||
|
|
||||||
class BallSystem : public System {
|
class BallSystem : public System
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
BallSystem(World *world, std::shared_ptr<dd::EventBroker> eventBroker)
|
BallSystem(World *world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||||
: System(world, eventBroker) { }
|
: System(world, eventBroker) { }
|
||||||
@@ -49,9 +55,12 @@ public:
|
|||||||
void OnEntityRemoved(EntityID entity) override;
|
void OnEntityRemoved(EntityID entity) override;
|
||||||
|
|
||||||
EntityID CreateBall();
|
EntityID CreateBall();
|
||||||
|
void CreateLife(int);
|
||||||
EntityID Ball() { return m_Ball; };
|
EntityID Ball() { return m_Ball; };
|
||||||
void SetBall(const EntityID& ball) { m_Ball = 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; }
|
float& EdgeX() { return m_EdgeX; }
|
||||||
void SetEdgeX(const float& edgeX) { m_EdgeX = edgeX; }
|
void SetEdgeX(const float& edgeX) { m_EdgeX = edgeX; }
|
||||||
float& EdgeY() { return m_EdgeY; }
|
float& EdgeY() { return m_EdgeY; }
|
||||||
@@ -68,6 +77,7 @@ public:
|
|||||||
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
|
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
float m_XMovementMultiplier = 2.f;
|
||||||
float m_EdgeX = 3.2f;
|
float m_EdgeX = 3.2f;
|
||||||
float m_EdgeY = 5.2f;
|
float m_EdgeY = 5.2f;
|
||||||
int m_MultiBalls = 0;
|
int m_MultiBalls = 0;
|
||||||
@@ -90,6 +100,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ struct Ball : Component
|
|||||||
{
|
{
|
||||||
int Number = 0;
|
int Number = 0;
|
||||||
float Speed = 5.f;
|
float Speed = 5.f;
|
||||||
|
int Combo = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ struct Pad : Component
|
|||||||
|
|
||||||
float SlowdownModifier = 5.f;
|
float SlowdownModifier = 5.f;
|
||||||
float AccelerationSpeed = 40.f;
|
float AccelerationSpeed = 40.f;
|
||||||
float MaxSpeed = 20.f;
|
float MaxSpeed = 5.f;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-09-29.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_ECOMBOEVENT_H
|
||||||
|
#define DAYDREAM_ECOMBOEVENT_H
|
||||||
|
|
||||||
|
#include "Core/Entity.h"
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct ComboEvent : Event
|
||||||
|
{
|
||||||
|
EntityID Ball;
|
||||||
|
int Combo;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_ECOMBOEVENT_H
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Core/CTransform.h"
|
#include "Core/CTransform.h"
|
||||||
|
#include "Core/CTemplate.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Rendering/CSprite.h"
|
#include "Rendering/CSprite.h"
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
#include "Game/ELifeLost.h"
|
#include "Game/ELifeLost.h"
|
||||||
#include "Game/EResetBall.h"
|
#include "Game/EResetBall.h"
|
||||||
#include "Game/EScoreEvent.h"
|
#include "Game/EScoreEvent.h"
|
||||||
#include "Physics/CRectangleShape.h"
|
#include "Game/EComboEvent.h"
|
||||||
#include "Game/EMultiBall.h"
|
#include "Game/EMultiBall.h"
|
||||||
#include "Game/EMultiBallLost.h"
|
#include "Game/EMultiBallLost.h"
|
||||||
#include "Game/EGameOver.h"
|
#include "Game/EGameOver.h"
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
#include "Game/Bricks/CPowerUpBrick.h"
|
#include "Game/Bricks/CPowerUpBrick.h"
|
||||||
#include "Physics/CPhysics.h"
|
#include "Physics/CPhysics.h"
|
||||||
#include "Physics/CCircleShape.h"
|
#include "Physics/CCircleShape.h"
|
||||||
|
#include "Physics/CRectangleShape.h"
|
||||||
#include "Physics/ESetImpulse.h"
|
#include "Physics/ESetImpulse.h"
|
||||||
#include "Physics/EContact.h"
|
#include "Physics/EContact.h"
|
||||||
#include "Sound/CCollisionSound.h"
|
#include "Sound/CCollisionSound.h"
|
||||||
@@ -62,7 +64,6 @@ public:
|
|||||||
void Initialize() override;
|
void Initialize() override;
|
||||||
|
|
||||||
void CreateBasicLevel(int, int, glm::vec2, float);
|
void CreateBasicLevel(int, int, glm::vec2, float);
|
||||||
void CreateLife(int);
|
|
||||||
void SaveLevel(int, int, glm::vec2, int); // Shouldn't be here, but I'm experimenting.
|
void SaveLevel(int, int, glm::vec2, int); // Shouldn't be here, but I'm experimenting.
|
||||||
void LoadLevel(char[20]);
|
void LoadLevel(char[20]);
|
||||||
void CreateBrick(int, int, glm::vec2, float, int);
|
void CreateBrick(int, int, glm::vec2, float, int);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Core/Component.h"
|
#include "Core/Component.h"
|
||||||
#include "Core/CTransform.h"
|
#include "Core/CTransform.h"
|
||||||
|
#include "Core/CTemplate.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Core/EKeyDown.h"
|
#include "Core/EKeyDown.h"
|
||||||
#include "Core/EKeyUp.h"
|
#include "Core/EKeyUp.h"
|
||||||
|
|||||||
@@ -94,8 +94,7 @@ set(SOURCE_FILES
|
|||||||
${SOURCE_FILES_Physics}
|
${SOURCE_FILES_Physics}
|
||||||
${SOURCE_FILES_Game}
|
${SOURCE_FILES_Game}
|
||||||
${SOURCE_FILES_Sound}
|
${SOURCE_FILES_Sound}
|
||||||
${SOURCE_FILES_GUI}
|
${SOURCE_FILES_GUI})
|
||||||
../../include/Game/EMultiBallLost.h)
|
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||||
|
|||||||
@@ -18,6 +18,30 @@ 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);
|
||||||
|
|
||||||
|
auto ent = m_World->CreateEntity();
|
||||||
|
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||||
|
transform->Position = glm::vec3(-0.f, 50.f, -10.f);
|
||||||
|
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||||
|
transform->Velocity = glm::vec3(0.0f, 0.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);
|
||||||
|
std::shared_ptr<Components::Template> ballTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||||
|
physics->Static = false;
|
||||||
|
physics->Category = CollisionLayer::Type::Ball;
|
||||||
|
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
|
||||||
|
physics->Calculate = true;
|
||||||
|
m_World->CommitEntity(ent);
|
||||||
|
|
||||||
|
SetBall(ent);
|
||||||
|
|
||||||
|
for (int i = 0; i < Lives(); i++) {
|
||||||
|
CreateLife(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::BallSystem::Update(double dt)
|
void dd::Systems::BallSystem::Update(double dt)
|
||||||
@@ -32,12 +56,10 @@ void dd::Systems::BallSystem::Update(double dt)
|
|||||||
|
|
||||||
void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
|
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||||
|
if (templateCheck != nullptr){ return; }
|
||||||
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
|
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
|
||||||
if (ballComponent != nullptr) {
|
if (ballComponent != nullptr) {
|
||||||
if (Ball() == NULL) {
|
|
||||||
SetBall(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ReplaceBall() == true) {
|
if (ReplaceBall() == true) {
|
||||||
SetReplaceBall(false);
|
SetReplaceBall(false);
|
||||||
|
|
||||||
@@ -90,15 +112,15 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Lives() != PastLives()) {
|
if (Lives() != PastLives()) {
|
||||||
/*auto life = m_World->GetComponent<Components::Life>(entity);
|
auto life = m_World->GetComponent<Components::Life>(entity);
|
||||||
if (life != nullptr) {
|
if (life != nullptr) {
|
||||||
if (life->Number + 1 == PastLives()) {
|
if (life->Number + 1 == PastLives()) {
|
||||||
/*m_World->RemoveComponent<Components::Life>(entity);
|
m_World->RemoveComponent<Components::Life>(entity);
|
||||||
// m_World->RemoveComponent<Components::Transform>(entity);
|
m_World->RemoveComponent<Components::Transform>(entity);
|
||||||
m_World->RemoveEntity(entity);*/
|
m_World->RemoveEntity(entity);
|
||||||
SetPastLives(Lives());
|
SetPastLives(Lives());
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ballComponent != nullptr) {
|
if (ballComponent != nullptr) {
|
||||||
@@ -163,11 +185,17 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
|||||||
|
|
||||||
if (m_World->GetProperty<std::string>(otherEntitiy, "Name") == "Pad"){
|
if (m_World->GetProperty<std::string>(otherEntitiy, "Name") == "Pad"){
|
||||||
auto padTransform = m_World->GetComponent<Components::Transform>(otherEntitiy);
|
auto padTransform = m_World->GetComponent<Components::Transform>(otherEntitiy);
|
||||||
float x = ballTransform->Position.x - padTransform->Position.x;
|
float x = (ballTransform->Position.x - padTransform->Position.x) * XMovementMultiplier();
|
||||||
|
|
||||||
float y = glm::cos((abs(x) / (1.6f)) * glm::pi<float>() / 2.f) + 1.f;
|
float y = glm::cos((abs(x) / (1.6f)) * glm::pi<float>() / 2.f) + 1.f;
|
||||||
|
|
||||||
ballTransform->Velocity = glm::normalize(glm::vec3(x, y ,0.f)) * ballComponent->Speed;
|
ballTransform->Velocity = glm::normalize(glm::vec3(x, y ,0.f)) * ballComponent->Speed;
|
||||||
|
ballComponent->Combo = 0;
|
||||||
|
Events::ComboEvent ec;
|
||||||
|
ec.Combo = ballComponent->Combo;
|
||||||
|
ec.Ball = ballEntity;
|
||||||
|
EventBroker->Publish(ec);
|
||||||
|
//std::cout << "Combo: " << ballComponent->Combo << std::endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
glm::vec2 reflectedVelocity = glm::reflect(ballVelocity, event.Normal);
|
glm::vec2 reflectedVelocity = glm::reflect(ballVelocity, event.Normal);
|
||||||
@@ -181,6 +209,8 @@ EntityID dd::Systems::BallSystem::CreateBall()
|
|||||||
{
|
{
|
||||||
auto ent = m_World->CloneEntity(Ball());
|
auto ent = m_World->CloneEntity(Ball());
|
||||||
|
|
||||||
|
m_World->RemoveComponent<Components::Template>(ent);
|
||||||
|
|
||||||
/* auto ent = m_World->CreateEntity();
|
/* auto ent = m_World->CreateEntity();
|
||||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||||
transform->Position = glm::vec3(0.5f, 0.26f, -10.f);
|
transform->Position = glm::vec3(0.5f, 0.26f, -10.f);
|
||||||
@@ -205,6 +235,23 @@ EntityID dd::Systems::BallSystem::CreateBall()
|
|||||||
return ent;
|
return ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dd::Systems::BallSystem::CreateLife(int number)
|
||||||
|
{
|
||||||
|
auto life = m_World->CreateEntity();
|
||||||
|
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(life);
|
||||||
|
transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f);
|
||||||
|
transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
||||||
|
|
||||||
|
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
|
||||||
|
lifeNr->Number = number;
|
||||||
|
|
||||||
|
auto model = m_World->AddComponent<Components::Model>(life);
|
||||||
|
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
||||||
|
|
||||||
|
|
||||||
|
m_World->CommitEntity(life);
|
||||||
|
}
|
||||||
|
|
||||||
bool dd::Systems::BallSystem::OnLifeLost(const dd::Events::LifeLost &event)
|
bool dd::Systems::BallSystem::OnLifeLost(const dd::Events::LifeLost &event)
|
||||||
{
|
{
|
||||||
SetLives(Lives() - 1);
|
SetLives(Lives() - 1);
|
||||||
|
|||||||
@@ -17,30 +17,9 @@ void dd::Systems::LevelSystem::Initialize()
|
|||||||
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);
|
||||||
|
|
||||||
/*for (int i = 0; i < Lives(); i++) {
|
|
||||||
CreateLife(i);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::LevelSystem::CreateLife(int number)
|
|
||||||
{
|
|
||||||
/*auto life = m_World->CreateEntity();
|
|
||||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(life);
|
|
||||||
transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f);
|
|
||||||
transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
|
||||||
|
|
||||||
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
|
|
||||||
lifeNr->Number = number;
|
|
||||||
|
|
||||||
auto model = m_World->AddComponent<Components::Model>(life);
|
|
||||||
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
|
||||||
|
|
||||||
|
|
||||||
m_World->CommitEntity(life);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void dd::Systems::LevelSystem::Update(double dt)
|
void dd::Systems::LevelSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
if (!m_Initialized) {
|
if (!m_Initialized) {
|
||||||
@@ -51,6 +30,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)
|
||||||
{
|
{
|
||||||
|
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||||
|
if (templateCheck != nullptr){ return; }
|
||||||
|
|
||||||
auto ball = m_World->GetComponent<Components::Ball>(entity);
|
auto ball = m_World->GetComponent<Components::Ball>(entity);
|
||||||
SetNotResettingTheStage(NotResettingTheStage() + 0.01 * dt);
|
SetNotResettingTheStage(NotResettingTheStage() + 0.01 * dt);
|
||||||
|
|
||||||
@@ -93,14 +75,14 @@ void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 s
|
|||||||
{
|
{
|
||||||
SetNumberOfBricks(rows * lines);
|
SetNumberOfBricks(rows * lines);
|
||||||
//std::cout << "You're only doing this once, right?" << std::endl;
|
//std::cout << "You're only doing this once, right?" << std::endl;
|
||||||
int num = 0;
|
int num = Lines();
|
||||||
for (int i = 0; i < rows; i++) {
|
for (int i = 0; i < rows; i++) {
|
||||||
num++;
|
num--;
|
||||||
for (int j = 0; j < Lines(); j++) {
|
for (int j = 0; j < Lines(); j++) {
|
||||||
CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, num);
|
CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, num);
|
||||||
}
|
}
|
||||||
if (num == 7)
|
if (num == 1)
|
||||||
num = 0;
|
num = Lines();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetNumberOfBricks(rows * lines);
|
SetNumberOfBricks(rows * lines);
|
||||||
@@ -121,9 +103,9 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
|
|||||||
cPhys->Category = CollisionLayer::Type::Brick;
|
cPhys->Category = CollisionLayer::Type::Brick;
|
||||||
cPhys->Mask = CollisionLayer::Type::Ball;
|
cPhys->Mask = CollisionLayer::Type::Ball;
|
||||||
|
|
||||||
std::string fileName = "Textures/Bricks/";
|
/*std::string fileName = "Textures/Bricks/";
|
||||||
fileName.append(std::to_string(num));
|
fileName.append(std::to_string(num));
|
||||||
fileName.append(".png");
|
fileName.append(".png");*/
|
||||||
//sprite->SpriteFile = fileName;
|
//sprite->SpriteFile = fileName;
|
||||||
model->ModelFile = "Models/Test/Brick/Brick.obj";
|
model->ModelFile = "Models/Test/Brick/Brick.obj";
|
||||||
if ((line == 1 && row == 4) || (line == 3 && row == 2) || (line == 5 && row == 2)) {
|
if ((line == 1 && row == 4) || (line == 3 && row == 2) || (line == 5 && row == 2)) {
|
||||||
@@ -151,17 +133,17 @@ void dd::Systems::LevelSystem::ProcessCollision()
|
|||||||
|
|
||||||
void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity)
|
void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity)
|
||||||
{
|
{
|
||||||
auto brick = m_World->GetComponent<Components::Brick>(entity);
|
/*auto brick = m_World->GetComponent<Components::Brick>(entity);
|
||||||
if (brick != nullptr) {
|
if (brick != nullptr) {
|
||||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||||
Events::ScoreEvent es;
|
Events::ScoreEvent es;
|
||||||
es.Score = brick->Score;
|
es.Score = brick->Score;
|
||||||
EventBroker->Publish(es);
|
EventBroker->Publish(es);
|
||||||
/*if (numberOfBricks < 1) {
|
if (numberOfBricks < 1) {
|
||||||
EndLevel();
|
EndLevel();
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||||
@@ -205,6 +187,12 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ball != nullptr && Restarting() == false) {
|
if (ball != nullptr && Restarting() == false) {
|
||||||
|
ball->Combo += 1;
|
||||||
|
Events::ComboEvent ec;
|
||||||
|
ec.Combo = ball->Combo;
|
||||||
|
ec.Ball = entityBall;
|
||||||
|
EventBroker->Publish(ec);
|
||||||
|
|
||||||
auto ballTransform = m_World->GetComponent<Components::Transform>(entityBall);
|
auto ballTransform = m_World->GetComponent<Components::Transform>(entityBall);
|
||||||
|
|
||||||
// m_World->RemoveComponent<Components::Brick>(entityBrick);
|
// m_World->RemoveComponent<Components::Brick>(entityBrick);
|
||||||
@@ -237,11 +225,13 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
//SetMultiBalls(MultiBalls() + 1);
|
//SetMultiBalls(MultiBalls() + 1);
|
||||||
}
|
}
|
||||||
Events::ScoreEvent es;
|
Events::ScoreEvent es;
|
||||||
es.Score = brick->Score;
|
es.Score = brick->Score * ball->Combo;
|
||||||
EventBroker->Publish(es);
|
EventBroker->Publish(es);
|
||||||
|
|
||||||
|
std::cout << "Combo: " << ball->Combo << std::endl;
|
||||||
//std::cout << NumberOfBricks() << std::endl;
|
//std::cout << NumberOfBricks() << std::endl;
|
||||||
//std::cout << "Score: " << Score() << std::endl;
|
//std::cout << "Brick Score: " << brick->Score << std::endl;
|
||||||
|
std::cout << "Score: " << Score() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ void dd::Systems::PadSystem::Initialize()
|
|||||||
|
|
||||||
void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
|
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||||
|
if (templateCheck != nullptr){ return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::PadSystem::Update(double dt)
|
void dd::Systems::PadSystem::Update(double dt)
|
||||||
@@ -59,7 +60,9 @@ void dd::Systems::PadSystem::Update(double dt)
|
|||||||
}
|
}
|
||||||
transform->Position += transform->Velocity * (float)dt;
|
transform->Position += transform->Velocity * (float)dt;
|
||||||
transform->Velocity += acceleration * (float)dt;
|
transform->Velocity += acceleration * (float)dt;
|
||||||
transform->Velocity -= transform->Velocity * pad->SlowdownModifier * (float)dt;
|
if (glm::abs(transform->Velocity.x) > 1 || (!Left() && !Right())) {
|
||||||
|
transform->Velocity -= transform->Velocity * pad->SlowdownModifier * (float) dt;
|
||||||
|
}
|
||||||
|
|
||||||
if (Left()) {
|
if (Left()) {
|
||||||
acceleration.x = -pad->AccelerationSpeed;
|
acceleration.x = -pad->AccelerationSpeed;
|
||||||
|
|||||||
Reference in New Issue
Block a user