Merge remote-tracking branch 'origin/master' into Sound
This commit is contained in:
+36
-18
@@ -87,6 +87,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>();
|
||||
@@ -103,22 +104,13 @@ public:
|
||||
|
||||
|
||||
//TODO: Remove tobias light-test code.
|
||||
{
|
||||
auto t_BrickWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_BrickWall);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(t_BrickWall);
|
||||
//TODO: Rename SpriteFile to DiffuseTexture or similar.
|
||||
sprite->SpriteFile = "Textures/Test/Brick_Diffuse.png";
|
||||
sprite->NormalTexture = "Textures/Test/Brick_Normal.png";
|
||||
sprite->SpecularTexture = "Textures/Test/Brick_Specular.png";
|
||||
}
|
||||
|
||||
/*{
|
||||
}*/
|
||||
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
transform->Position = glm::vec3(0.5f, 0.f, -10.f);
|
||||
transform->Position = glm::vec3(0.5f, 0.f, -9.9f);
|
||||
transform->Scale = glm::vec3(1.f, 1.f, 1.f);
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
|
||||
@@ -142,11 +134,33 @@ public:
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
{
|
||||
auto t_BrickWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_BrickWall);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(t_BrickWall);
|
||||
//TODO: Rename SpriteFile to DiffuseTexture or similar.
|
||||
sprite->SpriteFile = "Textures/Ball.png";
|
||||
sprite->NormalTexture = "Textures/Test/Brick_Normal.png";
|
||||
sprite->SpecularTexture = "Textures/Test/Brick_Specular.png";
|
||||
}
|
||||
|
||||
{
|
||||
auto t_BrickWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_BrickWall);
|
||||
transform->Position = glm::vec3(0.4f, 0.f, -9.5f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(t_BrickWall);
|
||||
//TODO: Rename SpriteFile to DiffuseTexture or similar.
|
||||
sprite->SpriteFile = "Textures/Ball.png";
|
||||
sprite->NormalTexture = "Textures/Test/Brick_Normal.png";
|
||||
sprite->SpecularTexture = "Textures/Test/Brick_Specular.png";
|
||||
}
|
||||
|
||||
{
|
||||
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";
|
||||
@@ -196,7 +210,7 @@ public:
|
||||
auto ent = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
transform->Position = glm::vec3(0.f, -3.f, -10.f);
|
||||
transform->Scale = glm::vec3(2.f, 0.5f, 1.f);
|
||||
transform->Scale = glm::vec3(8.f, 0.5f, 1.f);
|
||||
transform->Orientation = glm::rotate(transform->Orientation, glm::radians(25.f), glm::vec3(0, 0, -1));
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
|
||||
@@ -348,7 +362,7 @@ public:
|
||||
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
|
||||
* glm::toMat4(orientation2D)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueSprite(texturediff, texturenorm, texturespec, modelMatrix, spriteComponent->Color);
|
||||
EnqueueSprite(texturediff, texturenorm, texturespec, modelMatrix, spriteComponent->Color, absoluteTransform.Position.z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,13 +385,15 @@ public:
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
//TODO: This Depth is probably wrong.
|
||||
job.Depth = (glm::vec4(1,1,1,0) * modelMatrix).z;
|
||||
|
||||
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)
|
||||
void EnqueueSprite(Texture* texture, Texture* normalTexture, Texture* specularTexture, glm::mat4 modelMatrix, glm::vec4 color, float depth)
|
||||
{
|
||||
SpriteJob job;
|
||||
job.TextureID = texture->ResourceID;
|
||||
@@ -386,8 +402,10 @@ public:
|
||||
job.SpecularTexture = *specularTexture;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
job.Depth = depth;
|
||||
|
||||
m_RendererQueue.Deferred.Add(job);
|
||||
|
||||
m_RendererQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
void EnqueuePointLight(glm::vec3 position, glm::vec3 diffuseColor, glm::vec3 specularColor, float radius)
|
||||
|
||||
@@ -93,6 +93,8 @@ private:
|
||||
void CreateBuffers();
|
||||
GLuint CreateQuad();
|
||||
|
||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||
|
||||
void DrawDeferred(RenderQueue &objects, RenderQueue &lights);
|
||||
void DrawForward(RenderQueue &objects, RenderQueue &lights);
|
||||
void DrawScene(RenderQueue &objects, ShaderProgram &program);
|
||||
|
||||
@@ -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
|
||||
@@ -9,13 +9,17 @@
|
||||
#include "Core/CTransform.h"
|
||||
#include "Rendering/CSprite.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>
|
||||
@@ -47,6 +51,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);
|
||||
@@ -56,12 +61,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;
|
||||
|
||||
@@ -70,6 +80,8 @@ private:
|
||||
int tLines = 8;
|
||||
glm::vec2 tSpaceBetweenBricks = glm::vec2(2, 0.5);
|
||||
int tSpaceToEdge = 0;
|
||||
|
||||
EntityID entityToRemove = NULL;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -7,19 +7,22 @@
|
||||
|
||||
#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 "Game/CBall.h"
|
||||
#include "Core/Component.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace dd
|
||||
@@ -37,19 +40,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;
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +69,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>
|
||||
|
||||
@@ -55,6 +55,8 @@ private:
|
||||
b2Vec2 m_Gravity;
|
||||
b2World* m_PhysicsWorld;
|
||||
float m_TimeStep;
|
||||
float m_Accumulator;
|
||||
|
||||
int m_VelocityIterations, m_PositionIterations;
|
||||
|
||||
std::unordered_map<EntityID, b2Body*> m_EntitiesToBodies;
|
||||
@@ -78,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