Obstacles följer spelaren :)

This commit is contained in:
ViktorLjung
2014-03-13 03:29:16 +01:00
parent 40725bd2d4
commit 1cff0571d3
3 changed files with 19 additions and 8 deletions
@@ -4,17 +4,16 @@ Systems::LevelGenerationSystem::LevelGenerationSystem( World* world )
: System(world)
{
elapsedtime = 0;
startx = 0;
startyz = glm::vec2(0, -1000);
}
void Systems::LevelGenerationSystem::SpawnObstacle()
{
typeRandom = 0 + (rand() % 3);
EntityID ent;
ent = m_World->CreateEntity();
@@ -25,7 +24,7 @@ void Systems::LevelGenerationSystem::SpawnObstacle()
collision = m_World->AddComponent<Components::Collision>(ent, "Collision");
model = m_World->AddComponent<Components::Model>(ent, "Model");
positionRandom = -500 + (rand() % 1000);
positionRandom = -500 + startx + (rand() % 1000);
switch (typeRandom)
{
@@ -103,4 +102,14 @@ void Systems::LevelGenerationSystem::Update( double dt )
}
void Systems::LevelGenerationSystem::UpdateEntity( double dt, EntityID entity, EntityID parent )
{
if( m_World->GetProperty<std::string>(entity, "Name") == "PlayerShip")
{
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
startyz = glm::vec2(0, transformComponent->Position.z - 1000);
startx = transformComponent->Position.x;
}
}
@@ -7,7 +7,6 @@
#include "Components/Bounds.h"
#include "Components/Collision.h"
#include "Components/Model.h"
#include "Components/PointLight.h"
namespace Systems
{
@@ -20,11 +19,14 @@ namespace Systems
void SpawnObstacle();
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
private:
int typeRandom;
int positionRandom;
glm::vec2 startyz;
float startx;
double elapsedtime;
std::list<EntityID> obstacles;
+1 -1
View File
@@ -18,7 +18,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
if (input == nullptr)
return;
float speed = 20.0f;
float speed = 200.0f;
auto name = m_World->GetProperty<std::string>(entity, "Name");
if (name == "Camera") {