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,16 +4,15 @@ 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;
@@ -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;
}
}