mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2026-02-04 08:09:19 +01:00
Update README.md
Add GameProject to Solution
This commit is contained in:
98
Game/Game.cpp
Normal file
98
Game/Game.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
#include "pch.h"
|
||||
#include "Game.h"
|
||||
|
||||
Game::Game(const Window& window)
|
||||
: BaseGame { window } {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
Game::~Game() {
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
void Game::Initialize() {
|
||||
|
||||
}
|
||||
|
||||
void Game::Cleanup() {
|
||||
}
|
||||
|
||||
void Game::Update(float elapsedSec) {
|
||||
// Check keyboard state
|
||||
//const Uint8 *pStates = SDL_GetKeyboardState( nullptr );
|
||||
//if ( pStates[SDL_SCANCODE_RIGHT] )
|
||||
//{
|
||||
// std::cout << "Right arrow key is down\n";
|
||||
//}
|
||||
//if ( pStates[SDL_SCANCODE_LEFT] && pStates[SDL_SCANCODE_UP])
|
||||
//{
|
||||
// std::cout << "Left and up arrow keys are down\n";
|
||||
//}
|
||||
}
|
||||
|
||||
void Game::Draw() const {
|
||||
ClearBackground();
|
||||
}
|
||||
|
||||
void Game::ProcessKeyDownEvent(const SDL_KeyboardEvent& e) {
|
||||
//std::cout << "KEYDOWN event: " << e.keysym.sym << std::endl;
|
||||
}
|
||||
|
||||
void Game::ProcessKeyUpEvent(const SDL_KeyboardEvent& e) {
|
||||
//std::cout << "KEYUP event: " << e.keysym.sym << std::endl;
|
||||
//switch ( e.keysym.sym )
|
||||
//{
|
||||
//case SDLK_LEFT:
|
||||
// //std::cout << "Left arrow key released\n";
|
||||
// break;
|
||||
//case SDLK_RIGHT:
|
||||
// //std::cout << "`Right arrow key released\n";
|
||||
// break;
|
||||
//case SDLK_1:
|
||||
//case SDLK_KP_1:
|
||||
// //std::cout << "Key 1 released\n";
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
|
||||
void Game::ProcessMouseMotionEvent(const SDL_MouseMotionEvent& e) {
|
||||
//std::cout << "MOUSEMOTION event: " << e.x << ", " << e.y << std::endl;
|
||||
}
|
||||
|
||||
void Game::ProcessMouseDownEvent(const SDL_MouseButtonEvent& e) {
|
||||
//std::cout << "MOUSEBUTTONDOWN event: ";
|
||||
//switch ( e.button )
|
||||
//{
|
||||
//case SDL_BUTTON_LEFT:
|
||||
// std::cout << " left button " << std::endl;
|
||||
// break;
|
||||
//case SDL_BUTTON_RIGHT:
|
||||
// std::cout << " right button " << std::endl;
|
||||
// break;
|
||||
//case SDL_BUTTON_MIDDLE:
|
||||
// std::cout << " middle button " << std::endl;
|
||||
// break;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
void Game::ProcessMouseUpEvent(const SDL_MouseButtonEvent& e) {
|
||||
//std::cout << "MOUSEBUTTONUP event: ";
|
||||
//switch ( e.button )
|
||||
//{
|
||||
//case SDL_BUTTON_LEFT:
|
||||
// std::cout << " left button " << std::endl;
|
||||
// break;
|
||||
//case SDL_BUTTON_RIGHT:
|
||||
// std::cout << " right button " << std::endl;
|
||||
// break;
|
||||
//case SDL_BUTTON_MIDDLE:
|
||||
// std::cout << " middle button " << std::endl;
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
|
||||
void Game::ClearBackground() const {
|
||||
glClearColor(0.0f, 0.0f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
30
Game/Game.h
Normal file
30
Game/Game.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include "BaseGame.h"
|
||||
|
||||
class Game : public BaseGame
|
||||
{
|
||||
public:
|
||||
explicit Game(const Window& window);
|
||||
Game(const Game& other) = delete;
|
||||
Game& operator=(const Game& other) = delete;
|
||||
Game(Game&& other) = delete;
|
||||
Game& operator=(Game&& other) = delete;
|
||||
// http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rh-override
|
||||
~Game();
|
||||
|
||||
void Update(float elapsedSec) override;
|
||||
void Draw() const override;
|
||||
|
||||
// Event handling
|
||||
void ProcessKeyDownEvent(const SDL_KeyboardEvent& e) override;
|
||||
void ProcessKeyUpEvent(const SDL_KeyboardEvent& e) override;
|
||||
void ProcessMouseMotionEvent(const SDL_MouseMotionEvent& e) override;
|
||||
void ProcessMouseDownEvent(const SDL_MouseButtonEvent& e) override;
|
||||
void ProcessMouseUpEvent(const SDL_MouseButtonEvent& e) override;
|
||||
|
||||
private:
|
||||
// FUNCTIONS
|
||||
void Initialize();
|
||||
void Cleanup();
|
||||
void ClearBackground() const;
|
||||
};
|
||||
164
Game/Game.vcxproj
Normal file
164
Game/Game.vcxproj
Normal file
@@ -0,0 +1,164 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{0f40114e-3e0c-4195-b425-91fd5ef586ad}</ProjectGuid>
|
||||
<RootNamespace>Game</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)\Libraries\SDLTtf\SDL2_ttf-2.20.2\include;$(SolutionDir)\Libraries\SDLMixer\SDL2_mixer-2.6.3\include;$(SolutionDir)\Libraries\SDLImage\SDL2_image-2.6.3\include;$(SolutionDir)\Libraries\SDLMain\SDL2-2.26.3\include;$(SolutionDir)\Engine;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)\x64\Debug;$(SolutionDir)\Libraries\SDLTtf\SDL2_ttf-2.20.2\lib\x64;$(SolutionDir)\Libraries\SDLMixer\SDL2_mixer-2.6.3\lib\x64;$(SolutionDir)\Libraries\SDLImage\SDL2_image-2.6.3\lib\x64;$(SolutionDir)\Libraries\SDLMain\SDL2-2.26.3\lib\x64;$(LibraryPath)</LibraryPath>
|
||||
<CustomBuildAfterTargets>BuildCompile</CustomBuildAfterTargets>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>Engine.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Command>
|
||||
</Command>
|
||||
<Message>Copying dll files to executable</Message>
|
||||
</CustomBuildStep>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy "$(SolutionDir)Libraries\SDLMain\SDL2-2.26.3\lib\x64\*.dll" "$(TargetDir)" /y /d
|
||||
xcopy "$(SolutionDir)Libraries\SDLImage\SDL2_image-2.6.3\lib\x64\*.dll" "$(TargetDir)" /y /d
|
||||
xcopy "$(SolutionDir)Libraries\SDLMixer\SDL2_mixer-2.6.3\lib\x64\*.dll" "$(TargetDir)" /y /d
|
||||
xcopy "$(SolutionDir)Libraries\SDLTtf\SDL2_ttf-2.20.2\lib\x64\*.dll" "$(TargetDir)" /y /d
|
||||
xcopy "$(SolutionDir)Resources\*.*" "$(TargetDir)" /y /d /s</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Game.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="pch.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Game.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<PropertyGroup>
|
||||
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
36
Game/Game.vcxproj.filters
Normal file
36
Game/Game.vcxproj.filters
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Game.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Game.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
40
Game/main.cpp
Normal file
40
Game/main.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "pch.h"
|
||||
#include <ctime>
|
||||
#include "Game.h"
|
||||
|
||||
|
||||
void StartHeapControl();
|
||||
void DumpMemoryLeaks();
|
||||
|
||||
int SDL_main(int argv, char** args) {
|
||||
srand(static_cast<unsigned int>(time(nullptr)));
|
||||
|
||||
StartHeapControl();
|
||||
|
||||
Game* pGame { new Game { Window { "Project name - Name, first name - 1DAEXX", 846.f, 500.f } } };
|
||||
pGame->Run();
|
||||
delete pGame;
|
||||
|
||||
DumpMemoryLeaks();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void StartHeapControl() {
|
||||
#if defined(DEBUG) | defined(_DEBUG)
|
||||
// Notify user if heap is corrupt
|
||||
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
|
||||
|
||||
// Report detected leaks when the program exits
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
|
||||
// Set a breakpoint on the specified object allocation order number
|
||||
//_CrtSetBreakAlloc( 156 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void DumpMemoryLeaks() {
|
||||
#if defined(DEBUG) | defined(_DEBUG)
|
||||
_CrtDumpMemoryLeaks();
|
||||
#endif
|
||||
}
|
||||
1
Game/pch.cpp
Normal file
1
Game/pch.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "pch.h"
|
||||
20
Game/pch.h
Normal file
20
Game/pch.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
//ML Detection Extension
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <cstdlib>
|
||||
#include <crtdbg.h>
|
||||
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
// SDL and OpenGL Includes
|
||||
#pragma warning(disable : 26812)
|
||||
#pragma warning(disable : 4820)
|
||||
#include <SDL.h>
|
||||
#include <SDL_opengl.h>
|
||||
#include <SDL_ttf.h>
|
||||
#include <SDL_mixer.h>
|
||||
#include <SDL_image.h>
|
||||
|
||||
#pragma warning(default : 26812)
|
||||
#include "structs.h"
|
||||
Reference in New Issue
Block a user