diff --git a/.vs/OpenNitemare3D/v16/.suo b/.vs/OpenNitemare3D/v16/.suo
new file mode 100644
index 0000000..d3ec948
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/.suo differ
diff --git a/.vs/OpenNitemare3D/v16/Browse.VC.db b/.vs/OpenNitemare3D/v16/Browse.VC.db
new file mode 100644
index 0000000..e327d9d
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/Browse.VC.db differ
diff --git a/.vs/OpenNitemare3D/v16/Browse.VC.opendb b/.vs/OpenNitemare3D/v16/Browse.VC.opendb
new file mode 100644
index 0000000..ac93209
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/Browse.VC.opendb differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/1928eadcb1516338/IMG.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/1928eadcb1516338/IMG.ipch
new file mode 100644
index 0000000..282a71c
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/1928eadcb1516338/IMG.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/31ee4db49cd13b60/FRANKENSTEIN.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/31ee4db49cd13b60/FRANKENSTEIN.ipch
new file mode 100644
index 0000000..8ebe6d9
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/31ee4db49cd13b60/FRANKENSTEIN.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/32ed6a55a19f24d0/ENTITY.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/32ed6a55a19f24d0/ENTITY.ipch
new file mode 100644
index 0000000..84bf8bb
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/32ed6a55a19f24d0/ENTITY.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/3b12e172e3b39c5/VECTOR2F.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/3b12e172e3b39c5/VECTOR2F.ipch
new file mode 100644
index 0000000..6fee435
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/3b12e172e3b39c5/VECTOR2F.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/69b07e04aab473f3/GRAPHICS.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/69b07e04aab473f3/GRAPHICS.ipch
new file mode 100644
index 0000000..acc3ee2
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/69b07e04aab473f3/GRAPHICS.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/8b37597dca4975e8/IMG.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/8b37597dca4975e8/IMG.ipch
new file mode 100644
index 0000000..3caa9ee
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/8b37597dca4975e8/IMG.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/9dcae4ffcdd763d3/CAMERA.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/9dcae4ffcdd763d3/CAMERA.ipch
new file mode 100644
index 0000000..f9f6523
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/9dcae4ffcdd763d3/CAMERA.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/b09d9874587a9841/PLAYER.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/b09d9874587a9841/PLAYER.ipch
new file mode 100644
index 0000000..30d87a9
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/b09d9874587a9841/PLAYER.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/ca9b1765d8ac28b5/MAIN.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/ca9b1765d8ac28b5/MAIN.ipch
new file mode 100644
index 0000000..cec50f8
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/ca9b1765d8ac28b5/MAIN.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/d87d2f071a6ebce8/PLAYER.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/d87d2f071a6ebce8/PLAYER.ipch
new file mode 100644
index 0000000..bfeaeca
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/d87d2f071a6ebce8/PLAYER.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/eaf53f264122bd90/CAMERA.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/eaf53f264122bd90/CAMERA.ipch
new file mode 100644
index 0000000..d801674
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/eaf53f264122bd90/CAMERA.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/ecac06d9ff905868/PAL.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/ecac06d9ff905868/PAL.ipch
new file mode 100644
index 0000000..8572dc1
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/ecac06d9ff905868/PAL.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/fab4132d98ba3e92/VECTOR2I.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/fab4132d98ba3e92/VECTOR2I.ipch
new file mode 100644
index 0000000..d4b5e3f
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/fab4132d98ba3e92/VECTOR2I.ipch differ
diff --git a/.vs/OpenNitemare3D/v16/ipch/AutoPCH/fef95d281b70be38/PAL.ipch b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/fef95d281b70be38/PAL.ipch
new file mode 100644
index 0000000..ea72bca
Binary files /dev/null and b/.vs/OpenNitemare3D/v16/ipch/AutoPCH/fef95d281b70be38/PAL.ipch differ
diff --git a/OpenNitemare3D.sln b/OpenNitemare3D.sln
new file mode 100644
index 0000000..2d2ba54
--- /dev/null
+++ b/OpenNitemare3D.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30011.22
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenNitemare3D", "OpenNitemare3D\OpenNitemare3D.vcxproj", "{0B6E6793-6D5A-4C27-8E36-97D728BE51A3}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0B6E6793-6D5A-4C27-8E36-97D728BE51A3}.Debug|x64.ActiveCfg = Debug|x64
+ {0B6E6793-6D5A-4C27-8E36-97D728BE51A3}.Debug|x64.Build.0 = Debug|x64
+ {0B6E6793-6D5A-4C27-8E36-97D728BE51A3}.Debug|x86.ActiveCfg = Debug|Win32
+ {0B6E6793-6D5A-4C27-8E36-97D728BE51A3}.Debug|x86.Build.0 = Debug|Win32
+ {0B6E6793-6D5A-4C27-8E36-97D728BE51A3}.Release|x64.ActiveCfg = Release|x64
+ {0B6E6793-6D5A-4C27-8E36-97D728BE51A3}.Release|x64.Build.0 = Release|x64
+ {0B6E6793-6D5A-4C27-8E36-97D728BE51A3}.Release|x86.ActiveCfg = Release|Win32
+ {0B6E6793-6D5A-4C27-8E36-97D728BE51A3}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {BDE9FC5A-C18A-48D5-A314-522C166C69BA}
+ EndGlobalSection
+EndGlobal
diff --git a/OpenNitemare3D/Debug/OpenNitemare3D.log b/OpenNitemare3D/Debug/OpenNitemare3D.log
new file mode 100644
index 0000000..48f8a1d
--- /dev/null
+++ b/OpenNitemare3D/Debug/OpenNitemare3D.log
@@ -0,0 +1,8 @@
+ img.cpp
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\engine\img\img.cpp(89,24): warning C4018: '<=': signed/unsigned mismatch
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\engine\img\img.cpp(100,10): error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\engine\img\img.cpp(96,11): warning C4101: 'temp': unreferenced local variable
+ pal.cpp
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\engine\pal\pal.cpp(45,25): warning C4018: '<=': signed/unsigned mismatch
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\engine\pal\pal.cpp(28,16): error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ Generating Code...
diff --git a/OpenNitemare3D/Debug/OpenNitemare3D.tlog/CL.command.1.tlog b/OpenNitemare3D/Debug/OpenNitemare3D.tlog/CL.command.1.tlog
new file mode 100644
index 0000000..46b134b
--- /dev/null
+++ b/OpenNitemare3D/Debug/OpenNitemare3D.tlog/CL.command.1.tlog
@@ -0,0 +1 @@
+ÿþ
\ No newline at end of file
diff --git a/OpenNitemare3D/Debug/OpenNitemare3D.tlog/OpenNitemare3D.lastbuildstate b/OpenNitemare3D/Debug/OpenNitemare3D.tlog/OpenNitemare3D.lastbuildstate
new file mode 100644
index 0000000..1645373
--- /dev/null
+++ b/OpenNitemare3D/Debug/OpenNitemare3D.tlog/OpenNitemare3D.lastbuildstate
@@ -0,0 +1,2 @@
+PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.25.28610:TargetPlatformVersion=10.0.18362.0:
+Debug|Win32|C:\Users\robot\source\repos\OpenNitemare3D\|
diff --git a/OpenNitemare3D/Debug/OpenNitemare3D.tlog/unsuccessfulbuild b/OpenNitemare3D/Debug/OpenNitemare3D.tlog/unsuccessfulbuild
new file mode 100644
index 0000000..e69de29
diff --git a/OpenNitemare3D/Debug/vc142.idb b/OpenNitemare3D/Debug/vc142.idb
new file mode 100644
index 0000000..5af0e3f
Binary files /dev/null and b/OpenNitemare3D/Debug/vc142.idb differ
diff --git a/OpenNitemare3D/Debug/vc142.pdb b/OpenNitemare3D/Debug/vc142.pdb
new file mode 100644
index 0000000..b795a2b
Binary files /dev/null and b/OpenNitemare3D/Debug/vc142.pdb differ
diff --git a/OpenNitemare3D/OpenNitemare3D.vcxproj b/OpenNitemare3D/OpenNitemare3D.vcxproj
new file mode 100644
index 0000000..8f25295
--- /dev/null
+++ b/OpenNitemare3D/OpenNitemare3D.vcxproj
@@ -0,0 +1,184 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ {0B6E6793-6D5A-4C27-8E36-97D728BE51A3}
+ OpenNitemare3D
+ 10.0
+
+
+
+ Application
+ true
+ v142
+ Unicode
+
+
+ Application
+ false
+ v142
+ true
+ Unicode
+
+
+ Application
+ true
+ v142
+ Unicode
+
+
+ Application
+ false
+ v142
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OpenNitemare3D/OpenNitemare3D.vcxproj.filters b/OpenNitemare3D/OpenNitemare3D.vcxproj.filters
new file mode 100644
index 0000000..0995470
--- /dev/null
+++ b/OpenNitemare3D/OpenNitemare3D.vcxproj.filters
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+ {d1cda2ce-c33e-4864-bc44-d037e036f83e}
+
+
+ {7db0c3c1-4803-4975-9851-3ee5fdc24d79}
+
+
+ {cecc57ac-9712-4776-8c11-c3cef62783bf}
+
+
+ {390196a0-f76a-4eb7-a12e-9aef2d6e5b77}
+
+
+ {a9761b7f-8a41-4590-8962-72d5b1ef2c86}
+
+
+ {72b5627f-c898-482e-ac21-444ff36fcc2e}
+
+
+ {a0a8a9ec-16ea-426b-ab88-e275720d80f2}
+
+
+ {7328e56c-da6c-4960-83e0-bffcd1fc5d0b}
+
+
+ {d23c70d9-4f5e-4edc-9928-352ada0ad377}
+
+
+ {16229d52-3d60-4766-bb18-353b4b6f89b9}
+
+
+ {503263a6-a637-43c3-8cf8-07e215306731}
+
+
+
+
+ engine\img
+
+
+ engine\pal
+
+
+
+ engine\math
+
+
+ engine\entity
+
+
+ engine\math
+
+
+ engine\camera
+
+
+ game\entities\player
+
+
+
+
+ engine\img
+
+
+ engine\pal
+
+
+ engine\entity
+
+
+ engine\math
+
+
+ engine\math
+
+
+ game\entities
+
+
+ engine\img
+
+
+ engine\img
+
+
+ engine\camera
+
+
+ engine\map
+
+
+ game\entities\player
+
+
+
\ No newline at end of file
diff --git a/OpenNitemare3D/OpenNitemare3D.vcxproj.user b/OpenNitemare3D/OpenNitemare3D.vcxproj.user
new file mode 100644
index 0000000..5df420f
--- /dev/null
+++ b/OpenNitemare3D/OpenNitemare3D.vcxproj.user
@@ -0,0 +1,6 @@
+
+
+
+ false
+
+
\ No newline at end of file
diff --git a/OpenNitemare3D/Release/Camera.obj b/OpenNitemare3D/Release/Camera.obj
new file mode 100644
index 0000000..bd5298a
Binary files /dev/null and b/OpenNitemare3D/Release/Camera.obj differ
diff --git a/OpenNitemare3D/Release/Entity.obj b/OpenNitemare3D/Release/Entity.obj
new file mode 100644
index 0000000..a141f18
Binary files /dev/null and b/OpenNitemare3D/Release/Entity.obj differ
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.Build.CppClean.log b/OpenNitemare3D/Release/OpenNitemare3D.Build.CppClean.log
new file mode 100644
index 0000000..9e2915a
--- /dev/null
+++ b/OpenNitemare3D/Release/OpenNitemare3D.Build.CppClean.log
@@ -0,0 +1,21 @@
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\vc142.pdb
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\main.obj
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\player.obj
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\pal.obj
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\vector2i.obj
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\vector2f.obj
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\img.obj
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\entity.obj
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\camera.obj
+c:\users\robot\source\repos\opennitemare3d\release\opennitemare3d.exe
+c:\users\robot\source\repos\opennitemare3d\release\opennitemare3d.pdb
+c:\users\robot\source\repos\opennitemare3d\release\opennitemare3d.ipdb
+c:\users\robot\source\repos\opennitemare3d\release\opennitemare3d.iobj
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\vcpkg.applocal.log
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\opennitemare3d.tlog\cl.command.1.tlog
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\opennitemare3d.tlog\cl.read.1.tlog
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\opennitemare3d.tlog\cl.write.1.tlog
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\opennitemare3d.tlog\link.command.1.tlog
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\opennitemare3d.tlog\link.read.1.tlog
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\opennitemare3d.tlog\link.write.1.tlog
+c:\users\robot\source\repos\opennitemare3d\opennitemare3d\release\opennitemare3d.tlog\opennitemare3d.write.1u.tlog
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.log b/OpenNitemare3D/Release/OpenNitemare3D.log
new file mode 100644
index 0000000..842f194
--- /dev/null
+++ b/OpenNitemare3D/Release/OpenNitemare3D.log
@@ -0,0 +1,20 @@
+ main.cpp
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(49,54): warning C4309: 'argument': truncation of constant value
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(49,49): warning C4309: 'argument': truncation of constant value
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(49,44): warning C4309: 'argument': truncation of constant value
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(116,28): warning C4553: '==': result of expression not used; did you intend '='?
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(138,13): warning C4326: return type of 'main' should be 'int' instead of 'void'
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(323,60): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(324,60): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(332,24): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(354,25): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(357,32): warning C4244: 'argument': conversion from 'float' to 'Uint32', possible loss of data
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(387,53): warning C4309: 'argument': truncation of constant value
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(387,48): warning C4309: 'argument': truncation of constant value
+C:\Users\robot\source\repos\OpenNitemare3D\OpenNitemare3D\main.cpp(387,43): warning C4309: 'argument': truncation of constant value
+ Generating code
+ 1 of 439 functions ( 0.2%) were compiled, the rest were copied from previous compilation.
+ 0 functions were new in current compilation
+ 0 functions had inline decision re-evaluated but remain unchanged
+ Finished generating code
+ OpenNitemare3D.vcxproj -> C:\Users\robot\source\repos\OpenNitemare3D\Release\OpenNitemare3D.exe
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.tlog/CL.command.1.tlog b/OpenNitemare3D/Release/OpenNitemare3D.tlog/CL.command.1.tlog
new file mode 100644
index 0000000..6f484db
Binary files /dev/null and b/OpenNitemare3D/Release/OpenNitemare3D.tlog/CL.command.1.tlog differ
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.tlog/CL.read.1.tlog b/OpenNitemare3D/Release/OpenNitemare3D.tlog/CL.read.1.tlog
new file mode 100644
index 0000000..87c8b6a
Binary files /dev/null and b/OpenNitemare3D/Release/OpenNitemare3D.tlog/CL.read.1.tlog differ
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.tlog/CL.write.1.tlog b/OpenNitemare3D/Release/OpenNitemare3D.tlog/CL.write.1.tlog
new file mode 100644
index 0000000..36dc8ad
Binary files /dev/null and b/OpenNitemare3D/Release/OpenNitemare3D.tlog/CL.write.1.tlog differ
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.tlog/OpenNitemare3D.lastbuildstate b/OpenNitemare3D/Release/OpenNitemare3D.tlog/OpenNitemare3D.lastbuildstate
new file mode 100644
index 0000000..8f7b735
--- /dev/null
+++ b/OpenNitemare3D/Release/OpenNitemare3D.tlog/OpenNitemare3D.lastbuildstate
@@ -0,0 +1,2 @@
+PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.25.28610:TargetPlatformVersion=10.0.18362.0:
+Release|Win32|C:\Users\robot\source\repos\OpenNitemare3D\|
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.tlog/OpenNitemare3D.write.1u.tlog b/OpenNitemare3D/Release/OpenNitemare3D.tlog/OpenNitemare3D.write.1u.tlog
new file mode 100644
index 0000000..bc17f52
Binary files /dev/null and b/OpenNitemare3D/Release/OpenNitemare3D.tlog/OpenNitemare3D.write.1u.tlog differ
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.tlog/link.command.1.tlog b/OpenNitemare3D/Release/OpenNitemare3D.tlog/link.command.1.tlog
new file mode 100644
index 0000000..b0d74fd
Binary files /dev/null and b/OpenNitemare3D/Release/OpenNitemare3D.tlog/link.command.1.tlog differ
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.tlog/link.read.1.tlog b/OpenNitemare3D/Release/OpenNitemare3D.tlog/link.read.1.tlog
new file mode 100644
index 0000000..5ca71c0
Binary files /dev/null and b/OpenNitemare3D/Release/OpenNitemare3D.tlog/link.read.1.tlog differ
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.tlog/link.write.1.tlog b/OpenNitemare3D/Release/OpenNitemare3D.tlog/link.write.1.tlog
new file mode 100644
index 0000000..a12da91
Binary files /dev/null and b/OpenNitemare3D/Release/OpenNitemare3D.tlog/link.write.1.tlog differ
diff --git a/OpenNitemare3D/Release/OpenNitemare3D.vcxproj.FileListAbsolute.txt b/OpenNitemare3D/Release/OpenNitemare3D.vcxproj.FileListAbsolute.txt
new file mode 100644
index 0000000..e69de29
diff --git a/OpenNitemare3D/Release/Player.obj b/OpenNitemare3D/Release/Player.obj
new file mode 100644
index 0000000..cce69c4
Binary files /dev/null and b/OpenNitemare3D/Release/Player.obj differ
diff --git a/OpenNitemare3D/Release/Vector2f.obj b/OpenNitemare3D/Release/Vector2f.obj
new file mode 100644
index 0000000..0f9232d
Binary files /dev/null and b/OpenNitemare3D/Release/Vector2f.obj differ
diff --git a/OpenNitemare3D/Release/Vector2i.obj b/OpenNitemare3D/Release/Vector2i.obj
new file mode 100644
index 0000000..551d228
Binary files /dev/null and b/OpenNitemare3D/Release/Vector2i.obj differ
diff --git a/OpenNitemare3D/Release/img.obj b/OpenNitemare3D/Release/img.obj
new file mode 100644
index 0000000..72a4121
Binary files /dev/null and b/OpenNitemare3D/Release/img.obj differ
diff --git a/OpenNitemare3D/Release/main.obj b/OpenNitemare3D/Release/main.obj
new file mode 100644
index 0000000..d7bc450
Binary files /dev/null and b/OpenNitemare3D/Release/main.obj differ
diff --git a/OpenNitemare3D/Release/pal.obj b/OpenNitemare3D/Release/pal.obj
new file mode 100644
index 0000000..808f913
Binary files /dev/null and b/OpenNitemare3D/Release/pal.obj differ
diff --git a/OpenNitemare3D/Release/vc142.pdb b/OpenNitemare3D/Release/vc142.pdb
new file mode 100644
index 0000000..407d389
Binary files /dev/null and b/OpenNitemare3D/Release/vc142.pdb differ
diff --git a/OpenNitemare3D/Release/vcpkg.applocal.log b/OpenNitemare3D/Release/vcpkg.applocal.log
new file mode 100644
index 0000000..e02abfc
--- /dev/null
+++ b/OpenNitemare3D/Release/vcpkg.applocal.log
@@ -0,0 +1 @@
+
diff --git a/OpenNitemare3D/engine/camera/Camera.cpp b/OpenNitemare3D/engine/camera/Camera.cpp
new file mode 100644
index 0000000..19ccb2e
--- /dev/null
+++ b/OpenNitemare3D/engine/camera/Camera.cpp
@@ -0,0 +1,38 @@
+#include "Camera.h"
+
+Camera::Camera()
+{
+ //planeX = -0.65;
+ //planeY = 0.01;
+}
+
+void Camera::SetPosition(Vector2f position)
+{
+ SetPosition(position.x, position.y);
+}
+
+void Camera::SetPosition(float x, float y)
+{
+ position = Vector2f(x, y);
+
+}
+
+void Camera::SetRotation(float rotation)
+{
+ this->rotation = rotation;
+}
+
+Vector2f Camera::GetPosition()
+{
+ return position;
+}
+
+Vector2i Camera::GetGridPosition()
+{
+ return Vector2i(position.x / 64, position.y / 64);
+}
+
+float Camera::GetRotation()
+{
+ return rotation;
+}
diff --git a/OpenNitemare3D/engine/camera/Camera.h b/OpenNitemare3D/engine/camera/Camera.h
new file mode 100644
index 0000000..b626de4
--- /dev/null
+++ b/OpenNitemare3D/engine/camera/Camera.h
@@ -0,0 +1,29 @@
+#ifndef _CAMERA_H
+#define _CAMERA_H
+#include "../math/Vector2f.h"
+#include
+#include "../math/Vector2i.h"
+class Camera {
+private:
+ Vector2f plane;
+ Vector2f position;
+ Vector2i gridPosition;
+ float rotation;
+public:
+ Camera();
+
+ //setters
+ void SetPosition(Vector2f position);
+ void SetPosition(float x, float y);
+ void SetRotation(float rotation);
+ double planeX = -0, planeY = 0.66; //the 2d raycaster version of camera plane
+
+
+ //getters
+ Vector2f GetPosition();
+ Vector2i GetGridPosition();
+ float GetRotation();
+};
+
+
+#endif
\ No newline at end of file
diff --git a/OpenNitemare3D/engine/entity/Entity.cpp b/OpenNitemare3D/engine/entity/Entity.cpp
new file mode 100644
index 0000000..ad7843e
--- /dev/null
+++ b/OpenNitemare3D/engine/entity/Entity.cpp
@@ -0,0 +1,65 @@
+#include "Entity.h"
+
+void Entity::AddEntity(Entity* entity)
+{
+}
+
+Entity::Entity()
+{
+ SetPosition(0, 0);
+ SetRotation(0);
+}
+
+Vector2f Entity::GetPosition()
+{
+ return position;
+}
+
+Vector2i Entity::GetTilePosition()
+{
+ return Vector2i((int)position.x, (int)position.y );
+}
+
+Vector2i Entity::GetHitBox()
+{
+ return hitbox;
+}
+
+float Entity::GetRotation()
+{
+ return rotation;
+}
+
+void Entity::SetPosition(float x, float y)
+{
+ position.x = x;
+ position.y = y;
+}
+
+void Entity::SetPosition(Vector2f position)
+{
+ SetPosition(position.x, position.y);
+}
+
+void Entity::SetRotation(float rotation)
+{
+ this->rotation = rotation;
+}
+
+void Entity::SetHitBox(int w, int h)
+{
+ hitbox = Vector2i(w, h);
+}
+
+void Entity::SetHitBox(Vector2i hitbox)
+{
+ this->hitbox = hitbox;
+}
+
+void Entity::Update(float deltaTime)
+{
+}
+
+void Entity::OnCollision(Entity* sender)
+{
+}
diff --git a/OpenNitemare3D/engine/entity/Entity.h b/OpenNitemare3D/engine/entity/Entity.h
new file mode 100644
index 0000000..a25455b
--- /dev/null
+++ b/OpenNitemare3D/engine/entity/Entity.h
@@ -0,0 +1,45 @@
+#ifndef _ENTITY_H
+#define _ENTITY_H
+#include "../camera/Camera.h"
+#include "../map/Map.h"
+#include
+class Entity {
+
+protected:
+ Vector2f position;
+ Vector2i tilePosition;
+ Vector2i hitbox;
+ int sprite;
+ float rotation;
+ std::vector* entities;
+
+ void AddEntity(Entity* entity);
+ Camera* camera;
+ Map map;
+
+public:
+ Entity();
+
+ //getters
+ Vector2f GetPosition();
+ Vector2i GetTilePosition();
+ Vector2i GetHitBox();
+ float GetRotation();
+
+ //setters
+ void SetPosition(float x, float y);
+ void SetPosition(Vector2f position);
+ void SetRotation(float rotation);
+ void SetHitBox(int w, int h);
+ void SetHitBox(Vector2i hitbox);
+
+
+
+ //functions
+ void Update(float deltaTime);
+ void OnCollision(Entity* sender);
+
+
+};
+
+#endif
\ No newline at end of file
diff --git a/OpenNitemare3D/engine/img/Color.h b/OpenNitemare3D/engine/img/Color.h
new file mode 100644
index 0000000..726bc8f
--- /dev/null
+++ b/OpenNitemare3D/engine/img/Color.h
@@ -0,0 +1,27 @@
+#ifndef _COLOR_H
+#define _COLOR_H
+//because SDL_Color took up too many bytes
+
+struct Color {
+
+
+ std::int8_t r, g, b;
+ Color(std::int8_t r, std::int8_t g, std::int8_t b) {
+ this->r = r;
+ this->g = g;
+ this->b = b;
+ }
+ Color() {
+
+ }
+
+ friend bool operator!=(const Color& a, const Color& b) {
+ if (a.r != b.r && a.b != b.b && a.g != b.g) {
+ return true;
+ }
+ return false;
+ }
+};
+
+
+#endif // !_COLOR_H
diff --git a/OpenNitemare3D/engine/img/Sprite.h b/OpenNitemare3D/engine/img/Sprite.h
new file mode 100644
index 0000000..038dcff
--- /dev/null
+++ b/OpenNitemare3D/engine/img/Sprite.h
@@ -0,0 +1,22 @@
+#ifndef _SPRITE_H
+#define _SPRITE_H
+#include "Color.h"
+#include
+
+struct Sprite {
+public:
+ std::int8_t width, height;
+ std::vector buffer;
+ Sprite(std::int8_t width, std::int8_t height, std::vector buffer) {
+ this->width = width;
+ this->height = height;
+ this->buffer = buffer;
+ }
+ Sprite() {
+
+ }
+
+
+};
+
+#endif
\ No newline at end of file
diff --git a/OpenNitemare3D/engine/img/img.cpp b/OpenNitemare3D/engine/img/img.cpp
new file mode 100644
index 0000000..db51649
--- /dev/null
+++ b/OpenNitemare3D/engine/img/img.cpp
@@ -0,0 +1,140 @@
+#include
+#include
+#include "img.h"
+
+
+
+
+Sprite* IMG::operator [](size_t index)
+{
+ if (index > mSurfaces.size())
+ {
+ return NULL;
+ }
+
+
+ return mSurfaces[index];
+}
+
+size_t IMG::GetNumImages()
+{
+ return mSurfaces.size();
+}
+
+
+
+int IMG::ReadFiles(FILE* pFile, offsetVector& offsets)
+{
+ //color buffer[MAX_SIZE * MAX_SIZE];
+ std::vector buffer;
+ uint8_t sizeX;
+ uint8_t sizeY;
+ uint8_t pixValue;
+
+ if (fseek(pFile, offsets[0], SEEK_SET) != 0)
+ {
+ printf("Failed to seek to next file in list; malformed?\n");
+ return IMG_NOK;
+ }
+
+
+ while (feof(pFile) == false)
+ {
+ int j = 0;
+ fread(&sizeX, 1, 1, pFile);
+ fread(&sizeY, 1, 1, pFile);
+ fseek(pFile, 8, SEEK_CUR);
+ for (int i = 0; i < sizeX * sizeY; i++)
+ {
+ fread(&pixValue, 1, 1, pFile);
+ buffer.push_back(mPal[pixValue]);
+ }
+ Sprite* s = new Sprite(sizeX, sizeY, buffer);
+
+ mSurfaces.push_back(s);
+ buffer.clear();
+ }
+
+
+ return IMG_OK;
+}
+void IMG::GetFileOffsets(FILE* pFile, offsetVector& offsets)
+{
+ int retval;
+ uint32_t offset;
+ uint32_t lowestOffset = 0xFFFFFFFF;
+
+ do
+ {
+ retval = fread(&offset, 4, 1, pFile);
+ if (offset != 0)
+ {
+ offsets.push_back(offset);
+ if (offset < lowestOffset)
+ {
+ lowestOffset = offset;
+ }
+ }
+ } while (ftell(pFile) <= lowestOffset && retval > 0);
+}
+
+int IMG::LoadImgFile(std::string imgFile)
+{
+ FILE* pFile;
+ offsetVector fileOffsets;
+ uint32_t temp;
+
+ fileOffsets.clear();
+
+ pFile = fopen(imgFile.c_str(), "rb");
+ if (pFile == NULL)
+ {
+ printf("could not open IMG file\n");
+ return IMG_NOK;
+ }
+
+ fseek(pFile, 4, SEEK_SET);
+
+
+
+ GetFileOffsets(pFile, fileOffsets);
+ if (ReadFiles(pFile, fileOffsets) == IMG_NOK)
+ {
+ return IMG_NOK;
+ }
+
+ return IMG_OK;
+}
+
+int IMG::Init(std::string palFile, std::string imgFile)
+{
+ if (mPal.ReadPal(palFile, APPARENT_OFFSET) != PAL_OK)
+ {
+ return IMG_NOK;
+ }
+
+ if (LoadImgFile(imgFile) != IMG_OK)
+ {
+ return IMG_NOK;
+ }
+
+ return IMG_OK;
+}
+
+void IMG::Cleanup()
+{
+
+
+
+}
+
+IMG::IMG()
+{
+
+}
+
+IMG::~IMG()
+{
+ Cleanup();
+}
+
diff --git a/OpenNitemare3D/engine/img/img.h b/OpenNitemare3D/engine/img/img.h
new file mode 100644
index 0000000..44c4680
--- /dev/null
+++ b/OpenNitemare3D/engine/img/img.h
@@ -0,0 +1,49 @@
+#ifndef _IMG_H
+#define _IMG_H
+
+#include
+#include "../pal/pal.h"
+#include "Sprite.h"
+#undef main
+
+#define APPARENT_OFFSET 1156
+#define MAX_SIZE 255
+
+#define IMG_OK 0
+#define IMG_NOK -1
+
+
+
+
+class IMG
+{
+private:
+ typedef std::vector surfaceVector;
+ typedef std::vector offsetVector;
+ std::vector sprites;
+
+ surfaceVector mSurfaces;
+
+ int ReadFiles(FILE *pFile, offsetVector &offsets);
+ int LoadImgFile(std::string imgFile);
+ void GetFileOffsets(FILE *pFile, offsetVector &offsets);
+
+protected:
+
+public:
+
+
+
+
+ PAL mPal;
+ int Init(std::string palFile, std::string imgFile);
+ void Cleanup();
+
+ size_t GetNumImages();
+ Sprite* operator [](size_t index);
+
+ IMG();
+ ~IMG();
+};
+
+#endif
diff --git a/OpenNitemare3D/engine/map/Map.h b/OpenNitemare3D/engine/map/Map.h
new file mode 100644
index 0000000..031f6ad
--- /dev/null
+++ b/OpenNitemare3D/engine/map/Map.h
@@ -0,0 +1,13 @@
+#ifndef _MAP_H
+#define _MAP_H
+#include
+class Map {
+public:
+ std::vector maptiles;
+ Map() {
+
+ }
+
+
+};
+#endif // !_MAP_H
diff --git a/OpenNitemare3D/engine/math/Vector2f.cpp b/OpenNitemare3D/engine/math/Vector2f.cpp
new file mode 100644
index 0000000..69821c3
--- /dev/null
+++ b/OpenNitemare3D/engine/math/Vector2f.cpp
@@ -0,0 +1,13 @@
+#include "Vector2f.h"
+
+Vector2f::Vector2f()
+{
+ x = 0;
+ y = 0;
+}
+
+Vector2f::Vector2f(float x, float y)
+{
+ this->x = x;
+ this->y = y;
+}
diff --git a/OpenNitemare3D/engine/math/Vector2f.h b/OpenNitemare3D/engine/math/Vector2f.h
new file mode 100644
index 0000000..63579a4
--- /dev/null
+++ b/OpenNitemare3D/engine/math/Vector2f.h
@@ -0,0 +1,12 @@
+#ifndef _VECTOR2F_H
+#define _VECTOR2F_H
+class Vector2f {
+public:
+ float x, y;
+ Vector2f();
+ Vector2f(float x, float y);
+
+};
+
+
+#endif
\ No newline at end of file
diff --git a/OpenNitemare3D/engine/math/Vector2i.cpp b/OpenNitemare3D/engine/math/Vector2i.cpp
new file mode 100644
index 0000000..9d9bb17
--- /dev/null
+++ b/OpenNitemare3D/engine/math/Vector2i.cpp
@@ -0,0 +1,13 @@
+#include "Vector2i.h"
+
+Vector2i::Vector2i()
+{
+ x = 0;
+ y = 0;
+}
+
+Vector2i::Vector2i(int x, int y)
+{
+ this->x = x;
+ this->y = y;
+}
diff --git a/OpenNitemare3D/engine/math/Vector2i.h b/OpenNitemare3D/engine/math/Vector2i.h
new file mode 100644
index 0000000..42e8c09
--- /dev/null
+++ b/OpenNitemare3D/engine/math/Vector2i.h
@@ -0,0 +1,11 @@
+#ifndef _VECTOR2I_H
+#define _VECTOR2FI_H
+class Vector2i {
+public:
+ int x, y;
+ Vector2i();
+ Vector2i(int x, int y);
+
+};
+
+#endif
\ No newline at end of file
diff --git a/OpenNitemare3D/engine/pal/pal.cpp b/OpenNitemare3D/engine/pal/pal.cpp
new file mode 100644
index 0000000..457897b
--- /dev/null
+++ b/OpenNitemare3D/engine/pal/pal.cpp
@@ -0,0 +1,76 @@
+#include
+
+#include "pal.h"
+
+#define RED 0
+#define GREEN 1
+#define BLUE 2
+
+size_t PAL::GetFileSize(FILE * pFile)
+{
+ size_t fileLen;
+
+ fseek(pFile, 0, SEEK_END);
+ fileLen = ftell(pFile);
+ rewind(pFile);
+
+ return fileLen;
+}
+
+unsigned int PAL::ReadPal(std::string filename, uint32_t offset)
+{
+ uint8_t buffer[3];
+ Color curPal;
+ size_t fileLen;
+
+ mPalettes.clear();
+
+ FILE* pFile = fopen(filename.c_str(), "rb");
+ if (pFile == NULL)
+ {
+ printf("File could not be opened\n");
+ return PAL_NOK;
+ }
+
+ fileLen = GetFileSize(pFile);
+
+ if (offset > fileLen)
+ {
+ printf("Offset greater than file size\n");
+ return PAL_NOK;
+ }
+
+ fseek(pFile, offset, SEEK_SET);
+
+ for (int i = offset; i <= fileLen; i += 3)
+ {
+ fread(buffer, 1, 3, pFile);
+ curPal.r = buffer[RED];
+ curPal.g = buffer[GREEN];
+ curPal.b = buffer[BLUE];
+
+ mPalettes.push_back(curPal);
+ }
+
+ return PAL_OK;
+}
+
+size_t PAL::GetNumPalettes()
+{
+ return mPalettes.size();
+}
+
+Color PAL::operator [](size_t index)
+{
+ return mPalettes[index];
+}
+
+PAL::PAL()
+{
+
+}
+
+PAL::~PAL()
+{
+
+}
diff --git a/OpenNitemare3D/engine/pal/pal.h b/OpenNitemare3D/engine/pal/pal.h
new file mode 100644
index 0000000..174f3d9
--- /dev/null
+++ b/OpenNitemare3D/engine/pal/pal.h
@@ -0,0 +1,39 @@
+#ifndef __PAL_H__
+#define __PAL_H__
+
+#include
+#include
+
+#include
+#include "../img/Color.h"
+
+#define PAL_OK 0
+#define PAL_NOK -1
+
+/*
+typedef struct
+{
+ std::int8_t r;
+ std::int8_t g;
+ std::int8_t b;
+}Palette;
+*/
+class PAL
+{
+private:
+ std::vector mPalettes;
+
+ size_t GetFileSize(FILE *pFile);
+
+protected:
+
+public:
+ unsigned int ReadPal(std::string filename, uint32_t offset);
+ size_t GetNumPalettes();
+ Color operator[](size_t);
+
+ PAL();
+ ~PAL();
+};
+
+#endif
diff --git a/OpenNitemare3D/game/entities/Frankenstein.h b/OpenNitemare3D/game/entities/Frankenstein.h
new file mode 100644
index 0000000..15d799c
--- /dev/null
+++ b/OpenNitemare3D/game/entities/Frankenstein.h
@@ -0,0 +1,5 @@
+#pragma once
+#include "../../engine/entity/Entity.h"
+class Frankenstein : public Entity {
+
+};
\ No newline at end of file
diff --git a/OpenNitemare3D/game/entities/player/Player.cpp b/OpenNitemare3D/game/entities/player/Player.cpp
new file mode 100644
index 0000000..754e28c
--- /dev/null
+++ b/OpenNitemare3D/game/entities/player/Player.cpp
@@ -0,0 +1,56 @@
+#include "Player.h"
+#include
+#include
+Player::Player()
+{
+
+}
+
+Player::Player(float x, float y, Camera* camera, Map map)
+{
+ SetPosition(x + 20, y);
+ SetRotation(0);
+ this->camera = camera;
+ this->map = map;
+
+}
+
+void Player::Update(float deltaTime)
+{
+ //SetRotation_(90);
+ float rotSpeed = deltaTime * 3; //the constant value is in radians/second
+ float oldRot = rotation;
+ const Uint8* state = SDL_GetKeyboardState(NULL);
+ if (state[SDL_SCANCODE_UP]) {
+
+ //if (worldMap[int(posX + dirX * moveSpeed)][int(posY)] == false) posX += dirX * moveSpeed;
+ //if (worldMap[int(posX)][int(posY + dirY * moveSpeed)] == false) posY += dirY * moveSpeed;
+
+ position.x += dirX * speed * deltaTime;
+ position.y += dirY * speed * deltaTime;
+
+ }
+ if (state[SDL_SCANCODE_LEFT]) {
+ rotation -= rotSpeed;
+ }
+
+ if (state[SDL_SCANCODE_RIGHT]) {
+ rotation += rotSpeed;
+ }
+
+ dirX = cos(rotation);
+ dirY = sin(rotation);
+ float oldPlaneX = camera->planeX;
+ camera->planeX = camera->planeX * cos(rotation - oldRot) - camera->planeY * sin(rotation - oldRot);
+ camera->planeY = oldPlaneX * sin(rotation-oldRot) + camera->planeY*cos(rotation - oldRot);
+}
+
+void Player::OnCollision(Entity* sender)
+{
+}
+
+void Player::SetRotation_(float rot)
+{
+ camera->planeX = camera->planeX * cos(rot) - camera->planeY * sin(rot);
+ camera->planeY = camera->planeX * sin(rot) + camera->planeY * cos(rot);
+}
diff --git a/OpenNitemare3D/game/entities/player/Player.h b/OpenNitemare3D/game/entities/player/Player.h
new file mode 100644
index 0000000..9c5d8a9
--- /dev/null
+++ b/OpenNitemare3D/game/entities/player/Player.h
@@ -0,0 +1,18 @@
+#ifndef _PLAYER_H
+#define _PLAYER_H
+#include "../../../engine/entity/Entity.h"
+class Player : public Entity{
+private:
+
+public:
+ float speed = 3;
+ float rotation = 0;
+ Player();
+ Player(float x, float y, Camera* camera, Map map);
+ void Update(float deltaTime);
+ void OnCollision(Entity* sender);
+ void SetRotation_(float rot);
+ double dirX = -1.0, dirY = 0.0; //initial direction vector
+
+};
+#endif // !_PLAYER_H
diff --git a/OpenNitemare3D/main.cpp b/OpenNitemare3D/main.cpp
new file mode 100644
index 0000000..ff829ff
--- /dev/null
+++ b/OpenNitemare3D/main.cpp
@@ -0,0 +1,411 @@
+#include
+#undef main
+#include "engine/img/img.h"
+#include
+#include "game/entities/player/Player.h"
+#include
+#include
+IMG img;
+
+SDL_Window* window = SDL_CreateWindow("Nitemare 3D", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0);
+SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
+bool open = true;
+
+int ray_w = 320, ray_h = 200;
+
+
+
+Uint32* pixels = new Uint32[ray_w * ray_h];
+
+SDL_Texture* canvas = SDL_CreateTexture
+(
+ renderer,
+ SDL_PIXELFORMAT_ARGB8888,
+ SDL_TEXTUREACCESS_STREAMING,
+ ray_w, ray_h
+);
+
+static Uint32 ColourToUint(Color c)
+{
+ return (Uint32)((c.r << 16) + (c.g << 8) + (c.b << 0));
+}
+
+void DrawPixel(int x, int y, Color color) {
+ pixels[y * ray_w + x] = ColourToUint(color);
+}
+
+void ClearScreen() {
+ for (int x = 0; x < ray_w; x++) {
+ for (int y = 0; y < ray_h; y++) {
+ DrawPixel(x, y, Color(0, 0, 0));
+ }
+ }
+}
+
+void Draw2DSprite(Sprite* sprite, int x, int y) {
+ int i = 0;
+ for (int tx = 0; tx < sprite->width; tx++) {
+ for (int ty = 0; ty < sprite->height; ty++) {
+ if (sprite->buffer[i] != Color(255, 255, 255)) {
+ DrawPixel(tx + x, ty + y, sprite->buffer[i]);
+ }
+
+ i++;
+ }
+ }
+}
+
+struct wall {
+ std::int8_t x, y;
+ std::int8_t texture;
+};
+
+std::vector walls;
+
+
+Color GetPixel(Sprite* sprite, int x, int y) {
+ int i = x + y * 64;
+ return sprite->buffer[i];
+}
+
+
+
+std::vector offsets;
+char* mapbuff = new char[8192];
+void LoadMap(int index) {
+ std::ifstream is;
+
+ is.open("MAP.1", std::ios::binary);
+
+
+ is.seekg(514 + (8192*index));
+ is.read(mapbuff, 8192);
+}
+#include
+
+
+/*
+for some reason Nitemare 3D has room types for floors and draws the walls based the room type
+
+
+ floor layout in map file:
+ #####
+ #####
+ &&&&&
+
+ what's drawn:
+ WWWW
+ W####W
+ W####W
+ D&&&&D
+ DDDD
+
+ so now I have to write a bunch of sphagetti code to fix this
+*/
+void AddWalls(std::vector map) {
+ for (int x = 0; x < 64; x++) {
+ for (int y = 0; y < 64; y++) {
+ int i = x + y*64;
+
+ //if the nearby is empty, add wall
+ if (map[i] != 1) {
+ int X = x - 1;
+ int I = X + y * 64;
+ if (map[I] == 1) {
+ //std::cout << "Tile " << X << "," << y << " should be wall! \n";
+ map[I] == 420;
+ }
+ }
+ }
+ }
+}
+Uint32 time = 0; //time of current frame
+Uint32 oldTime = 0; //time of previous frame
+const int fps = 60;
+const int fpsDelay = 1000 / fps;
+Uint32 frameStart;
+int frameTime;
+
+int CalculateOffset(int index) {
+ if (index > 14) {
+ return index - 8;
+ }
+
+ return 0;
+}
+
+
+void main() {
+
+
+ LoadMap(0);
+ Map map;
+
+
+ std::ofstream myfile("map1.txt", std::ios::binary);
+ for (int i = 0; i < 64 * 64; i++) {
+ map.maptiles.push_back(0);
+ }
+ if (myfile.is_open())
+ {
+ int j = 0;
+ int k = 64 * 64;
+ for (int i = 0; i < 64 * 64*2; i++) {
+
+ if (i % 2 == 0) {
+
+ //maptiles.push_back(mapbuff[i]);
+ map.maptiles[j] = mapbuff[i];
+ k--;
+ j++;
+ myfile << mapbuff[i];
+
+ }
+
+
+ }
+
+ myfile.close();
+ }
+
+
+ AddWalls(map.maptiles);
+ /*
+ int j = 0;
+ for (int i = 0; i < 64 * 64 * 2; i++) {
+ if (j % 2 == 0) {
+ maptiles[i] = mapbuff[i];
+ }
+ }
+ */
+
+ Camera* c = new Camera();
+
+
+ img.Init("GAME.PAL", "IMG.1");
+
+ memset(pixels, 255, ray_w * ray_h * sizeof(Uint32));
+
+ SDL_Event event;
+ SDL_RenderSetLogicalSize(renderer, 320, 240);
+
+ Player* player = new Player(22, 56, c, map);
+ std::cout << "cock\n";
+
+
+
+ while (open) {
+ //std::cout << player->GetTilePosition().x << "," << player->GetTilePosition().y << std::endl;
+ Uint64 start = SDL_GetPerformanceCounter();
+ frameStart = SDL_GetTicks();
+ while (SDL_PollEvent(&event)) {
+
+ }
+ SDL_RenderClear(renderer);
+
+ ClearScreen();
+
+
+ for (int x = 0; x < ray_w; x++)
+ {
+ //calculate ray position and direction
+ double cameraX = 2 * x / double(ray_w) - 1; //x-coordinate in camera space
+ double rayDirX = player->dirX + c->planeX * cameraX;
+ double rayDirY = player->dirY + c->planeY * cameraX;
+ //which box of the map we're in
+
+ int mapX = player->GetTilePosition().x;//int(posX);
+ int mapY = player->GetTilePosition().y;//int(posY);
+
+ //length of ray from current position to next x or y-side
+ double sideDistX;
+ double sideDistY;
+
+ //length of ray from one x or y-side to next x or y-side
+ double deltaDistX = std::abs(1 / rayDirX);
+ double deltaDistY = std::abs(1 / rayDirY);
+ double perpWallDist;
+
+ //what direction to step in x or y-direction (either +1 or -1)
+ int stepX;
+ int stepY;
+
+ int hit = 0; //was there a wall hit?
+ int side; //was a NS or a EW wall hit?
+
+ // Alternative code for deltaDist in case division through zero is not supported
+ deltaDistX = (rayDirY == 0) ? 0 : ((rayDirX == 0) ? 1 : abs(1 / rayDirX));
+ deltaDistY = (rayDirX == 0) ? 0 : ((rayDirY == 0) ? 1 : abs(1 / rayDirY));
+
+
+ //calculate step and initial sideDist
+ if (rayDirX < 0)
+ {
+ stepX = -1;
+ sideDistX = (player->GetPosition().x - mapX) * deltaDistX;
+ }
+ else
+ {
+ stepX = 1;
+ sideDistX = (mapX + 1.0 - player->GetPosition().x) * deltaDistX;
+ }
+ if (rayDirY < 0)
+ {
+ stepY = -1;
+ sideDistY = (player->GetPosition().y - mapY) * deltaDistY;
+ }
+ else
+ {
+ stepY = 1;
+ sideDistY = (mapY + 1.0 - player->GetPosition().y) * deltaDistY;
+ }
+
+ int texture = 1;
+ //perform DDA
+ while (hit == 0)
+ {
+ //jump to next map square, OR in x-direction, OR in y-direction
+ if (sideDistX < sideDistY)
+ {
+ sideDistX += deltaDistX;
+ mapX += stepX;
+ side = 0;
+ }
+ else
+ {
+ sideDistY += deltaDistY;
+ mapY += stepY;
+ side = 1;
+ }
+ //Check if ray has hit a wall
+ //if (map.worldMap[mapX][mapY] > 0) hit9 = 1;
+
+
+ //what?
+ //int wall = map.maptiles[-(mapX - mapY * 64)];
+ int wall = map.maptiles[mapX + mapY * 64];
+ texture = wall;
+
+ if (texture >= 3) {
+ texture++;
+ }
+ if (texture >= 4) {
+ texture++;
+ }
+
+ if (wall <= 181 && wall > 0) hit = 1;
+
+
+
+ }
+
+
+
+ //Calculate distance projected on camera direction (Euclidean distance will give fisheye effect!)
+ if (side == 0) perpWallDist = (mapX - player->GetPosition().x + (1 - stepX) / 2) / rayDirX;
+ else perpWallDist = (mapY - player->GetPosition().y + (1 - stepY) / 2) / rayDirY;
+
+
+ //Calculate height of line to draw on screen
+ int lineHeight = (int)(ray_h / perpWallDist);
+
+ //calculate lowest and highest pixel to fill in current stripe
+ int drawStart = -lineHeight / 2 + ray_h / 2;
+ if (drawStart < 0)drawStart = 0;
+ int drawEnd = lineHeight / 2 + ray_h / 2;
+ if (drawEnd >= ray_h)drawEnd = ray_h - 1;
+
+ //texturing calculations
+ int texNum = 1;//map.worldMap[mapX][mapY] - 1; //1 subtracted from it so that texture 0 can be used!
+
+ //calculate value of wallX
+ float wallX; //where exactly the wall was hit
+ if (side == 0) wallX = player->GetPosition().y + perpWallDist * rayDirY;
+ else wallX = player->GetPosition().x + perpWallDist * rayDirX;
+ wallX -= floor((wallX));
+
+ //x coordinate on the texture
+ int texX = int(wallX * float(64));
+ if (side == 0 && rayDirX > 0) texX = 64 - texX - 1;
+ if (side == 1 && rayDirY < 0) texX = 64 - texX - 1;
+
+ float step = 1.0 * 64 / lineHeight;
+ // Starting texture coordinate
+ float texPos = (drawStart - ray_h / 2 + lineHeight / 2) * step;
+ for (int y = drawStart; y < drawEnd; y++)
+ {
+ // Cast the texture coordinate to integer, and mask with (texHeight - 1) in case of overflow
+ int texY = (int)texPos & (64 - 1);
+ texPos += step;
+
+ DrawPixel(x, y, GetPixel(img[texture], texY, texX));
+ }
+
+
+
+
+
+
+ }
+
+ oldTime = time;
+ time = SDL_GetTicks();
+
+ float frameTime = (time - oldTime) / 1000.0; //frametime is the time this frame has taken, in seconds
+
+ if (fpsDelay > frameTime) {
+ SDL_Delay(fpsDelay - frameTime);
+ }
+
+ Uint64 end = SDL_GetPerformanceCounter();
+
+ const Uint8* state = SDL_GetKeyboardState(NULL);
+
+
+ player->Update(frameTime);
+
+
+
+
+
+
+
+
+
+
+ //player->SetPosition(posX, posY);
+ Draw2DSprite(img[700], 160, 100);
+
+
+
+ for (int x = 0; x < 64; x++) {
+ for (int y = 0; y < 64; y++) {
+ int ti = -(x - y * 64);
+
+ if (map.maptiles[ti] != 1) {
+ //Draw2DSprite(img[1], x * 64, y * 64);
+ DrawPixel(x, y, Color(255, 255, 255));
+ }
+ else {
+ DrawPixel(x, y, Color(0, 0, 0));
+ }
+ }
+ }
+
+
+ DrawPixel(player->GetTilePosition().x, player->GetTilePosition().x, Color(0, 0, 0));
+
+
+ SDL_UpdateTexture(canvas, NULL, pixels, ray_w * sizeof(Uint32));
+ SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
+ SDL_RenderCopy(renderer, canvas, NULL, NULL);
+ SDL_RenderPresent(renderer);
+
+
+
+
+
+
+
+ }
+}
\ No newline at end of file
diff --git a/OpenNitemare3D/packages.config b/OpenNitemare3D/packages.config
new file mode 100644
index 0000000..de5c698
--- /dev/null
+++ b/OpenNitemare3D/packages.config
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file