35 Commits

Author SHA1 Message Date
tleety 6b5c153c5d Stopped kraken arm from looping, now it dissapears instead 2015-10-22 11:53:36 +02:00
tleety d6e0b8a36f Merge remote-tracking branch 'origin' into Tobias 2015-10-22 11:12:23 +02:00
tleety de8209bdda Kraken arm now splashes around when it arrives 2015-10-22 11:12:11 +02:00
PlatinumSkink 59c23026d2 Put all LifeStuff into a new LifeSystem. Appears to be working. 2015-10-22 10:34:22 +02:00
PlatinumSkink 1a6f18da94 Random direction upon ResetBall, turn in direction. 2015-10-21 16:53:04 +02:00
PlatinumSkink 83f4da59d4 Merge branch 'LevelSystemAndSuch' 2015-10-21 15:47:54 +02:00
PlatinumSkink ff3813a7cf A metric ton of minifixes! 2015-10-21 15:46:32 +02:00
Jace 17c30ff610 Merge branch 'master' of github.com:teamfisk/AgileBreakOut 2015-10-21 15:38:46 +02:00
Jace 52f7e3f64b Control over animation looping and event on animation completion 2015-10-21 15:38:34 +02:00
Jace e7c1dc20ba HACK: For some reason Blender likes to create a first frame that doesn't start at time 0 2015-10-21 15:37:58 +02:00
Jace 2df78e011a Fixed Renderer trying to play animations when there is no animation component 2015-10-21 15:35:57 +02:00
tleety df264fb732 Added a ink brick texture 2015-10-21 15:16:34 +02:00
PlatinumSkink f0b36c6f12 Fixed Kraken battle. I think. Made it so you do not shoot projectiles or squids when struggling with Kraken. 2015-10-21 15:12:50 +02:00
tleety e9942dad4a Merge branch 'Tobias' 2015-10-21 14:48:33 +02:00
tleety cbaf300b03 Smallfix 2015-10-21 14:47:36 +02:00
tleety 11b792c85a Merge remote-tracking branch 'origin' into Tobias 2015-10-21 14:39:38 +02:00
tleety 726244b043 Combo particle is now more visable and better 2015-10-21 14:39:04 +02:00
Stiffly d0668effea Merge remote-tracking branch 'origin/master' into Sound 2015-10-21 13:18:42 +02:00
PlatinumSkink 2954e2cbb3 Merge remote-tracking branch 'origin/master' into LevelSystemAndSuch 2015-10-20 16:14:55 +02:00
Jace 9b8546abb2 Fixed your score frames 2015-10-20 16:13:33 +02:00
Stiffly c23c7e4d8e Story sound. Tom could be improved. 2015-10-20 16:12:55 +02:00
PlatinumSkink c1e4e6c0bd KrakenHit event includes max health, current, and new. 2015-10-20 15:58:02 +02:00
tleety 0f506bfe35 Merge branch 'master' of github.com:teamfisk/AgileBreakOut into Tobias 2015-10-20 15:57:40 +02:00
PlatinumSkink e26156c093 Kraken Battle Implemented. Feel free to comment.
To get to battle faster, change CurrentCluster to 0.
2015-10-20 15:57:06 +02:00
tleety 9ffa8e9609 Kraken arm shows up when you take the powerup 2015-10-20 15:57:02 +02:00
Jace 0fabac14a8 fixup! CMAKE Conditional compilation against DirectX and OpenGL targets 2015-10-20 15:48:13 +02:00
Jace 14b4fd9813 fixup! CMAKE Conditional compilation against DirectX and OpenGL targets 2015-10-20 15:39:12 +02:00
Stiffly ec509358b1 Powerup sound, not done 2015-10-20 14:20:46 +02:00
tleety ce61de1d5c Merge remote-tracking branch 'origin/Physics' into Tobias 2015-10-20 11:03:45 +02:00
tleety f688981b06 Started work on kraken arm powerup visual changes. 2015-10-20 11:03:40 +02:00
viktorljung a85a703991 animations! 2015-10-20 11:02:03 +02:00
viktorljung f5957fc91a Merge remote-tracking branch 'origin/master' into Physics
Conflicts:
	include/Core/Engine.h
2015-10-20 11:01:42 +02:00
tleety b4486c6bf3 Added cheat and water changes to the defaul commit 2015-10-20 10:36:11 +02:00
viktorljung 9e8d176999 Animation models and stuff 2015-10-19 16:48:42 +02:00
Stiffly 71521b5b02 Added squid-bounce wav 2015-10-19 16:41:57 +02:00
43 changed files with 2523 additions and 693 deletions
+1
View File
@@ -31,6 +31,7 @@ if(BUILD_RENDERER_OPENGL)
endif()
# Compiling for DirectX target
if(BUILD_RENDERER_DIRECTX)
add_definitions(-DBUILD_RENDERER_DIRECTX)
include_directories(${PROJECT_SOURCE_DIR}/include/Rendering/DirectX)
endif()
+1 -1
View File
@@ -9,4 +9,4 @@ BGMVolume=0.5
[Video]
Fullscreen=false
Width=675
Height=1080[Water]Radius=0.3[Cheat]GodMode=false
Height=1080[Water]Radius=0.3[Cheat]GodMode=false[Water]Radius=0.3[Cheat]GodMode=false
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

File diff suppressed because one or more lines are too long
+561 -487
View File
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
+13 -6
View File
@@ -48,12 +48,14 @@
#include "Game/CLifebuoy.h"
#include "Game/CProjectile.h"
#include "Game/CBrick.h"
#include "Game/CBrickPart.h"
#include "Game/CWall.h"
#include "Game/CKraken.h"
#include "Game/CBackground.h"
#include "Game/CTravels.h"
#include "Game/CStickyAim.h"
#include "Game/BallSystem.h"
#include "Game/LifeSystem.h"
#include "Game/HitLagSystem.h"
#include "Game/TravellingSystem.h"
#include "Game/LifebuoySystem.h"
@@ -144,6 +146,7 @@ public:
m_World->ComponentFactory.Register<Components::Physics>();
m_World->ComponentFactory.Register<Components::Ball>();
m_World->ComponentFactory.Register<Components::Brick>();
m_World->ComponentFactory.Register<Components::BrickPart>();
m_World->ComponentFactory.Register<Components::Pad>();
m_World->ComponentFactory.Register<Components::Wall>();
m_World->ComponentFactory.Register<Components::Background>();
@@ -197,6 +200,9 @@ public:
m_World->SystemFactory.Register<Systems::WaterSystem>(
[this]() { return new Systems::WaterSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::WaterSystem>();
m_World->SystemFactory.Register<Systems::LifeSystem>(
[this]() { return new Systems::LifeSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::LifeSystem>();
m_World->ComponentFactory.Register<Components::Model>();
m_World->ComponentFactory.Register<Components::Template>();
@@ -207,6 +213,9 @@ public:
m_World->Initialize();
//auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
//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);
@@ -361,13 +370,11 @@ public:
job.ModelMatrix = modelMatrix * model->m_Matrix;
job.Color = modelComponent->Color;
if (model->m_Skeleton != nullptr) {
if (model->m_Skeleton != nullptr && animationComponent != nullptr) {
job.Skeleton = model->m_Skeleton;
if (animationComponent != nullptr) {
job.AnimationName = animationComponent->Name;
job.AnimationTime = animationComponent->Time;
job.NoRootMotion = animationComponent->NoRootMotion;
}
job.AnimationName = animationComponent->Name;
job.AnimationTime = animationComponent->Time;
job.NoRootMotion = animationComponent->NoRootMotion;
}
m_RendererQueue.Deferred.Add(job);
+649
View File
@@ -0,0 +1,649 @@
/*
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 "CTemplate.h"
#include "Core/ConfigFile.h"
#include "Core/EventBroker.h"
#include "Rendering/CModel.h"
#include "Rendering/CSprite.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/CLifebuoy.h"
#include "Game/CProjectile.h"
#include "Game/CBrick.h"
#include "Game/CWall.h"
#include "Game/CKraken.h"
#include "Game/CBackground.h"
#include "Game/CTravels.h"
#include "Game/CStickyAim.h"
#include "Game/BallSystem.h"
#include "Game/HitLagSystem.h"
#include "Game/TravellingSystem.h"
#include "Game/LifebuoySystem.h"
#include "Game/ProjectileSystem.h"
#include "Game/KrakenSystem.h"
#include "Game/Bricks/CPowerUpBrick.h"
#include "Game/BrickComponents.h"
#include "Game/EScreenShake.h"
#include "Physics/PhysicsSystem.h"
#include "Physics/CPhysics.h"
#include "Physics/CRectangleShape.h"
#include "Physics/ESetImpulse.h"
#include "Physics/CWaterVolume.h"
#include "Physics/CParticle.h"
#include "Physics/CParticleEmitter.h"
#include "Rendering/AnimationSystem.h"
#include "Game/EGameStart.h"
#include "Sound/EPlaySound.h"
#include "GUI/Frame.h"
#include "GUI/Button.h"
#include "Game/GUI/MainMenu.h"
#include "Game/GUI/HUD.h"
namespace dd
{
class Engine
{
public:
Engine(int argc, char* argv[]) {
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
LOG_LEVEL = static_cast<_LOG_LEVEL>(config->GetValue<int>("Debug.LogLevel", 1));
m_EventBroker = std::make_shared<EventBroker>();
m_Renderer = std::make_shared<Renderer>();
m_Renderer->SetFullscreen(config->GetValue<bool>("Video.Fullscreen", false));
m_Renderer->SetResolution(Rectangle(
0,
0,
config->GetValue<int>("Video.Width", 675),
config->GetValue<int>("Video.Height", 1080)
));
m_Renderer->Initialize();
m_FrameStack = new GUI::Frame(m_EventBroker.get());
m_FrameStack->Width = 675;
m_FrameStack->Height = 1080;
if (config->GetValue<bool>("Debug.SkipStory", false)) {
Events::GameStart e;
m_EventBroker->Publish(e);
auto hud = new GUI::HUD(m_FrameStack, "HUD");
}
else {
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::Wall>();
m_World->ComponentFactory.Register<Components::Background>();
m_World->ComponentFactory.Register<Components::Life>();
m_World->ComponentFactory.Register<Components::Lifebuoy>();
m_World->ComponentFactory.Register<Components::Projectile>();
m_World->ComponentFactory.Register<Components::Kraken>();
m_World->ComponentFactory.Register<Components::StickyAim>();
m_World->ComponentFactory.Register<Components::Travels>();
m_World->ComponentFactory.Register<Components::PowerUp>();
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
m_World->ComponentFactory.Register<Components::StandardBrick>();
m_World->ComponentFactory.Register<Components::MultiBallBrick>();
m_World->ComponentFactory.Register<Components::LifebuoyBrick>();
m_World->ComponentFactory.Register<Components::StickyBrick>();
m_World->ComponentFactory.Register<Components::InkBlasterBrick>();
m_World->ComponentFactory.Register<Components::KrakenAttackBrick>();
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->SystemFactory.Register<Systems::HitLagSystem>(
[this]() { return new Systems::HitLagSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::HitLagSystem>();
m_World->SystemFactory.Register<Systems::LifebuoySystem>(
[this]() { return new Systems::LifebuoySystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::LifebuoySystem>();
m_World->SystemFactory.Register<Systems::ProjectileSystem>(
[this]() { return new Systems::ProjectileSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::ProjectileSystem>();
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::PhysicsSystem>();
m_World->SystemFactory.Register<Systems::AnimationSystem>(
[this]() { return new Systems::AnimationSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::AnimationSystem>();
m_World->SystemFactory.Register<Systems::TravellingSystem>(
[this]() { return new Systems::TravellingSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::TravellingSystem>();
m_World->SystemFactory.Register<Systems::KrakenSystem>(
[this]() { return new Systems::KrakenSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::KrakenSystem>();
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->ComponentFactory.Register<Components::Particle>();
m_World->ComponentFactory.Register<Components::ParticleEmitter>();
m_World->Initialize();
<<<<<<< HEAD
//PointLightTest
{
auto t_Light = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
transform->Position = glm::vec3(-3.f, 6.f, -5.f);
transform->Sticky = true;
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
pl->Radius = 20.f;
pl->Diffuse = glm::vec3(0.8f, 0.7f, 0.05f);
auto model = m_World->AddComponent<Components::Model>(t_Light);
model->ModelFile = "Models/Core/UnitSphere.obj";
m_World->CommitEntity(t_Light);
}
{
auto t_Light = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
transform->Position = glm::vec3(3.f, -5.f, -5.f);
transform->Sticky = true;
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
pl->Radius = 15.f;
pl->Diffuse = glm::vec3(0.1f, 0.5f, 0.8f);
auto model = m_World->AddComponent<Components::Model>(t_Light);
model->ModelFile = "Models/Core/UnitSphere.obj";
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(6.f, 6.f, 10.f);
transform->Sticky = false;
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
m_World->CommitEntity(t_halfPipe);
}
{
auto t_halfPipe = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
transform->Position = glm::vec3(0.f, 34.6f, -15.f);
transform->Scale = glm::vec3(6.f, 6.f, 10.f);
transform->Sticky = false;
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 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);
}
// auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
//Water test
{
auto t_waterBody = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
transform->Scale = glm::vec3(7.0f, 1.5f, 1.f);
transform->Sticky = true;
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
m_World->CommitEntity(t_waterBody);
}
//ParticleTest
/*{
auto Pe = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(Pe);
auto particleEmitter= m_World->AddComponent<Components::ParticleEmitter>(Pe);
auto emitteSprite = m_World->AddComponent<Components::Sprite>(Pe);
transform->Position = glm::vec3(0.f, 0.f, -10.f);
emitteSprite->SpriteFile = "Textures/Test/Brick_Normal.png";
particleEmitter->GravityScale = 0.0f;
particleEmitter->SpawnRate = 1.f;
particleEmitter->NumberOfTicks = 2;
particleEmitter->Speed = 1.f;
particleEmitter->ParticlesPerTick = 5;
particleEmitter->Spread = glm::pi<float>()*2;
particleEmitter->EmittingAngle = glm::pi<float>();
particleEmitter->LifeTime = 50;
{
auto Pt = m_World->CreateEntity(Pe);
auto PtTransform = m_World->AddComponent<Components::Transform>(Pt);
auto PtSprite = m_World->AddComponent<Components::Sprite>(Pt);
auto PtParticle = m_World->AddComponent<Components::Particle>(Pt);
auto PtTemplate = m_World->AddComponent<Components::Template>(Pt);
//PtTransform->Velocity = glm::vec3(1.0f, 0.f, 0.f);
PtTransform->Position = transform->Position;
PtSprite->SpriteFile = "Textures/Background.png";
PtParticle->LifeTime = 3.f;
PtParticle->Flags = static_cast<ParticleFlags::Type>(ParticleFlags::Type::Powder | ParticleFlags::Type::ParticleContactFilter | ParticleFlags::Type::FixtureContactFilter);
}
m_World->CommitEntity(Pe);
}*/
//TODO: Why does the ball not collide with these bricks?
//BottomBox
{
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> 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;
physics->Category = CollisionLayer::Wall;
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::LifeBuoy);
transform->Sticky = true;
m_World->CommitEntity(BottomWall);
}
{
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> 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->CollisionType = CollisionType::Type::Static;
physics->Category = CollisionLayer::Wall;
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
transform->Sticky = true;
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> 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->CollisionType = CollisionType::Type::Static;
physics->Category = CollisionLayer::Wall;
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
transform->Sticky = true;
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> 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->CollisionType = CollisionType::Type::Static;
physics->Category = CollisionLayer::Wall;
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
transform->Sticky = true;
m_World->CommitEntity(rightWall);
}
=======
//auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
>>>>>>> origin/master
//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);
} else {
m_EventBroker->Process<Systems::SoundSystem>();
}
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();
}
std::unique_ptr<dd::Camera> defaultCamera = nullptr;
// 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);
Components::Animation* animationComponent = m_World->GetComponent<Components::Animation>(entity);
EnqueueModel(modelAsset, modelMatrix, modelComponent, animationComponent);
}
}
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, const Components::Model* modelComponent, const Components::Animation* animationComponent)
{
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 * model->m_Matrix;
job.Color = modelComponent->Color;
if (model->m_Skeleton != nullptr) {
job.Skeleton = model->m_Skeleton;
if (animationComponent != nullptr) {
job.AnimationName = animationComponent->Name;
job.AnimationTime = animationComponent->Time;
job.NoRootMotion = animationComponent->NoRootMotion;
}
}
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;
glm::vec3 m_CameraPosition = glm::vec3(0.f, 0.f, 0.f);
//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.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav";
// e.IsAmbient = true;
// m_EventBroker->Publish(e);
}
{
// dd::Events::PlaySound e;
// e.FilePath = "Sounds/BGM/water-flowing.wav";
// e.Gain = 0.3f;
// e.IsAmbient = true;
// m_EventBroker->Publish(e);
}
return true;
};
double m_LastTime;
};
}
+19 -10
View File
@@ -1,6 +1,8 @@
#ifndef DAYDREAM_BALLSYSTEM_H
#define DAYDREAM_BALLSYSTEM_H
#include <random>
#include "Core/System.h"
#include "Core/World.h"
#include "Core/EventBroker.h"
@@ -8,14 +10,17 @@
#include "Core/CTemplate.h"
#include "Core/ResourceManager.h"
#include "Core/ConfigFile.h"
#include "Physics/CPhysics.h"
#include "Physics/CCircleShape.h"
#include "Physics/CRectangleShape.h"
#include "Physics/EContact.h"
#include "Rendering/CModel.h"
#include "Rendering/CSprite.h"
#include "Rendering/CPointLight.h"
#include "Rendering/CAnimation.h"
#include "Game/CBall.h"
#include "Game/CPowerUp.h"
#include "Game/CLife.h"
@@ -30,6 +35,8 @@
#include "Game/EStickyAttachedToPad.h"
#include "Game/EInkBlaster.h"
#include "Game/EInkBlasterOver.h"
#include "Game/EKrakenAttack.h"
#include "Game/EKrakenAttackEnd.h"
#include "Game/EStageCleared.h"
#include "Game/EArrivedAtNewStage.h"
#include "Game/EGameOver.h"
@@ -39,7 +46,9 @@
#include "Game/EHitLag.h"
#include "Game/EActionButton.h"
#include "Game/ELifebuoyHit.h"
#include "Physics/ECreateParticleSequence.h"
#include "Sound/CCollisionSound.h"
namespace dd
{
@@ -74,7 +83,6 @@ public:
void OnEntityRemoved(EntityID entity) override;
EntityID CreateBall();
void CreateLife(int);
EntityID Ball() { return m_Ball; };
void SetBall(const EntityID& ball) { m_Ball = ball; }
@@ -86,22 +94,18 @@ public:
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:
std::mt19937 m_RandomGenerator;
float m_XMovementMultiplier = 2.f;
float m_EdgeX = 3.4f; //Actually 3.2, but anyways.
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;
bool m_Waiting = true;
@@ -109,9 +113,12 @@ private:
bool m_InkBlaster = false;
bool m_InkAttached = false;
bool m_InkBlockedWaiting = false;
bool m_KrakenAttack = false;
double m_KrakenCharge = 0;
bool m_Restarting = false;
int m_StickyCounter = 3;
bool m_GodMode = false;
bool m_First = true;
bool m_StageBlockedWaiting = false;
@@ -123,13 +130,14 @@ private:
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::StickyPad> m_EStickyPad;
dd::EventRelay<BallSystem, dd::Events::InkBlaster> m_EInkBlaster;
dd::EventRelay<BallSystem, dd::Events::InkBlasterOver> m_EInkBlasterOver;
dd::EventRelay<BallSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
dd::EventRelay<BallSystem, dd::Events::KrakenAttackEnd> m_EKrakenAttackEnd;
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<BallSystem, dd::Events::Resume> m_EResume;
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
@@ -138,13 +146,14 @@ private:
dd::EventRelay<BallSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
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 OnStickyPad(const dd::Events::StickyPad &event);
bool OnInkBlaster(const dd::Events::InkBlaster &event);
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
bool OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event);
bool OnPause(const dd::Events::Pause &event);
bool OnResume(const dd::Events::Resume &event);
bool OnActionButton(const dd::Events::ActionButton &event);
+1 -1
View File
@@ -19,7 +19,7 @@ struct Brick : Component
//0 = empty, 1 = normal, 2 = multi-brick, 3 = lifebuoy, 4 = sticky, 5 = blaster, 6 = kraken
int Type = 0;
bool Removed = false;
int Number = 0; // For the Kraken to keep track of which bricks needs replacing.
int Number = 100; // For the Kraken to keep track of which bricks needs replacing.
//What number of types each is.
const int EmptyBrickSpace = 0;
+25
View File
@@ -0,0 +1,25 @@
//
// Created by Adniklastrator on 2015-10-21.
//
#ifndef DAYDREAM_CBRICKPART_H
#define DAYDREAM_CBRICKPART_H
#include "Core/Component.h"
namespace dd
{
namespace Components
{
struct BrickPart : Component
{
};
}
}
#endif //DAYDREAM_CBRICKPART_H
+2 -1
View File
@@ -15,7 +15,8 @@ namespace Components
struct Kraken : Component {
int Health = 10;
int MaxHealth = 30;
int Health = MaxHealth;
int CurrentAction = 1;
const int Idle = 1;
+2 -1
View File
@@ -15,7 +15,8 @@ namespace Events
struct BrickGenerating : Event
{
glm::vec3 Origin;
glm::vec3 Origin1;
glm::vec3 Origin2;
int TargetLine;
int Set;
};
+25
View File
@@ -0,0 +1,25 @@
//
// Created by Adniklastrator on 2015-10-21.
//
#ifndef DAYDREAM_EKRAKENATTACKEND_H
#define DAYDREAM_EKRAKENATTACKEND_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct KrakenAttackEnd : Event
{
};
}
}
#endif //DAYDREAM_EKRAKENATTACKEND_H
+3
View File
@@ -17,6 +17,9 @@ struct KrakenHit : Event
{
EntityID Kraken;
EntityID Hitter;
int MaxHealth;
int CurrentHealth;
int NewHealth;
};
}
+14 -5
View File
@@ -51,6 +51,7 @@ public:
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &HUD::OnGameOver);
EVENT_SUBSCRIBE_MEMBER(m_ClusterClear, &HUD::OnClusterClear);
EVENT_SUBSCRIBE_MEMBER(m_KrakenAttack, &HUD::OnKrakenAttack);
EVENT_SUBSCRIBE_MEMBER(m_KrakenAttackEnd, &HUD::OnKrakenAttackEnd);
updateScore();
}
@@ -71,22 +72,23 @@ private:
EventRelay<Frame, Events::GameOver> m_EGameOver;
EventRelay<Frame, Events::ClusterClear> m_ClusterClear;
EventRelay<Frame, Events::KrakenAttack> m_KrakenAttack;
EventRelay<Frame, Events::KrakenAttackEnd> m_KrakenAttackEnd;
void updateScore()
{
m_ScoreNumberFrame->SetLeft(Width / 2.f - m_ScoreNumberFrame->Width / 2.f);
m_ScoreBackMid->SetLeft(m_ScoreNumberFrame->Left());
m_ScoreBackMid->Width = m_ScoreNumberFrame->Width;
m_ScoreBackMid->Height = m_ScoreNumberFrame->Height + 35;
m_ScoreBackMid->SetLeft(m_ScoreNumberFrame->Left() + 4);
m_ScoreBackLeft->SetRight(m_ScoreBackMid->Left());
m_ScoreBackLeft->Width = 40;
//m_ScoreBackLeft->Width = 40;
m_ScoreBackLeft->Height = m_ScoreBackMid->Height;
m_ScoreBackLeft->SetRight(m_ScoreBackMid->Left());
m_ScoreBackRight->SetLeft(m_ScoreBackMid->Right());
m_ScoreBackRight->Width = 40;
//m_ScoreBackRight->Width = 40;
m_ScoreBackRight->Height = m_ScoreBackMid->Height;
m_ScoreBackRight->SetLeft(m_ScoreBackMid->Right());
}
bool OnScore(const Events::ScoreEvent& event)
@@ -122,6 +124,13 @@ private:
return true;
}
bool OnKrakenAttackEnd(const Events::KrakenAttackEnd& event)
{
m_KrakenAttackSlider->Hide();
return true;
}
};
}
+4
View File
@@ -5,6 +5,7 @@
#include "GUI/Slider.h"
#include "Core/ResourceManager.h"
#include "Game/GUI/ELoadingFrameComplete.h"
#include "Sound/EPlaySound.h"
namespace dd
{
@@ -56,6 +57,9 @@ public:
e.FrameName = Name();
e.Frame = this;
EventBroker->Publish(e);
Events::PlaySound se;
se.FilePath = "Sounds/jap-story.wav";
EventBroker->Publish(se);
}
}
}
+7 -3
View File
@@ -21,6 +21,8 @@
#include "Physics/ECreateParticleSequence.h"
#include "Game/EPause.h"
#include "Game/EResume.h"
#include "Game/EComboEvent.h"
#include "Game/EScoreEvent.h"
#include "Game/EKrakenAppear.h"
#include "Game/EKrakenAttack.h"
#include "Game/EKrakenHit.h"
@@ -29,6 +31,7 @@
#include "Game/CTravels.h"
#include "Game/CKraken.h"
#include "Game/CBall.h"
#include "Game/CProjectile.h"
#include "Sound/CCollisionSound.h"
//#include "Core/Camera.h" Camera Component
@@ -62,12 +65,13 @@ private:
bool m_ReturnToIdle = false;
EntityID m_KrakenTemplate;
std::string m_Action = "Idle";
int m_NumberOfActions;
float m_KrakenTimer = 0;
float m_KrakenSecondsToAction = 1;
float m_KrakenSecondsToAction = 10;
const int Idle = 1;
std::array<int, 14> m_Bricks;
std::array<int, 14> m_Colors;
std::array<int, 42> m_Bricks;
std::array<int, 42> m_Colors;
dd::EventRelay<KrakenSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<KrakenSystem, dd::Events::Resume> m_EResume;
+8 -2
View File
@@ -23,6 +23,7 @@
#include "Transform/EMove.h"
#include "Game/CBrick.h"
#include "Game/CBrickPart.h"
#include "Game/CBall.h"
#include "Game/CLife.h"
#include "Game/CWall.h"
@@ -172,8 +173,12 @@ private:
std::array<int, 42> m_Bricks;
std::array<glm::vec4, 42> m_Colors;
std::array<int, 14> m_BrickSet;
std::array<glm::vec4, 14> m_ColorSet;
std::array<int, 42> m_BrickSet;
std::array<glm::vec4, 42> m_ColorSet;
std::array<bool, 42> m_KrakenBricks;
bool m_BrickGenerating = false;
dd::Events::BrickGenerating m_BrickGeneratingEvent;
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
@@ -201,6 +206,7 @@ private:
bool OnResume(const dd::Events::Resume &event);
bool OnHitPad(const dd::Events::HitPad &event);
bool OnBrickGenerating(const dd::Events::BrickGenerating &event);
bool BrickGenerating(const dd::Events::BrickGenerating &event);
void GetBrickSet(int Set);
bool OnKrakenDefeated(const dd::Events::KrakenDefeated &event);
+75
View File
@@ -0,0 +1,75 @@
//
// Created by Adniklastrator on 2015-10-22.
//
#ifndef DAYDREAM_LIFESYSTEM_H
#define DAYDREAM_LIFESYSTEM_H
#include "Core/System.h"
#include "Core/CTransform.h"
#include "Core/CTemplate.h"
#include "Core/EventBroker.h"
#include "Core/World.h"
#include "Core/ConfigFile.h"
#include "Transform/EMove.h"
#include "Rendering/CModel.h"
#include "Game/CLife.h"
#include "Game/EPause.h"
#include "Game/EResume.h"
#include "Game/ELifeLost.h"
#include "Game/EGameOver.h"
#include "Game/EKrakenAttackEnd.h"
namespace dd
{
namespace Systems
{
class LifeSystem : public System
{
public:
LifeSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker)
{ }
void Initialize() override;
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
bool IsPaused() const { return m_Pause; }
void SetPause(const bool& pause) { m_Pause = pause; }
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; }
private:
bool m_Pause = false;
int m_Lives = 3;
int m_PastLives = 3;
bool m_GodMode = false;
void CreateLife(int);
dd::EventRelay<LifeSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<LifeSystem, dd::Events::Resume> m_EResume;
dd::EventRelay<LifeSystem, dd::Events::LifeLost> m_ELifeLost;
bool OnPause(const dd::Events::Pause &event);
bool OnResume(const dd::Events::Resume &event);
bool OnLifeLost(const dd::Events::LifeLost &event);
};
}
}
#endif //DAYDREAM_LIFESYSTEM_H
+6
View File
@@ -43,6 +43,7 @@
#include "Game/EStickyAttachedToPad.h"
#include "Game/EInkBlaster.h"
#include "Game/EKrakenAttack.h"
#include "Game/EKrakenAttackEnd.h"
#include "Game/EPowerUpTaken.h"
#include "Game/EStageCleared.h"
#include "Game/EPause.h"
@@ -50,6 +51,7 @@
#include "Game/EHitLag.h"
#include "Game/EScreenShake.h"
#include "Game/EActionButton.h"
#include "Rendering/CAnimation.h"
#include "Game/EBrickGenerating.h"
@@ -103,6 +105,8 @@ private:
double m_KrakenStrength = 0;
double m_PlayerStrength = 0;
float m_Edge = 2.8f;
EntityID m_KrakenArm = NULL;
EntityID m_KrakenArmHitbox = NULL;
Components::Transform* m_Transform = nullptr;
Components::Pad* m_Pad = nullptr;
std::shared_ptr<Components::Transform> m_StickTransform;
@@ -123,6 +127,7 @@ private:
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<PadSystem, dd::Events::Resume> m_EResume;
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
dd::EventRelay<PadSystem, dd::Events::KrakenAttackEnd> m_EKrakenAttackEnd;
dd::EventRelay<PadSystem, dd::Events::StickyPad> m_EStickyPad;
dd::EventRelay<PadSystem, dd::Events::StickyAttachedToPad> m_EStickyAttachedToPad;
dd::EventRelay<PadSystem, dd::Events::ActionButton> m_EActionButton;
@@ -140,6 +145,7 @@ private:
bool OnPause(const dd::Events::Pause &event);
bool OnResume(const dd::Events::Resume &event);
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
bool OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event);
bool OnStickyPad(const dd::Events::StickyPad &event);
bool OnStickyAttachedToPad(const dd::Events::StickyAttachedToPad &event);
bool OnActionButton(const dd::Events::ActionButton &event);
+7
View File
@@ -19,6 +19,8 @@
#include "Game/EResume.h"
#include "Game/EInkBlaster.h"
#include "Game/EInkBlasterOver.h"
#include "Game/EKrakenAttack.h"
#include "Game/EKrakenAttackEnd.h"
#include "Game/EActionButton.h"
#include "Game/EHitPad.h"
#include "Game/CProjectile.h"
@@ -52,6 +54,7 @@ private:
bool m_Pause = false;
bool m_InkBlaster = false;
bool m_SquidLoaded = false;
bool m_KrakenAttack = false;
int m_Shots = 0;
float m_InkBlasterSpeed = 5;
EntityID m_InkBlastTemplate;
@@ -61,6 +64,8 @@ private:
dd::EventRelay<ProjectileSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<ProjectileSystem, dd::Events::Resume> m_EResume;
dd::EventRelay<ProjectileSystem, dd::Events::InkBlaster> m_EInkBlaster;
dd::EventRelay<ProjectileSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
dd::EventRelay<ProjectileSystem, dd::Events::KrakenAttackEnd> m_EKrakenAttackEnd;
dd::EventRelay<ProjectileSystem, dd::Events::HitPad> m_EHitPad;
dd::EventRelay<ProjectileSystem, dd::Events::ActionButton> m_EActionButton;
@@ -68,6 +73,8 @@ private:
bool OnPause(const dd::Events::Pause &event);
bool OnResume(const dd::Events::Resume &event);
bool OnInkBlaster(const dd::Events::InkBlaster &event);
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
bool OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event);
bool OnHitPad(const dd::Events::HitPad &event);
bool OnActionButton(const dd::Events::ActionButton &event);
};
+2
View File
@@ -42,6 +42,8 @@
#include "Rendering/CSprite.h"
#include "Rendering/CModel.h"
#include "Sound/EPlaySound.h"
namespace dd
{
+5 -3
View File
@@ -29,9 +29,11 @@
#define GLFW_INCLUDE_GLU
#define NOMINMAX
#include <GLFW/glfw3.h>
#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WGL
#include <GLFW/glfw3native.h>
#ifdef BUILD_RENDERER_DIRECTX
#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WGL
#include <GLFW/glfw3native.h>
#endif
#include <glext.h>
#include "Core/Util/GLError.h"
+3
View File
@@ -4,6 +4,9 @@
#include "Core/System.h"
#include "Core/World.h"
#include "Rendering/CAnimation.h"
#include "Rendering/EAnimationComplete.h"
#include "Rendering/CModel.h"
#include "Rendering/Model.h"
#include "Game/EPause.h"
#include "Game/EResume.h"
+1
View File
@@ -13,6 +13,7 @@ struct Animation : Component
std::string Name;
double Time = 0.0;
double Speed = 0.0;
bool Loop = true;
bool NoRootMotion = true;
};
+21
View File
@@ -0,0 +1,21 @@
#ifndef RENDERING_EANIMATIONCOMPLETE_H__
#define RENDERING_EANIMATIONCOMPLETE_H__
#include "Core/Entity.h"
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct AnimationComplete
{
EntityID Entity;
std::string Animation;
};
}
}
#endif
+1
View File
@@ -41,6 +41,7 @@ private:
const std::string MENU_BGM = "Sounds/BGM/eastern-music.wav";
const std::string GAME_BGM = "Sounds/BGM/under-the-sea-n.wav";
const std::string WATER_BGM = "Sounds/BGM/water-flowing.wav";
const std::string STORY_VOICE = "Sounds/jap-story.wav";
float m_BGMMasterVolume = 1.f;
float m_SFXMasterVolume = 1.f;
+16 -20
View File
@@ -112,6 +112,17 @@ set(SOURCE_FILES
${SOURCE_FILES_GUI}
)
set(LIBRARIES
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
${GLFW_LIBRARIES}
${Boost_LIBRARIES}
${assimp_LIBRARIES}
${PNG_LIBRARIES}
${X11_LIBRARIES}
${OPENAL_LIBRARY}
${liquidfun_LIBRARIES}
)
if(BUILD_RENDERER_OPENGL)
set(SOURCE_FILES ${SOURCE_FILES}
@@ -123,6 +134,9 @@ if(BUILD_RENDERER_DIRECTX)
set(SOURCE_FILES ${SOURCE_FILES}
${SOURCE_FILES_Rendering_DirectX}
)
set(LIBRARIES ${LIBRARIES}
${CMAKE_LIBRARY_PATH}/DirectXTK.lib
)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
@@ -133,16 +147,7 @@ endif()
add_library(game ${SOURCE_FILES})
target_link_libraries(game
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
${GLFW_LIBRARIES}
${Boost_LIBRARIES}
${assimp_LIBRARIES}
${PNG_LIBRARIES}
${X11_LIBRARIES}
${OPENAL_LIBRARY}
${liquidfun_LIBRARIES}
${CMAKE_LIBRARY_PATH}/DirectXTK.lib
${LIBRARIES}
)
add_executable(breakout
@@ -150,15 +155,6 @@ add_executable(breakout
)
target_link_libraries(breakout
game
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
${GLFW_LIBRARIES}
${Boost_LIBRARIES}
${assimp_LIBRARIES}
${PNG_LIBRARIES}
${X11_LIBRARIES}
${OPENAL_LIBRARY}
${liquidfun_LIBRARIES}
${CMAKE_LIBRARY_PATH}/DirectXTK.lib
${LIBRARIES}
)
+48 -68
View File
@@ -12,15 +12,17 @@ void dd::Systems::BallSystem::RegisterComponents(ComponentFactory *cf)
void dd::Systems::BallSystem::Initialize()
{
std::random_device rd;
m_RandomGenerator = std::mt19937(rd());
EVENT_SUBSCRIBE_MEMBER(m_Contact, &BallSystem::Contact);
EVENT_SUBSCRIBE_MEMBER(m_ELifeLost, &BallSystem::OnLifeLost);
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &BallSystem::OnMultiBallLost);
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &BallSystem::OnResetBall);
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad);
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster);
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &BallSystem::OnKrakenAttack);
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttackEnd, &BallSystem::OnKrakenAttackEnd);
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
EVENT_SUBSCRIBE_MEMBER(m_EResume, &BallSystem::OnResume);
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
@@ -35,6 +37,7 @@ void dd::Systems::BallSystem::Initialize()
transform->Position = glm::vec3(-20.f, 0.26f, -10.f);
transform->Scale = glm::vec3(0.3f, 0.3f, 0.3f);
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
transform->Orientation = glm::quat();
auto model = m_World->AddComponent<Components::Model>(ent);
model->ModelFile = "Models/Sid/Sid.dae";
auto animation = m_World->AddComponent<Components::Animation>(ent);
@@ -50,6 +53,8 @@ void dd::Systems::BallSystem::Initialize()
physics->Category = CollisionLayer::Type::Ball;
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall | CollisionLayer::LifeBuoy);
physics->Calculate = true;
auto collisionSound = m_World->AddComponent<Components::CollisionSound>(ent);
collisionSound->FilePath = "Sounds/Jelly/squid-bounce-n.wav";
m_World->CommitEntity(ent);
@@ -61,27 +66,11 @@ void dd::Systems::BallSystem::Initialize()
transform2->Velocity = glm::vec3(0.0f, -10.f, 0.f);
}
for (int i = 0; i < Lives(); i++) {
CreateLife(i);
}
m_GodMode = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<bool>("Cheat.GodMode", false);
SetReplaceBall(true);
}
void dd::Systems::BallSystem::Update(double dt)
{
if (Lives() == 0)
{
Events::GameOver e;
EventBroker->Publish(e);
Events::Pause p;
p.Type = "All";
EventBroker->Publish(p);
//TODO: Make this not so ugly
SetLives(-1);
}
ResolveContacts();
}
@@ -124,7 +113,11 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
if (ReplaceBall()) {
SetReplaceBall(false);
m_Waiting = true;
std::uniform_real_distribution<float> dist(-0.5f, 0.5f);
float random = dist(m_RandomGenerator);
ballComponent->SavedSpeed = glm::vec3(random, 1, 0.f);
ballComponent->Waiting = true;
auto transform = m_World->GetComponent<Components::Transform>(entity);
}
if (ballComponent->Waiting) {
@@ -132,12 +125,17 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
m_Restarting = false;
ballComponent->Waiting = false;
auto transform = m_World->GetComponent<Components::Transform>(entity);
transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
/*std::uniform_real_distribution<float> dist(-0.5f, 0.5f);
float random = dist(m_RandomGenerator);*/
transform->Velocity = glm::normalize(ballComponent->SavedSpeed) * ballComponent->Speed;
} else if (!ballComponent->Sticky) {
auto transform = m_World->GetComponent<Components::Transform>(entity);
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
//transform->Position = glm::vec3(0.0f, -3.f, -10.f);
transform->Orientation = glm::quat();
if (m_First) {
transform->Orientation = glm::quat();
m_First = false;
}
return;
}
}
@@ -168,7 +166,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
m_World->RemoveEntity(entity);
Events::MultiBallLost e;
EventBroker->Publish(e);
} else if (Lives() == PastLives() && !m_Restarting) {
} else if (!m_Restarting) { //If we lose lives when we shouldn't, look here.
Events::ResetBall be;
EventBroker->Publish(be);
Events::LifeLost e;
@@ -195,16 +193,6 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
}*/
}
if (Lives() != PastLives()) {
auto life = m_World->GetComponent<Components::Life>(entity);
if (life != nullptr) {
if (life->Number + 1 == PastLives()) {
m_World->RemoveEntity(entity);
SetPastLives(Lives());
}
}
}
if (ballComponent != nullptr) {
if (!ballComponent->Sticky)
{
@@ -318,17 +306,20 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
particleEvent.EmittingAngle = glm::half_pi<float>();
particleEvent.Spread = 0.f;
particleEvent.NumberOfTicks = 1;
particleEvent.ParticleLifeTime = 2.f;
particleEvent.ParticleLifeTime = 1.3f;
particleEvent.ParticlesPerTick = 1;
particleEvent.Position = glm::vec3(ballTransform->Position.x, -3.f, -3.f);
if (ballTransform->Position.x >= 2.7f) {
particleEvent.Position = glm::vec3(2.7f, -3.f, -3.f);
} else if (ballTransform->Position.x <= -2.7f) {
particleEvent.Position = glm::vec3(-2.7f, -3.f, -3.f);
particleEvent.Position = glm::vec3(ballTransform->Position.x, -3.5f, -3.f);
if (ballTransform->Position.x >= 2.5f) {
particleEvent.Position = glm::vec3(2.5f, -3.5f, -3.f);
} else if (ballTransform->Position.x <= -2.5f) {
particleEvent.Position = glm::vec3(-2.5f, -3.5f, -3.f);
}
particleEvent.ScaleValues.push_back(glm::vec3(1.f));
particleEvent.ScaleValues.push_back(glm::vec3(1.5f));
particleEvent.ScaleValues.push_back(glm::vec3(2.f));
particleEvent.Color = glm::vec4(1.f);
particleEvent.Speed = 0;
particleEvent.Speed = 1.f;
particleEvent.AlphaValues.push_back(1.f);
particleEvent.AlphaValues.push_back(0.7f);
if (ballComponent->Combo <= 9) {
particleEvent.SpriteFile = "Textures/Combo/Combo00" + std::to_string(ballComponent->Combo) + ".png";
@@ -428,31 +419,6 @@ EntityID dd::Systems::BallSystem::CreateBall()
return ent;
}
void dd::Systems::BallSystem::CreateLife(int number)
{
auto life = m_World->CreateEntity();
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(life);
transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f);
transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
lifeNr->Number = number;
auto model = m_World->AddComponent<Components::Model>(life);
model->ModelFile = "Models/Sid/Sid.dae";
m_World->CommitEntity(life);
}
bool dd::Systems::BallSystem::OnLifeLost(const dd::Events::LifeLost &event)
{
if (!m_GodMode){
SetLives(Lives() - 1);
}
return true;
}
bool dd::Systems::BallSystem::OnMultiBallLost(const dd::Events::MultiBallLost &event)
{
SetMultiBalls(MultiBalls() - 1);
@@ -526,11 +492,25 @@ bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver
return true;
}
bool dd::Systems::BallSystem::OnKrakenAttack(const dd::Events::KrakenAttack &event)
{
m_KrakenAttack = true;
return true;
}
bool dd::Systems::BallSystem::OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event)
{
m_KrakenAttack = false;
return true;
}
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
{
if (!m_StageBlockedWaiting) {
if (!m_InkBlockedWaiting) {
m_Waiting = false;
if (!m_KrakenAttack) {
if (!m_StageBlockedWaiting) {
if (!m_InkBlockedWaiting) {
m_Waiting = false;
}
}
}
return true;
+62 -11
View File
@@ -80,10 +80,14 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI
switch (kraken->CurrentAction)
{
case 1: // Idle
//m_KrakenTimer += dt;
m_KrakenTimer += dt;
if (m_KrakenTimer > m_KrakenSecondsToAction) {
if (m_NumberOfActions == 0) {
kraken->CurrentAction = 3;
break;
}
m_KrakenTimer = 0;
std::uniform_real_distribution<float> dist(1, 2.999f);
std::uniform_real_distribution<float> dist(1, 4.999f);
float random = dist(m_RandomGenerator);
//std::cout << random << std::endl;
kraken->CurrentAction = random;
@@ -91,6 +95,7 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI
}
break;
case 2: // Grabbing
m_NumberOfActions++;
kraken->CurrentAction = 5;
krakenAttack.ChargeUpdate = 0;
krakenAttack.KrakenStrength = 0.1;
@@ -98,9 +103,30 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI
EventBroker->Publish(krakenAttack);
break;
case 3: // Brick Generating
break;
case 4: // Moving
break;
{
m_NumberOfActions++;
kraken->CurrentAction = 1;
Events::BrickGenerating e;
e.Origin1 = glm::vec3(-5, 7, -10);
e.Origin2 = glm::vec3(5, 7, -10);
std::uniform_real_distribution<float> dist(1, 5.999f);
float random = dist(m_RandomGenerator);
e.Set = random;
EventBroker->Publish(e);
break;
}
case 4: // Brick Generating second case
{
kraken->CurrentAction = 1;
Events::BrickGenerating e;
e.Origin1 = glm::vec3(-5, 7, -10);
e.Origin2 = glm::vec3(5, 7, -10);
std::uniform_real_distribution<float> dist(1, 5.999f);
float random = dist(m_RandomGenerator);
e.Set = random;
EventBroker->Publish(e);
break;
}
case 5: // Taunting
if (m_ReturnToIdle) {
m_ReturnToIdle = false;
@@ -161,13 +187,38 @@ bool dd::Systems::KrakenSystem::OnContact(const dd::Events::Contact &event)
return false;
}
auto ball = m_World->GetComponent<Components::Ball>(otherEntitiy);
if (ball != nullptr) {
auto projectile = m_World->GetComponent<Components::Projectile>(otherEntitiy);
if (projectile != nullptr) {
Events::ScoreEvent es;
es.Score = 23;
Events::KrakenHit e;
e.Kraken = krakenEntity;
e.Hitter = otherEntitiy;
e.MaxHealth = kraken->MaxHealth;
e.CurrentHealth = kraken->Health;
e.NewHealth = kraken->Health - 1;
EventBroker->Publish(e);
m_World->RemoveEntity(otherEntitiy);
return true;
}
auto ball = m_World->GetComponent<Components::Ball>(otherEntitiy);
if (ball != nullptr) {
ball->Combo += 1;
Events::ComboEvent ec;
ec.Combo = ball->Combo;
ec.Ball = otherEntitiy;
EventBroker->Publish(ec);
Events::ScoreEvent es;
es.Score = ball->Combo * 23;
Events::KrakenHit e;
e.Kraken = krakenEntity;
e.Hitter = otherEntitiy;
e.MaxHealth = kraken->MaxHealth;
e.CurrentHealth = kraken->Health;
e.NewHealth = kraken->Health - 1;
EventBroker->Publish(e);
}
return true;
}
bool dd::Systems::KrakenSystem::OnKrakenAppear(const dd::Events::KrakenAppear &event)
@@ -191,9 +242,9 @@ bool dd::Systems::KrakenSystem::OnKrakenAttack(const dd::Events::KrakenAttack &e
bool dd::Systems::KrakenSystem::OnKrakenHit(const dd::Events::KrakenHit &event)
{
auto kraken = m_World->GetComponent<Components::Kraken>(event.Kraken);
//kraken->Health--;
kraken->Health--;
//std::cout << kraken->Health << std::endl;
kraken->Health = -1;
//kraken->Health = -1;
if (kraken->Health < 0) {
Events::KrakenDefeated e;
e.Kraken = event.Kraken;
@@ -210,9 +261,9 @@ bool dd::Systems::KrakenSystem::OnKrakenDefeated(const dd::Events::KrakenDefeate
auto kraken = m_World->GetComponent<Components::Kraken>(event.Kraken);
auto physicsComponent = m_World->GetComponent<Components::Physics>(event.Kraken);
/*physicsComponent->CollisionType = CollisionType::Type::Dynamic;
physicsComponent->GravityScale = 1.f;
physicsComponent->GravityScale = 1.f;*/
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
physicsComponent->Calculate = false;*/
/*physicsComponent->Calculate = false;*/
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(event.Kraken);
auto transformComponentHitter = m_World->GetComponent<Components::Transform>(event.Hitter);
+132 -42
View File
@@ -248,6 +248,9 @@ void dd::Systems::LevelSystem::Update(double dt)
if (!m_Initialized) {
GetNextLevel();
CreateLevel(0);
for (int i = 0; i < m_KrakenBricks.size(); i++) {
m_KrakenBricks[i] = false;
}
m_Initialized = true;
}
}
@@ -275,6 +278,15 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
}
}
auto brickPart = m_World->GetComponent<Components::BrickPart>(entity);
if (brickPart != nullptr) {
auto transform = m_World->GetComponent<Components::Transform>(entity);
if (transform->Position.y < -10) {
m_World->RemoveEntity(entity);
return;
}
}
auto brick = m_World->GetComponent<Components::Brick>(entity);
if (brick != nullptr) {
auto transform = m_World->GetComponent<Components::Transform>(entity);
@@ -307,6 +319,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
}
m_LooseBricks--;
m_World->RemoveEntity(entity);
return;
}
}
@@ -434,8 +447,9 @@ EntityID dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spac
auto type = m_World->AddComponent<Components::StickyBrick>(brick);
model->ModelFile = "Models/Brick/StickyBrick.obj";
} else if (typeInt == InkBlasterBrick) {
cBrick->Type = InkBlasterBrick;
cBrick->Type = InkBlasterBrick;
auto type = m_World->AddComponent<Components::InkBlasterBrick>(brick);
//model->ModelFile = "Models/Brick/InkBrick.obj";
model->Color = glm::vec4(0.1f, 0.1f, 0.1f, 1.0f);
} else if (typeInt == KrakenAttackBrick) {
cBrick->Type = KrakenAttackBrick;
@@ -456,26 +470,41 @@ EntityID dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spac
bool dd::Systems::LevelSystem::OnBrickGenerating(const dd::Events::BrickGenerating &event)
{
GetBrickSet(event.Set);
LOG_DEBUG("This is happening.");
m_BrickGenerating = true;
m_BrickGeneratingEvent = event;
return true;
}
int rows = 2;
bool dd::Systems::LevelSystem::BrickGenerating(const dd::Events::BrickGenerating &event)
{
GetBrickSet(event.Set);
int rows = 6;
int lines = 7;
int getter = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < lines; j++) {
auto ent = CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), -4, 1, m_BrickSet[getter], m_ColorSet[getter]);
if (ent != NULL) {
auto transform = m_World->GetComponent<Components::Transform>(ent);
Events::Move e;
e.GoalPosition = transform->Position;
transform->Position = event.Origin;
e.Entity = ent;
e.Speed = 6;
e.Queue = false;
EventBroker->Publish(e);
m_LooseBricks++;
SetNumberOfBricks(NumberOfBricks() + 1);
if (!m_KrakenBricks[getter]) {
auto ent = CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), -3.2, 1, m_BrickSet[getter], m_ColorSet[getter]);
if (ent != NULL) {
auto brick = m_World->GetComponent<Components::Brick>(ent);
brick->Number = getter;
m_KrakenBricks[getter] = true;
auto transform = m_World->GetComponent<Components::Transform>(ent);
Events::Move e;
e.GoalPosition = transform->Position;
if (j < 4) {
transform->Position = event.Origin1;
} else {
transform->Position = event.Origin2;
}
e.Entity = ent;
e.Speed = 6;
e.Queue = false;
EventBroker->Publish(e);
m_LooseBricks++;
SetNumberOfBricks(NumberOfBricks() + 1);
}
}
getter++;
}
@@ -483,10 +512,10 @@ bool dd::Systems::LevelSystem::OnBrickGenerating(const dd::Events::BrickGenerati
return true;
}
void dd::Systems::LevelSystem::GetBrickSet(int set)
void dd::Systems::LevelSystem::GetBrickSet(int set) // These are sets the Kraken gets!
{
std::array<int, 14> level;
std::array<glm::vec4, 14> color;
std::array<int, 42> level;
std::array<glm::vec4, 42> color;
// Level array indicates type of brick.
// 0 is empty space.
// 1 is standard brick.
@@ -517,51 +546,99 @@ void dd::Systems::LevelSystem::GetBrickSet(int set)
if (set == 1) {
level =
{1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1 };
{1, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 2,
1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0};
color =
{r, r, r, r, r, r, r,
r, r, r, r, r, r, r };
r, r, r, r, r, r, r,
r, r, r, r, r, r, r,
r, r, r, r, r, r, r,
r, r, r, r, r, r, r,
r, r, r, r, r, r, r};
}
else if (set == 2) {
level =
{2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2 };
{0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
3, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1,
0, 0, 0, 0, 0, 0, 0};
color =
{w, w, w, w, w, w, w,
w, w, w, w, w, w, w };
{y, y, y, y, y, y, y,
y, y, y, y, y, y, y,
y, y, y, y, y, y, y,
y, y, y, y, y, y, y,
y, y, y, y, y, y, y,
y, y, y, y, y, y, y};
}
else if (set == 3) {
level =
{0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0 };
0, 0, 0, 0, 0, 0, 0,
1, 0, 1, 0, 1, 0, 1,
0, 1, 1, 1, 1, 1, 0,
0, 0, 4, 1, 1, 0, 0,
0, 0, 0, 1, 0, 0, 0};
color =
{w, w, w, w, w, w, w,
w, w, w, w, w, w, w };
{b, b, b, b, b, b, b,
b, b, b, b, b, b, b,
b, b, b, b, b, b, b,
b, b, b, b, b, b, b,
b, b, b, b, b, b, b,
b, b, b, b, b, b, b};
}
else if (set == 4) {
level =
{0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0 };
1, 1, 1, 1, 1, 3, 1,
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0};
color =
{w, w, w, w, w, w, w,
w, w, w, w, w, w, w };
{m, m, m, m, m, m, m,
m, m, m, m, m, m, m,
m, m, m, m, m, m, m,
m, m, m, m, m, m, m,
m, m, m, m, m, m, m,
m, m, m, m, m, m, m};
}
else if (set == 5) {
level =
{0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0 };
0, 1, 1, 0, 1, 1, 0,
0, 1, 2, 0, 1, 1, 0,
0, 1, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0};
color =
{w, w, w, w, w, w, w,
w, w, w, w, w, w, w };
{g, g, g, g, g, g, g,
g, g, g, g, g, g, g,
g, g, g, g, g, g, g,
g, g, g, g, g, g, g,
g, g, g, g, g, g, g,
g, g, g, g, g, g, g};
}
else if (set == 6) {
level =
{0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0 };
{0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0};
color =
{w, w, w, w, w, w, w,
w, w, w, w, w, w, w };
{r, r, r, r, r, r, r,
r, r, r, r, r, r, r,
r, r, r, r, r, r, r,
r, r, r, r, r, r, r,
r, r, r, r, r, r, r,
r, r, r, r, r, r, r};
}
std::copy(std::begin(level), std::end(level), std::begin(m_BrickSet));
@@ -576,6 +653,11 @@ void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity)
bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
{
auto templateCheck = m_World->GetComponent<Components::Template>(event.Entity1);
if (templateCheck != nullptr){ return false; }
templateCheck = m_World->GetComponent<Components::Template>(event.Entity2);
if (templateCheck != nullptr){ return false; }
EntityID entityBrick;
EntityID entityBall;
EntityID entityShot = 0;
@@ -653,10 +735,12 @@ void dd::Systems::LevelSystem::BrickHit(EntityID entityHitter, EntityID entityBr
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
auto transformComponentHitter = m_World->GetComponent<Components::Transform>(entityHitter);
auto brickModel = m_World->GetComponent<Components::Model>(entityBrick);
if (brick->Number < 50) {
m_KrakenBricks[brick->Number] = false;
}
// Check if the brick is any kind of special.
auto multi = m_World->GetComponent<Components::MultiBallBrick>(entityBrick);
if (multi != nullptr) {
@@ -835,6 +919,7 @@ bool dd::Systems::LevelSystem::OnPowerUpTaken(const dd::Events::PowerUpTaken &ev
bool dd::Systems::LevelSystem::OnKrakenDefeated(const dd::Events::KrakenDefeated &event)
{
m_BrickGenerating = false;
SetNumberOfBricks(NumberOfBricks() - 1);
m_LooseBricks--;
@@ -1024,7 +1109,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
1, 1, 1, 1, 1, 1, 1,
1, 0, 1, 2, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 6,
0, 0, 0, 0, 0, 0, 0};
color =
{w, w, w, w, w, w, w,
@@ -1121,6 +1206,10 @@ void dd::Systems::LevelSystem::GetNextLevel()
bool dd::Systems::LevelSystem::OnHitPad(const dd::Events::HitPad &event)
{
m_Cleared = false;
if (m_BrickGenerating) {
m_BrickGenerating = false;
BrickGenerating(m_BrickGeneratingEvent);
}
return true;
}
@@ -1162,6 +1251,7 @@ void dd::Systems::LevelSystem::CreateBrokenModelPart(EntityID Parent, std::strin
auto ent = m_World->CreateEntity(Parent);
auto cTemplate = m_World->AddComponent<Components::Template>(ent);
auto cTransform = m_World->AddComponent<Components::Transform>(ent);
auto cBrickPart = m_World->AddComponent<Components::BrickPart>(ent);
cTransform->Position = RelativePosition;
+101
View File
@@ -0,0 +1,101 @@
//
// Created by Adniklastrator on 2015-10-13.
//
#include "PrecompiledHeader.h"
#include "Game/LifeSystem.h"
void dd::Systems::LifeSystem::Initialize()
{
EVENT_SUBSCRIBE_MEMBER(m_EPause, &LifeSystem::OnPause);
EVENT_SUBSCRIBE_MEMBER(m_EResume, &LifeSystem::OnResume);
EVENT_SUBSCRIBE_MEMBER(m_ELifeLost, &LifeSystem::OnLifeLost);
for (int i = 0; i < Lives(); i++) {
CreateLife(i);
}
m_GodMode = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<bool>("Cheat.GodMode", false);
}
void dd::Systems::LifeSystem::Update(double dt)
{
if (m_Pause) {
return;
}
if (Lives() < 0) {
Events::KrakenAttackEnd ek;
EventBroker->Publish(ek);
Events::GameOver e;
EventBroker->Publish(e);
Events::Pause p;
p.Type = "All";
EventBroker->Publish(p);
//TODO: Make this not so ugly
SetLives(3);
}
}
void dd::Systems::LifeSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
{
if (m_Pause) {
return;
}
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
if (templateCheck != nullptr){ return; }
if (Lives() != PastLives()) {
auto life = m_World->GetComponent<Components::Life>(entity);
if (life != nullptr) {
if (life->Number + 1 == PastLives()) {
m_World->RemoveEntity(entity);
SetPastLives(Lives());
}
}
}
}
void dd::Systems::LifeSystem::CreateLife(int number)
{
auto life = m_World->CreateEntity();
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(life);
transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f);
transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
lifeNr->Number = number;
auto model = m_World->AddComponent<Components::Model>(life);
model->ModelFile = "Models/Sid/Sid.dae";
m_World->CommitEntity(life);
}
bool dd::Systems::LifeSystem::OnLifeLost(const dd::Events::LifeLost &event)
{
if (!m_GodMode){
SetLives(Lives() - 1);
}
return true;
}
bool dd::Systems::LifeSystem::OnPause(const dd::Events::Pause &event)
{
/*if (event.Type != "LifeSystem" && event.Type != "All") {
return false;
}*/
m_Pause = true;
return true;
}
bool dd::Systems::LifeSystem::OnResume(const dd::Events::Resume &event)
{
/*if (event.Type != "LifeSystem" && event.Type != "All") {
return false;
}*/
m_Pause = false;
return true;
}
+1 -1
View File
@@ -143,7 +143,7 @@ bool dd::Systems::LifebuoySystem::OnLifebuoyHit(const dd::Events::LifebuoyHit &e
e.EmittingAngle = glm::half_pi<float>();
e.Spread = 0.5f;
e.NumberOfTicks = 1;
e.ParticleLifeTime = 1.f;
e.ParticleLifeTime = 2.f;
e.ParticlesPerTick = 1;
e.Position = transformComponent->Position;
e.ScaleValues.clear();
+52 -6
View File
@@ -34,6 +34,7 @@ void dd::Systems::PadSystem::Initialize()
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
EVENT_SUBSCRIBE_MEMBER(m_EResume, &PadSystem::OnResume);
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack);
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttackEnd, &PadSystem::OnKrakenAttackEnd);
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &PadSystem::OnStickyPad);
EVENT_SUBSCRIBE_MEMBER(m_EStickyAttachedToPad, &PadSystem::OnStickyAttachedToPad);
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &PadSystem::OnActionButton);
@@ -151,7 +152,6 @@ void dd::Systems::PadSystem::Update(double dt)
Events::KrakenAttack e;
e.ChargeUpdate = m_KrakenCharge;
EventBroker->Publish(e);
//std::cout << "Charge: " << m_KrakenCharge << std::endl;
return;
}
@@ -271,7 +271,8 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
EventBroker->Publish(e);
} else if (val == GLFW_KEY_G) {
Events::BrickGenerating e;
e.Origin = glm::vec3(-5, 7, -10);
e.Origin1 = glm::vec3(-5, 7, -10);
e.Origin2 = glm::vec3(5, 7, -10);
e.Set = 1;
EventBroker->Publish(e);
} else if (val == GLFW_KEY_L) {
@@ -296,7 +297,7 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
} else if (val == GLFW_KEY_Q) {
Events::Move e;
e.Entity = Entity();
e.GoalPosition = glm::vec3(0, 0, -10);
e.GoalPosition = glm::vec3(0, 0, -10);
e.Speed = 5;
e.Queue = false;
EventBroker->Publish(e);
@@ -473,18 +474,63 @@ bool dd::Systems::PadSystem::OnKrakenAttack(const dd::Events::KrakenAttack &even
transform->Velocity = glm::vec3(0, 0, 0);
acceleration = glm::vec3(0, 0, 0);
LOG_INFO("Kraken arm duuude");
if (!m_KrakenArm){
LOG_INFO("InKrakenArmDuuude");
m_KrakenArm = m_World->CreateEntity(Entity());
auto transform = m_World->AddComponent<Components::Transform>(m_KrakenArm);
transform->Position = glm::vec3(1.f, -3.0f, 0.f);
auto model = m_World->AddComponent<Components::Model>(m_KrakenArm);
model->ModelFile = "Models/Kraken/Arm.dae";
auto animation = m_World->AddComponent<Components::Animation>(m_KrakenArm);
animation->Speed = 1.0f;
animation->Loop = false;
m_World->CommitEntity(m_KrakenArm);
m_KrakenArmHitbox = m_World->CreateEntity();
auto hb_transform = m_World->AddComponent<Components::Transform>(m_KrakenArmHitbox);
hb_transform->Position = transform->Position + glm::vec3(-1.f, -5.0f, -10.f);
//hb_transform->Position = glm::vec3(-2.f, -8.0f, -10.f);
hb_transform->Scale = glm::vec3(2.5f, 2.5f, 1.f);
hb_transform->Velocity = glm::vec3(0.f, 10.f, 0.f);
//auto hb_sprite = m_World->AddComponent<Components::Sprite>(m_KrakenArmHitbox);
//hb_sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
auto hb_physics = m_World->AddComponent<Components::Physics>(m_KrakenArmHitbox);
hb_physics->Calculate = true;
hb_physics->CollisionType = CollisionType::Type::Static;
hb_physics->Category = CollisionLayer::Type::Other;
hb_physics->Mask = CollisionLayer::Type::Water;
hb_physics->GravityScale = 0.f;
auto hb_HitBox = m_World->AddComponent<Components::CircleShape>(m_KrakenArmHitbox);
hb_HitBox->Radius = 1.25f;
m_World->CommitEntity(m_KrakenArmHitbox);
}
SetTransform(transform);
SetAcceleration(acceleration);
} else if (m_KrakenCharge >= 1) {
m_KrakenAttack = false;
m_KrakenCharge = 0;
m_KrakenStrength = 0;
m_PlayerStrength = 0;
Events::KrakenAttackEnd e;
EventBroker->Publish(e);
}
return true;
}
bool dd::Systems::PadSystem::OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event)
{
m_KrakenAttack = false;
m_KrakenCharge = 0;
m_KrakenStrength = 0;
m_PlayerStrength = 0;
m_World->RemoveEntity(m_KrakenArm);
m_World->RemoveEntity(m_KrakenArmHitbox);
m_KrakenArm = NULL;
m_KrakenArmHitbox = NULL;
return true;
}
bool dd::Systems::PadSystem::OnStickyPad(const dd::Events::StickyPad &event)
{
return true;
+38 -22
View File
@@ -13,6 +13,8 @@ void dd::Systems::ProjectileSystem::Initialize()
EVENT_SUBSCRIBE_MEMBER(m_EPause, &ProjectileSystem::OnPause);
EVENT_SUBSCRIBE_MEMBER(m_EResume, &ProjectileSystem::OnResume);
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &ProjectileSystem::OnInkBlaster);
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &ProjectileSystem::OnKrakenAttack);
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttackEnd, &ProjectileSystem::OnKrakenAttackEnd);
EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &ProjectileSystem::OnHitPad);
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &ProjectileSystem::OnActionButton);
@@ -113,34 +115,48 @@ bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
return true;
}
bool dd::Systems::ProjectileSystem::OnKrakenAttack(const dd::Events::KrakenAttack &event)
{
m_KrakenAttack = true;
return true;
}
bool dd::Systems::ProjectileSystem::OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event)
{
m_KrakenAttack = false;
return true;
}
bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButton &event)
{
if (m_InkBlaster && m_SquidLoaded) {
auto ent = m_World->CloneEntity(m_InkBlastTemplate);
m_World->RemoveComponent<Components::Template>(ent);
auto projectile = m_World->GetComponent<Components::Projectile>(ent);
projectile->Speed = m_InkBlasterSpeed;
auto transform = m_World->GetComponent<Components::Transform>(ent);
transform->Position = event.Position;
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
m_Shots--;
if (m_Shots <= 0) {
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
m_InkBlaster = false;
m_SquidLoaded = false;
ball->InkBlaster = false;
ball->Sticky = false;
ball->Waiting = true;
{
Events::InkBlasterOver e;
e.Ball = m_AttachedSquid;
EventBroker->Publish(e);
}
if (!m_KrakenAttack) {
if (m_InkBlaster && m_SquidLoaded) {
auto ent = m_World->CloneEntity(m_InkBlastTemplate);
m_World->RemoveComponent<Components::Template>(ent);
auto projectile = m_World->GetComponent<Components::Projectile>(ent);
projectile->Speed = m_InkBlasterSpeed;
auto transform = m_World->GetComponent<Components::Transform>(ent);
transform->Position = event.Position;
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
m_Shots--;
if (m_Shots <= 0) {
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
m_InkBlaster = false;
m_SquidLoaded = false;
ball->InkBlaster = false;
ball->Sticky = false;
ball->Waiting = true;
{
Events::InkBlasterOver e;
e.Ball = m_AttachedSquid;
EventBroker->Publish(e);
}
{
Events::ActionButton e;
EventBroker->Publish(e);
}
}
}
}
return true;
+8
View File
@@ -37,6 +37,7 @@ void dd::Systems::PhysicsSystem::InitializeWater()
m_ParticleSystemDef.radius = radius;
m_ParticleSystemDef.gravityScale = gravityScale;
m_ParticleSystemDef.density = 4.f;
m_ParticleSystemDef.surfaceTensionNormalStrength = 0.07;
m_WaterParticleSystem = m_PhysicsWorld->CreateParticleSystem(&m_ParticleSystemDef);
}
@@ -820,6 +821,7 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event)
model = m_World->GetComponent<Components::Model>(event.Entity1);
}
Events::PlaySound se;
//Spawn a particle when a brick collides with somthing
Events::CreateParticleSequence e;
@@ -843,14 +845,19 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event)
auto PowerKraken = m_World->GetComponent<Components::KrakenAttackBrick>(entity);
if (PowerFriend) {
se.FilePath = "Sounds/jap-awesome.wav";
e.SpriteFile = "Textures/PowerUps/Friends.png";
} else if (PowerSaviour) {
se.FilePath = "Sounds/jap-awesome.wav";
e.SpriteFile = "Textures/PowerUps/Saviour.png";
} else if (PowerSticky) {
se.FilePath = "Sounds/jap-awesome.wav";
e.SpriteFile = "Textures/PowerUps/Sticky.png";
} else if (PowerInkBlaster){
se.FilePath = "Sounds/jap-awesome.wav";
e.SpriteFile = "Textures/PowerUps/InkBlaster.png";
} else if (PowerKraken) {
se.FilePath = "Sounds/jap-awesome.wav";
e.SpriteFile = "Textures/PowerUps/RealeaseTheKraken.png";
}
else {
@@ -873,6 +880,7 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event)
}
EventBroker->Publish(e);
EventBroker->Publish(se);
return true;
+23 -2
View File
@@ -24,8 +24,29 @@ void dd::Systems::AnimationSystem::Update(double dt)
}
for (auto& component : *animations) {
auto animation = static_cast<Components::Animation*>(component.get());
animation->Time += animation->Speed * dt;
EntityID ent = component->Entity;
auto animationComponent = static_cast<Components::Animation*>(component.get());
// Get animation information
auto modelComponent = m_World->GetComponent<Components::Model>(ent);
auto model = ResourceManager::Load<Model>(modelComponent->ModelFile);
auto skeleton = model->m_Skeleton;
auto animation = skeleton->GetAnimation(animationComponent->Name);
if (animationComponent->Speed != 0.0) {
double nextTime = animationComponent->Time + animationComponent->Speed * dt;
if (glm::abs(nextTime) > animation->Duration) {
if (!animationComponent->Loop) {
animationComponent->Time = glm::sign(nextTime) * animation->Duration;
animationComponent->Speed = 0.0;
LOG_DEBUG("Animation \"%s\" on Entity %i finished.", animationComponent->Name.c_str(), ent);
Events::AnimationComplete e;
e.Entity = ent;
e.Animation = animationComponent->Name;
}
}
animationComponent->Time = nextTime;
}
}
}
+4
View File
@@ -293,6 +293,10 @@ dd::RawModel::RawModel(std::string fileName)
Skeleton::Animation::Keyframe animationFrame;
animationFrame.Index = keyframe;
animationFrame.Time = frameTimes[keyframe] / animation->mTicksPerSecond;
// HACK: For some reason Blender likes to create a first frame that doesn't start at time 0
if (keyframe == 0) {
animationFrame.Time = 0;
}
for (auto &kv2 : kv.second) {
int boneID = kv2.first;
auto &property = kv2.second;
+1 -1
View File
@@ -154,7 +154,7 @@ int dd::Skeleton::GetKeyframe(const Animation& animation, double time)
for (int keyframe = 0; keyframe < animation.Keyframes.size(); ++keyframe) {
if (animation.Keyframes[keyframe].Time > time)
return glm::max(0, keyframe - 1); // HACK: If the time is less than the first keyframe, don
return (keyframe - 1) % animation.Keyframes.size();
}
return 0;
+5
View File
@@ -188,6 +188,11 @@ bool dd::Systems::SoundSystem::OnContact(const dd::Events::Contact &event)
bool dd::Systems::SoundSystem::OnGameStart(const dd::Events::GameStart &event)
{
{
dd::Events::StopSound e;
e.FilePath = STORY_VOICE;
EventBroker->Publish(e);
}
{
dd::Events::StopSound e;
e.FilePath = MENU_BGM;