Merge remote-tracking branch 'origin/master' into water
Conflicts: include/Core/Engine.h include/Physics/PhysicsSystem.h include/Sound/SoundSystem.h src/game/Physics/PhysicsSystem.cpp src/game/Sound/SoundSystem.cpp PS:min teori i förra commiten var sann
This commit is contained in:
+41
-110
@@ -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"
|
||||
@@ -113,10 +114,6 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::PowerUp>();
|
||||
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
|
||||
|
||||
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
||||
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PhysicsSystem>();
|
||||
|
||||
m_World->SystemFactory.Register<Systems::LevelSystem>(
|
||||
[this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::LevelSystem>();
|
||||
@@ -126,6 +123,12 @@ 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>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
@@ -135,31 +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, -9.f);
|
||||
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
transform->Velocity = glm::vec3(0.0f, -10.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);
|
||||
physics->Static = false;
|
||||
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();
|
||||
@@ -207,6 +185,7 @@ public:
|
||||
m_World->CommitEntity(background);
|
||||
}
|
||||
|
||||
// auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||
//Water test
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
@@ -271,64 +250,35 @@ public:
|
||||
//TODO: Why does the ball not collide with these bricks?
|
||||
//BottomBox
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(0.f, -7.f, -9.9f);
|
||||
transform->Scale = glm::vec3(10.f, 0.5f, 1.f);
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
auto BottomWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(BottomWall);
|
||||
transform->Position = glm::vec3(0.f, -6.f, -10.f);
|
||||
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(BottomWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
topWall);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->Static = true;
|
||||
m_World->CommitEntity(topWall);
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(BottomWall);
|
||||
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(BottomWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
m_World->CommitEntity(BottomWall);
|
||||
}
|
||||
//SideBox
|
||||
// {
|
||||
// auto topWall = m_World->CreateEntity();
|
||||
// std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
// transform->Position = glm::vec3(3.f, -3.0f, -9.9f);
|
||||
// transform->Scale = glm::vec3(0.5f, 3.f, 1.f);
|
||||
// std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
// sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
// std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
// topWall);
|
||||
// std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
// physics->Static = true;
|
||||
// m_World->CommitEntity(topWall);
|
||||
// }
|
||||
// //OtherSideBox
|
||||
// {
|
||||
// auto topWall = m_World->CreateEntity();
|
||||
// std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
// transform->Position = glm::vec3(-4.f, -3.0f, -9.9f);
|
||||
// transform->Scale = glm::vec3(0.5f, 3.0f, 1.f);
|
||||
// std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
// sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
// std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
// topWall);
|
||||
// std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
// physics->Static = true;
|
||||
// m_World->CommitEntity(topWall);
|
||||
// }
|
||||
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
|
||||
topWall);
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(0.f, 6.f, -10.f);
|
||||
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
topWall);
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(topWall);
|
||||
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->Static = true;
|
||||
physics->Category = CollisionLayer::Type::Wall;
|
||||
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::Brick;
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
@@ -343,13 +293,13 @@ public:
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(leftWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
leftWall);
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(leftWall);
|
||||
rectangleShape->Dimensions = glm::vec2(0.5f, 20.f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(leftWall);
|
||||
physics->Static = true;
|
||||
physics->Category = CollisionLayer::Type::Wall;
|
||||
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::Brick;
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
|
||||
m_World->CommitEntity(leftWall);
|
||||
}
|
||||
@@ -364,37 +314,16 @@ public:
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(rightWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
rightWall);
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(rightWall);
|
||||
rectangleShape->Dimensions = glm::vec2(0.5f, 20.f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(rightWall);
|
||||
physics->Static = true;
|
||||
physics->Category = CollisionLayer::Type::Wall;
|
||||
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::Brick;
|
||||
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
m_World->CommitEntity(rightWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
m_World->SetProperty(ent, "Name", "Pad");
|
||||
auto ctransform = m_World->AddComponent<Components::Transform>(ent);
|
||||
ctransform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
ctransform->Scale = glm::vec3(1.0f, 1.0f, 1.f);
|
||||
auto rectangle = m_World->AddComponent<Components::RectangleShape>(ent);
|
||||
auto physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
physics->Category = CollisionLayer::Type::Pad;
|
||||
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::PowerUp;
|
||||
physics->Calculate = true;
|
||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
cModel->ModelFile = "Models/Submarine2.obj";
|
||||
|
||||
auto pad = m_World->AddComponent<Components::Pad>(ent);
|
||||
m_World->CommitEntity(ent);
|
||||
}
|
||||
|
||||
|
||||
//EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &Engine::OnGameStart);
|
||||
m_EGameStart = decltype(m_EGameStart)(std::bind(&Engine::OnGameStart, this, std::placeholders::_1));
|
||||
m_EventBroker->Subscribe(m_EGameStart);
|
||||
@@ -605,17 +534,19 @@ private:
|
||||
//Todo: Move this
|
||||
{
|
||||
dd::Events::PlaySound e;
|
||||
e.path = "Sounds/BGM/under-the-sea-instrumental.wav";
|
||||
e.isAmbient = true;
|
||||
e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav";
|
||||
e.IsAmbient = true;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
dd::Events::PlaySound e;
|
||||
e.path = "Sounds/BGM/water-flowing.wav";
|
||||
e.volume = 0.3f;
|
||||
e.isAmbient = true;
|
||||
e.FilePath = "Sounds/BGM/water-flowing.wav";
|
||||
e.Gain = 0.3f;
|
||||
e.IsAmbient = true;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
double m_LastTime;
|
||||
};
|
||||
|
||||
@@ -1,562 +0,0 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <Sound/CCollisionSound.h>
|
||||
|
||||
#include "ResourceManager.h"
|
||||
#include "OBJ.h"
|
||||
#include "Model.h"
|
||||
#include "Texture.h"
|
||||
#include "EventBroker.h"
|
||||
#include "RenderQueue.h"
|
||||
#include "Renderer.h"
|
||||
#include "InputManager.h"
|
||||
//TODO: Remove includes that are only here for the temporary draw solution.
|
||||
#include "World.h"
|
||||
#include "CTransform.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "CTemplate.h"
|
||||
#include "Rendering/CPointLight.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Sound/SoundSystem.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include "Game/LevelSystem.h"
|
||||
#include "Game/PadSystem.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/BallSystem.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
|
||||
#include "Game/EGameStart.h"
|
||||
#include "Sound/EPlaySound.h"
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "GUI/Button.h"
|
||||
#include "Game/MainMenu.h"
|
||||
#include "Game/HUD.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Engine
|
||||
{
|
||||
|
||||
public:
|
||||
Engine(int argc, char* argv[]) {
|
||||
m_EventBroker = std::make_shared<EventBroker>();
|
||||
|
||||
m_Renderer = std::make_shared<Renderer>();
|
||||
m_Renderer->SetFullscreen(false);
|
||||
//m_Renderer->SetResolution(Rectangle(0, 0, 1920, 1080));
|
||||
m_Renderer->SetResolution(Rectangle(0, 0, 675, 1080));
|
||||
m_Renderer->Initialize();
|
||||
|
||||
m_FrameStack = new GUI::Frame(m_EventBroker.get());
|
||||
m_FrameStack->Width = 675;
|
||||
m_FrameStack->Height = 1080;
|
||||
auto hud = new GUI::HUD(m_FrameStack, "HUD");
|
||||
auto menu = new GUI::MainMenu(m_FrameStack, "MainMenu");
|
||||
|
||||
m_InputManager = std::make_shared<InputManager>(m_Renderer->Window(), m_EventBroker);
|
||||
|
||||
m_World = std::make_shared<World>(m_EventBroker);
|
||||
|
||||
//TODO: Move this out of engine.h
|
||||
m_World->ComponentFactory.Register<Components::Transform>();
|
||||
m_World->SystemFactory.Register<Systems::TransformSystem>(
|
||||
[this]() { return new Systems::TransformSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::TransformSystem>();
|
||||
m_World->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::CollisionSound>();
|
||||
m_World->SystemFactory.Register<Systems::SoundSystem>(
|
||||
[this]() { return new Systems::SoundSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::SoundSystem>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Sprite>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::RectangleShape>();
|
||||
m_World->ComponentFactory.Register<Components::Physics>();
|
||||
m_World->ComponentFactory.Register<Components::Ball>();
|
||||
m_World->ComponentFactory.Register<Components::Brick>();
|
||||
m_World->ComponentFactory.Register<Components::Pad>();
|
||||
m_World->ComponentFactory.Register<Components::Life>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::PowerUp>();
|
||||
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
|
||||
|
||||
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
||||
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PhysicsSystem>();
|
||||
|
||||
m_World->SystemFactory.Register<Systems::LevelSystem>(
|
||||
[this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::LevelSystem>();
|
||||
m_World->SystemFactory.Register<Systems::PadSystem>(
|
||||
[this]() { return new Systems::PadSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PadSystem>();
|
||||
m_World->SystemFactory.Register<Systems::BallSystem>(
|
||||
[this]() { return new Systems::BallSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::BallSystem>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
m_World->ComponentFactory.Register<Components::PointLight>();
|
||||
m_World->ComponentFactory.Register<Components::WaterVolume>();
|
||||
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, -9.f);
|
||||
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
transform->Velocity = glm::vec3(0.0f, -10.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;
|
||||
<<<<<<< HEAD
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
physics->Category = CollisionLayer::Type::Ball;
|
||||
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
|
||||
physics->Calculate = true;
|
||||
=======
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
>>>>>>> origin/master
|
||||
|
||||
auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
||||
plight->Radius = 2.f;
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
}
|
||||
|
||||
//PointLightTest
|
||||
{
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(2.f, 1.5f, -9.f);
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 8.f;
|
||||
m_World->CommitEntity(t_Light);
|
||||
}
|
||||
|
||||
//Halfpipe background test model.
|
||||
{
|
||||
auto t_halfPipe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -15.f);
|
||||
transform->Scale = glm::vec3(15.f);
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(1.f, 1.f, 1.f, 0.3f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
}
|
||||
|
||||
//Background
|
||||
{
|
||||
auto background = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(background);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -30.f);
|
||||
transform->Scale = glm::vec3(2681.f / 50.f, 1080.f / 50.f, 1.f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(background);
|
||||
sprite->SpriteFile = "Textures/Background.png";
|
||||
m_World->CommitEntity(background);
|
||||
}
|
||||
|
||||
//Water test
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -4.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.f, 1.5f, 1.f);
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
//TODO: Why does the ball not collide with these bricks?
|
||||
//BottomBox
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(0.f, -6.f, -9.9f);
|
||||
transform->Scale = glm::vec3(10.f, 0.5f, 1.f);
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
topWall);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->Static = true;
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
//SideBox
|
||||
// {
|
||||
// auto topWall = m_World->CreateEntity();
|
||||
// std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
// transform->Position = glm::vec3(3.f, -3.0f, -9.9f);
|
||||
// transform->Scale = glm::vec3(0.5f, 3.f, 1.f);
|
||||
// std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
// sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
// std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
// topWall);
|
||||
// std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
// physics->Static = true;
|
||||
// m_World->CommitEntity(topWall);
|
||||
// }
|
||||
// //OtherSideBox
|
||||
// {
|
||||
// auto topWall = m_World->CreateEntity();
|
||||
// std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
// transform->Position = glm::vec3(-4.f, -3.0f, -9.9f);
|
||||
// transform->Scale = glm::vec3(0.5f, 3.0f, 1.f);
|
||||
// std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
// sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
// std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
// topWall);
|
||||
// std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
// physics->Static = true;
|
||||
// m_World->CommitEntity(topWall);
|
||||
// }
|
||||
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
|
||||
topWall);
|
||||
transform->Position = glm::vec3(0.f, 6.f, -10.f);
|
||||
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
topWall);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->Static = true;
|
||||
physics->Category = CollisionLayer::Type::Wall;
|
||||
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::Brick;
|
||||
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto leftWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
|
||||
leftWall);
|
||||
transform->Position = glm::vec3(-4.f, 1.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 20.f, 1.f);
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(leftWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
leftWall);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(leftWall);
|
||||
physics->Static = true;
|
||||
physics->Category = CollisionLayer::Type::Wall;
|
||||
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::Brick;
|
||||
|
||||
m_World->CommitEntity(leftWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto rightWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
|
||||
rightWall);
|
||||
transform->Position = glm::vec3(4.f, 1.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 20.f, 1.f);
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(rightWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
rightWall);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(rightWall);
|
||||
physics->Static = true;
|
||||
physics->Category = CollisionLayer::Type::Wall;
|
||||
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::Brick;
|
||||
|
||||
m_World->CommitEntity(rightWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
m_World->SetProperty(ent, "Name", "Pad");
|
||||
auto ctransform = m_World->AddComponent<Components::Transform>(ent);
|
||||
ctransform->Position = glm::vec3(0.f, -5.f, -10.f);
|
||||
ctransform->Scale = glm::vec3(1.0f, 1.0f, 1.f);
|
||||
auto rectangle = m_World->AddComponent<Components::RectangleShape>(ent);
|
||||
auto physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
physics->Category = CollisionLayer::Type::Pad;
|
||||
physics->Mask = CollisionLayer::Type::Ball | CollisionLayer::Type::PowerUp;
|
||||
physics->Calculate = true;
|
||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
cModel->ModelFile = "Models/Submarine2.obj";
|
||||
|
||||
auto pad = m_World->AddComponent<Components::Pad>(ent);
|
||||
m_World->CommitEntity(ent);
|
||||
}
|
||||
|
||||
|
||||
//EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &Engine::OnGameStart);
|
||||
m_EGameStart = decltype(m_EGameStart)(std::bind(&Engine::OnGameStart, this, std::placeholders::_1));
|
||||
m_EventBroker->Subscribe(m_EGameStart);
|
||||
|
||||
m_LastTime = glfwGetTime();
|
||||
}
|
||||
|
||||
bool Running() const { return !glfwWindowShouldClose(m_Renderer->Window()); }
|
||||
|
||||
void Tick()
|
||||
{
|
||||
double currentTime = glfwGetTime();
|
||||
double dt = currentTime - m_LastTime;
|
||||
m_LastTime = currentTime;
|
||||
|
||||
// Update input
|
||||
m_InputManager->Update(dt);
|
||||
// Swap event queues to get fresh input data in the read queue
|
||||
//m_EventBroker->Swap();
|
||||
|
||||
ResourceManager::Update();
|
||||
if (m_GameIsRunning) {
|
||||
m_World->Update(dt);
|
||||
}
|
||||
m_EventBroker->Process<GUI::Frame>();
|
||||
m_FrameStack->UpdateLayered(dt);
|
||||
|
||||
m_RendererQueue.Clear();
|
||||
m_FrameStack->DrawLayered(m_RendererQueue);
|
||||
//TODO Fill up the renderQueue with models (Temp fix)
|
||||
if (m_GameIsRunning) {
|
||||
TEMPAddToRenderQueue();
|
||||
}
|
||||
|
||||
// Render scene
|
||||
//TODO send renderqueue to draw.
|
||||
m_Renderer->Draw(m_RendererQueue);
|
||||
|
||||
m_EventBroker->Process<Engine>();
|
||||
// Swap event queues
|
||||
m_EventBroker->Swap();
|
||||
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||
std::shared_ptr<Systems::LevelSystem> m_LevelSystem;
|
||||
|
||||
//TODO: Get this out of engine.h
|
||||
void TEMPAddToRenderQueue()
|
||||
{
|
||||
if (!m_TransformSystem)
|
||||
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
||||
|
||||
for (auto &pair : *m_World->GetEntities())
|
||||
{
|
||||
EntityID entity = pair.first;
|
||||
|
||||
auto templateComponent = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateComponent)
|
||||
continue;
|
||||
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (!transform)
|
||||
continue;
|
||||
|
||||
auto modelComponent = m_World->GetComponent<Components::Model>(entity);
|
||||
if (modelComponent)
|
||||
{
|
||||
Model* modelAsset = nullptr;
|
||||
modelAsset = ResourceManager::Load<Model>(modelComponent->ModelFile);
|
||||
|
||||
if (modelAsset)
|
||||
{
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(), absoluteTransform.Position)
|
||||
* glm::toMat4(absoluteTransform.Orientation)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color, modelComponent->ModelFile);
|
||||
}
|
||||
}
|
||||
|
||||
auto pointLightComponent = m_World->GetComponent<Components::PointLight>(entity);
|
||||
if (pointLightComponent)
|
||||
{
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
EnqueuePointLight(absoluteTransform.Position,
|
||||
pointLightComponent->Diffuse,
|
||||
pointLightComponent->Specular,
|
||||
pointLightComponent->Radius);
|
||||
}
|
||||
|
||||
auto parent = m_World->GetEntityParent(entity);
|
||||
if(parent != 0) {
|
||||
auto waterParticleComponent = m_World->GetComponent<Components::WaterVolume>(parent);
|
||||
if (waterParticleComponent) {
|
||||
//TODO: Remove hardcoded color.
|
||||
//TODO: Do i even need modelMatrix?
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueWaterParticles(absoluteTransform.Position, glm::vec4(1.f, 1.f, 1.f, 1.f), modelMatrix, absoluteTransform.Position.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto spriteComponent = m_World->GetComponent<Components::Sprite>(entity);
|
||||
if (spriteComponent)
|
||||
{
|
||||
|
||||
std::string normal = spriteComponent->NormalTexture;
|
||||
std::string spec = spriteComponent->SpecularTexture;
|
||||
|
||||
if (normal.empty()) {
|
||||
normal = "Textures/Core/NeutralNormalMap.png";
|
||||
}
|
||||
if (spec.empty()) {
|
||||
spec = "Textures/Core/NeutralSpecularMap.png";
|
||||
}
|
||||
auto texturediff = ResourceManager::Load<Texture>(spriteComponent->SpriteFile);
|
||||
auto texturenorm = ResourceManager::Load<Texture>(normal);
|
||||
auto texturespec = ResourceManager::Load<Texture>(spec);
|
||||
|
||||
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
glm::quat orientation2D = glm::angleAxis(glm::eulerAngles(absoluteTransform.Orientation).z, glm::vec3(0, 0, -1));
|
||||
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
|
||||
* glm::toMat4(orientation2D)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueSprite(texturediff, texturenorm, texturespec, modelMatrix, spriteComponent->Color, absoluteTransform.Position.z);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO: Get this out of engine.h
|
||||
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color, std::string fileName)
|
||||
{
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
ModelJob job;
|
||||
job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;
|
||||
job.DiffuseTexture = (texGroup.Texture) ? *texGroup.Texture : 0;
|
||||
job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0;
|
||||
job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0;
|
||||
job.VAO = model->VAO;
|
||||
job.ElementBuffer = model->ElementBuffer;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
|
||||
m_RendererQueue.Deferred.Add(job);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Get this out of engine.h
|
||||
void EnqueueSprite(Texture* texture, Texture* normalTexture, Texture* specularTexture, glm::mat4 modelMatrix, glm::vec4 color, float depth)
|
||||
{
|
||||
SpriteJob job;
|
||||
job.TextureID = texture->ResourceID;
|
||||
job.DiffuseTexture = *texture;
|
||||
job.NormalTexture = *normalTexture;
|
||||
job.SpecularTexture = *specularTexture;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
job.Depth = depth;
|
||||
|
||||
|
||||
m_RendererQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
void EnqueuePointLight(glm::vec3 position, glm::vec3 diffuseColor, glm::vec3 specularColor, float radius)
|
||||
{
|
||||
PointLightJob job;
|
||||
job.Position = position;
|
||||
job.DiffuseColor = diffuseColor;
|
||||
job.SpecularColor = specularColor;
|
||||
job.Radius = radius;
|
||||
|
||||
m_RendererQueue.Lights.Add(job);
|
||||
|
||||
}
|
||||
|
||||
void EnqueueWaterParticles(glm::vec3 position, glm::vec4 color, glm::mat4 modelMatrix, float depth)
|
||||
{
|
||||
WaterParticleJob job;
|
||||
job.Position = position;
|
||||
job.Color = color;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Depth = depth;
|
||||
|
||||
m_RendererQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<EventBroker> m_EventBroker;
|
||||
GUI::Frame* m_FrameStack = nullptr;
|
||||
std::shared_ptr<Renderer> m_Renderer;
|
||||
RenderQueueCollection m_RendererQueue;
|
||||
std::shared_ptr<InputManager> m_InputManager;
|
||||
std::shared_ptr<World> m_World;
|
||||
|
||||
//TODO: Redo
|
||||
bool m_GameIsRunning = false;
|
||||
dd::EventRelay<Engine, dd::Events::GameStart> m_EGameStart;
|
||||
bool OnGameStart(const dd::Events::GameStart &event)
|
||||
{
|
||||
m_GameIsRunning = true;
|
||||
//Todo: Move this
|
||||
{
|
||||
dd::Events::PlaySound e;
|
||||
e.path = "Sounds/BGM/under-the-sea-instrumental.wav";
|
||||
e.isAmbient = true;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
dd::Events::PlaySound e;
|
||||
e.path = "Sounds/BGM/water-flowing.wav";
|
||||
e.volume = 0.3f;
|
||||
e.isAmbient = true;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
};
|
||||
double m_LastTime;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <list>
|
||||
#include <tuple>
|
||||
|
||||
#define EVENT_SUBSCRIBE_MEMBER(relay, handler) \
|
||||
relay = decltype(relay)(std::bind(handler, this, std::placeholders::_1)); \
|
||||
@@ -123,16 +124,23 @@ public:
|
||||
void Unsubscribe(BaseEventRelay &relay);
|
||||
|
||||
private:
|
||||
bool m_IsProcessing = false;
|
||||
|
||||
typedef std::string ContextTypeName_t; // typeid(ContextType).name()
|
||||
typedef std::string EventTypeName_t; // typeid(EventType).name()
|
||||
|
||||
typedef std::unordered_multimap<EventTypeName_t, BaseEventRelay*> EventRelays_t;
|
||||
typedef std::unordered_map<ContextTypeName_t, EventRelays_t> ContextRelays_t;
|
||||
ContextRelays_t m_ContextRelays;
|
||||
std::vector<BaseEventRelay*> m_RelaysToSubscribe;
|
||||
std::vector<BaseEventRelay*> m_RelaysToUnsubscribe;
|
||||
|
||||
typedef std::list<std::pair<EventTypeName_t, std::shared_ptr<Event>>> EventQueue_t;
|
||||
std::shared_ptr<EventQueue_t> m_EventQueueRead;
|
||||
std::shared_ptr<EventQueue_t> m_EventQueueWrite;
|
||||
|
||||
void subscribeImmediate(BaseEventRelay& relay);
|
||||
void unsubscribeImmediate(BaseEventRelay& relay);
|
||||
};
|
||||
|
||||
template <typename EventType>
|
||||
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
|
||||
// Triggers commit events in systems
|
||||
// TODO: Replace completely by EComponentCreated?
|
||||
int CommitEntity(EntityID entity);
|
||||
void CommitEntity(EntityID entity);
|
||||
|
||||
/** Get all components of a specific type.
|
||||
|
||||
|
||||
@@ -60,6 +60,10 @@ protected:
|
||||
|
||||
virtual bool OnMouseMove(const Events::MouseMove& event)
|
||||
{
|
||||
if (Hidden()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isOver = Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1));
|
||||
if (isOver && !m_MouseIsOver) { // Enter
|
||||
if (!m_IsDown) {
|
||||
@@ -88,6 +92,11 @@ protected:
|
||||
}
|
||||
virtual bool OnMousePress(const Events::MousePress& event)
|
||||
{
|
||||
if (Hidden()) {
|
||||
LOG_DEBUG("Pressed hidden button");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1))) {
|
||||
return false;
|
||||
}
|
||||
@@ -107,6 +116,11 @@ protected:
|
||||
}
|
||||
virtual bool OnMouseRelease(const Events::MouseRelease& event)
|
||||
{
|
||||
if (Hidden()) {
|
||||
LOG_DEBUG("Released hidden button");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isOver = Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1));
|
||||
if (!isOver && !m_IsDown) {
|
||||
return false;
|
||||
|
||||
+42
-57
@@ -1,6 +1,8 @@
|
||||
#ifndef GUI_NUMBERFRAME_H__
|
||||
#define GUI_NUMBERFRAME_H__
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "GUI/TextureFrame.h"
|
||||
|
||||
namespace dd
|
||||
@@ -14,32 +16,16 @@ public:
|
||||
NumberFrame(Frame* parent, std::string name)
|
||||
: Frame(parent, name)
|
||||
{
|
||||
m_NumberTextures[0] = "Textures/GUI/Numbers/N0.png";
|
||||
m_NumberTextures[1] = "Textures/GUI/Numbers/N1.png";
|
||||
m_NumberTextures[2] = "Textures/GUI/Numbers/N2.png";
|
||||
m_NumberTextures[3] = "Textures/GUI/Numbers/N3.png";
|
||||
m_NumberTextures[4] = "Textures/GUI/Numbers/N4.png";
|
||||
m_NumberTextures[5] = "Textures/GUI/Numbers/N5.png";
|
||||
m_NumberTextures[6] = "Textures/GUI/Numbers/N6.png";
|
||||
m_NumberTextures[7] = "Textures/GUI/Numbers/N7.png";
|
||||
m_NumberTextures[8] = "Textures/GUI/Numbers/N8.png";
|
||||
m_NumberTextures[9] = "Textures/GUI/Numbers/N9.png";
|
||||
|
||||
// Create number frame if missing
|
||||
for (int i = 0; i < 10; i++) {
|
||||
auto frame = new GUI::TextureFrame(this, "NumberFrameDigit");
|
||||
frame->SetTexture(m_NumberTextures[0]);
|
||||
frame->DisableScissor();
|
||||
// Position frame based on alignment
|
||||
if (i > 0) {
|
||||
frame->X = i * 20;
|
||||
}
|
||||
Width += frame->Width;
|
||||
if (Height < frame->Height) {
|
||||
Height = frame->Height;
|
||||
}
|
||||
m_NumberFrames.push_front(frame);
|
||||
}
|
||||
m_CharacterTextures['0'] = "Textures/GUI/Numbers/N0.png";
|
||||
m_CharacterTextures['1'] = "Textures/GUI/Numbers/N1.png";
|
||||
m_CharacterTextures['2'] = "Textures/GUI/Numbers/N2.png";
|
||||
m_CharacterTextures['3'] = "Textures/GUI/Numbers/N3.png";
|
||||
m_CharacterTextures['4'] = "Textures/GUI/Numbers/N4.png";
|
||||
m_CharacterTextures['5'] = "Textures/GUI/Numbers/N5.png";
|
||||
m_CharacterTextures['6'] = "Textures/GUI/Numbers/N6.png";
|
||||
m_CharacterTextures['7'] = "Textures/GUI/Numbers/N7.png";
|
||||
m_CharacterTextures['8'] = "Textures/GUI/Numbers/N8.png";
|
||||
m_CharacterTextures['9'] = "Textures/GUI/Numbers/N9.png";
|
||||
|
||||
SetNumber(0);
|
||||
}
|
||||
@@ -50,41 +36,40 @@ public:
|
||||
m_Number = number;
|
||||
|
||||
// Clear number textures
|
||||
//for (auto& frame : m_NumberFrames) {
|
||||
// frame->SetTexture("");
|
||||
//}
|
||||
for (auto& frame : m_NumberFrames) {
|
||||
frame->SetTexture("");
|
||||
}
|
||||
|
||||
//Width = 0;
|
||||
//Height = 0;
|
||||
Width = 0;
|
||||
Height = 0;
|
||||
|
||||
int n = 0;
|
||||
do {
|
||||
// // Create number frame if missing
|
||||
// if (m_NumberFrames.size() <= n) {
|
||||
// auto frame = new GUI::TextureFrame(this, "NumberFrameDigit");
|
||||
// frame->DisableScissor();
|
||||
// m_NumberFrames.push_front(frame);
|
||||
// }
|
||||
std::string digits = std::to_string(number);
|
||||
|
||||
int i = 0;
|
||||
for (char& c : digits) {
|
||||
// Create number frame if missing
|
||||
if (i >= m_NumberFrames.size()) {
|
||||
auto frame = new GUI::TextureFrame(this, "NumberFrameDigit");
|
||||
if (i > 0) {
|
||||
frame->SetLeft(m_NumberFrames[i - 1]->Right());
|
||||
}
|
||||
frame->DisableScissor();
|
||||
m_NumberFrames.push_back(frame);
|
||||
}
|
||||
|
||||
// Update value
|
||||
int digit = number % 10;
|
||||
m_NumberFrames[n]->SetTexture(m_NumberTextures[digit]);
|
||||
//Width += m_NumberFrames[n]->Width;
|
||||
//if (Height < m_NumberFrames[n]->Height) {
|
||||
// Height = m_NumberFrames[n]->Height;
|
||||
//}
|
||||
// // Position frame based on alignment
|
||||
// if (n > 0) {
|
||||
// if (!m_LeftAligned) {
|
||||
// m_NumberFrames[n]->SetLeft(m_NumberFrames[n - 1]->Right());
|
||||
// } else {
|
||||
// m_NumberFrames[n]->SetRight(m_NumberFrames[n - 1]->Left());
|
||||
// }
|
||||
// }
|
||||
std::string texture = "Textures/Core/ErrorTexture.png";
|
||||
if (m_CharacterTextures.find(c) != m_CharacterTextures.end()) {
|
||||
texture = m_CharacterTextures.at(c);
|
||||
}
|
||||
m_NumberFrames[i]->SetTexture(m_CharacterTextures.at(c));
|
||||
Width += m_NumberFrames[i]->Width;
|
||||
if (Height < m_NumberFrames[i]->Height) {
|
||||
Height = m_NumberFrames[i]->Height;
|
||||
}
|
||||
|
||||
number /= 10;
|
||||
n++;
|
||||
} while (number > 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void SetLeftAlign() { m_LeftAligned = true; }
|
||||
@@ -99,7 +84,7 @@ private:
|
||||
int m_Number = 0;
|
||||
bool m_LeftAligned = true;
|
||||
|
||||
std::string m_NumberTextures[10];
|
||||
std::unordered_map<char, std::string> m_CharacterTextures;
|
||||
std::deque<TextureFrame*> m_NumberFrames;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,23 +5,42 @@
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/CTransform.h"
|
||||
#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 {
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems {
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class BallSystem : public System {
|
||||
class BallSystem : public System
|
||||
{
|
||||
public:
|
||||
BallSystem(World *world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker) { }
|
||||
|
||||
~BallSystem();
|
||||
|
||||
EventRelay<BallSystem, Events::Contact> m_Contact;
|
||||
bool Contact(const Events::Contact &event);
|
||||
|
||||
|
||||
void RegisterComponents(ComponentFactory *cf) override;
|
||||
|
||||
@@ -39,11 +58,64 @@ public:
|
||||
// Called when an entity is removed
|
||||
void OnEntityRemoved(EntityID entity) override;
|
||||
|
||||
private:
|
||||
EntityID CreateBall();
|
||||
void CreateLife(int);
|
||||
EntityID Ball() { return m_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; }
|
||||
void SetEdgeX(const float& edgeX) { m_EdgeX = edgeX; }
|
||||
float& EdgeY() { return m_EdgeY; }
|
||||
void SetEdgeY(const float& edgeY) { m_EdgeY = edgeY; }
|
||||
int& MultiBalls() { return m_MultiBalls; }
|
||||
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
||||
int& Lives() { return m_Lives; }
|
||||
void SetLives(const int& lives) { m_Lives = lives; }
|
||||
int& PastLives() { return m_PastLives; }
|
||||
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
|
||||
bool ReplaceBall() const { return m_ReplaceBall; }
|
||||
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
|
||||
private:
|
||||
float m_XMovementMultiplier = 2.f;
|
||||
float m_EdgeX = 3.2f;
|
||||
float m_EdgeY = 5.2f;
|
||||
int m_MultiBalls = 0;
|
||||
int m_Lives = 3;
|
||||
int m_PastLives = 3;
|
||||
bool m_ReplaceBall = false;
|
||||
bool m_Pause = false;
|
||||
EntityID m_LastCollision = 999999;
|
||||
|
||||
glm::vec3 m_SavedSpeed;
|
||||
bool m_InitializePause = false;
|
||||
|
||||
EntityID m_Ball;
|
||||
|
||||
std::unordered_map<EntityID, std::list<glm::vec2>> m_Contacts;
|
||||
void ResolveContacts();
|
||||
|
||||
dd::EventRelay<BallSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||
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;
|
||||
EventRelay<BallSystem, Events::Contact> m_Contact;
|
||||
|
||||
bool Contact(const Events::Contact &event);
|
||||
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);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,9 @@ struct Ball : Component
|
||||
{
|
||||
int Number = 0;
|
||||
float Speed = 5.f;
|
||||
int Combo = 0;
|
||||
bool Paused = false;
|
||||
glm::vec3 SavedSpeed = glm::vec3(0, 0, 0);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -15,9 +15,8 @@ namespace Components
|
||||
|
||||
struct Brick : Component
|
||||
{
|
||||
int Points = 10;
|
||||
int Hits = 1;
|
||||
int Score = 50;
|
||||
int Type = 0;
|
||||
bool Removed = false;
|
||||
};
|
||||
|
||||
|
||||
+1
-4
@@ -17,12 +17,9 @@ namespace Components
|
||||
|
||||
struct Pad : Component
|
||||
{
|
||||
int Lives;
|
||||
int Points;
|
||||
|
||||
float SlowdownModifier = 5.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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-28.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EMULTIBALLLOST_H
|
||||
#define DAYDREAM_EMULTIBALLLOST_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct MultiBallLost : Event
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EMULTIBALLLOST_H
|
||||
@@ -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
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef GUI_FPSCOUNTER_H__
|
||||
#define GUI_FPSCOUNTER_H__
|
||||
|
||||
#include <numeric>
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "GUI/NumberFrame.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace GUI
|
||||
{
|
||||
|
||||
class FPSCounter : public Frame
|
||||
{
|
||||
public:
|
||||
FPSCounter(Frame* parent, std::string name)
|
||||
: Frame(parent, name)
|
||||
{
|
||||
m_FrameTimes.resize(m_MaxSamples);
|
||||
m_Numbers = new GUI::NumberFrame(this, "FPSCounterNumberFrame");
|
||||
}
|
||||
|
||||
virtual void Update(double dt)
|
||||
{
|
||||
m_FrameTimes[m_CurrentFrame % m_MaxSamples] = dt;
|
||||
double sum = std::accumulate(m_FrameTimes.begin(), m_FrameTimes.end(), 0.0);
|
||||
sum /= std::min(m_CurrentFrame, m_MaxSamples);
|
||||
m_Numbers->SetNumber(std::round(1.0 / sum));
|
||||
|
||||
m_CurrentFrame++;
|
||||
}
|
||||
|
||||
private:
|
||||
NumberFrame* m_Numbers = nullptr;
|
||||
|
||||
int m_MaxSamples = 100;
|
||||
int m_CurrentFrame = 0;
|
||||
std::vector<double> m_FrameTimes;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "GUI/NumberFrame.h"
|
||||
#include "Core/EKeyUp.h"
|
||||
#include "Game/EScoreEvent.h"
|
||||
#include "Game/FPSCounter.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -24,6 +25,15 @@ public:
|
||||
m_LevelIndicator = new GUI::TextureFrame(this, "HUDLevelIndicator");
|
||||
m_LevelIndicator->SetTexture("Textures/GUI/HUD/LevelIndicatorBG.png");
|
||||
|
||||
m_AreaNumberFrame = new GUI::NumberFrame(m_LevelIndicator, "HUDScoreNumberFrameawdawdwa");
|
||||
m_AreaNumberFrame->X = 132;
|
||||
m_AreaNumberFrame->Y = 19;
|
||||
m_AreaNumberFrame->SetNumber(6);
|
||||
m_StageNumberFrame = new GUI::NumberFrame(m_LevelIndicator, "HUDScoreNumberFrameawdawdwa");
|
||||
m_StageNumberFrame->X = 165;
|
||||
m_StageNumberFrame->Y = 19;
|
||||
m_StageNumberFrame->SetNumber(5);
|
||||
|
||||
m_ScoreIndicator = new GUI::TextureFrame(this, "HUDScoreIndicator");
|
||||
m_ScoreIndicator->SetTexture("Textures/GUI/HUD/ScoreIndicatorBG.png");
|
||||
m_ScoreIndicator->SetRight(Right());
|
||||
@@ -31,19 +41,25 @@ public:
|
||||
m_ScoreNumberFrame->X = 15;
|
||||
m_ScoreNumberFrame->Y = 21;
|
||||
|
||||
m_FPSCounter = new GUI::FPSCounter(this, "FPSCounter");
|
||||
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EScore, &HUD::OnScore);
|
||||
}
|
||||
|
||||
private:
|
||||
TextureFrame* m_LevelIndicator = nullptr;
|
||||
TextureFrame* m_ScoreIndicator = nullptr;
|
||||
NumberFrame* m_AreaNumberFrame = nullptr;
|
||||
NumberFrame* m_StageNumberFrame = nullptr;
|
||||
NumberFrame* m_ScoreNumberFrame = nullptr;
|
||||
FPSCounter* m_FPSCounter = nullptr;
|
||||
|
||||
EventRelay<Frame, Events::ScoreEvent> m_EScore;
|
||||
|
||||
bool OnScore(const Events::ScoreEvent& event)
|
||||
{
|
||||
m_ScoreNumberFrame->SetNumber(m_ScoreNumberFrame->Number() + event.Score);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
+41
-28
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
@@ -19,21 +20,24 @@
|
||||
#include "Game/ELifeLost.h"
|
||||
#include "Game/EResetBall.h"
|
||||
#include "Game/EScoreEvent.h"
|
||||
#include "Physics/CRectangleShape.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"
|
||||
#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>
|
||||
#include <intrin.h>
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -42,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
|
||||
{
|
||||
@@ -62,11 +66,8 @@ public:
|
||||
void Initialize() override;
|
||||
|
||||
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 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);
|
||||
|
||||
@@ -79,10 +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; }
|
||||
int& Lives() { return m_Lives; }
|
||||
void SetLives(const int& lives) { m_Lives = lives; }
|
||||
int& PastLives() { return m_PastLives; }
|
||||
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
|
||||
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; }
|
||||
@@ -100,16 +99,17 @@ public:
|
||||
|
||||
glm::vec2& SpaceBetweenBricks() { return m_SpaceBetweenBricks; }
|
||||
void SetSpaceBetweenBricks(const glm::vec2& spaceBetweenBricks) { m_SpaceBetweenBricks = spaceBetweenBricks; }
|
||||
float& EdgeX() { return m_EdgeX; }
|
||||
void SetEdgeX(const float& edgeX) { m_EdgeX = edgeX; }
|
||||
float& EdgeY() { return m_EdgeY; }
|
||||
void SetEdgeY(const float& edgeY) { m_EdgeY = edgeY; }
|
||||
float& NotResettingTheStage() { return m_NotResettingTheStage; }
|
||||
void SetNotResettingTheStage(const float& notResettingTheStage) { m_NotResettingTheStage = notResettingTheStage; }
|
||||
|
||||
private:
|
||||
bool m_Cleared = false;
|
||||
bool m_Restarting = false;
|
||||
bool m_Initialized = false;
|
||||
int m_Lives = 3;
|
||||
int m_PastLives = 3;
|
||||
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;
|
||||
@@ -118,24 +118,37 @@ private:
|
||||
int m_Lines = 7;
|
||||
float m_SpaceToEdge = 0.25f;
|
||||
glm::vec2 m_SpaceBetweenBricks = glm::vec2(1, 0.4);
|
||||
float m_EdgeX = 3.2f;
|
||||
float m_EdgeY = 5.2f;
|
||||
float m_NotResettingTheStage = 5.f;
|
||||
|
||||
const int EmptyBrickSpace = 0;
|
||||
const int StandardBrick = 1;
|
||||
const int MultiBallBrick = 2;
|
||||
|
||||
EntityID m_BrickTemplate;
|
||||
|
||||
std::array<int, 42> m_Bricks;
|
||||
|
||||
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LevelSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
|
||||
dd::EventRelay<LevelSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||
dd::EventRelay<LevelSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
|
||||
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 OnLifeLost(const dd::Events::LifeLost &event);
|
||||
bool OnScoreEvent(const dd::Events::ScoreEvent &event);
|
||||
bool OnMultiBall(const dd::Events::MultiBall &event);
|
||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||
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();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -61,15 +61,15 @@ private:
|
||||
{
|
||||
if (event.Slider == m_SFXSlider) {
|
||||
Events::MasterVolume e;
|
||||
e.isAmbient = false;
|
||||
e.gain = event.Percentage;
|
||||
e.IsAmbient = false;
|
||||
e.Gain = event.Percentage;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
if (event.Slider == m_BGMSlider) {
|
||||
Events::MasterVolume e;
|
||||
e.isAmbient = true;
|
||||
e.gain = event.Percentage;
|
||||
e.IsAmbient = true;
|
||||
e.Gain = event.Percentage;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
|
||||
+19
-14
@@ -9,6 +9,7 @@
|
||||
#include "Core/System.h"
|
||||
#include "Core/Component.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EKeyUp.h"
|
||||
@@ -27,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
|
||||
@@ -45,8 +48,6 @@ public:
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
EntityID CreateBall();
|
||||
|
||||
EntityID& Entity() { return m_Entity; }
|
||||
void SetEntity(const EntityID& ent) { m_Entity = ent; }
|
||||
glm::vec3 Acceleration() const { return m_Acceleration; }
|
||||
@@ -56,39 +57,43 @@ public:
|
||||
void SetLeft(const bool& left) { m_Left = left; }
|
||||
bool Right() const { return m_Right; }
|
||||
void SetRight(const bool& right) { m_Right = right; }
|
||||
bool ReplaceBall() const { return m_ReplaceBall; }
|
||||
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
||||
bool MultiBall() const { return m_MultiBall; }
|
||||
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
|
||||
float Edge() const { return m_Edge; }
|
||||
void SetEdge(const float& edge) { m_Edge = edge; }
|
||||
|
||||
Components::Transform* Transform() const { return m_Transform; }
|
||||
void SetTransform(Components::Transform* transform) { m_Transform = transform; }
|
||||
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);
|
||||
bool m_Left = false, m_Right = false, m_ReplaceBall = false, m_MultiBall = false;
|
||||
Components::Transform* m_Transform;
|
||||
Components::Pad* m_Pad;
|
||||
bool m_Left = false;
|
||||
bool m_Right = false;
|
||||
bool m_ReplaceBall = false;
|
||||
bool m_MultiBall = false;
|
||||
float m_Edge = 2.8f;
|
||||
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::ResetBall> m_EResetBall;
|
||||
dd::EventRelay<PadSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||
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 OnResetBall(const dd::Events::ResetBall &event);
|
||||
bool OnMultiBall(const dd::Events::MultiBall &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;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Components
|
||||
|
||||
struct CircleShape : public Component
|
||||
{
|
||||
// Circles are circles
|
||||
float Radius = 1.f;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+38
-38
@@ -7,24 +7,24 @@ namespace dd {
|
||||
namespace ParticleFlags {
|
||||
|
||||
enum Type {
|
||||
waterParticle = 0,
|
||||
zombieParticle = 1 << 1,
|
||||
wallParticle = 1 << 2,
|
||||
springParticle = 1 << 3,
|
||||
elasticParticle = 1 << 4,
|
||||
viscousParticle = 1 << 5,
|
||||
powderParticle = 1 << 6,
|
||||
tensileParticle = 1 << 7,
|
||||
colorMixingParticle = 1 << 8,
|
||||
destructionListenerParticle = 1 << 9,
|
||||
barrierParticle = 1 << 10,
|
||||
staticPressureParticle = 1 << 11,
|
||||
reactiveParticle = 1 << 12,
|
||||
repulsiveParticle = 1 << 13,
|
||||
fixtureContactListenerParticle = 1 << 14,
|
||||
particleContactListenerParticle = 1 << 15,
|
||||
fixtureContactFilterParticle = 1 << 16,
|
||||
particleContactFilterParticle = 1 << 17
|
||||
Water = 0,
|
||||
Zombie = 1 << 1,
|
||||
Wall = 1 << 2,
|
||||
Spring = 1 << 3,
|
||||
Elastic = 1 << 4,
|
||||
Viscous = 1 << 5,
|
||||
Powder = 1 << 6,
|
||||
Tensile = 1 << 7,
|
||||
ColorMixing = 1 << 8,
|
||||
DestructionListener = 1 << 9,
|
||||
Barrier = 1 << 10,
|
||||
StaticPressure = 1 << 11,
|
||||
Reactive = 1 << 12,
|
||||
Repulsive = 1 << 13,
|
||||
FixtureContactListener = 1 << 14,
|
||||
ParticleContactListener = 1 << 15,
|
||||
FixtureContactFilter = 1 << 16,
|
||||
ParticleContactFilter = 1 << 17
|
||||
};
|
||||
}
|
||||
|
||||
@@ -36,26 +36,26 @@ struct Particle : public Component
|
||||
float Radius = 0.5f;
|
||||
float LifeTime = 5.0f;
|
||||
|
||||
ParticleFlags::Type Flags =
|
||||
ParticleFlags::Type::waterParticle |
|
||||
ParticleFlags::Type::zombieParticle |
|
||||
ParticleFlags::Type::wallParticle |
|
||||
ParticleFlags::Type::springParticle |
|
||||
ParticleFlags::Type::elasticParticle |
|
||||
ParticleFlags::Type::viscousParticle |
|
||||
ParticleFlags::Type::powderParticle |
|
||||
ParticleFlags::Type::tensileParticle |
|
||||
ParticleFlags::Type::colorMixingParticle |
|
||||
ParticleFlags::Type::destructionListenerParticle |
|
||||
ParticleFlags::Type::barrierParticle |
|
||||
ParticleFlags::Type::staticPressureParticle |
|
||||
ParticleFlags::Type::reactiveParticle |
|
||||
ParticleFlags::Type::repulsiveParticle |
|
||||
ParticleFlags::Type::fixtureContactListenerParticle |
|
||||
ParticleFlags::Type::particleContactListenerParticle |
|
||||
ParticleFlags::Type::fixtureContactFilterParticle |
|
||||
ParticleFlags::Type::particleContactFilterParticle;
|
||||
|
||||
ParticleFlags::Type Flags = static_cast<ParticleFlags::Type>(
|
||||
ParticleFlags::Water
|
||||
| ParticleFlags::Zombie
|
||||
| ParticleFlags::Wall
|
||||
| ParticleFlags::Spring
|
||||
| ParticleFlags::Elastic
|
||||
| ParticleFlags::Viscous
|
||||
| ParticleFlags::Powder
|
||||
| ParticleFlags::Tensile
|
||||
| ParticleFlags::ColorMixing
|
||||
| ParticleFlags::DestructionListener
|
||||
| ParticleFlags::Barrier
|
||||
| ParticleFlags::StaticPressure
|
||||
| ParticleFlags::Reactive
|
||||
| ParticleFlags::Repulsive
|
||||
| ParticleFlags::FixtureContactListener
|
||||
| ParticleFlags::ParticleContactListener
|
||||
| ParticleFlags::FixtureContactFilter
|
||||
| ParticleFlags::ParticleContactFilter
|
||||
);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ struct ParticleEmitter : public Component
|
||||
float Speed = 2.f;
|
||||
double LifeTime = 100;
|
||||
|
||||
//ParticleSystem variables
|
||||
//System variables
|
||||
float GravityScale = 1.0f;
|
||||
};
|
||||
|
||||
|
||||
+31
-15
@@ -18,24 +18,40 @@ enum Type
|
||||
Wall = 1 << 6
|
||||
};
|
||||
}
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Physics: public Component
|
||||
namespace CollisionType
|
||||
{
|
||||
bool Static = true;
|
||||
bool Calculate = false;
|
||||
float GravityScale = 0.f;
|
||||
CollisionLayer::Type Category = CollisionLayer::Type::Other;
|
||||
CollisionLayer::Type Mask =
|
||||
CollisionLayer::Type::Pad |
|
||||
CollisionLayer::Type::Ball |
|
||||
CollisionLayer::Type::Brick |
|
||||
CollisionLayer::Type::Water |
|
||||
CollisionLayer::Type::PowerUp |
|
||||
CollisionLayer::Type::Wall |
|
||||
CollisionLayer::Type::Other;
|
||||
enum Type
|
||||
{
|
||||
Static = 0,
|
||||
Kinematic = 1,
|
||||
Dynamic = 2,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Physics: public Component
|
||||
{
|
||||
CollisionType::Type CollisionType = CollisionType::Type::Static;
|
||||
|
||||
bool Calculate = false;
|
||||
float GravityScale = 0.f;
|
||||
|
||||
|
||||
CollisionLayer::Type Category = CollisionLayer::Type::Other;
|
||||
CollisionLayer::Type Mask = static_cast<CollisionLayer::Type>(
|
||||
CollisionLayer::Pad
|
||||
| CollisionLayer::Ball
|
||||
| CollisionLayer::Brick
|
||||
| CollisionLayer::Water
|
||||
| CollisionLayer::PowerUp
|
||||
| CollisionLayer::Wall
|
||||
| CollisionLayer::Other
|
||||
);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Components
|
||||
|
||||
struct RectangleShape : public Component
|
||||
{
|
||||
|
||||
glm::vec2 Dimensions = glm::vec2(1.f, 1.f);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ struct CreateParticleSequence : public Event
|
||||
//Particle
|
||||
std::string SpriteFile = "Texures/Core/ErrorTexture.png";
|
||||
double ParticleLifeTime = 3.f;
|
||||
ParticleFlags::Type Flags = ParticleFlags::Type::powderParticle | ParticleFlags::Type::particleContactFilterParticle | ParticleFlags::Type::fixtureContactFilterParticle;
|
||||
ParticleFlags::Type Flags = static_cast<ParticleFlags::Type>(ParticleFlags::Powder | ParticleFlags::ParticleContactFilter | ParticleFlags::FixtureContactFilter);
|
||||
float Radius = 1.f;
|
||||
};
|
||||
|
||||
|
||||
+130
-156
@@ -2,118 +2,122 @@
|
||||
#define DAYDREAM_PHYSICSSYSTEM_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <random>
|
||||
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <Box2D/Box2D.h>
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "CRectangleShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include <Box2D/Box2D.h>
|
||||
#include "Core/CTransform.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Physics/CParticle.h"
|
||||
#include "Physics/CParticleEmitter.h"
|
||||
#include "Core/CTemplate.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/ECreateParticleSequence.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 "Game/EPause.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
|
||||
class PhysicsSystem : public System
|
||||
{
|
||||
friend class ContractListener;
|
||||
friend class DestructionListener;
|
||||
|
||||
public:
|
||||
PhysicsSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker) {}
|
||||
|
||||
~PhysicsSystem();
|
||||
|
||||
EventRelay<PhysicsSystem, Events::SetImpulse> m_SetImpulse;
|
||||
bool SetImpulse(const Events::SetImpulse &event);
|
||||
|
||||
EventRelay<PhysicsSystem, Events::CreateParticleSequence> m_ECreateParticleSequence;
|
||||
bool CreateParticleSequence(const Events::CreateParticleSequence &event);
|
||||
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
void Initialize() override;
|
||||
|
||||
// Called once per system every tick
|
||||
void Update(double dt) override;
|
||||
// Called once for every entity in the world every tick
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
// Called when components are committed to an entity
|
||||
void OnEntityCommit(EntityID entity) override;
|
||||
|
||||
// Called when an entity is removed
|
||||
void OnEntityRemoved(EntityID entity) override;
|
||||
|
||||
private:
|
||||
b2Vec2 m_Gravity;
|
||||
b2World* m_PhysicsWorld;
|
||||
float m_TimeStep;
|
||||
float m_Accumulator;
|
||||
|
||||
int m_VelocityIterations, m_PositionIterations;
|
||||
|
||||
std::mt19937 gen;
|
||||
|
||||
std::unordered_map<EntityID, b2Body*> m_EntitiesToBodies;
|
||||
std::unordered_map<b2Body*, EntityID> m_BodiesToEntities;
|
||||
|
||||
void CreateBody(EntityID entity);
|
||||
|
||||
b2ParticleSystem* m_WaterParticleSystem;
|
||||
std::vector<b2ParticleGroup*> t_ParticleGroup;
|
||||
|
||||
std::unordered_map<EntityID, const b2ParticleHandle*> m_EntitiesToWaterParticleHandle;
|
||||
std::unordered_map<const b2ParticleHandle*, EntityID> m_WaterParticleHandleToEntities;
|
||||
|
||||
std::vector<std::unordered_map<EntityID, const b2ParticleHandle*>> m_EntitiesToParticleHandle;
|
||||
std::vector<std::unordered_map<const b2ParticleHandle*, EntityID>> m_ParticleHandleToEntities;
|
||||
|
||||
b2ParticleSystem* CreateParticleSystem(float radius, float gravityScale, int maxCount);
|
||||
void InitializeWater();
|
||||
void CreateParticleGroup(EntityID entity);
|
||||
void CreateParticleEmitter(EntityID entity);
|
||||
void UpdateParticleEmitters(double dt); //TODO: Remove them and particles if needed.
|
||||
|
||||
//TODO: Fill struct with info needed.
|
||||
struct ParticleEmitter
|
||||
namespace Systems
|
||||
{
|
||||
std::vector<b2ParticleSystem*> ParticleSystem;
|
||||
std::vector<EntityID> ParticleEmitter;
|
||||
std::vector<EntityID> ParticleTemplate;
|
||||
};
|
||||
ParticleEmitter m_ParticleEmitters;
|
||||
|
||||
//TODO: Struct med listor är bättre än en lista med structs
|
||||
struct Impulse
|
||||
{
|
||||
b2Body* Body;
|
||||
b2Vec2 Impulse;
|
||||
b2Vec2 Point;
|
||||
};
|
||||
std::list<Impulse> m_Impulses;
|
||||
class PhysicsSystem : public System
|
||||
{
|
||||
friend class ContractListener;
|
||||
friend class DestructionListener;
|
||||
|
||||
class DestructionListener : public b2DestructionListener
|
||||
public:
|
||||
PhysicsSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker) { }
|
||||
|
||||
~PhysicsSystem();
|
||||
|
||||
EventRelay<PhysicsSystem, Events::CreateParticleSequence> m_ECreateParticleSequence;
|
||||
bool CreateParticleSequence(const Events::CreateParticleSequence &event);
|
||||
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
void Initialize() override;
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
void OnEntityCommit(EntityID entity) override;
|
||||
void OnEntityRemoved(EntityID entity) override;
|
||||
|
||||
private:
|
||||
struct Impulse
|
||||
{
|
||||
b2Body* Body;
|
||||
b2Vec2 Vector;
|
||||
b2Vec2 Point;
|
||||
};
|
||||
bool m_Pause = false;
|
||||
|
||||
std::mt19937 gen;
|
||||
|
||||
|
||||
b2Vec2 m_Gravity = b2Vec2(0.f, -9.82f);
|
||||
b2World* m_PhysicsWorld = nullptr;
|
||||
float m_TimeStep = 1.f/60.f;
|
||||
float m_Accumulator = 0.f;
|
||||
int m_VelocityIterations = 6;
|
||||
int m_PositionIterations = 2;
|
||||
|
||||
b2ParticleSystem* m_WaterParticleSystem;
|
||||
std::vector<b2ParticleGroup*> t_ParticleGroup;
|
||||
|
||||
std::unordered_map<const b2ParticleHandle*, EntityID> m_WaterParticleHandleToEntities;
|
||||
std::unordered_map<EntityID, const b2ParticleHandle*> m_EntitiesToWaterParticleHandle;
|
||||
std::vector<std::unordered_map<EntityID, const b2ParticleHandle*>> m_EntitiesToParticleHandle;
|
||||
std::vector<std::unordered_map<const b2ParticleHandle*, EntityID>> m_ParticleHandleToEntities;
|
||||
std::unordered_map<EntityID, b2Body*> m_EntitiesToBodies;
|
||||
std::unordered_map<b2Body*, EntityID> m_BodiesToEntities;
|
||||
|
||||
|
||||
|
||||
void CreateBody(EntityID entity);
|
||||
void SyncEntitiesWithBodies();
|
||||
void SyncBodiesWithEntities();
|
||||
void InitializeWater();
|
||||
void CreateParticleGroup(EntityID entity);
|
||||
|
||||
b2ParticleSystem* CreateParticleSystem(float radius, float gravityScale, int maxCount);
|
||||
void CreateParticleEmitter(EntityID entity);
|
||||
void UpdateParticleEmitters(double dt); //TODO: Remove them and particles if needed.
|
||||
|
||||
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 //TODO CHANGE NAMES
|
||||
{
|
||||
std::vector<b2ParticleSystem*> ParticleSystem;
|
||||
std::vector<EntityID> ParticleEmitter;
|
||||
std::vector<EntityID> ParticleTemplate;
|
||||
};
|
||||
ParticleEmitter m_ParticleEmitters;
|
||||
|
||||
std::list<Impulse> m_Impulses;
|
||||
|
||||
|
||||
class DestructionListener : public b2DestructionListener
|
||||
{
|
||||
public:
|
||||
DestructionListener(PhysicsSystem* physicsSystem)
|
||||
@@ -127,7 +131,7 @@ private:
|
||||
LOG_INFO("Particle ded");
|
||||
|
||||
|
||||
b2ParticleHandle* handle = particleSystem->GetParticleHandleFromIndex(index);
|
||||
const b2ParticleHandle* handle = particleSystem->GetParticleHandleFromIndex(index);
|
||||
for (int i = 0; i < m_PhysicsSystem->m_ParticleEmitters.ParticleSystem.size(); i++) {
|
||||
if(m_PhysicsSystem->m_ParticleEmitters.ParticleSystem[i] == particleSystem) {
|
||||
std::unordered_map<const b2ParticleHandle*, EntityID>::iterator it = m_PhysicsSystem->m_ParticleHandleToEntities[i].find(handle);
|
||||
@@ -144,57 +148,7 @@ private:
|
||||
PhysicsSystem* m_PhysicsSystem;
|
||||
};
|
||||
|
||||
class ContactListener : public b2ContactListener
|
||||
{
|
||||
public:
|
||||
ContactListener(PhysicsSystem* physicsSystem)
|
||||
: m_PhysicsSystem(physicsSystem) { }
|
||||
|
||||
void BeginContact(b2Contact* contact)
|
||||
{
|
||||
b2WorldManifold worldManifold;
|
||||
|
||||
contact->GetWorldManifold(&worldManifold);
|
||||
|
||||
Events::Contact e;
|
||||
e.Entity1 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()];
|
||||
e.Entity2 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
|
||||
e.Normal = glm::normalize(glm::vec2(contact->GetManifold()->localNormal.x, contact->GetManifold()->localNormal.y));
|
||||
e.SignificantNormal = glm::normalize((glm::abs(e.Normal.x) > glm::abs(e.Normal.y)) ? glm::vec2(e.Normal.x, 0) : glm::vec2(0, e.Normal.y));
|
||||
|
||||
m_PhysicsSystem->EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
void EndContact(b2Contact* contact)
|
||||
{
|
||||
|
||||
}
|
||||
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
|
||||
{
|
||||
EntityID entityA = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()];
|
||||
EntityID entityB = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
|
||||
|
||||
auto physicsComponentA = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityA);
|
||||
auto physicsComponentB = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityB);
|
||||
|
||||
if (physicsComponentA != nullptr && physicsComponentB != nullptr) {
|
||||
if (physicsComponentA->Calculate || physicsComponentB->Calculate) {
|
||||
// Turn of collisions
|
||||
contact->SetEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
PhysicsSystem* m_PhysicsSystem;
|
||||
};
|
||||
|
||||
class ParticleContactDisabler : public b2ContactFilter
|
||||
class ParticleContactDisabler : public b2ContactFilter
|
||||
{
|
||||
public:
|
||||
ParticleContactDisabler() { };
|
||||
@@ -211,12 +165,32 @@ private:
|
||||
|
||||
};
|
||||
|
||||
DestructionListener* m_DestructionListener;
|
||||
ParticleContactDisabler m_ParticleContactDisabler;
|
||||
ContactListener* m_ContactListener;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class ContactListener : public b2ContactListener
|
||||
{
|
||||
public:
|
||||
ContactListener(PhysicsSystem* physicsSystem)
|
||||
: m_PhysicsSystem(physicsSystem) { }
|
||||
|
||||
void BeginContact(b2Contact* contact);
|
||||
void EndContact(b2Contact* contact);
|
||||
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
|
||||
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);
|
||||
|
||||
private:
|
||||
PhysicsSystem* m_PhysicsSystem;
|
||||
};
|
||||
|
||||
DestructionListener* m_DestructionListener;
|
||||
ParticleContactDisabler m_ParticleContactDisabler;
|
||||
ContactListener* m_ContactListener;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_PHYSICSSYSTEM_H
|
||||
#endif
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
#ifndef DAYDREAM_PHYSICSSYSTEM_H
|
||||
#define DAYDREAM_PHYSICSSYSTEM_H
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "CRectangleShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include <Box2D/Box2D.h>
|
||||
#include "Core/CTransform.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Game/CPad.h"
|
||||
<<<<<<< HEAD
|
||||
#include "Game/CBall.h"
|
||||
=======
|
||||
#include "Physics/CWaterVolume.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
>>>>>>> origin/master
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
|
||||
class PhysicsSystem : public System
|
||||
{
|
||||
friend class ContractListener;
|
||||
|
||||
public:
|
||||
PhysicsSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker) {}
|
||||
|
||||
~PhysicsSystem();
|
||||
|
||||
EventRelay<PhysicsSystem, Events::SetImpulse> m_SetImpulse;
|
||||
bool SetImpulse(const Events::SetImpulse &event);
|
||||
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
void Initialize() override;
|
||||
|
||||
// Called once per system every tick
|
||||
void Update(double dt) override;
|
||||
// Called once for every entity in the world every tick
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
// Called when components are committed to an entity
|
||||
void OnEntityCommit(EntityID entity) override;
|
||||
|
||||
// Called when an entity is removed
|
||||
void OnEntityRemoved(EntityID entity) override;
|
||||
|
||||
private:
|
||||
b2Vec2 m_Gravity;
|
||||
b2World* m_PhysicsWorld;
|
||||
float m_TimeStep;
|
||||
float m_Accumulator;
|
||||
|
||||
int m_VelocityIterations, m_PositionIterations;
|
||||
|
||||
std::unordered_map<EntityID, b2Body*> m_EntitiesToBodies;
|
||||
std::unordered_map<b2Body*, EntityID> m_BodiesToEntities;
|
||||
|
||||
void CreateBody(EntityID entity);
|
||||
|
||||
b2ParticleSystem *m_ParticleSystem;
|
||||
b2ParticleGroup* t_watergroup;
|
||||
|
||||
std::unordered_map<EntityID, const b2ParticleHandle*> m_EntitiesToParticleHandle;
|
||||
std::unordered_map<const b2ParticleHandle*, EntityID> m_ParticleHandleToEntities;
|
||||
|
||||
void InitializeWater();
|
||||
void SyncWater(); //TODO: Probably remove this
|
||||
void CreateParticleGroup(EntityID entity);
|
||||
|
||||
struct Impulse
|
||||
{
|
||||
b2Body* Body;
|
||||
b2Vec2 Impulse;
|
||||
b2Vec2 Point;
|
||||
};
|
||||
std::list<Impulse> m_Impulses;
|
||||
|
||||
|
||||
|
||||
class ContactListener : public b2ContactListener
|
||||
{
|
||||
public:
|
||||
ContactListener(PhysicsSystem* physicsSystem)
|
||||
: m_PhysicsSystem(physicsSystem) { }
|
||||
|
||||
void BeginContact(b2Contact* contact)
|
||||
{
|
||||
b2WorldManifold worldManifold;
|
||||
|
||||
contact->GetWorldManifold(&worldManifold);
|
||||
|
||||
Events::Contact e;
|
||||
e.Entity1 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()];
|
||||
e.Entity2 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
|
||||
e.Normal = glm::normalize(glm::vec2(contact->GetManifold()->localNormal.x, contact->GetManifold()->localNormal.y));
|
||||
e.SignificantNormal = glm::normalize((glm::abs(e.Normal.x) > glm::abs(e.Normal.y)) ? glm::vec2(e.Normal.x, 0) : glm::vec2(0, e.Normal.y));
|
||||
|
||||
m_PhysicsSystem->EventBroker->Publish(e);
|
||||
}
|
||||
void EndContact(b2Contact* contact)
|
||||
{
|
||||
|
||||
}
|
||||
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
|
||||
{
|
||||
EntityID entityA = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()];
|
||||
EntityID entityB = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
|
||||
|
||||
auto physicsComponentA = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityA);
|
||||
auto physicsComponentB = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityB);
|
||||
|
||||
if (physicsComponentA != nullptr && physicsComponentB != nullptr) {
|
||||
if (physicsComponentA->Calculate || physicsComponentB->Calculate) {
|
||||
// Turn of collisions
|
||||
contact->SetEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
PhysicsSystem* m_PhysicsSystem;
|
||||
};
|
||||
|
||||
ContactListener* m_ContactListener;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_PHYSICSSYSTEM_H
|
||||
@@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by Adam on 2015-09-17.
|
||||
//
|
||||
|
||||
#ifndef COMPONENTS_CCOLLISIONSOUND_H__
|
||||
#define COMPONENTS_CCOLLISIONSOUND_H__
|
||||
|
||||
@@ -9,17 +5,15 @@
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct CollisionSound : public Component
|
||||
{
|
||||
std::string filePath;
|
||||
std::string FilePath;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by Adam on 2015-09-24.
|
||||
//
|
||||
|
||||
#ifndef EVENTS_EMASTERVOLUME_H__
|
||||
#define EVENTS_EMASTERVOLUME_H__
|
||||
|
||||
@@ -9,19 +5,17 @@
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct MasterVolume : public Event
|
||||
{
|
||||
float gain = 1;
|
||||
float Gain = 1;
|
||||
//To determine what channel group to apply the change to.
|
||||
bool isAmbient = false;
|
||||
bool IsAmbient = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
#ifndef Events_PlaySFX_h__
|
||||
#define Events_PlaySFX_h__
|
||||
#ifndef EVENTS_PLAYSFX_H__
|
||||
#define EVENTS_PLAYSFX_H__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct PlaySound : Event
|
||||
{
|
||||
std::string path;
|
||||
float volume = 1.f;
|
||||
float pitch = 1.f;
|
||||
bool isAmbient = false;
|
||||
std::string FilePath;
|
||||
float Gain = 1.f;
|
||||
float Pitch = 1.f;
|
||||
bool IsAmbient = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -8,16 +8,12 @@ namespace dd
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct StopSound : public Event
|
||||
{
|
||||
std::string path;
|
||||
std::string FilePath;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,27 +12,31 @@ namespace dd
|
||||
class Sound : public Resource
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
public:
|
||||
ALuint Buffer() { return m_Buffer; };
|
||||
std::string Path() { return m_Path; };
|
||||
float Gain() { return m_Gain; };
|
||||
void SetGain(const float Gain) { m_Gain = Gain; };
|
||||
|
||||
private:
|
||||
Sound(std::string path);
|
||||
|
||||
float m_Gain = 1;
|
||||
ALuint m_Buffer;
|
||||
std::string m_Path;
|
||||
|
||||
//File-info
|
||||
char m_Type[4];
|
||||
unsigned long m_Size, m_ChunkSize;
|
||||
short m_FormatType, m_Channels;
|
||||
unsigned long m_SampleRate, m_AvgBytesPerSec;
|
||||
short m_BytesPerSample, m_BitsPerSample;
|
||||
unsigned long m_DataSize;
|
||||
unsigned int m_DataSize;
|
||||
std::map<std::string, ALuint> m_BufferCache;
|
||||
ALuint LoadFile(std::string path);
|
||||
|
||||
ALuint m_Buffer;
|
||||
std::string m_Path;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+20
-22
@@ -1,63 +1,61 @@
|
||||
#ifndef DAYDREAM_SOUND_H
|
||||
#define DAYDREAM_SOUND_H
|
||||
|
||||
#ifndef SYSTEMS_SOUNDSYSTEM_H__
|
||||
#define SYSTEMS_SOUNDSYSTEM_H__
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Sound.h"
|
||||
#include "Sound/EPlaySound.h"
|
||||
#include "Sound/EStopSound.h"
|
||||
#include "Sound/EMasterVolume.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class SoundSystem : public System {
|
||||
public:
|
||||
SoundSystem(World *world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker) { }
|
||||
|
||||
~SoundSystem();
|
||||
|
||||
void Initialize() override;
|
||||
void Update(double dt) override;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
float m_BGMMasterVolume = 1.f;
|
||||
float m_SFXMasterVolume = 1.f;
|
||||
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
|
||||
std::map<ALuint, Sound*> m_SFXSourcesToBuffers;
|
||||
ALCdevice* m_Device = nullptr;
|
||||
|
||||
//Events
|
||||
dd::EventRelay<SoundSystem, dd::Events::PlaySound> m_EPlaySFX;
|
||||
dd::EventRelay<SoundSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<SoundSystem, dd::Events::StopSound> m_EStopSound;
|
||||
dd::EventRelay<SoundSystem, dd::Events::MasterVolume> m_EMasterVolume;
|
||||
bool OnPlaySound(const dd::Events::PlaySound &event);
|
||||
//On contact: play the sound given in the CCOllisionSound.
|
||||
dd::EventRelay<SoundSystem, dd::Events::Contact> m_EContact;
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
dd::EventRelay<SoundSystem, dd::Events::StopSound> m_EStopSound;
|
||||
bool OnStopSound(const dd::Events::StopSound &event);
|
||||
dd::EventRelay<SoundSystem, dd::Events::MasterVolume> m_EMasterVolume;
|
||||
bool OnMasterVolume(const dd::Events::MasterVolume &event);
|
||||
|
||||
ALuint CreateSource();
|
||||
|
||||
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
|
||||
std::map<ALuint, Sound*> m_SFXSourcesToBuffers;
|
||||
|
||||
ALCdevice* m_Device;
|
||||
|
||||
float m_BGMMasterVolume, m_SFXMasterVolume;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_SOUND_H
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user