Merge branch 'feature/timer' into develop
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
46
src/toolbox/Timer.h
Normal file
46
src/toolbox/Timer.h
Normal file
@@ -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; }
|
||||
};
|
||||
}
|
||||
@@ -64,6 +64,7 @@
|
||||
<ClInclude Include="src\shaders\shader_program.h" />
|
||||
<ClInclude Include="src\shaders\entity_shader.h" />
|
||||
<ClInclude Include="src\stb_image.h" />
|
||||
<ClInclude Include="src\toolbox\Timer.h" />
|
||||
<ClInclude Include="src\toolbox\toolbox.h" />
|
||||
<ClInclude Include="src\scenes\startup_Scene.h" />
|
||||
</ItemGroup>
|
||||
@@ -128,16 +129,16 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>C:\opencv\build\include;$(IncludePath);C:\opencv\opencv\build\include</IncludePath>
|
||||
<LibraryPath>C:\opencv\build\x64\vc15\lib;$(LibraryPath);C:\opencv\opencv\build\x64\vc15\lib</LibraryPath>
|
||||
<IncludePath>C:\opencv\build\include;$(IncludePath);C:\opencv\opencv\build\include;C:\opencv\build\include</IncludePath>
|
||||
<LibraryPath>C:\opencv\build\x64\vc15\lib;$(LibraryPath);C:\opencv\opencv\build\x64\vc15\lib;C:\opencv\build\x64\vc15\lib</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\opencv\opencv\build\include</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\opencv\opencv\build\x64\vc15\lib</LibraryPath>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\opencv\opencv\build\include;C:\opencv\build\include</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\opencv\opencv\build\x64\vc15\lib;C:\opencv\build\x64\vc15\lib</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -169,7 +170,7 @@
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>opencv_world452d.lib;%(AdditionalDependencies); opencv_world452.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>opencv_world452d.lib;%(AdditionalDependencies); opencv_world452.lib;opencv_world452d.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -210,7 +211,7 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>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</AdditionalDependencies>
|
||||
<AdditionalDependencies>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</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@@ -152,6 +152,9 @@
|
||||
<ClInclude Include="src\computervision\BackgroundRemover.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\toolbox\Timer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="res\haarcascade_frontalface_alt.xml" />
|
||||
|
||||
Reference in New Issue
Block a user