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

Conflicts:
	src/game/Game/LevelSystem.cpp
This commit is contained in:
viktorljung
2015-10-08 20:17:24 +02:00
16 changed files with 343 additions and 32 deletions
+6
View File
@@ -44,10 +44,12 @@
#include "Game/CBall.h" #include "Game/CBall.h"
#include "Game/CPad.h" #include "Game/CPad.h"
#include "Game/CLifebuoy.h" #include "Game/CLifebuoy.h"
#include "Game/CProjectile.h"
#include "Game/CBrick.h" #include "Game/CBrick.h"
#include "Game/BallSystem.h" #include "Game/BallSystem.h"
#include "Game/HitLagSystem.h" #include "Game/HitLagSystem.h"
#include "Game/LifebuoySystem.h" #include "Game/LifebuoySystem.h"
#include "Game/ProjectileSystem.h"
#include "Game/Bricks/CPowerUpBrick.h" #include "Game/Bricks/CPowerUpBrick.h"
#include "Physics/PhysicsSystem.h" #include "Physics/PhysicsSystem.h"
@@ -113,6 +115,7 @@ public:
m_World->ComponentFactory.Register<Components::Pad>(); m_World->ComponentFactory.Register<Components::Pad>();
m_World->ComponentFactory.Register<Components::Life>(); m_World->ComponentFactory.Register<Components::Life>();
m_World->ComponentFactory.Register<Components::Lifebuoy>(); m_World->ComponentFactory.Register<Components::Lifebuoy>();
m_World->ComponentFactory.Register<Components::Projectile>();
m_World->ComponentFactory.Register<Components::PowerUp>(); m_World->ComponentFactory.Register<Components::PowerUp>();
m_World->ComponentFactory.Register<Components::PowerUpBrick>(); m_World->ComponentFactory.Register<Components::PowerUpBrick>();
@@ -132,6 +135,9 @@ public:
m_World->SystemFactory.Register<Systems::LifebuoySystem>( m_World->SystemFactory.Register<Systems::LifebuoySystem>(
[this]() { return new Systems::LifebuoySystem(m_World.get(), m_EventBroker); }); [this]() { return new Systems::LifebuoySystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::LifebuoySystem>(); m_World->AddSystem<Systems::LifebuoySystem>();
m_World->SystemFactory.Register<Systems::ProjectileSystem>(
[this]() { return new Systems::ProjectileSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::ProjectileSystem>();
m_World->SystemFactory.Register<Systems::PhysicsSystem>( m_World->SystemFactory.Register<Systems::PhysicsSystem>(
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); }); [this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::PhysicsSystem>(); m_World->AddSystem<Systems::PhysicsSystem>();
+4 -1
View File
@@ -22,6 +22,7 @@
#include "Game/EMultiBall.h" #include "Game/EMultiBall.h"
#include "Game/EMultiBallLost.h" #include "Game/EMultiBallLost.h"
#include "Game/EStickyPad.h" #include "Game/EStickyPad.h"
#include "Game/EInkBlaster.h"
#include "Game/EGameOver.h" #include "Game/EGameOver.h"
#include "Game/EPause.h" #include "Game/EPause.h"
#include "Game/EHitPad.h" #include "Game/EHitPad.h"
@@ -94,8 +95,8 @@ private:
bool m_Pause = false; bool m_Pause = false;
bool m_Waiting = true; bool m_Waiting = true;
bool m_Sticky = false; bool m_Sticky = false;
bool m_InkBlaster = false;
int m_StickyCounter = 5; int m_StickyCounter = 5;
EntityID m_LastCollision = 999999;
glm::vec3 m_SavedSpeed; glm::vec3 m_SavedSpeed;
bool m_InitializePause = false; bool m_InitializePause = false;
@@ -110,6 +111,7 @@ private:
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall; dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall; dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
dd::EventRelay<BallSystem, dd::Events::StickyPad> m_EStickyPad; dd::EventRelay<BallSystem, dd::Events::StickyPad> m_EStickyPad;
dd::EventRelay<BallSystem, dd::Events::InkBlaster> m_EInkBlaster;
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause; dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact; dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton; dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
@@ -120,6 +122,7 @@ private:
bool OnResetBall(const dd::Events::ResetBall &event); bool OnResetBall(const dd::Events::ResetBall &event);
bool OnMultiBall(const dd::Events::MultiBall &event); bool OnMultiBall(const dd::Events::MultiBall &event);
bool OnStickyPad(const dd::Events::StickyPad &event); bool OnStickyPad(const dd::Events::StickyPad &event);
bool OnInkBlaster(const dd::Events::InkBlaster &event);
bool OnPause(const dd::Events::Pause &event); bool OnPause(const dd::Events::Pause &event);
bool OnActionButton(const dd::Events::ActionButton &event); bool OnActionButton(const dd::Events::ActionButton &event);
}; };
+1
View File
@@ -20,6 +20,7 @@ struct Ball : Component
int Combo = 0; int Combo = 0;
bool Paused = false; bool Paused = false;
bool Waiting = true; bool Waiting = true;
bool InkBlaster = false;
bool Sticky = false; bool Sticky = false;
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0); glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
glm::vec3 SavedSpeed = glm::vec3(0, 0, 0); glm::vec3 SavedSpeed = glm::vec3(0, 0, 0);
+25
View File
@@ -0,0 +1,25 @@
//
// Created by Adniklastrator on 2015-10-08.
//
#ifndef DAYDREAM_CPROJECTILE_H
#define DAYDREAM_CPROJECTILE_H
#include "Core/Component.h"
namespace dd
{
namespace Components
{
struct Projectile : Component
{
};
}
}
#endif //DAYDREAM_CPROJECTILE_H
+1 -1
View File
@@ -15,7 +15,7 @@ namespace Events
struct ActionButton : Event struct ActionButton : Event
{ {
glm::vec3 Position;
}; };
} }
+3 -1
View File
@@ -6,6 +6,7 @@
#define DAYDREAM_EHITPAD_H #define DAYDREAM_EHITPAD_H
#include "Core/EventBroker.h" #include "Core/EventBroker.h"
#include "Core/Entity.h"
namespace dd namespace dd
{ {
@@ -13,7 +14,8 @@ namespace Events
{ {
struct HitPad : Event struct HitPad : Event
{ {
EntityID Pad;
EntityID Ball;
}; };
} }
} }
+25
View File
@@ -0,0 +1,25 @@
//
// Created by Adniklastrator on 2015-10-08.
//
#ifndef DAYDREAM_EINKBLASTER_H
#define DAYDREAM_EINKBLASTER_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct InkBlaster : Event
{
Components::Transform* Transform;
};
}
}
#endif //DAYDREAM_EINKBLASTER_H
+1 -1
View File
@@ -1,5 +1,5 @@
// //
// Created by Adniklastrator on 2015-09-17. // Created by Adniklastrator on 2015-10-08.
// //
#ifndef DAYDREAM_ELIFEBUOY_H #ifndef DAYDREAM_ELIFEBUOY_H
+3
View File
@@ -15,6 +15,7 @@
#include "Game/CBrick.h" #include "Game/CBrick.h"
#include "Game/CBall.h" #include "Game/CBall.h"
#include "Game/CLife.h" #include "Game/CLife.h"
#include "Game/CProjectile.h"
#include "Game/CPowerUp.h" #include "Game/CPowerUp.h"
#include "Game/EStageCleared.h" #include "Game/EStageCleared.h"
#include "Game/ELifeLost.h" #include "Game/ELifeLost.h"
@@ -24,6 +25,7 @@
#include "Game/EHitPad.h" #include "Game/EHitPad.h"
#include "Game/ELifebuoy.h" #include "Game/ELifebuoy.h"
#include "Game/EStickyPad.h" #include "Game/EStickyPad.h"
#include "Game/EInkBlaster.h"
#include "Game/EMultiBall.h" #include "Game/EMultiBall.h"
#include "Game/EMultiBallLost.h" #include "Game/EMultiBallLost.h"
#include "Game/EPause.h" #include "Game/EPause.h"
@@ -127,6 +129,7 @@ private:
const int MultiBallBrick = 2; const int MultiBallBrick = 2;
const int LifebuoyBrick = 3; const int LifebuoyBrick = 3;
const int StickyBrick = 4; const int StickyBrick = 4;
const int InkBlasterBrick = 5;
EntityID m_BrickTemplate; EntityID m_BrickTemplate;
+72
View File
@@ -0,0 +1,72 @@
//
// Created by Adniklastrator on 2015-09-09.
//
#ifndef DAYDREAM_PROJECTILESYSTEM_H
#define DAYDREAM_PROJECTILESYSTEM_H
#include "Core/System.h"
#include "Core/CTransform.h"
#include "Core/CTemplate.h"
#include "Core/EventBroker.h"
#include "Core/World.h"
#include "Physics/EContact.h"
#include "Rendering/CModel.h"
#include "Physics/CPhysics.h"
#include "Physics/CCircleShape.h"
#include "Game/EPause.h"
#include "Game/EInkBlaster.h"
#include "Game/EActionButton.h"
#include "Game/EHitPad.h"
#include "Game/CProjectile.h"
#include "Game/CBall.h"
#include <fstream>
#include <iostream>
namespace dd
{
namespace Systems
{
class ProjectileSystem : public System
{
public:
ProjectileSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker)
{ }
void Initialize() override;
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
bool IsPaused() const { return m_Pause; }
void SetPause(const bool& pause) { m_Pause = pause; }
private:
bool m_Pause = false;
bool m_InkBlaster = false;
bool m_SquidLoaded = false;
int m_Shots = 0;
EntityID m_InkBlastTemplate;
EntityID m_AttachedSquid;
dd::EventRelay<ProjectileSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<ProjectileSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<ProjectileSystem, dd::Events::InkBlaster> m_EInkBlaster;
dd::EventRelay<ProjectileSystem, dd::Events::HitPad> m_EHitPad;
dd::EventRelay<ProjectileSystem, dd::Events::ActionButton> m_EActionButton;
bool OnContact(const dd::Events::Contact &event);
bool OnPause(const dd::Events::Pause &event);
bool OnInkBlaster(const dd::Events::InkBlaster &event);
bool OnHitPad(const dd::Events::HitPad &event);
bool OnActionButton(const dd::Events::ActionButton &event);
};
}
}
#endif //DAYDREAM_PROJECTILESYSTEM_H
+2 -1
View File
@@ -16,7 +16,8 @@ enum Type
PowerUp = 1 << 4, PowerUp = 1 << 4,
Other = 1 << 5, Other = 1 << 5,
Wall = 1 << 6, Wall = 1 << 6,
LifeBuoy = 1 << 7 LifeBuoy = 1 << 7,
Projectile = 1 << 8
}; };
} }
+17 -13
View File
@@ -19,6 +19,7 @@ void dd::Systems::BallSystem::Initialize()
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);
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad); EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad);
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster);
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause); EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton); EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
@@ -44,9 +45,6 @@ void dd::Systems::BallSystem::Initialize()
physics->Calculate = true; physics->Calculate = true;
transform->Sticky = true; transform->Sticky = true;
//auto plight = m_World->AddComponent<Components::PointLight>(ent);
//plight->Radius = 2.f;
m_World->CommitEntity(ent); m_World->CommitEntity(ent);
SetBall(ent); SetBall(ent);
@@ -114,7 +112,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
if (m_Waiting == false) { if (m_Waiting == false) {
ballComponent->Waiting = false; ballComponent->Waiting = false;
auto transform = m_World->GetComponent<Components::Transform>(entity); auto transform = m_World->GetComponent<Components::Transform>(entity);
transform->Velocity = glm::normalize(glm::vec3(-0.5f, 1, 0.f)) * ballComponent->Speed; transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
if (ballComponent->Sticky) { if (ballComponent->Sticky) {
transform->Velocity = ballComponent->SavedSpeed; transform->Velocity = ballComponent->SavedSpeed;
m_StickyCounter--; m_StickyCounter--;
@@ -260,6 +258,8 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
auto padTransform = m_World->GetComponent<Components::Transform>(otherEntitiy); auto padTransform = m_World->GetComponent<Components::Transform>(otherEntitiy);
Events::HitPad e; Events::HitPad e;
e.Ball = ballEntity;
e.Pad = otherEntitiy;
EventBroker->Publish(e); EventBroker->Publish(e);
// Events::HitLag el; // Events::HitLag el;
// el.Time = 0.1f; // el.Time = 0.1f;
@@ -272,12 +272,17 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
ballComponent->Combo = 0; ballComponent->Combo = 0;
if (m_Sticky) { if (m_InkBlaster) {
m_InkBlaster = false;
ballComponent->Sticky = true;
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
ballTransform->Velocity = glm::vec3(0.f, 0.f, 0.f);
} else if (m_Sticky) {
m_Sticky = false; m_Sticky = false;
m_Waiting = true; m_Waiting = true;
ballComponent->Sticky = true; ballComponent->Sticky = true;
ballComponent->Waiting = true; ballComponent->Waiting = true;
ballComponent->StickyPlacement = padTransform->Position - ballTransform->Position; ballComponent->StickyPlacement = ballTransform->Position - padTransform->Position;
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed; ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
ballTransform->Velocity *= -1; ballTransform->Velocity *= -1;
return true; return true;
@@ -304,13 +309,6 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
normalList.push_back(event.Normal); normalList.push_back(event.Normal);
m_Contacts[ballEntity] = normalList; m_Contacts[ballEntity] = normalList;
} }
auto brick = m_World->GetComponent<Components::Brick>(otherEntitiy);
if (brick != nullptr) {
auto physicsComponent = m_World->GetComponent<Components::Physics>(otherEntitiy);
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
}
} }
return true; return true;
@@ -427,6 +425,12 @@ bool dd::Systems::BallSystem::OnStickyPad(const dd::Events::StickyPad &event)
return true; return true;
} }
bool dd::Systems::BallSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
{
m_InkBlaster = true;
return true;
}
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event) bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
{ {
m_Waiting = false; m_Waiting = false;
+57 -10
View File
@@ -30,7 +30,7 @@ void dd::Systems::LevelSystem::Initialize()
cPhys->CollisionType = CollisionType::Type::Static; cPhys->CollisionType = CollisionType::Type::Static;
cPhys->GravityScale = 0.f; cPhys->GravityScale = 0.f;
cPhys->Category = CollisionLayer::Type::Brick; cPhys->Category = CollisionLayer::Type::Brick;
cPhys->Mask = static_cast<CollisionLayer::Type> (CollisionLayer::Type::Ball | CollisionLayer::Type::Wall | CollisionLayer::LifeBuoy); cPhys->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Ball | CollisionLayer::Type::Projectile | CollisionLayer::Type::Wall | CollisionLayer::LifeBuoy);
transform->Sticky = false; transform->Sticky = false;
model->ModelFile = "Models/Brick/WhiteBrick.obj"; model->ModelFile = "Models/Brick/WhiteBrick.obj";
@@ -90,6 +90,9 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
} else if (brick->Type == StickyBrick) { } else if (brick->Type == StickyBrick) {
Events::StickyPad e; Events::StickyPad e;
EventBroker->Publish(e); EventBroker->Publish(e);
} else if (brick->Type == InkBlasterBrick) {
Events::InkBlaster e;
EventBroker->Publish(e);
} }
m_LooseBricks--; m_LooseBricks--;
m_World->RemoveEntity(entity); m_World->RemoveEntity(entity);
@@ -203,6 +206,10 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
cBrick->Type = StickyBrick; cBrick->Type = StickyBrick;
auto model = m_World->GetComponent<Components::Model>(brick); auto model = m_World->GetComponent<Components::Model>(brick);
model->ModelFile = "Models/Brick/StickyBrick.obj"; model->ModelFile = "Models/Brick/StickyBrick.obj";
} else if (typeInt == InkBlasterBrick) {
cBrick->Type = InkBlasterBrick;
auto model = m_World->GetComponent<Components::Model>(brick);
model->Color = glm::vec4(0.1f, 0.1f, 0.1f, .0f);
} }
float x = line * spacesBetweenBricks.x; float x = line * spacesBetweenBricks.x;
float y = row * spacesBetweenBricks.y; float y = row * spacesBetweenBricks.y;
@@ -218,8 +225,10 @@ void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity)
bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event) bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
{ {
LOG_DEBUG("Collision happened!");
EntityID entityBrick; EntityID entityBrick;
EntityID entityBall; EntityID entityBall;
EntityID entityShot = 0;
auto ball = m_World->GetComponent<Components::Ball>(event.Entity2); auto ball = m_World->GetComponent<Components::Ball>(event.Entity2);
auto brick = m_World->GetComponent<Components::Brick>(event.Entity1); auto brick = m_World->GetComponent<Components::Brick>(event.Entity1);
if (brick != nullptr) { if (brick != nullptr) {
@@ -239,7 +248,19 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
if (ball != nullptr) { if (ball != nullptr) {
entityBall = event.Entity1; entityBall = event.Entity1;
} else { } else {
return false; auto shot = m_World->GetComponent<Components::Projectile>(event.Entity1);
if (shot != nullptr) {
LOG_DEBUG("Entity1 is a shot!");
entityShot = event.Entity1;
} else {
shot = m_World->GetComponent<Components::Projectile>(event.Entity2);
if (shot != nullptr) {
LOG_DEBUG("Entity2 is a shot!");
entityShot = event.Entity2;
} else {
return false;
}
}
} }
} }
@@ -248,13 +269,37 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
return false; return false;
} }
/*auto power = m_World->GetComponent<Components::PowerUpBrick>(entityBrick); if (entityShot != 0) {
if (power != nullptr && NumberOfBricks() > 1) { // For when a brick gets shot.
Events::CreatePowerUp e; brick->Removed = true;
auto transform = m_World->GetComponent<Components::Transform>(entityBrick);
e.Position = transform->Position; auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
EventBroker->Publish(e); physicsComponent->CollisionType = CollisionType::Type::Dynamic;
}*/ physicsComponent->GravityScale = 1.f;
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
auto transformComponentShot = m_World->GetComponent<Components::Transform>(entityShot);
Events::SetImpulse e;
e.Entity = entityBrick;
glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentShot->Position.x - transformComponentBrick->Position.x) / 4),
transformComponentBrick->Position.y + ((transformComponentShot->Position.y - transformComponentBrick->Position.y) / 4));
e.Impulse = glm::normalize(point)*5.f;
e.Point = point;
EventBroker->Publish(e);
SetNumberOfBricks(NumberOfBricks() - 1);
Events::ScoreEvent es;
es.Score = brick->Score;
EventBroker->Publish(es);
m_World->RemoveEntity(entityShot);
return true;
}
if (!Restarting() && !brick->Removed) { if (!Restarting() && !brick->Removed) {
brick->Removed = true; brick->Removed = true;
@@ -268,6 +313,7 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
auto ballTransform = m_World->GetComponent<Components::Transform>(entityBall); auto ballTransform = m_World->GetComponent<Components::Transform>(entityBall);
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick); auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
physicsComponent->GravityScale = 1.f; physicsComponent->GravityScale = 1.f;
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall); physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
@@ -381,6 +427,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
// 2 is multiball brick. // 2 is multiball brick.
// 3 is lifebuoy brick. // 3 is lifebuoy brick.
// 4 is sticky brick. // 4 is sticky brick.
// 5 is ink blaster brick.
if (m_CurrentCluster == 0) { if (m_CurrentCluster == 0) {
if (m_CurrentLevel == 1) { if (m_CurrentLevel == 1) {
level = level =
@@ -431,7 +478,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1,
1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1,
4, 0, 0, 3, 0, 0, 1}; 4, 0, 0, 3, 0, 0, 5};
} else if (m_CurrentLevel == 2) { } else if (m_CurrentLevel == 2) {
level = level =
{1, 0, 0, 0, 0, 0, 1, {1, 0, 0, 0, 0, 0, 1,
-2
View File
@@ -50,7 +50,6 @@ void dd::Systems::LifebuoySystem::Update(double dt)
if (transformComponent->Position.y < m_DownEdge) { if (transformComponent->Position.y < m_DownEdge) {
m_World->RemoveEntity(it->Entity); m_World->RemoveEntity(it->Entity);
m_LifeBuoys.erase(it++); m_LifeBuoys.erase(it++);
LOG_INFO("Removed buoy");
} }
else { else {
@@ -65,7 +64,6 @@ void dd::Systems::LifebuoySystem::Update(double dt)
auto modelComponent = m_World->GetComponent<Components::Model>(it->Entity); auto modelComponent = m_World->GetComponent<Components::Model>(it->Entity);
modelComponent->Color = glm::vec4(0.5f, 0.5f, 0.5f, 0.f); modelComponent->Color = glm::vec4(0.5f, 0.5f, 0.5f, 0.f);
LOG_INFO("Buoy is sinking");
} }
++it; ++it;
} }
+2 -2
View File
@@ -63,8 +63,7 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
if (ball->Sticky) { if (ball->Sticky) {
auto transform = m_World->GetComponent<Components::Transform>(entity); auto transform = m_World->GetComponent<Components::Transform>(entity);
transform->Position = Transform()->Position; transform->Position = Transform()->Position;
transform->Position -= ball->StickyPlacement; transform->Position += ball->StickyPlacement;
transform->Orientation = glm::quat();
} }
} }
} }
@@ -170,6 +169,7 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
EventBroker->Publish(e); EventBroker->Publish(e);
} else if (val == GLFW_KEY_SPACE) { } else if (val == GLFW_KEY_SPACE) {
Events::ActionButton e; Events::ActionButton e;
e.Position = Transform()->Position;
EventBroker->Publish(e); EventBroker->Publish(e);
} else if (val == GLFW_KEY_D) { } else if (val == GLFW_KEY_D) {
return false; return false;
+124
View File
@@ -0,0 +1,124 @@
//
// Created by Adniklastrator on 2015-10-08.
//
#include "PrecompiledHeader.h"
#include "Game/ProjectileSystem.h"
void dd::Systems::ProjectileSystem::Initialize()
{
EVENT_SUBSCRIBE_MEMBER(m_EContact, &ProjectileSystem::OnContact);
EVENT_SUBSCRIBE_MEMBER(m_EPause, &ProjectileSystem::OnPause);
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &ProjectileSystem::OnInkBlaster);
EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &ProjectileSystem::OnHitPad);
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &ProjectileSystem::OnActionButton);
//Ink Blast
{
auto ent = m_World->CreateEntity();
m_World->SetProperty(ent, "Name", "Projectile");
std::shared_ptr<Components::Transform> ctransform = m_World->AddComponent<Components::Transform>(ent);
auto circleShape = m_World->AddComponent<Components::CircleShape>(ent);
auto inkBlastTemplate = m_World->AddComponent<Components::Template>(ent);
circleShape->Radius = 0.1f;
auto physics = m_World->AddComponent<Components::Physics>(ent);
physics->CollisionType = CollisionType::Type::Dynamic;
physics->Category = CollisionLayer::Type::Projectile;
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall);
physics->Calculate = true;
ctransform->Sticky = true;
ctransform->Position = glm::vec3(0.f, 0.f, -10.f);
ctransform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
auto cModel = m_World->AddComponent<Components::Model>(ent);
cModel->ModelFile = "Models/Test/Ball/Sid.obj";
auto projectile = m_World->AddComponent<Components::Projectile>(ent);
m_World->CommitEntity(ent);
m_InkBlastTemplate = ent;
}
return;
}
void dd::Systems::ProjectileSystem::Update(double dt)
{
}
void dd::Systems::ProjectileSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
{
if (IsPaused()) {
return;
}
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
if (templateCheck != nullptr){ return; }
auto shot = m_World->GetComponent<Components::Projectile>(entity);
if (shot != nullptr) {
auto transform = m_World->GetComponent<Components::Transform>(entity);
if (transform->Position.y > 8) {
m_World->RemoveEntity(entity);
}
}
}
bool dd::Systems::ProjectileSystem::OnPause(const dd::Events::Pause &event)
{
if (event.Type != "ProjectileSystem" && event.Type != "All") {
return false;
}
if (IsPaused()) {
SetPause(false);
} else {
SetPause(true);
}
return true;
}
bool dd::Systems::ProjectileSystem::OnContact(const dd::Events::Contact &event)
{
return true;
}
bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
{
m_InkBlaster = true;
m_Shots = 5;
return true;
}
bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
{
if (m_InkBlaster) {
m_SquidLoaded = true;
m_AttachedSquid = event.Ball;
}
return true;
}
bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButton &event)
{
if (m_InkBlaster && m_SquidLoaded) {
auto ent = m_World->CloneEntity(m_InkBlastTemplate);
m_World->RemoveComponent<Components::Template>(ent);
auto transform = m_World->GetComponent<Components::Transform>(ent);
transform->Position = event.Position;
transform->Velocity = glm::vec3(0, 5, 0);
m_Shots--;
if (m_Shots <= 0) {
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
m_InkBlaster = false;
m_SquidLoaded = false;
ball->InkBlaster = false;
ball->Sticky = false;
}
}
return true;
}