freecamfixed
This commit is contained in:
@@ -27,47 +27,58 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
||||
return;
|
||||
|
||||
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
||||
if (name == "Camera" && freecamEnabled) {
|
||||
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);
|
||||
|
||||
float speed = m_PlayerSpeed;
|
||||
if(input->KeyState[GLFW_KEY_LEFT_SHIFT]) {
|
||||
speed *= 4.0f;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_LEFT_ALT]) {
|
||||
speed /= 4.0f;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_A]) {
|
||||
transform->Position -= Camera_Right * (float)dt * speed;
|
||||
}
|
||||
else if(input->KeyState[GLFW_KEY_D]) {
|
||||
transform->Position += Camera_Right * (float)dt * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_W]) {
|
||||
transform->Position -= Camera_Forward * (float)dt * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_S]) {
|
||||
transform->Position += Camera_Forward * (float)dt * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_SPACE]) {
|
||||
transform->Position += glm::vec3(0, 1, 0) * (float)dt * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_LEFT_CONTROL]) {
|
||||
transform->Position -= glm::vec3(0, 1, 0) * (float)dt * speed;
|
||||
}
|
||||
|
||||
if (input->MouseState[GLFW_MOUSE_BUTTON_LEFT]) {
|
||||
// TOUCHING THIS CODE MIGHT COUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
|
||||
//---------------------------------------------------------------------
|
||||
transform->Orientation = glm::angleAxis<float>(input->dY/300.f,glm::vec3(1,0,0)) * transform->Orientation;
|
||||
|
||||
transform->Orientation = transform->Orientation * glm::angleAxis<float>(input->dX/300.f,glm::vec3(0,1,0));
|
||||
//---------------------------------------------------------------------
|
||||
// TOUCHING THIS CODE MIGHT COUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
|
||||
if (name == "Camera") {
|
||||
if(input->KeyState[GLFW_KEY_F4] && !input->LastKeyState[GLFW_KEY_F4]) {
|
||||
if(freecamEnabled)
|
||||
freecamEnabled = false;
|
||||
else
|
||||
freecamEnabled = true;
|
||||
}
|
||||
if(freecamEnabled)
|
||||
{
|
||||
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);
|
||||
|
||||
float speed = m_PlayerSpeed;
|
||||
if(input->KeyState[GLFW_KEY_LEFT_SHIFT]) {
|
||||
speed *= 4.0f;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_LEFT_ALT]) {
|
||||
speed /= 4.0f;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_A]) {
|
||||
transform->Position -= Camera_Right * (float)dt * speed;
|
||||
}
|
||||
else if(input->KeyState[GLFW_KEY_D]) {
|
||||
transform->Position += Camera_Right * (float)dt * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_W]) {
|
||||
transform->Position -= Camera_Forward * (float)dt * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_S]) {
|
||||
transform->Position += Camera_Forward * (float)dt * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_SPACE]) {
|
||||
transform->Position += glm::vec3(0, 1, 0) * (float)dt * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_LEFT_CONTROL]) {
|
||||
transform->Position -= glm::vec3(0, 1, 0) * (float)dt * speed;
|
||||
}
|
||||
|
||||
if (input->MouseState[GLFW_MOUSE_BUTTON_LEFT]) {
|
||||
// TOUCHING THIS CODE MIGHT COUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
|
||||
//---------------------------------------------------------------------
|
||||
transform->Orientation = glm::angleAxis<float>(input->dY/300.f,glm::vec3(1,0,0)) * transform->Orientation;
|
||||
|
||||
transform->Orientation = transform->Orientation * glm::angleAxis<float>(input->dX/300.f,glm::vec3(0,1,0));
|
||||
//---------------------------------------------------------------------
|
||||
// TOUCHING THIS CODE MIGHT COUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (name == "Player")
|
||||
{
|
||||
auto bounds = m_World->GetComponent<Components::Bounds>(entity, "Bounds");
|
||||
@@ -130,12 +141,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
||||
}
|
||||
|
||||
|
||||
if(input->KeyState[GLFW_KEY_F4] && !input->LastKeyState[GLFW_KEY_F4]) {
|
||||
if(freecamEnabled)
|
||||
freecamEnabled = false;
|
||||
else
|
||||
freecamEnabled = true;
|
||||
}
|
||||
|
||||
|
||||
//powerup
|
||||
auto collisionComponent = m_World->GetComponent<Components::Collision>(entity, "Collision");
|
||||
|
||||
Reference in New Issue
Block a user