Added the Grid, Camera, Level system
Basic player Started (Barely) on the TextureManager And other fixes
30
DevAssets/ConvertTexture.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import os
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
def convert_to_32bit(file_path):
|
||||||
|
try:
|
||||||
|
# Open the image
|
||||||
|
image = Image.open(file_path)
|
||||||
|
|
||||||
|
# Convert to 32-bit color depth
|
||||||
|
if image.mode != 'RGBA':
|
||||||
|
image = image.convert('RGBA')
|
||||||
|
|
||||||
|
# Save the converted image
|
||||||
|
converted_file_path = file_path.replace('.png', '_32bit.png')
|
||||||
|
image.save(converted_file_path)
|
||||||
|
|
||||||
|
print(f"Conversion complete for '{file_path}'. Saved as '{converted_file_path}'")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
script_directory = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
png_files = [f for f in os.listdir(script_directory) if f.lower().endswith('.png')]
|
||||||
|
|
||||||
|
if not png_files:
|
||||||
|
print("No .png files found in the script directory.")
|
||||||
|
else:
|
||||||
|
for file_name in png_files:
|
||||||
|
file_path = os.path.join(script_directory, file_name)
|
||||||
|
convert_to_32bit(file_path)
|
||||||
BIN
DevAssets/MapCount.psd
Normal file
@@ -31,6 +31,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="BaseGame.h" />
|
<ClInclude Include="BaseGame.h" />
|
||||||
|
<ClInclude Include="colors.h" />
|
||||||
<ClInclude Include="Matrix2x3.h" />
|
<ClInclude Include="Matrix2x3.h" />
|
||||||
<ClInclude Include="base.h" />
|
<ClInclude Include="base.h" />
|
||||||
<ClInclude Include="SoundEffect.h" />
|
<ClInclude Include="SoundEffect.h" />
|
||||||
@@ -95,9 +96,18 @@
|
|||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<IncludePath>..\Libraries\SDLTtf\SDL2_ttf-2.20.2\include;..\Libraries\SDLImage\SDL2_image-2.6.3\include;..\Libraries\SDLMixer\SDL2_mixer-2.6.3\include;..\Libraries\SDLMain\SDL2-2.26.3\include;$(IncludePath)</IncludePath>
|
<IncludePath>C:\Users\Bram\Desktop\Programming 2\Exam\dae16-VerhulstBram\Libraries\DearImGui;..\Libraries\SDLTtf\SDL2_ttf-2.20.2\include;..\Libraries\SDLImage\SDL2_image-2.6.3\include;..\Libraries\SDLMixer\SDL2_mixer-2.6.3\include;..\Libraries\SDLMain\SDL2-2.26.3\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>..\Libraries\SDLTtf\SDL2_ttf-2.20.2\lib\x64;..\Libraries\SDL2_mixer-2.6.3\lib\x64;..\Libraries\SDLImage\SDL2_image-2.6.3\lib\x64;..\Libraries\SDLMain\SDL2-2.26.3\lib\x64;$(LibraryPath)</LibraryPath>
|
<LibraryPath>..\Libraries\SDLTtf\SDL2_ttf-2.20.2\lib\x64;..\Libraries\SDL2_mixer-2.6.3\lib\x64;..\Libraries\SDLImage\SDL2_image-2.6.3\lib\x64;..\Libraries\SDLMain\SDL2-2.26.3\lib\x64;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<IncludePath>C:\Users\Bram\Desktop\Programming 2\Exam\dae16-VerhulstBram\Libraries\DearImGui;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<IncludePath>C:\Users\Bram\Desktop\Programming 2\Exam\dae16-VerhulstBram\Libraries\DearImGui;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<IncludePath>C:\Users\Bram\Desktop\Programming 2\Exam\dae16-VerhulstBram\Libraries\DearImGui;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
|||||||
@@ -42,6 +42,144 @@
|
|||||||
<ClCompile Include="Vector2f.cpp">
|
<ClCompile Include="Vector2f.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_allegro5.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_android.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_dx9.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_dx10.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_dx11.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_dx12.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_glfw.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_glut.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_opengl2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_opengl3.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_sdl2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_sdl3.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_sdlrenderer2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_sdlrenderer3.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_vulkan.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_wgpu.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_win32.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_allegro5\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_android_opengl3\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_emscripten_wgpu\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_glfw_opengl2\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_glfw_opengl3\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_glfw_vulkan\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_glut_opengl2\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_null\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_sdl2_directx11\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_sdl2_opengl2\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_sdl2_opengl3\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_sdl2_sdlrenderer2\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_sdl2_vulkan\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_sdl3_opengl3\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_sdl3_sdlrenderer3\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_win32_directx9\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_win32_directx10\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_win32_directx11\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_win32_directx12\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\example_win32_opengl3\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\examples\libs\usynergy\uSynergy.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\misc\cpp\imgui_stdlib.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\misc\fonts\binary_to_compressed_c.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\misc\freetype\imgui_freetype.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\imgui.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\imgui_demo.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\imgui_draw.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\imgui_tables.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\imgui_widgets.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="BaseGame.h">
|
<ClInclude Include="BaseGame.h">
|
||||||
@@ -77,5 +215,110 @@
|
|||||||
<ClInclude Include="Transform.h">
|
<ClInclude Include="Transform.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="colors.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_allegro5.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_android.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_dx9.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_dx10.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_dx11.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_dx12.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_glfw.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_glut.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_metal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_opengl2.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_opengl3.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_opengl3_loader.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_osx.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_sdl2.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_sdl3.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_sdlrenderer2.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_sdlrenderer3.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_vulkan.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_wgpu.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_win32.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\examples\example_allegro5\imconfig_allegro5.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\examples\libs\emscripten\emscripten_mainloop_stub.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\examples\libs\glfw\include\GLFW\glfw3.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\examples\libs\glfw\include\GLFW\glfw3native.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\examples\libs\usynergy\uSynergy.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\misc\cpp\imgui_stdlib.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\misc\freetype\imgui_freetype.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\misc\single_file\imgui_single_file.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imconfig.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imgui.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imgui_internal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imstb_rectpack.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imstb_textedit.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imstb_truetype.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
16
Engine/colors.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
#include "structs.h"
|
||||||
|
|
||||||
|
namespace Colors
|
||||||
|
{
|
||||||
|
const Color4f WHITE{ 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
|
const Color4f BLACK{ 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
|
|
||||||
|
const Color4f RED{ 1.0f, 0.0f, 0.0f, 1.0f };
|
||||||
|
const Color4f GREEN{ 0.0f, 1.0f, 0.0f, 1.0f };
|
||||||
|
const Color4f BLUE{ 0.0f, 0.0f, 1.0f, 1.0f };
|
||||||
|
|
||||||
|
const Color4f YELLOW{ 1.0f, 1.0f, 0.0f, 1.0f };
|
||||||
|
const Color4f MAGENTA{ 1.0f, 0.0f, 1.0f, 1.0f };
|
||||||
|
const Color4f CYAN{ 0.0f, 1.0f, 1.0f, 1.0f };
|
||||||
|
}
|
||||||
@@ -20,6 +20,21 @@ Point2f::Point2f()
|
|||||||
Point2f::Point2f(float x, float y)
|
Point2f::Point2f(float x, float y)
|
||||||
: x { x }, y { y } {
|
: x { x }, y { y } {
|
||||||
}
|
}
|
||||||
|
Point2f Point2f::operator+(const Point2f& other) const {
|
||||||
|
return Point2f { x + other.x, y + other.y };
|
||||||
|
}
|
||||||
|
Point2f Point2f::operator*(float other) const {
|
||||||
|
return Point2f { x * other, y * other };
|
||||||
|
}
|
||||||
|
Point2f Point2f::operator*(const Point2f& other) const {
|
||||||
|
return Point2f { x * other.x, y * other.y };
|
||||||
|
}
|
||||||
|
Point2f Point2f::operator*(int other) const {
|
||||||
|
return Point2f { x * float(other), y * float(other) };
|
||||||
|
}
|
||||||
|
Point2f Point2f::operator/(float other) const {
|
||||||
|
return Point2f { x / other, y / other };
|
||||||
|
}
|
||||||
|
|
||||||
// Point2f::Point2f(int x, int y)
|
// Point2f::Point2f(int x, int y)
|
||||||
// : x { (float)x }, y { (float)y } {
|
// : x { (float)x }, y { (float)y } {
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ struct Point2f
|
|||||||
explicit Point2f( float x, float y );
|
explicit Point2f( float x, float y );
|
||||||
//Point2f(int x, int y); //Stupid fix for it giving an error
|
//Point2f(int x, int y); //Stupid fix for it giving an error
|
||||||
|
|
||||||
|
//operator
|
||||||
|
Point2f operator+( const Point2f& other ) const;
|
||||||
|
Point2f operator*( float other ) const;
|
||||||
|
Point2f operator*( const Point2f& other ) const;
|
||||||
|
Point2f operator*( int other ) const;
|
||||||
|
Point2f operator/( float other ) const;
|
||||||
|
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,13 +5,17 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
#pragma region OpenGLDrawFunctionality
|
#pragma region OpenGLDrawFunctionality
|
||||||
void utils::SetColor( const Color4f& color )
|
void utils::SetColor( const Color4f& color )
|
||||||
{
|
{
|
||||||
glColor4f( color.r, color.g, color.b, color.a );
|
glColor4f( color.r, color.g, color.b, color.a );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void utils::ClearBackground( const Color4f& color ) {
|
||||||
|
glClearColor(color.r, color.g, color.b, color.a);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
void utils::DrawPoint( float x, float y, float pointSize )
|
void utils::DrawPoint( float x, float y, float pointSize )
|
||||||
{
|
{
|
||||||
glPointSize( pointSize );
|
glPointSize( pointSize );
|
||||||
@@ -684,3 +688,7 @@ bool utils::IntersectRectLine(const Rectf& r, const Point2f& p1, const Point2f&
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion CollisionFunctionality
|
#pragma endregion CollisionFunctionality
|
||||||
|
|
||||||
|
int utils::randRange(int min, int max) {
|
||||||
|
return min + rand() % (( max + 1 ) - min);
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ namespace utils
|
|||||||
|
|
||||||
void SetColor( const Color4f& color );
|
void SetColor( const Color4f& color );
|
||||||
|
|
||||||
|
void ClearBackground( const Color4f& color );
|
||||||
|
|
||||||
void DrawPoint( float x, float y, float pointSize = 1.0f );
|
void DrawPoint( float x, float y, float pointSize = 1.0f );
|
||||||
void DrawPoint( const Point2f& p, float pointSize = 1.0f );
|
void DrawPoint( const Point2f& p, float pointSize = 1.0f );
|
||||||
void DrawPoints( Point2f *pVertices, int nrVertices, float pointSize = 1.0f );
|
void DrawPoints( Point2f *pVertices, int nrVertices, float pointSize = 1.0f );
|
||||||
@@ -81,6 +83,7 @@ namespace utils
|
|||||||
bool IsPointOnLineSegment(const Point2f& p, const Point2f& a, const Point2f& b);
|
bool IsPointOnLineSegment(const Point2f& p, const Point2f& a, const Point2f& b);
|
||||||
bool IntersectRectLine(const Rectf& r, const Point2f& p1, const Point2f& p2, float& intersectMin, float& intersectMax);
|
bool IntersectRectLine(const Rectf& r, const Point2f& p1, const Point2f& p2, float& intersectMin, float& intersectMax);
|
||||||
|
|
||||||
|
int randRange(int min, int max);
|
||||||
#pragma endregion CollisionFunctionality
|
#pragma endregion CollisionFunctionality
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,21 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
|
|
||||||
|
Camera::Camera() : m_Position { 0, 0 }, m_Scale { 1.0f } {
|
||||||
|
}
|
||||||
|
Camera::Camera(const Point2f& position, const float scale) : m_Position { position }, m_Scale { scale } {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera::BeginRendering() const {
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(m_Position.x, m_Position.y, 0);
|
||||||
|
glScalef(m_Scale, m_Scale, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera::EndRendering() const {
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
Point2f Camera::TransformMouse(const Point2f& mousePos) const {
|
||||||
|
const Point2f translatedPosition = mousePos + m_Position;
|
||||||
|
return translatedPosition;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,8 +3,22 @@
|
|||||||
class Camera
|
class Camera
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Camera( );
|
||||||
|
Camera( const Point2f& position, float scale = 1);
|
||||||
|
|
||||||
|
void SetPosition( const Point2f& position ) { m_Position = position; }
|
||||||
|
void SetScale( const float scale ) { m_Scale = scale; }
|
||||||
|
|
||||||
|
const Point2f& GetPosition( ) const { return m_Position; }
|
||||||
|
float GetScale( ) const { return m_Scale; }
|
||||||
|
|
||||||
|
void BeginRendering() const;
|
||||||
|
void EndRendering() const;
|
||||||
|
|
||||||
|
Point2f TransformMouse (const Point2f& mousePos) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Point2f m_Position;
|
||||||
|
float m_Scale;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
|
||||||
|
#include "colors.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "WorldLevel.h"
|
||||||
|
|
||||||
Game::Game(const Window& window)
|
Game::Game(const Window& window)
|
||||||
: BaseGame { window }
|
: BaseGame { window }, m_Camera(Camera()), m_WorldLevel(WorldLevel(&m_Camera))
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
@@ -14,34 +16,42 @@ Game::~Game() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::Initialize() {
|
void Game::Initialize() {
|
||||||
m_WorldLevel = WorldLevel();
|
m_Camera.SetPosition(Point2f{GetViewPort().width / 2, GetViewPort().height / 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::Cleanup() {
|
void Game::Cleanup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::Update(float elapsedSec) {
|
void Game::Update(float elapsedSec) {
|
||||||
const Uint8 *pStates = SDL_GetKeyboardState( nullptr );
|
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
||||||
if ( pStates[SDL_SCANCODE_RIGHT] ) {
|
// if (pStates[SDL_SCANCODE_RIGHT]) {
|
||||||
m_CameraOffset.x += 100 * elapsedSec;
|
// m_CameraOffset.x += 200 * elapsedSec;
|
||||||
}
|
// }
|
||||||
if ( pStates[SDL_SCANCODE_LEFT] ) {
|
// if (pStates[SDL_SCANCODE_LEFT]) {
|
||||||
m_CameraOffset.x -= 100 * elapsedSec;
|
// m_CameraOffset.x -= 200 * elapsedSec;
|
||||||
|
// }
|
||||||
|
// if (pStates[SDL_SCANCODE_UP]) {
|
||||||
|
// m_CameraOffset.y += 200 * elapsedSec;
|
||||||
|
// }
|
||||||
|
// if (pStates[SDL_SCANCODE_DOWN]) {
|
||||||
|
// m_CameraOffset.y -= 200 * elapsedSec;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(m_IsMouseDown) {
|
||||||
|
Point2f newCameraPos = m_MousePos + m_MouseOffset;
|
||||||
|
m_Camera.SetPosition(newCameraPos);
|
||||||
|
} else {
|
||||||
|
m_MouseOffset = m_Camera.GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::Draw() const {
|
void Game::Draw() const {
|
||||||
ClearBackground();
|
utils::ClearBackground(Color4f(0.0f, 0.0f, 0.3f, 1.0f));
|
||||||
glPushMatrix();
|
//m_Camera.BeginRendering();
|
||||||
{
|
|
||||||
glTranslatef(m_CameraOffset.x , m_CameraOffset.y, 0);
|
|
||||||
m_WorldLevel.Draw();
|
m_WorldLevel.Draw();
|
||||||
utils::SetColor(Color4f{1.0f, 0.0f, 0.0f, 1.0f});
|
//m_Camera.EndRendering();
|
||||||
utils::FillEllipse(0,0,20,20);
|
|
||||||
}
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::ProcessKeyDownEvent(const SDL_KeyboardEvent& e) {
|
void Game::ProcessKeyDownEvent(const SDL_KeyboardEvent& e) {
|
||||||
@@ -66,10 +76,15 @@ void Game::ProcessKeyUpEvent(const SDL_KeyboardEvent& e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::ProcessMouseMotionEvent(const SDL_MouseMotionEvent& e) {
|
void Game::ProcessMouseMotionEvent(const SDL_MouseMotionEvent& e) {
|
||||||
//std::cout << "MOUSEMOTION event: " << e.x << ", " << e.y << std::endl;
|
m_MousePos = Point2f { float(e.x), float(e.y) };
|
||||||
|
m_WorldLevel.MouseMove(m_MousePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::ProcessMouseDownEvent(const SDL_MouseButtonEvent& e) {
|
void Game::ProcessMouseDownEvent(const SDL_MouseButtonEvent& e) {
|
||||||
|
m_IsMouseDown = true;
|
||||||
|
m_MouseOffset = Point2f(m_Camera.GetPosition() - m_MousePos);
|
||||||
|
|
||||||
|
|
||||||
//std::cout << "MOUSEBUTTONDOWN event: ";
|
//std::cout << "MOUSEBUTTONDOWN event: ";
|
||||||
//switch ( e.button )
|
//switch ( e.button )
|
||||||
//{
|
//{
|
||||||
@@ -87,6 +102,7 @@ void Game::ProcessMouseDownEvent(const SDL_MouseButtonEvent& e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::ProcessMouseUpEvent(const SDL_MouseButtonEvent& e) {
|
void Game::ProcessMouseUpEvent(const SDL_MouseButtonEvent& e) {
|
||||||
|
m_IsMouseDown = false;
|
||||||
//std::cout << "MOUSEBUTTONUP event: ";
|
//std::cout << "MOUSEBUTTONUP event: ";
|
||||||
//switch ( e.button )
|
//switch ( e.button )
|
||||||
//{
|
//{
|
||||||
@@ -101,8 +117,3 @@ void Game::ProcessMouseUpEvent(const SDL_MouseButtonEvent& e) {
|
|||||||
// break;
|
// break;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::ClearBackground() const {
|
|
||||||
glClearColor(0.0f, 0.0f, 0.3f, 1.0f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "BaseGame.h"
|
#include "BaseGame.h"
|
||||||
|
#include "Camera.h"
|
||||||
#include "WorldLevel.h"
|
#include "WorldLevel.h"
|
||||||
#include "WorldTile.h"
|
#include "WorldTile.h"
|
||||||
|
|
||||||
@@ -30,9 +31,13 @@ private:
|
|||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
void ClearBackground() const;
|
|
||||||
|
|
||||||
|
|
||||||
Point2f m_CameraOffset{0, 0};
|
Camera m_Camera;
|
||||||
WorldLevel m_WorldLevel;
|
WorldLevel m_WorldLevel;
|
||||||
|
|
||||||
|
Point2f m_MousePos{};
|
||||||
|
Point2f m_MouseOffset{};
|
||||||
|
bool m_IsMouseDown{};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -149,10 +149,158 @@ xcopy "$(SolutionDir)Resources\*.*" "$(TargetDir)" /y /d /s</Command>
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Camera.cpp" />
|
<ClCompile Include="Camera.cpp" />
|
||||||
<ClCompile Include="Game.cpp" />
|
<ClCompile Include="Game.cpp" />
|
||||||
<ClCompile Include="Level.cpp" />
|
<ClCompile Include="Level.cpp">
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SupportJustMyCode>true</SupportJustMyCode>
|
||||||
|
<AssemblerOutput>NoListing</AssemblerOutput>
|
||||||
|
<AssemblerListingLocation>x64\Debug\</AssemblerListingLocation>
|
||||||
|
<UndefineAllPreprocessorDefinitions>false</UndefineAllPreprocessorDefinitions>
|
||||||
|
<BrowseInformation>false</BrowseInformation>
|
||||||
|
<BrowseInformationFile>x64\Debug\</BrowseInformationFile>
|
||||||
|
<CompileAs>Default</CompileAs>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<DiagnosticsFormat>Column</DiagnosticsFormat>
|
||||||
|
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||||
|
<ErrorReporting>Prompt</ErrorReporting>
|
||||||
|
<ExpandAttributedSource>false</ExpandAttributedSource>
|
||||||
|
<ExceptionHandling>Sync</ExceptionHandling>
|
||||||
|
<EnableASAN>false</EnableASAN>
|
||||||
|
<EnableFuzzer>false</EnableFuzzer>
|
||||||
|
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||||
|
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||||
|
<FloatingPointModel>Precise</FloatingPointModel>
|
||||||
|
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||||
|
<GenerateModuleDependencies>false</GenerateModuleDependencies>
|
||||||
|
<GenerateSourceDependencies>false</GenerateSourceDependencies>
|
||||||
|
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
|
||||||
|
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||||
|
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||||
|
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
|
||||||
|
<LanguageStandard>Default</LanguageStandard>
|
||||||
|
<LanguageStandard_C>Default</LanguageStandard_C>
|
||||||
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
<ModuleDependenciesFile>x64\Debug\</ModuleDependenciesFile>
|
||||||
|
<ModuleOutputFile>x64\Debug\</ModuleOutputFile>
|
||||||
|
<OmitDefaultLibName>false</OmitDefaultLibName>
|
||||||
|
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
||||||
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
|
<ObjectFileName>x64\Debug\</ObjectFileName>
|
||||||
|
<CallingConvention>Cdecl</CallingConvention>
|
||||||
|
<ProgramDataBaseFileName>x64\Debug\vc143.pdb</ProgramDataBaseFileName>
|
||||||
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<PrecompiledHeaderOutputFile>x64\Debug\Game.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<PreprocessToFile>false</PreprocessToFile>
|
||||||
|
<PreprocessKeepComments>false</PreprocessKeepComments>
|
||||||
|
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
|
||||||
|
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||||
|
<ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies>
|
||||||
|
<ShowIncludes>false</ShowIncludes>
|
||||||
|
<SourceDependenciesFile>x64\Debug\</SourceDependenciesFile>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||||
|
<SmallerTypeCheck>false</SmallerTypeCheck>
|
||||||
|
<SpectreMitigation>false</SpectreMitigation>
|
||||||
|
<StructMemberAlignment>Default</StructMemberAlignment>
|
||||||
|
<TrackerLogDirectory>x64\Debug\Game.tlog\</TrackerLogDirectory>
|
||||||
|
<TranslateIncludes>false</TranslateIncludes>
|
||||||
|
<MinimalRebuildFromTracking>true</MinimalRebuildFromTracking>
|
||||||
|
<TreatWarningAsError>false</TreatWarningAsError>
|
||||||
|
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||||
|
<UseFullPaths>true</UseFullPaths>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<XMLDocumentationFileName>x64\Debug\</XMLDocumentationFileName>
|
||||||
|
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||||
|
<IntelJCCErratum>false</IntelJCCErratum>
|
||||||
|
<BuildStlModules>false</BuildStlModules>
|
||||||
|
<TreatAngleIncludeAsExternal>false</TreatAngleIncludeAsExternal>
|
||||||
|
<ExternalWarningLevel>InheritWarningLevel</ExternalWarningLevel>
|
||||||
|
<TreatExternalTemplatesAsInternal>true</TreatExternalTemplatesAsInternal>
|
||||||
|
<DisableAnalyzeExternal>false</DisableAnalyzeExternal>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_UNICODE;UNICODE;</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<LinkCompiled>true</LinkCompiled>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="pch.cpp" />
|
<ClCompile Include="pch.cpp" />
|
||||||
<ClCompile Include="WorldLevel.cpp" />
|
<ClCompile Include="Player.cpp" />
|
||||||
|
<ClCompile Include="TextureManager.cpp" />
|
||||||
|
<ClCompile Include="WorldLevel.cpp">
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SupportJustMyCode>true</SupportJustMyCode>
|
||||||
|
<AssemblerOutput>NoListing</AssemblerOutput>
|
||||||
|
<AssemblerListingLocation>x64\Debug\</AssemblerListingLocation>
|
||||||
|
<UndefineAllPreprocessorDefinitions>false</UndefineAllPreprocessorDefinitions>
|
||||||
|
<BrowseInformation>false</BrowseInformation>
|
||||||
|
<BrowseInformationFile>x64\Debug\</BrowseInformationFile>
|
||||||
|
<CompileAs>Default</CompileAs>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<DiagnosticsFormat>Column</DiagnosticsFormat>
|
||||||
|
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||||
|
<ErrorReporting>Prompt</ErrorReporting>
|
||||||
|
<ExpandAttributedSource>false</ExpandAttributedSource>
|
||||||
|
<ExceptionHandling>Sync</ExceptionHandling>
|
||||||
|
<EnableASAN>false</EnableASAN>
|
||||||
|
<EnableFuzzer>false</EnableFuzzer>
|
||||||
|
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||||
|
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||||
|
<FloatingPointModel>Precise</FloatingPointModel>
|
||||||
|
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||||
|
<GenerateModuleDependencies>false</GenerateModuleDependencies>
|
||||||
|
<GenerateSourceDependencies>false</GenerateSourceDependencies>
|
||||||
|
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
|
||||||
|
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||||
|
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||||
|
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
|
||||||
|
<LanguageStandard>Default</LanguageStandard>
|
||||||
|
<LanguageStandard_C>Default</LanguageStandard_C>
|
||||||
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
<ModuleDependenciesFile>x64\Debug\</ModuleDependenciesFile>
|
||||||
|
<ModuleOutputFile>x64\Debug\</ModuleOutputFile>
|
||||||
|
<OmitDefaultLibName>false</OmitDefaultLibName>
|
||||||
|
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
||||||
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
|
<ObjectFileName>x64\Debug\</ObjectFileName>
|
||||||
|
<CallingConvention>Cdecl</CallingConvention>
|
||||||
|
<ProgramDataBaseFileName>x64\Debug\vc143.pdb</ProgramDataBaseFileName>
|
||||||
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<PrecompiledHeaderOutputFile>x64\Debug\Game.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<PreprocessToFile>false</PreprocessToFile>
|
||||||
|
<PreprocessKeepComments>false</PreprocessKeepComments>
|
||||||
|
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
|
||||||
|
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||||
|
<ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies>
|
||||||
|
<ShowIncludes>false</ShowIncludes>
|
||||||
|
<SourceDependenciesFile>x64\Debug\</SourceDependenciesFile>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||||
|
<SmallerTypeCheck>false</SmallerTypeCheck>
|
||||||
|
<SpectreMitigation>false</SpectreMitigation>
|
||||||
|
<StructMemberAlignment>Default</StructMemberAlignment>
|
||||||
|
<TrackerLogDirectory>x64\Debug\Game.tlog\</TrackerLogDirectory>
|
||||||
|
<TranslateIncludes>false</TranslateIncludes>
|
||||||
|
<MinimalRebuildFromTracking>true</MinimalRebuildFromTracking>
|
||||||
|
<TreatWarningAsError>false</TreatWarningAsError>
|
||||||
|
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||||
|
<UseFullPaths>true</UseFullPaths>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<XMLDocumentationFileName>x64\Debug\</XMLDocumentationFileName>
|
||||||
|
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||||
|
<IntelJCCErratum>false</IntelJCCErratum>
|
||||||
|
<BuildStlModules>false</BuildStlModules>
|
||||||
|
<TreatAngleIncludeAsExternal>false</TreatAngleIncludeAsExternal>
|
||||||
|
<ExternalWarningLevel>InheritWarningLevel</ExternalWarningLevel>
|
||||||
|
<TreatExternalTemplatesAsInternal>true</TreatExternalTemplatesAsInternal>
|
||||||
|
<DisableAnalyzeExternal>false</DisableAnalyzeExternal>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_UNICODE;UNICODE;</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<LinkCompiled>true</LinkCompiled>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="WorldTile.cpp" />
|
<ClCompile Include="WorldTile.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -160,9 +308,14 @@ xcopy "$(SolutionDir)Resources\*.*" "$(TargetDir)" /y /d /s</Command>
|
|||||||
<ClInclude Include="Game.h" />
|
<ClInclude Include="Game.h" />
|
||||||
<ClInclude Include="Level.h" />
|
<ClInclude Include="Level.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
|
<ClInclude Include="Player.h" />
|
||||||
|
<ClInclude Include="TextureManager.h" />
|
||||||
<ClInclude Include="WorldLevel.h" />
|
<ClInclude Include="WorldLevel.h" />
|
||||||
<ClInclude Include="WorldTile.h" />
|
<ClInclude Include="WorldTile.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Level\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|||||||
@@ -24,6 +24,93 @@
|
|||||||
<ClCompile Include="pch.cpp">
|
<ClCompile Include="pch.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Camera.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Level.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="WorldLevel.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="WorldTile.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_allegro5.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_android.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_dx9.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_dx10.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_dx11.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_dx12.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_glfw.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_glut.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_opengl2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_opengl3.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_sdl2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_sdl3.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_sdlrenderer2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_sdlrenderer3.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_vulkan.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_wgpu.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\backends\imgui_impl_win32.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\misc\cpp\imgui_stdlib.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\misc\fonts\binary_to_compressed_c.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\misc\freetype\imgui_freetype.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\imgui.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\imgui_demo.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\imgui_draw.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\imgui_tables.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DearImGui\imgui_widgets.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Game.h">
|
<ClInclude Include="Game.h">
|
||||||
@@ -32,5 +119,104 @@
|
|||||||
<ClInclude Include="pch.h">
|
<ClInclude Include="pch.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Camera.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Level.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="WorldLevel.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="WorldTile.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_allegro5.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_android.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_dx9.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_dx10.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_dx11.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_dx12.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_glfw.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_glut.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_metal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_opengl2.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_opengl3.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_opengl3_loader.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_osx.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_sdl2.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_sdl3.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_sdlrenderer2.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_sdlrenderer3.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_vulkan.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_wgpu.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\backends\imgui_impl_win32.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\misc\cpp\imgui_stdlib.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\misc\freetype\imgui_freetype.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\misc\single_file\imgui_single_file.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imconfig.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imgui.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imgui_internal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imstb_rectpack.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imstb_textedit.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DearImGui\imstb_truetype.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "Level.h"
|
#include "Level.h"
|
||||||
Level::Level() {
|
|
||||||
|
#include <iostream>
|
||||||
|
Level::Level() : m_pCamera(nullptr) {
|
||||||
|
std::cout << "Cannot make level without a camera" << std::endl;
|
||||||
|
}
|
||||||
|
Level::Level(Camera* camera) {
|
||||||
|
m_pCamera = camera;
|
||||||
}
|
}
|
||||||
Level::~Level() {
|
Level::~Level() {
|
||||||
}
|
}
|
||||||
@@ -8,3 +14,5 @@ void Level::Update(float elapsedSec) {
|
|||||||
}
|
}
|
||||||
void Level::Draw() const {
|
void Level::Draw() const {
|
||||||
}
|
}
|
||||||
|
void Level::MouseMove(const Point2f& mousePos) {
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "Camera.h"
|
||||||
|
|
||||||
class Level
|
class Level
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Level();
|
Level();
|
||||||
~Level();
|
Level(Camera* camera);
|
||||||
|
virtual ~Level();
|
||||||
|
|
||||||
virtual void Update(float elapsedSec);
|
virtual void Update(float elapsedSec);
|
||||||
virtual void Draw() const;
|
virtual void Draw() const;
|
||||||
|
virtual void MouseMove(const Point2f& mousePos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Camera* m_pCamera;
|
||||||
};
|
};
|
||||||
|
|||||||
45
Game/Player.cpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
|
#include "colors.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "WorldLevel.h"
|
||||||
|
|
||||||
|
Player::Player(const Point2f& Position) : m_Position(Position), m_Size(Point2f{50, 20})
|
||||||
|
{}
|
||||||
|
|
||||||
|
void Player::Draw() const {
|
||||||
|
utils::SetColor(Colors::RED);
|
||||||
|
utils::DrawRect(Rectf{m_Position.x, m_Position.y, m_Size.x, m_Size.y});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::Update(float elapsedTime, const WorldLevel& level) {
|
||||||
|
Point2f acc{0, 0};
|
||||||
|
acc.y += m_Gravity.y;
|
||||||
|
|
||||||
|
Point2f nextPos = m_Position + m_Vel * elapsedTime * acc * elapsedTime * elapsedTime;
|
||||||
|
//collision checking
|
||||||
|
auto tiles = level.GetAllTiles();
|
||||||
|
for (int x{0}; x < WorldLevel::WORLD_WIDTH; ++x) {
|
||||||
|
for (int y{0}; y < WorldLevel::WORLD_HEIGHT; ++y) {
|
||||||
|
WorldTile* tile = tiles[x][y];
|
||||||
|
if (tile->GetTileType() == GroundTileTypes::Dirt) {
|
||||||
|
Rectf tileRect = Rectf{tile->GetPosition().x, tile->GetPosition().y, WorldLevel::TILE_WIDTH, WorldLevel::TILE_HEIGHT};
|
||||||
|
if (utils::IsOverlapping(nextPos, m_Size, tileRect)) {
|
||||||
|
//collision
|
||||||
|
if (m_Vel.y < 0) {
|
||||||
|
//collision from above
|
||||||
|
m_Position.y = tileRect.bottom;
|
||||||
|
m_Vel.y = 0;
|
||||||
|
} else {
|
||||||
|
m_Position.y = tileRect.bottom + m_Size.y;
|
||||||
|
m_Vel.y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_Vel = Point2f{m_Vel.x + float(acc.x * elapsedTime), m_Vel.y + float(acc.y * elapsedTime)};
|
||||||
|
// m_Position += m_Vel * elapsedTime;
|
||||||
|
m_Position = Point2f{m_Position.x + m_Vel.x * elapsedTime, m_Position.y + m_Vel.y * elapsedTime};
|
||||||
|
}
|
||||||
22
Game/Player.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class WorldLevel;
|
||||||
|
class Player
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
Player(const Point2f& Position);
|
||||||
|
void Update(float elapsedTime, const WorldLevel& level);
|
||||||
|
void Draw() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Point2f m_Position{};
|
||||||
|
Point2f m_Size{};
|
||||||
|
|
||||||
|
Point2f m_Vel{};
|
||||||
|
|
||||||
|
Point2f m_Acc{};
|
||||||
|
Point2f m_Gravity{ 0, -9.81f };
|
||||||
|
float m_MaxSpeed{ 200 };
|
||||||
|
|
||||||
|
};
|
||||||
2
Game/TextureManager.cpp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "TextureManager.h"
|
||||||
7
Game/TextureManager.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class TextureManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
};
|
||||||
@@ -1,25 +1,72 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "WorldLevel.h"
|
#include "WorldLevel.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
#include "colors.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
WorldLevel::WorldLevel() {
|
|
||||||
for (int i{ 0 }; i < 10; ++i) {
|
WorldLevel::WorldLevel(Camera* camera) : Level(camera), m_mousePos{ 0, 0 }, m_player(Player{ Point2f{ 0, 100 } }) {
|
||||||
for (int j{ 0 }; j < 10; ++j) {
|
// The grid is 34 x 50 big, the top center is 0,0 in world coords
|
||||||
m_WorldTiles[i][j] = WorldTile{ Point2f{ (float)i * 50, (float)j * 50 }, GroundTileTypes::Dirt };
|
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||||
}
|
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||||
}
|
int actualX = x - WORLD_WIDTH / 2;
|
||||||
}
|
m_worldTiles[x][y] = new WorldTile{ Point2f{ float(actualX * TILE_WIDTH), -float(y * TILE_HEIGHT) - TILE_HEIGHT}, GroundTileTypes::Dirt};
|
||||||
WorldLevel::~WorldLevel() {
|
|
||||||
}
|
|
||||||
void WorldLevel::Update(float elapsedSec) {
|
|
||||||
}
|
|
||||||
void WorldLevel::Draw() const {
|
|
||||||
for (int i{ 0 }; i < 10; ++i) {
|
|
||||||
for (int j{ 0 }; j < 10; ++j) {
|
|
||||||
utils::SetColor(Color4f{ 0.5f, 0.5f, 0.5f, 1.0f });
|
|
||||||
utils::FillRect(m_WorldTiles[i][j].GetPosition().x, m_WorldTiles[i][j].GetPosition().y, 50, 50);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// std::string dirtPath = + "tiles/dirt/dirt" + std::to_string(utils::randRange(1, 5)) + ".png";
|
||||||
|
// m_pTextTexture = new Texture(dirtPath);
|
||||||
}
|
}
|
||||||
|
WorldLevel::~WorldLevel() {
|
||||||
|
//delete m_pTextTexture;
|
||||||
|
|
||||||
|
}
|
||||||
|
void WorldLevel::Update(float elapsedSec) {
|
||||||
|
int mouseX, mouseY;
|
||||||
|
SDL_GetMouseState(&mouseX, &mouseY);
|
||||||
|
m_mousePos = Point2f{ float(mouseX), float(mouseY) };
|
||||||
|
m_player.Update(elapsedSec, *this);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
void WorldLevel::Draw() const {
|
||||||
|
m_pCamera->BeginRendering();
|
||||||
|
|
||||||
|
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||||
|
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||||
|
m_worldTiles[x][y]->Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
utils::SetColor(Colors::WHITE);
|
||||||
|
for (int x { -100 }; x < 100; ++x) {
|
||||||
|
for (int y { -100 }; y < 100; ++y) {
|
||||||
|
utils::DrawLine(x * 50, -5000, x * 50, 50000);
|
||||||
|
utils::DrawLine(-5000, y * 50, 50000, y * 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
utils::SetColor(Colors::MAGENTA);
|
||||||
|
utils::FillEllipse(0, 0, 10, 10);
|
||||||
|
|
||||||
|
m_player.Draw();
|
||||||
|
m_pCamera->EndRendering();
|
||||||
|
|
||||||
|
//utils::SetColor(Colors::WHITE);
|
||||||
|
//m_pTextTexture->Draw(Point2f{ 0, 0 });
|
||||||
|
|
||||||
|
}
|
||||||
|
void WorldLevel::MouseMove(const Point2f& mousePos) {
|
||||||
|
m_mousePos = mousePos;
|
||||||
|
}
|
||||||
|
WorldTile* WorldLevel::GetTileAt(const Point2f& pos) const {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
void WorldLevel::SetTileAt(const Point2f& pos, WorldTile* tile) {
|
||||||
|
}
|
||||||
|
std::array<std::array<WorldTile*, WorldLevel::WORLD_WIDTH>, WorldLevel::WORLD_HEIGHT> WorldLevel::GetAllTiles() const {
|
||||||
|
return m_worldTiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,41 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Level.h"
|
#include "Level.h"
|
||||||
|
#include "Texture.h"
|
||||||
|
#include "WorldLevel.h"
|
||||||
#include "WorldTile.h"
|
#include "WorldTile.h"
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
|
|
||||||
class WorldLevel : public Level {
|
class WorldLevel : public Level {
|
||||||
public:
|
public:
|
||||||
WorldLevel();
|
static const int WORLD_WIDTH = 34;
|
||||||
~WorldLevel();
|
static const int WORLD_HEIGHT = 34;
|
||||||
|
|
||||||
|
static const int TILE_WIDTH = 50;
|
||||||
|
static const int TILE_HEIGHT = 50;
|
||||||
|
|
||||||
|
WorldLevel(Camera* camera);
|
||||||
|
~WorldLevel() override;
|
||||||
|
|
||||||
void Update(float elapsedSec) override;
|
void Update(float elapsedSec) override;
|
||||||
void Draw() const override;
|
void Draw() const override;
|
||||||
|
|
||||||
|
void MouseMove(const Point2f& mousePos) override;
|
||||||
|
|
||||||
|
WorldTile* GetTileAt(const Point2f& pos) const;
|
||||||
|
void SetTileAt(const Point2f& pos, WorldTile* tile);
|
||||||
|
|
||||||
|
std::array<std::array<WorldTile*, WORLD_WIDTH>, WORLD_HEIGHT> GetAllTiles() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WorldTile m_WorldTiles[10][10];
|
|
||||||
|
|
||||||
|
|
||||||
|
std::array<std::array<WorldTile*, WORLD_WIDTH>, WORLD_HEIGHT> m_worldTiles;
|
||||||
|
|
||||||
|
Player m_player;
|
||||||
|
Point2f m_mousePos{};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "WorldTile.h"
|
#include "WorldTile.h"
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
WorldTile::WorldTile() {
|
WorldTile::WorldTile() {
|
||||||
|
|
||||||
}
|
}
|
||||||
WorldTile::WorldTile(const Point2f& position, GroundTileTypes groundTileType) : m_Position { position }, m_GroundTileType { groundTileType } {
|
WorldTile::WorldTile(const Point2f& position, GroundTileTypes groundTileType) : m_Position { position }, m_GroundTileType { groundTileType } {
|
||||||
|
const std::string dirtPath = + "tiles/dirt/dirt" + std::to_string(utils::randRange(1, 5)) + ".png";
|
||||||
|
m_pTexture = new Texture(dirtPath);
|
||||||
|
}
|
||||||
|
WorldTile::~WorldTile() {
|
||||||
|
delete m_pTexture;
|
||||||
}
|
}
|
||||||
void WorldTile::Draw() const {
|
void WorldTile::Draw() const {
|
||||||
if (m_GroundTileType != GroundTileTypes::Air) {
|
if (m_GroundTileType != GroundTileTypes::Air) {
|
||||||
utils::SetColor(Color4f{ 0.5f, 0.5f, 0.5f, 1.0f});
|
m_pTexture->Draw(m_Position);
|
||||||
utils::FillRect(m_Position.x, m_Position.y, 50, 50);
|
//utils::SetColor(Color4f{ 0.5f, 0.5f, 0.5f, 1.0f});
|
||||||
|
//utils::FillRect(m_Position.x, m_Position.y, 50, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "Texture.h"
|
||||||
|
|
||||||
enum class GroundTileTypes
|
enum class GroundTileTypes
|
||||||
{
|
{
|
||||||
@@ -10,16 +11,25 @@ class WorldTile {
|
|||||||
public:
|
public:
|
||||||
WorldTile();
|
WorldTile();
|
||||||
WorldTile(const Point2f& position, GroundTileTypes groundTileType);
|
WorldTile(const Point2f& position, GroundTileTypes groundTileType);
|
||||||
|
~WorldTile();
|
||||||
|
|
||||||
void Draw() const;
|
void Draw() const;
|
||||||
|
|
||||||
Point2f GetPosition() const { return m_Position; }
|
Point2f GetPosition() const { return m_Position; }
|
||||||
void SetPosition(const Point2f& position) { m_Position = position; }
|
void SetPosition(const Point2f& position) { m_Position = position; }
|
||||||
|
|
||||||
|
Point2f GetSize() const { return Point2f{ 50, 50 }; }
|
||||||
|
|
||||||
|
GroundTileTypes GetTileType() const { return m_GroundTileType; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Point2f m_Position;
|
Point2f m_Position;
|
||||||
GroundTileTypes m_GroundTileType;
|
GroundTileTypes m_GroundTileType;
|
||||||
|
|
||||||
|
Texture* m_pTexture;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
void StartHeapControl();
|
void StartHeapControl();
|
||||||
void DumpMemoryLeaks();
|
void DumpMemoryLeaks();
|
||||||
|
|
||||||
int SDL_main(int argv, char** args) {
|
int SDL_main(int argv, char** args)
|
||||||
|
{
|
||||||
srand(static_cast<unsigned int>(time(nullptr)));
|
srand(static_cast<unsigned int>(time(nullptr)));
|
||||||
|
|
||||||
StartHeapControl();
|
StartHeapControl();
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1
|
|||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Engine", "Engine\Engine.vcxproj", "{5ADAB721-CB6C-4EF5-89EB-20EC51A13CFC}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Engine", "Engine\Engine.vcxproj", "{5ADAB721-CB6C-4EF5-89EB-20EC51A13CFC}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Game", "Game\Game.vcxproj", "{0F40114E-3E0C-4195-B425-91FD5EF586AD}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Game", "Game\Game.vcxproj", "{0F40114E-3E0C-4195-B425-91FD5EF586AD}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{5ADAB721-CB6C-4EF5-89EB-20EC51A13CFC} = {5ADAB721-CB6C-4EF5-89EB-20EC51A13CFC}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|||||||
BIN
Resources/VisualStudioBad.png
Normal file
|
After Width: | Height: | Size: 232 KiB |
BIN
Resources/test.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
30
Resources/tiles/dirt/ConvertTexture.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import os
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
def convert_to_32bit(file_path):
|
||||||
|
try:
|
||||||
|
# Open the image
|
||||||
|
image = Image.open(file_path)
|
||||||
|
|
||||||
|
# Convert to 32-bit color depth
|
||||||
|
if image.mode != 'RGBA':
|
||||||
|
image = image.convert('RGBA')
|
||||||
|
|
||||||
|
# Save the converted image
|
||||||
|
converted_file_path = file_path.replace('.png', '_32bit.png')
|
||||||
|
image.save(converted_file_path)
|
||||||
|
|
||||||
|
print(f"Conversion complete for '{file_path}'. Saved as '{converted_file_path}'")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
script_directory = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
png_files = [f for f in os.listdir(script_directory) if f.lower().endswith('.png')]
|
||||||
|
|
||||||
|
if not png_files:
|
||||||
|
print("No .png files found in the script directory.")
|
||||||
|
else:
|
||||||
|
for file_name in png_files:
|
||||||
|
file_path = os.path.join(script_directory, file_name)
|
||||||
|
convert_to_32bit(file_path)
|
||||||
BIN
Resources/tiles/dirt/dirt1.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
Resources/tiles/dirt/dirt2.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
Resources/tiles/dirt/dirt3.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
Resources/tiles/dirt/dirt4.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
Resources/tiles/dirt/dirt5.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |