Created CPad and PadSystem. Doesn't do very much.
This commit is contained in:
@@ -58,28 +58,22 @@ public:
|
||||
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>();
|
||||
<<<<<<< HEAD
|
||||
m_World->SystemFactory.Register<Systems::LevelSystem>([this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::LevelSystem>();
|
||||
=======
|
||||
>>>>>>> origin/master
|
||||
m_World->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
m_World->Initialize();
|
||||
|
||||
<<<<<<< HEAD
|
||||
// auto ent = m_World->CreateEntity();
|
||||
// std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
// transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
// std::shared_ptr<Components::Model> model = m_World->AddComponent<Components::Model>(ent);
|
||||
// model->ModelFile = "Models/Core/UnitSphere.obj";
|
||||
=======
|
||||
auto ent = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
std::shared_ptr<Components::Model> model = m_World->AddComponent<Components::Model>(ent);
|
||||
model->ModelFile = "Models/Core/UnitSphere.obj";
|
||||
>>>>>>> origin/master
|
||||
|
||||
|
||||
m_LastTime = glfwGetTime();
|
||||
@@ -99,7 +93,8 @@ public:
|
||||
m_InputManager->Update(dt);
|
||||
|
||||
m_World->Update(dt);
|
||||
<<<<<<< HEAD
|
||||
|
||||
|
||||
//
|
||||
// if (glfwGetKey(m_Renderer->Window(), GLFW_KEY_R)) {
|
||||
// ResourceManager::Reload("Shaders/Deferred/3/Fragment.glsl");
|
||||
@@ -111,7 +106,6 @@ public:
|
||||
// Render scene
|
||||
//TODO send renderqueue to draw.
|
||||
// m_Renderer->Draw(m_RendererQueue);
|
||||
=======
|
||||
|
||||
if (glfwGetKey(m_Renderer->Window(), GLFW_KEY_R)) {
|
||||
ResourceManager::Reload("Shaders/Deferred/3/Fragment.glsl");
|
||||
@@ -123,7 +117,6 @@ public:
|
||||
// Render scene
|
||||
//TODO send renderqueue to draw.
|
||||
m_Renderer->Draw(m_RendererQueue);
|
||||
>>>>>>> origin/master
|
||||
|
||||
// Swap event queues
|
||||
m_EventBroker->Clear();
|
||||
|
||||
@@ -34,54 +34,23 @@ class InputController
|
||||
public:
|
||||
InputController(std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: EventBroker(eventBroker)
|
||||
, InGame(true)
|
||||
{ Initialize(); }
|
||||
|
||||
virtual void Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &InputController::_OnCommand);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &InputController::_OnMouseMove);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &InputController::OnGameStart);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &InputController::OnGameOver);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &InputController::OnCommand);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &InputController::OnMouseMove);
|
||||
}
|
||||
|
||||
virtual bool OnCommand(const Events::InputCommand &event) { return false; }
|
||||
virtual bool OnMouseMove(const Events::MouseMove &event) { return false; }
|
||||
virtual bool OnGameStart(const Events::GameStart &event)
|
||||
{
|
||||
InGame = true;
|
||||
return true;
|
||||
}
|
||||
virtual bool OnGameOver(const Events::GameOver &event)
|
||||
{
|
||||
InGame = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::shared_ptr<dd::EventBroker> EventBroker;
|
||||
bool InGame;
|
||||
|
||||
private:
|
||||
EventRelay<EventContext, Events::InputCommand> m_EInputCommand;
|
||||
EventRelay<EventContext, Events::MouseMove> m_EMouseMove;
|
||||
EventRelay<EventContext, Events::GameStart> m_EGameStart;
|
||||
EventRelay<EventContext, Events::GameOver> m_EGameOver;
|
||||
|
||||
virtual bool _OnCommand(const Events::InputCommand &event)
|
||||
{
|
||||
if (InGame || event.Value == 0)
|
||||
return OnCommand(event);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
virtual bool _OnMouseMove(const Events::MouseMove &event)
|
||||
{
|
||||
if (InGame)
|
||||
return OnMouseMove(event);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// Created by Administrator on 2015-09-10.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CPAD_H
|
||||
#define DAYDREAM_CPAD_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Pad : Component
|
||||
{
|
||||
//std::shared_ptr<dd::EventBroker> eventBroker;
|
||||
//EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, CPad::OnKeyDown);
|
||||
int Lives;
|
||||
int Points;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CPAD_H
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "Core/CTransform.h"
|
||||
//#include "Rendering/CSprite.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Core/World.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <intrin.h>
|
||||
@@ -49,8 +52,6 @@ public:
|
||||
|
||||
void EndLevel();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
int numberOfBricks;
|
||||
int tRows = 8;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-10.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_PADSYSTEM_H
|
||||
#define DAYDREAM_PADSYSTEM_H
|
||||
|
||||
#include "Core/InputController.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Input/EBindKey.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class PadSystem : public System
|
||||
{
|
||||
public:
|
||||
PadSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker)
|
||||
{ }
|
||||
|
||||
void Initialize() override ;
|
||||
private:
|
||||
dd::EventRelay<PadSystem, dd::Events::KeyDown> m_EKeyDown;
|
||||
|
||||
class PadSteeringInputController;
|
||||
std::array<std::shared_ptr<PadSteeringInputController>, 4> m_PadInputControllers;
|
||||
|
||||
bool OnKeyDown(const dd::Events::KeyDown &event);
|
||||
};
|
||||
|
||||
class PadSystem::PadSteeringInputController : InputController<PadSystem>
|
||||
{
|
||||
public:
|
||||
PadSteeringInputController(std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: InputController(eventBroker)
|
||||
{
|
||||
|
||||
}
|
||||
protected:
|
||||
virtual bool OnCommand(const Events::InputCommand &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //DAYDREAM_PADSYSTEM_H
|
||||
@@ -67,7 +67,7 @@ set(SOURCE_FILES
|
||||
${SOURCE_FILES_Rendering}
|
||||
${SOURCE_FILES_Transform}
|
||||
${SOURCE_FILES_Game}
|
||||
../../include/Game/CBrick.h ../../include/Game/EStageCleared.h)
|
||||
../../include/Game/CBrick.h ../../include/Game/EStageCleared.h ../../include/Game/CPad.h Game/PadSystem.cpp ../../include/Game/PadSystem.h)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
|
||||
@@ -4,14 +4,15 @@
|
||||
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/LevelSystem.h"
|
||||
#include "Core/World.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
|
||||
|
||||
void dd::Systems::LevelSystem::Initialize()
|
||||
{
|
||||
CreateBasicLevel(tRows, tLines, tSpaceBetweenBricks, tSpaceToEdge);
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,4 +67,5 @@ void dd::Systems::LevelSystem::EndLevel()
|
||||
Events::StageCleared e;
|
||||
EventBroker->Publish(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-10.
|
||||
//
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Game/PadSystem.h"
|
||||
#include "Core/World.h"
|
||||
|
||||
|
||||
void dd::Systems::PadSystem::Initialize()
|
||||
{
|
||||
Events::BindKey r;
|
||||
r.KeyCode = GLFW_KEY_RIGHT;
|
||||
r.Command = "right";
|
||||
EventBroker->Publish(r);
|
||||
|
||||
Events::BindKey l;
|
||||
l.KeyCode = GLFW_KEY_LEFT;
|
||||
l.Command = "right";
|
||||
EventBroker->Publish(l);
|
||||
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, PadSystem::OnKeyDown);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*bool dd::Systems::PadSteeringInputController::OnCommand(const Events::InputCommand &event)
|
||||
{
|
||||
std::string command = event.Command;
|
||||
|
||||
if (command == "right")
|
||||
{
|
||||
|
||||
}
|
||||
else if (command == "left")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
bool dd::Systems::PadSystem::PadSteeringInputController::OnCommand(const Events::InputCommand &event)
|
||||
{
|
||||
std::string command = event.Command;
|
||||
|
||||
if (command == "right")
|
||||
{
|
||||
|
||||
}
|
||||
else if (command == "left")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user