Fixed invisible item bug, maybe. Put 0.1 sec hitlag on impact with pad. Stable level loading?
This commit is contained in:
@@ -8,12 +8,14 @@
|
||||
#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"
|
||||
@@ -22,6 +24,7 @@
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/EHitLag.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -90,6 +93,7 @@ private:
|
||||
bool m_ReplaceBall = false;
|
||||
bool m_MultiBall = false;
|
||||
bool m_Pause = false;
|
||||
EntityID m_LastCollision = 999999;
|
||||
|
||||
glm::vec3 m_SavedSpeed;
|
||||
bool m_InitializePause = false;
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace Components
|
||||
|
||||
struct Brick : Component
|
||||
{
|
||||
int Points = 10;
|
||||
int Hits = 1;
|
||||
int Score = 50;
|
||||
bool Removed = false;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -224,6 +224,23 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
//TODO: Add support for power-up collisions
|
||||
}
|
||||
|
||||
auto brick = m_World->GetComponent<Components::Brick>(otherEntitiy);
|
||||
if (brick != nullptr) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(otherEntitiy);
|
||||
auto physics = m_World->GetComponent<Components::Physics>(otherEntitiy);
|
||||
auto rectangle = m_World->GetComponent<Components::RectangleShape>(otherEntitiy);
|
||||
int hey = 5;
|
||||
}
|
||||
|
||||
/*if (otherEntitiy == m_LastCollision) {
|
||||
|
||||
if (brick != nullptr) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
m_LastCollision = otherEntitiy;
|
||||
}*/
|
||||
|
||||
//if this is a brick thats dead do not collide :)
|
||||
|
||||
auto ballTransform = m_World->GetComponent<Components::Transform>(ballEntity);
|
||||
@@ -232,6 +249,10 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
if (m_World->GetProperty<std::string>(otherEntitiy, "Name") == "Pad"){
|
||||
Events::HitPad e;
|
||||
EventBroker->Publish(e);
|
||||
Events::HitLag el;
|
||||
el.Time = 0.1f;
|
||||
el.Type = "All";
|
||||
EventBroker->Publish(el);
|
||||
|
||||
auto padTransform = m_World->GetComponent<Components::Transform>(otherEntitiy);
|
||||
float x = (ballTransform->Position.x - padTransform->Position.x) * XMovementMultiplier();
|
||||
@@ -260,7 +281,7 @@ EntityID dd::Systems::BallSystem::CreateBall()
|
||||
|
||||
m_World->RemoveComponent<Components::Template>(ent);
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
//m_World->CommitEntity(ent);
|
||||
|
||||
return ent;
|
||||
}
|
||||
|
||||
@@ -164,32 +164,33 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
|
||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||
return;
|
||||
}
|
||||
//auto brick = m_World->CloneEntity(m_BrickTemplate);
|
||||
//m_World->RemoveComponent<Components::Template>(brick);
|
||||
//auto transform = m_World->GetComponent<Components::Transform>(brick);
|
||||
//auto cBrick = m_World->GetComponent<Components::Brick>(brick);
|
||||
//auto cPhys = m_World->GetComponent<Components::Physics>(brick);
|
||||
auto brick = m_World->CreateEntity();
|
||||
auto brick = m_World->CloneEntity(m_BrickTemplate);
|
||||
m_World->RemoveComponent<Components::Template>(brick);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(brick);
|
||||
auto cBrick = m_World->GetComponent<Components::Brick>(brick);
|
||||
auto cPhys = m_World->GetComponent<Components::Physics>(brick);
|
||||
|
||||
/*auto brick = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(brick);
|
||||
auto model = m_World->AddComponent<Components::Model>(brick);
|
||||
std::shared_ptr<Components::Brick> cBrick = m_World->AddComponent<Components::Brick>(brick);
|
||||
std::shared_ptr<Components::RectangleShape> cRec = m_World->AddComponent<Components::RectangleShape>(brick);
|
||||
std::shared_ptr<Components::Physics> cPhys = m_World->AddComponent<Components::Physics>(brick);
|
||||
std::shared_ptr<Components::Physics> cPhys = m_World->AddComponent<Components::Physics>(brick);*/
|
||||
//std::shared_ptr<Components::Template> cTemplate = m_World->AddComponent<Components::Template>(brick);
|
||||
cPhys->Static = false;
|
||||
cPhys->GravityScale = 0.f;
|
||||
cPhys->Category = CollisionLayer::Type::Brick;
|
||||
cPhys->Mask = CollisionLayer::Type::Ball;
|
||||
|
||||
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)) {
|
||||
std::shared_ptr<Components::PowerUpBrick> cPow = m_World->AddComponent<Components::PowerUpBrick>(brick);
|
||||
}*/
|
||||
|
||||
transform->Scale = glm::vec3(0.8, 0.2, 0.2);
|
||||
if (typeInt == 2) {
|
||||
//transform->Scale = glm::vec3(0.8, 0.2, 0.2);
|
||||
/*if (typeInt == 2) {
|
||||
std::shared_ptr<Components::PowerUpBrick> cPow = m_World->AddComponent<Components::PowerUpBrick>(brick);
|
||||
}
|
||||
}*/
|
||||
float x = line * spacesBetweenBricks.x;
|
||||
float y = row * spacesBetweenBricks.y;
|
||||
transform->Scale = glm::vec3(0.8, 0.2, 0.2);
|
||||
@@ -245,7 +246,9 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
if (!Restarting()) {
|
||||
if (!Restarting() && !brick->Removed) {
|
||||
brick->Removed = true;
|
||||
// Hit brick with ball code.
|
||||
ball->Combo += 1;
|
||||
Events::ComboEvent ec;
|
||||
ec.Combo = ball->Combo;
|
||||
|
||||
@@ -212,7 +212,10 @@ void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity)
|
||||
}
|
||||
|
||||
if (physicsComponent) {
|
||||
CreateBody(entity);
|
||||
auto it = m_EntitiesToBodies.find(entity);
|
||||
if(it == m_EntitiesToBodies.end()) {
|
||||
CreateBody(entity);
|
||||
}
|
||||
} else if (waterComponent) {
|
||||
CreateParticleGroup(entity);
|
||||
} else if (particleEmitterComponent) {
|
||||
|
||||
Reference in New Issue
Block a user