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
|
||||
Reference in New Issue
Block a user