Powerup timer fixed
This commit is contained in:
@@ -99,19 +99,21 @@ void Systems::LevelGenerationSystem::Update( double dt )
|
|||||||
auto transform = m_World->GetComponent<Components::Transform>(ent, "Transform");
|
auto transform = m_World->GetComponent<Components::Transform>(ent, "Transform");
|
||||||
if(transform != nullptr)
|
if(transform != nullptr)
|
||||||
{
|
{
|
||||||
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->Velocity.z = velocity;
|
||||||
transform->Position.y = 0;
|
transform->Position += transform->Velocity * (float)dt;
|
||||||
transform->Velocity.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(transform->Position.z > 800)
|
// Stop raising obstacles when they reach ground level
|
||||||
{
|
if (transform->Velocity.y > 0 && transform->Position.y >= 0) {
|
||||||
removethis.push_back(ent);
|
transform->Position.y = 0;
|
||||||
}
|
transform->Velocity.y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(transform->Position.z > 800)
|
||||||
|
{
|
||||||
|
removethis.push_back(ent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ Systems::PlayerSystem::PlayerSystem( World* world ) : System(world)
|
|||||||
m_CameraOffset = glm::vec3(0.f, 5.f, 14.f);
|
m_CameraOffset = glm::vec3(0.f, 5.f, 14.f);
|
||||||
m_CameraOrientation = glm::angleAxis<float>(glm::radians(15.0f),glm::vec3(1,0,0));
|
m_CameraOrientation = glm::angleAxis<float>(glm::radians(15.0f),glm::vec3(1,0,0));
|
||||||
|
|
||||||
freecamEnabled = false;
|
m_freecamEnabled = false;
|
||||||
|
m_poweruptimeleft = 0;
|
||||||
|
m_basespeed = 100.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::PlayerSystem::Update(double dt)
|
void Systems::PlayerSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
|
m_poweruptimeleft -= (float)dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
@@ -29,12 +31,12 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
||||||
if (name == "Camera") {
|
if (name == "Camera") {
|
||||||
if(input->KeyState[GLFW_KEY_F4] && !input->LastKeyState[GLFW_KEY_F4]) {
|
if(input->KeyState[GLFW_KEY_F4] && !input->LastKeyState[GLFW_KEY_F4]) {
|
||||||
if(freecamEnabled)
|
if(m_freecamEnabled)
|
||||||
freecamEnabled = false;
|
m_freecamEnabled = false;
|
||||||
else
|
else
|
||||||
freecamEnabled = true;
|
m_freecamEnabled = true;
|
||||||
}
|
}
|
||||||
if(freecamEnabled)
|
if(m_freecamEnabled)
|
||||||
{
|
{
|
||||||
glm::vec3 Camera_Right = glm::vec3(glm::vec4(1, 0, 0, 0) * transform->Orientation);
|
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);
|
glm::vec3 Camera_Forward = glm::vec3(glm::vec4(0, 0, 1, 0) * transform->Orientation);
|
||||||
@@ -154,15 +156,19 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
if(powerupComp != nullptr)
|
if(powerupComp != nullptr)
|
||||||
{
|
{
|
||||||
transform->Velocity.z = powerupComp->Speed;
|
transform->Velocity.z = powerupComp->Speed;
|
||||||
|
m_poweruptimeleft = 3.f;
|
||||||
m_World->RemoveEntity(ent);
|
m_World->RemoveEntity(ent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(m_poweruptimeleft <= 0)
|
||||||
|
{
|
||||||
|
transform->Velocity.z = m_basespeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update camera
|
// Update camera
|
||||||
if(! freecamEnabled)
|
if(! m_freecamEnabled)
|
||||||
{
|
{
|
||||||
auto cameraEntity = m_World->GetProperty<EntityID>(entity, "Camera");
|
auto cameraEntity = m_World->GetProperty<EntityID>(entity, "Camera");
|
||||||
auto cameraTransform = m_World->GetComponent<Components::Transform>(cameraEntity, "Transform");
|
auto cameraTransform = m_World->GetComponent<Components::Transform>(cameraEntity, "Transform");
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ namespace Systems
|
|||||||
glm::vec3 m_CameraOffset;
|
glm::vec3 m_CameraOffset;
|
||||||
glm::quat m_CameraOrientation;
|
glm::quat m_CameraOrientation;
|
||||||
|
|
||||||
bool freecamEnabled;
|
bool m_freecamEnabled;
|
||||||
|
float m_basespeed;
|
||||||
|
float m_poweruptimeleft;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user