Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn
Conflicts: Escape-the-Dawn/Systems/LevelGenerationSystem.cpp Escape-the-Dawn/Systems/PlayerSystem.cpp
This commit is contained in:
@@ -5,14 +5,14 @@ Systems::LevelGenerationSystem::LevelGenerationSystem( World* world )
|
||||
{
|
||||
elapsedtime = 0;
|
||||
|
||||
|
||||
velocity = 0;
|
||||
startx = 0;
|
||||
startyz = glm::vec2(0, -1000);
|
||||
}
|
||||
|
||||
void Systems::LevelGenerationSystem::SpawnObstacle()
|
||||
{
|
||||
typeRandom = 0 + (rand() % 3);
|
||||
typeRandom = 0 + (rand() % 10);
|
||||
|
||||
EntityID ent;
|
||||
|
||||
@@ -23,45 +23,64 @@ void Systems::LevelGenerationSystem::SpawnObstacle()
|
||||
bounds = m_World->AddComponent<Components::Bounds>(ent, "Bounds");
|
||||
collision = m_World->AddComponent<Components::Collision>(ent, "Collision");
|
||||
model = m_World->AddComponent<Components::Model>(ent, "Model");
|
||||
auto sound = m_World->AddComponent<Components::SoundEmitter>(ent, "SoundEmitter");
|
||||
|
||||
|
||||
positionRandom = -500 + startx + (rand() % 1000);
|
||||
transform->Position = glm::vec3(positionRandom, startyz);
|
||||
//transform->Velocity = glm::vec3(0.f, 10.f, 100.f);
|
||||
|
||||
switch (typeRandom)
|
||||
{
|
||||
case 0: // Mountain stuff :D
|
||||
sound->Loop = true;
|
||||
sound->Gain = 1.f;
|
||||
sound->ReferenceDistance = 15.f;
|
||||
m_World->GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(sound, "Sounds/hum.wav");
|
||||
|
||||
if(typeRandom >= 0 && typeRandom < 2) // Mountain stuff :D
|
||||
{
|
||||
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||
float scale = (float)(rand() % 1000) / 250;
|
||||
transform->Scale = glm::vec3(scale);
|
||||
bounds->VolumeVector = glm::vec3(9, 12, 7);
|
||||
bounds->Origin = glm::vec3(1,11,-1);
|
||||
model->ModelFile = "Models/obstacle_mountain_1.obj";
|
||||
}
|
||||
break;
|
||||
case 1: // Single Mountain :D
|
||||
else if(typeRandom >= 2 && typeRandom < 5) // Single Mountain :D
|
||||
{
|
||||
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||
float scale = (float)(rand() % 1000) / 200;
|
||||
transform->Scale = glm::vec3(scale);
|
||||
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:
|
||||
else if(typeRandom >= 5 && typeRandom < 8)
|
||||
{
|
||||
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||
float scale = (float)(rand() % 1000) / 100;
|
||||
transform->Scale = glm::vec3(scale);
|
||||
bounds->VolumeVector = glm::vec3(1, 1, 1);
|
||||
bounds->Origin = glm::vec3(0,1,0);
|
||||
model->ModelFile = "Models/obstacle_cube_1.obj";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(typeRandom >= 8 && typeRandom < 10)
|
||||
{
|
||||
float scale = (float)(rand() % 1000) / 100;
|
||||
bounds->VolumeVector = glm::vec3(4, 4, 4);
|
||||
bounds->Origin = glm::vec3(0,4,0);
|
||||
pointLight = m_World->AddComponent<Components::PointLight>(ent, "PointLight");
|
||||
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
|
||||
pointLight->Diffuse = glm::vec3(0.3, 1.0, 0.3);
|
||||
pointLight->constantAttenuation = 0.f;
|
||||
pointLight->linearAttenuation = 1.f;
|
||||
pointLight->quadraticAttenuation = 0.f;
|
||||
pointLight->spotExponent = 0.0f;
|
||||
|
||||
break;
|
||||
}
|
||||
powerUp = m_World->AddComponent<Components::PowerUp>(ent, "PowerUp");
|
||||
powerUp->Speed = 10.f;
|
||||
|
||||
model->ModelFile = "Models/powerup.obj";
|
||||
}
|
||||
|
||||
|
||||
// Put it below ground level
|
||||
transform->Position.y -= bounds->VolumeVector.y * 2.f;
|
||||
|
||||
}
|
||||
|
||||
@@ -75,14 +94,22 @@ void Systems::LevelGenerationSystem::Update( double dt )
|
||||
elapsedtime = 0;
|
||||
}
|
||||
|
||||
std::vector<EntityID> removethis;
|
||||
std::list<EntityID> removethis;
|
||||
|
||||
for(auto ent : obstacles)
|
||||
{
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(ent, "Transform");
|
||||
transformComponent->Position.z += 100.f * dt;
|
||||
auto transform = m_World->GetComponent<Components::Transform>(ent, "Transform");
|
||||
|
||||
if(transformComponent->Position.z > 100)
|
||||
transform->Velocity.z = -velocity;
|
||||
transform->Position += transform->Velocity * (float)dt;
|
||||
|
||||
// Stop raising obstacles when they reach ground level
|
||||
if (transform->Velocity.y > 0 && transform->Position.y >= 0) {
|
||||
transform->Position.y = 0;
|
||||
transform->Velocity.y = 0;
|
||||
}
|
||||
|
||||
if(transform->Position.z > 800)
|
||||
{
|
||||
removethis.push_back(ent);
|
||||
}
|
||||
@@ -104,6 +131,7 @@ void Systems::LevelGenerationSystem::UpdateEntity( double dt, EntityID entity, E
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
|
||||
startyz = glm::vec2(0, transformComponent->Position.z - 1000);
|
||||
startx = transformComponent->Position.x;
|
||||
velocity = transformComponent->Velocity.z;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user