Merge remote-tracking branch 'origin/master' into GLrenderer
This commit is contained in:
@@ -78,6 +78,7 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::Ball>();
|
||||
m_World->ComponentFactory.Register<Components::Brick>();
|
||||
m_World->ComponentFactory.Register<Components::Pad>();
|
||||
m_World->ComponentFactory.Register<Components::Life>();
|
||||
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
||||
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PhysicsSystem>();
|
||||
@@ -94,6 +95,8 @@ public:
|
||||
|
||||
|
||||
//TODO: Remove tobias light-test code.
|
||||
/*{
|
||||
}*/
|
||||
|
||||
//OctoBall
|
||||
{
|
||||
@@ -156,8 +159,8 @@ public:
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(0.f, 5.f, -10.f);
|
||||
transform->Scale = glm::vec3(15.f, 0.5f, 1.f);
|
||||
transform->Position = glm::vec3(0.f, 6.f, -10.f);
|
||||
transform->Scale = glm::vec3(18.f, 0.5f, 1.f);
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Components
|
||||
|
||||
struct Ball : Component
|
||||
{
|
||||
|
||||
int number = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Administrator on 2015-09-15.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CLIFE_H
|
||||
#define DAYDREAM_CLIFE_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Life : Component {
|
||||
|
||||
int number = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CLIFE_H
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Created by Administrator on 2015-09-15.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ELIFELOST_H
|
||||
#define DAYDREAM_ELIFELOST_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct LifeLost : Event
|
||||
{
|
||||
EntityID entity;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ELIFELOST_H
|
||||
@@ -10,13 +10,17 @@
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CLife.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
#include "Physics/CBoxShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <intrin.h>
|
||||
@@ -48,6 +52,7 @@ public:
|
||||
void Initialize() override;
|
||||
|
||||
void CreateBasicLevel(int, int, glm::vec2, int);
|
||||
void CreateLife(int);
|
||||
void SaveLevel(int, int, glm::vec2, int); // Shouldn't be here, but I'm experimenting.
|
||||
void LoadLevel(char[20]);
|
||||
void CreateBrick(int, int, glm::vec2, int, int);
|
||||
@@ -57,12 +62,17 @@ public:
|
||||
|
||||
void EndLevel();
|
||||
|
||||
void Update(double dt);
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
int lives = 3;
|
||||
int pastLives = 3;
|
||||
|
||||
private:
|
||||
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LevelSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool LifeLost(const dd::Events::LifeLost &event);
|
||||
|
||||
bool m_Initialized = false;
|
||||
|
||||
@@ -71,6 +81,8 @@ private:
|
||||
int tLines = 8;
|
||||
glm::vec2 tSpaceBetweenBricks = glm::vec2(2, 0.5);
|
||||
int tSpaceToEdge = 0;
|
||||
|
||||
EntityID entityToRemove = NULL;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -7,20 +7,23 @@
|
||||
|
||||
#include "Core/InputController.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/Component.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EKeyUp.h"
|
||||
#include "Input/EBindKey.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Physics/CBoxShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Core/Component.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace dd
|
||||
@@ -38,19 +41,26 @@ public:
|
||||
|
||||
void Initialize() override;
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
private:
|
||||
dd::EventRelay<PadSystem, dd::Events::KeyDown> m_EKeyDown;
|
||||
dd::EventRelay<PadSystem, dd::Events::KeyUp> m_EKeyUp;
|
||||
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<PadSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||
|
||||
bool OnKeyDown(const dd::Events::KeyDown &event);
|
||||
bool OnKeyUp(const dd::Events::KeyUp &event);
|
||||
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool LifeLost(const dd::Events::LifeLost &event);
|
||||
|
||||
EntityID removeThisObject = NULL;
|
||||
|
||||
float slowdownModifier = 5.f;
|
||||
float accelerationSpeed = 80.f;
|
||||
float maxSpeed = 40.f;
|
||||
|
||||
|
||||
|
||||
@@ -60,7 +70,7 @@ private:
|
||||
EntityID ent = 0;
|
||||
Components::Transform* transform;
|
||||
glm::vec3 acceleration = glm::vec3(0.f, 0.f, 0.f);
|
||||
bool left = false, right = false;
|
||||
bool left = false, right = false, replaceBall = false;
|
||||
};
|
||||
|
||||
class PadSystem::PadSteeringInputController : InputController<PadSystem>
|
||||
|
||||
@@ -80,6 +80,7 @@ private:
|
||||
e.Entity1 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()];
|
||||
e.Entity2 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
|
||||
|
||||
|
||||
m_PhysicsSystem->EventBroker->Publish(e);
|
||||
}
|
||||
void EndContact(b2Contact* contact)
|
||||
|
||||
Reference in New Issue
Block a user