Skip to content
Snippets Groups Projects
Commit d6f9c729 authored by JonShard's avatar JonShard
Browse files

Added plane speed and season counter to gui.

parent 43b7102d
Branches
No related tags found
No related merge requests found
......@@ -32,9 +32,6 @@ private:
static bool m_dayMoving;
static bool m_seasonMoving;
static bool m_marker;
static float m_season;
static float m_maxSeason;
public:
static float m_fovy; // The camera's field of view on Y axis. Used for zoom.
......@@ -48,6 +45,8 @@ public:
// Member hacked in for the exam. Move to a appropirate classes or containers
// for a good impolementation of the exam task:
static float m_season;
static float m_maxSeason;
static float m_planeSpeed;
static float m_planeMinSpeed;
static float m_planeMaxSpeed;
......
......@@ -115,7 +115,16 @@ int main(int argc, char** args)
"\n###################################################################"
"\nFrame rate: %d\nLast frame dt: %f\nTotal runtime: %f\n\n", oldFrameRate, dt, t);
float seasonSpeed = 10; // Basicly days per second.
Input::m_season += seasonSpeed * dt;
if (Input::m_season > Input::m_maxSeason)
{
Input::m_season = 0;
}
ImGui::Text("Season: %f", Input::m_season);
// Plane controls:
Entity* plane = Scene::getEntityByTag("planeCore");
if (plane == nullptr)
{
......@@ -124,11 +133,10 @@ int main(int argc, char** args)
glm::vec3 pos = plane-> getPosition();
glm::vec3 rot = glm::radians(plane-> getRotation());
if (Input::m_navKeyPressed[W])
{
rot += glm::vec3(0.01, 0, 0);
}
rot += glm::vec3(0.01, 0, 0); // Not need to multiply with dt on transformation
} // operations, since it is done by Scene in Scene::update().
if (Input::m_navKeyPressed[S])
{
rot -= glm::vec3(0.01, 0, 0);
......@@ -143,20 +151,20 @@ int main(int argc, char** args)
}
if (Input::m_navKeyPressed[period] && Input::m_planeSpeed < Input::m_planeMaxSpeed)
{
Input::m_planeSpeed += 0.03 * dt;
Input::m_planeSpeed += 0.03 * dt; // This is not done in scene, so here we muliply with dt.
}
if (Input::m_navKeyPressed[comma] && Input::m_planeSpeed > Input::m_planeMinSpeed)
{
Input::m_planeSpeed -= 0.03 * dt;
}
pos += glm::vec3(Input::m_planeSpeed) * glm::vec3(glm::sin(rot.y),
glm::sin(-rot.x),
glm::cos(rot.y)*glm::cos(rot.x));
ImGui::Text("Plane speed: %f", Input::m_planeSpeed);
plane-> setPosition(pos);
plane-> setRotation(glm::degrees(rot));
Renderer::clear();
Scene::update(dt);
......@@ -164,7 +172,6 @@ int main(int argc, char** args)
// Draws all the models in the scene.
Scene::draw(t);
ImGui::Text("Hello %d", 113);
//This can be done to debug positions
//glm::mat4 camPosDebugM2W = glm::translate(glm::mat4(1), glm::vec3(cameraTransform.position));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment