diff --git a/src/main.cpp b/src/main.cpp index 1ea8768..cf20294 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,6 +55,11 @@ int main(void) glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (key == GLFW_KEY_ESCAPE) + { + glfwSetWindowShouldClose(window, true); + } + current_scene->onKey(window, key, scancode, action, mods); }); diff --git a/src/toolbox/Timer.h b/src/toolbox/Timer.h new file mode 100644 index 0000000..80fd164 --- /dev/null +++ b/src/toolbox/Timer.h @@ -0,0 +1,46 @@ +#pragma once + +namespace toolbox +{ + /* + * This class represents a timer which needs to be updated + * every frame to work correctly. + */ + class Timer + { + private: + float current_time; + float final_time; + bool has_finished; + + public: + /* + * @brief: Constructor to make the timer + * + * @param final_time: The time which the timer needs to count to + */ + Timer(float final_time): current_time(0), final_time(final_time), has_finished(false) {} + + /* + * @brief: Updates the timer. Call this method once every iteration in the game loop + * + * @param delta: The deltatime of the game + */ + void UpdateTimer(const double delta) + { + current_time += delta; + + if (current_time >= final_time) + { + has_finished = true; + } + } + + /* + * @brief: Returns if the timer has finished + * + * @return: True if the timer has finished + */ + bool HasFinished() const { return has_finished; } + }; +} \ No newline at end of file diff --git a/wk2_fps.vcxproj b/wk2_fps.vcxproj index 527b982..555ce4b 100644 --- a/wk2_fps.vcxproj +++ b/wk2_fps.vcxproj @@ -64,6 +64,7 @@ + @@ -128,16 +129,16 @@ true - C:\opencv\build\include;$(IncludePath);C:\opencv\opencv\build\include - C:\opencv\build\x64\vc15\lib;$(LibraryPath);C:\opencv\opencv\build\x64\vc15\lib + C:\opencv\build\include;$(IncludePath);C:\opencv\opencv\build\include;C:\opencv\build\include + C:\opencv\build\x64\vc15\lib;$(LibraryPath);C:\opencv\opencv\build\x64\vc15\lib;C:\opencv\build\x64\vc15\lib false false - $(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\opencv\opencv\build\include - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\opencv\opencv\build\x64\vc15\lib + $(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\opencv\opencv\build\include;C:\opencv\build\include + $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\opencv\opencv\build\x64\vc15\lib;C:\opencv\build\x64\vc15\lib @@ -169,7 +170,7 @@ Console true $(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories) - opencv_world452d.lib;%(AdditionalDependencies); opencv_world452.lib + opencv_world452d.lib;%(AdditionalDependencies); opencv_world452.lib;opencv_world452d.lib @@ -210,7 +211,7 @@ true true $(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies); opencv_world452.lib + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies); opencv_world452.lib;opencv_world452d.lib diff --git a/wk2_fps.vcxproj.filters b/wk2_fps.vcxproj.filters index 4092abd..3dc1142 100644 --- a/wk2_fps.vcxproj.filters +++ b/wk2_fps.vcxproj.filters @@ -152,6 +152,9 @@ Header Files + + Header Files +