Obstacles följer spelaren :)
This commit is contained in:
@@ -4,16 +4,15 @@ Systems::LevelGenerationSystem::LevelGenerationSystem( World* world )
|
|||||||
: System(world)
|
: System(world)
|
||||||
{
|
{
|
||||||
elapsedtime = 0;
|
elapsedtime = 0;
|
||||||
|
|
||||||
|
|
||||||
|
startx = 0;
|
||||||
startyz = glm::vec2(0, -1000);
|
startyz = glm::vec2(0, -1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::LevelGenerationSystem::SpawnObstacle()
|
void Systems::LevelGenerationSystem::SpawnObstacle()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typeRandom = 0 + (rand() % 3);
|
typeRandom = 0 + (rand() % 3);
|
||||||
|
|
||||||
|
|
||||||
EntityID ent;
|
EntityID ent;
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ void Systems::LevelGenerationSystem::SpawnObstacle()
|
|||||||
collision = m_World->AddComponent<Components::Collision>(ent, "Collision");
|
collision = m_World->AddComponent<Components::Collision>(ent, "Collision");
|
||||||
model = m_World->AddComponent<Components::Model>(ent, "Model");
|
model = m_World->AddComponent<Components::Model>(ent, "Model");
|
||||||
|
|
||||||
positionRandom = -500 + (rand() % 1000);
|
positionRandom = -500 + startx + (rand() % 1000);
|
||||||
|
|
||||||
switch (typeRandom)
|
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/Bounds.h"
|
||||||
#include "Components/Collision.h"
|
#include "Components/Collision.h"
|
||||||
#include "Components/Model.h"
|
#include "Components/Model.h"
|
||||||
#include "Components/PointLight.h"
|
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
{
|
{
|
||||||
@@ -20,11 +19,14 @@ namespace Systems
|
|||||||
void SpawnObstacle();
|
void SpawnObstacle();
|
||||||
|
|
||||||
void Update(double dt) override;
|
void Update(double dt) override;
|
||||||
|
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int typeRandom;
|
int typeRandom;
|
||||||
int positionRandom;
|
int positionRandom;
|
||||||
glm::vec2 startyz;
|
glm::vec2 startyz;
|
||||||
|
float startx;
|
||||||
|
|
||||||
double elapsedtime;
|
double elapsedtime;
|
||||||
|
|
||||||
std::list<EntityID> obstacles;
|
std::list<EntityID> obstacles;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
if (input == nullptr)
|
if (input == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float speed = 20.0f;
|
float speed = 200.0f;
|
||||||
|
|
||||||
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
||||||
if (name == "Camera") {
|
if (name == "Camera") {
|
||||||
|
|||||||
Reference in New Issue
Block a user