Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn
Conflicts: Escape-the-Dawn/GameWorld.cpp Escape-the-Dawn/plane.obj
This commit is contained in:
@@ -4,7 +4,7 @@ Systems::LevelGenerationSystem::LevelGenerationSystem( World* world )
|
||||
: System(world)
|
||||
{
|
||||
elapsedtime = 0;
|
||||
startyz = glm::vec2(0, -200);
|
||||
startyz = glm::vec2(0, -1000);
|
||||
}
|
||||
|
||||
void Systems::LevelGenerationSystem::SpawnObstacle()
|
||||
@@ -12,7 +12,7 @@ void Systems::LevelGenerationSystem::SpawnObstacle()
|
||||
|
||||
|
||||
|
||||
typeRandom = 0 + (rand() % 5);
|
||||
typeRandom = 0 + (rand() % 3);
|
||||
|
||||
|
||||
EntityID ent;
|
||||
@@ -25,45 +25,28 @@ void Systems::LevelGenerationSystem::SpawnObstacle()
|
||||
collision = m_World->AddComponent<Components::Collision>(ent, "Collision");
|
||||
model = m_World->AddComponent<Components::Model>(ent, "Model");
|
||||
|
||||
positionRandom = -500 + (rand() % 1000);
|
||||
|
||||
switch (typeRandom)
|
||||
{
|
||||
case 0:
|
||||
|
||||
positionRandom = -500 + (rand() % 1000);
|
||||
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||
bounds->VolumeVector = glm::vec3(4, 4, 4);
|
||||
bounds->VolumeVector = glm::vec3(9, 12, 7);
|
||||
bounds->Origin = glm::vec3(1,11,-1);
|
||||
model->ModelFile = "Models/obstacle_mountain_1.obj";
|
||||
|
||||
break;
|
||||
case 1:
|
||||
|
||||
positionRandom = -100 + (rand() % 200);
|
||||
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||
bounds->VolumeVector = glm::vec3(4, 4, 4);
|
||||
bounds->VolumeVector = glm::vec3(3.5f, 7.5f, 3.5f);
|
||||
bounds->Origin = glm::vec3(0,7.5f,0);
|
||||
model->ModelFile = "Models/obstacle_mountain_2.obj";
|
||||
|
||||
break;
|
||||
case 2:
|
||||
|
||||
positionRandom = -100 + (rand() % 200);
|
||||
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||
bounds->VolumeVector = glm::vec3(4, 4, 4);
|
||||
model->ModelFile = "Models/obstacle_mountain_3.obj";
|
||||
|
||||
break;
|
||||
case 3:
|
||||
|
||||
positionRandom = -100 + (rand() % 200);
|
||||
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||
bounds->VolumeVector = glm::vec3(4, 4, 4);
|
||||
model->ModelFile = "Models/obstacle_mountain_4.obj";
|
||||
|
||||
break;
|
||||
case 4:
|
||||
|
||||
positionRandom = -100 + (rand() % 200);
|
||||
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||
bounds->VolumeVector = glm::vec3(4, 4, 4);
|
||||
bounds->VolumeVector = glm::vec3(1, 1, 1);
|
||||
bounds->Origin = glm::vec3(0,1,0);
|
||||
model->ModelFile = "Models/obstacle_cube_1.obj";
|
||||
|
||||
break;
|
||||
@@ -78,16 +61,32 @@ void Systems::LevelGenerationSystem::Update( double dt )
|
||||
|
||||
elapsedtime += dt;
|
||||
|
||||
if(elapsedtime > 1.0){
|
||||
if(elapsedtime > 0.1){
|
||||
SpawnObstacle();
|
||||
elapsedtime = 0;
|
||||
}
|
||||
|
||||
std::vector<EntityID> removethis;
|
||||
|
||||
for(auto ent : obstacles)
|
||||
{
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(ent, "Transform");
|
||||
transformComponent->Position.z += 15.f * dt;
|
||||
transformComponent->Position.z += 100.f * dt;
|
||||
|
||||
if(transformComponent->Position.z > 100)
|
||||
{
|
||||
removethis.push_back(ent);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for(auto ent : removethis)
|
||||
{
|
||||
m_World->RemoveEntity(ent);
|
||||
obstacles.remove(ent);
|
||||
}
|
||||
removethis.clear();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "Components/Model.h"
|
||||
|
||||
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
class LevelGenerationSystem : public System
|
||||
@@ -28,7 +27,8 @@ namespace Systems
|
||||
glm::vec2 startyz;
|
||||
double elapsedtime;
|
||||
|
||||
std::vector<EntityID> obstacles;
|
||||
std::list<EntityID> obstacles;
|
||||
|
||||
|
||||
std::shared_ptr<Components::Transform> transform;
|
||||
std::shared_ptr<Components::Bounds> bounds;
|
||||
|
||||
@@ -23,7 +23,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
||||
glm::vec3 Camera_Right = glm::vec3(glm::vec4(1, 0, 0, 0) * transform->Orientation);
|
||||
glm::vec3 Camera_Forward = glm::vec3(glm::vec4(0, 0, 1, 0) * transform->Orientation);
|
||||
|
||||
float speed = 8.0f;
|
||||
float speed = 15.0f;
|
||||
if(input->KeyState[GLFW_KEY_LEFT_SHIFT]) {
|
||||
speed *= 2.0f;
|
||||
}
|
||||
|
||||
@@ -27,10 +27,19 @@ void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID p
|
||||
auto model = m_CachedModels[modelComponent->ModelFile];
|
||||
m_Renderer->AddModelToDraw(model, transformComponent->Position, transformComponent->Orientation);
|
||||
}
|
||||
|
||||
// Debug draw bounds
|
||||
#ifdef DEBUG
|
||||
auto bounds = m_World->GetComponent<Components::Bounds>(entity, "Bounds");
|
||||
if (bounds != nullptr) {
|
||||
glm::vec3 origin = transformComponent->Position + bounds->Origin;
|
||||
m_Renderer->AddAABBToDraw(origin, bounds->VolumeVector);
|
||||
}
|
||||
#endif
|
||||
|
||||
auto pointLightComponent = m_World->GetComponent<Components::PointLight>(entity, "PointLight");
|
||||
if (pointLightComponent != nullptr)
|
||||
{
|
||||
|
||||
m_Renderer->AddPointLightToDraw(
|
||||
transformComponent->Position,
|
||||
pointLightComponent->Specular,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "Components/Model.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/Camera.h"
|
||||
#include "Components/Bounds.h"
|
||||
#include "Renderer.h"
|
||||
|
||||
namespace Systems
|
||||
|
||||
Reference in New Issue
Block a user