diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 5f0b95d..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "Box"] - path = Box - url = https://github.com/Ratstail91/Box.git diff --git a/Airport.sln b/Airport.sln index ee6bc06..516911c 100644 --- a/Airport.sln +++ b/Airport.sln @@ -3,19 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.6.33801.468 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Airport", "Airport.vcxproj", "{B6819868-2E07-4E17-8B91-33E8B0D39530}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Airport", "Airport\Airport.vcxproj", "{B6819868-2E07-4E17-8B91-33E8B0D39530}" ProjectSection(ProjectDependencies) = postProject {26360002-CC2A-469A-9B28-BA0C1AF41657} = {26360002-CC2A-469A-9B28-BA0C1AF41657} {2937C4D3-5C8D-4E59-9B6D-452B409F4ABA} = {2937C4D3-5C8D-4E59-9B6D-452B409F4ABA} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Toy", "Box\Toy\Toy.vcxproj", "{26360002-CC2A-469A-9B28-BA0C1AF41657}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Box", "Box\Box.vcxproj", "{2937C4D3-5C8D-4E59-9B6D-452B409F4ABA}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Box", "Airport\Box\Box.vcxproj", "{2937C4D3-5C8D-4E59-9B6D-452B409F4ABA}" ProjectSection(ProjectDependencies) = postProject {26360002-CC2A-469A-9B28-BA0C1AF41657} = {26360002-CC2A-469A-9B28-BA0C1AF41657} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Toy", "Airport\Box\Toy\Toy.vcxproj", "{26360002-CC2A-469A-9B28-BA0C1AF41657}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -32,14 +32,6 @@ Global {B6819868-2E07-4E17-8B91-33E8B0D39530}.Release|x64.Build.0 = Release|x64 {B6819868-2E07-4E17-8B91-33E8B0D39530}.Release|x86.ActiveCfg = Release|Win32 {B6819868-2E07-4E17-8B91-33E8B0D39530}.Release|x86.Build.0 = Release|Win32 - {26360002-CC2A-469A-9B28-BA0C1AF41657}.Debug|x64.ActiveCfg = Debug|x64 - {26360002-CC2A-469A-9B28-BA0C1AF41657}.Debug|x64.Build.0 = Debug|x64 - {26360002-CC2A-469A-9B28-BA0C1AF41657}.Debug|x86.ActiveCfg = Debug|Win32 - {26360002-CC2A-469A-9B28-BA0C1AF41657}.Debug|x86.Build.0 = Debug|Win32 - {26360002-CC2A-469A-9B28-BA0C1AF41657}.Release|x64.ActiveCfg = Release|x64 - {26360002-CC2A-469A-9B28-BA0C1AF41657}.Release|x64.Build.0 = Release|x64 - {26360002-CC2A-469A-9B28-BA0C1AF41657}.Release|x86.ActiveCfg = Release|Win32 - {26360002-CC2A-469A-9B28-BA0C1AF41657}.Release|x86.Build.0 = Release|Win32 {2937C4D3-5C8D-4E59-9B6D-452B409F4ABA}.Debug|x64.ActiveCfg = Debug|x64 {2937C4D3-5C8D-4E59-9B6D-452B409F4ABA}.Debug|x64.Build.0 = Debug|x64 {2937C4D3-5C8D-4E59-9B6D-452B409F4ABA}.Debug|x86.ActiveCfg = Debug|Win32 @@ -48,6 +40,14 @@ Global {2937C4D3-5C8D-4E59-9B6D-452B409F4ABA}.Release|x64.Build.0 = Release|x64 {2937C4D3-5C8D-4E59-9B6D-452B409F4ABA}.Release|x86.ActiveCfg = Release|Win32 {2937C4D3-5C8D-4E59-9B6D-452B409F4ABA}.Release|x86.Build.0 = Release|Win32 + {26360002-CC2A-469A-9B28-BA0C1AF41657}.Debug|x64.ActiveCfg = Debug|x64 + {26360002-CC2A-469A-9B28-BA0C1AF41657}.Debug|x64.Build.0 = Debug|x64 + {26360002-CC2A-469A-9B28-BA0C1AF41657}.Debug|x86.ActiveCfg = Debug|Win32 + {26360002-CC2A-469A-9B28-BA0C1AF41657}.Debug|x86.Build.0 = Debug|Win32 + {26360002-CC2A-469A-9B28-BA0C1AF41657}.Release|x64.ActiveCfg = Release|x64 + {26360002-CC2A-469A-9B28-BA0C1AF41657}.Release|x64.Build.0 = Release|x64 + {26360002-CC2A-469A-9B28-BA0C1AF41657}.Release|x86.ActiveCfg = Release|Win32 + {26360002-CC2A-469A-9B28-BA0C1AF41657}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Airport.vcxproj b/Airport/Airport.vcxproj similarity index 93% rename from Airport.vcxproj rename to Airport/Airport.vcxproj index 2e76442..b2e07b5 100644 --- a/Airport.vcxproj +++ b/Airport/Airport.vcxproj @@ -117,7 +117,7 @@ _DEBUG;%(PreprocessorDefinitions) true stdc17 - $(SDL2Dir)\include;$(SDL2ImageDir)\include;$(SDL2MixerDir)\include;$(SDL2TTFDir)\include;$(SolutionDir)Box/source;$(SolutionDir)Box/Toy/source;%(AdditionalIncludeDirectories) + $(SDL2Dir)\include;$(SDL2ImageDir)\include;$(SDL2MixerDir)\include;$(SDL2TTFDir)\include;$(ProjectDir)Box/source;$(ProjectDir)Box/Toy/source Console @@ -131,8 +131,7 @@ xcopy "$(SDL2Dir)\lib\x64\SDL2.dll" "$(OutDir)" /Y /I /E xcopy "$(SDL2ImageDir)\lib\x64\SDL2_image.dll" "$(OutDir)" /Y /I /E xcopy "$(SDL2MixerDir)\lib\x64\SDL2_mixer.dll" "$(OutDir)" /Y /I /E -xcopy "$(SDL2TTFDir)\lib\x64\SDL2_ttf.dll" "$(OutDir)" /Y /I /E -xcopy "$(ProjectDir)assets" "$(Outdir)assets" /Y /I /E +xcopy "$(SDL2TTFDir)\lib\x64\SDL2_ttf.dll" "$(OutDir)" /Y /I /E $(Platform)\$(Configuration)\$(TargetName).bsc @@ -147,7 +146,7 @@ xcopy "$(ProjectDir)assets" "$(Outdir)assets" /Y /I /E NDEBUG;%(PreprocessorDefinitions) true stdc17 - $(SDL2Dir)\include;$(SDL2ImageDir)\include;$(SDL2MixerDir)\include;$(SDL2TTFDir)\include;$(SolutionDir)Box/source;$(SolutionDir)Box/Toy/source;%(AdditionalIncludeDirectories) + $(SDL2Dir)\include;$(SDL2ImageDir)\include;$(SDL2MixerDir)\include;$(SDL2TTFDir)\include;$(ProjectDir)Box/source;$(ProjectDir)Box/Toy/source None @@ -164,8 +163,7 @@ xcopy "$(ProjectDir)assets" "$(Outdir)assets" /Y /I /E xcopy "$(SDL2Dir)\lib\x64\SDL2.dll" "$(OutDir)" /Y /I /E xcopy "$(SDL2ImageDir)\lib\x64\SDL2_image.dll" "$(OutDir)" /Y /I /E xcopy "$(SDL2MixerDir)\lib\x64\SDL2_mixer.dll" "$(OutDir)" /Y /I /E -xcopy "$(SDL2TTFDir)\lib\x64\SDL2_ttf.dll" "$(OutDir)" /Y /I /E -xcopy "$(ProjectDir)assets" "$(Outdir)assets" /Y /I /E +xcopy "$(SDL2TTFDir)\lib\x64\SDL2_ttf.dll" "$(OutDir)" /Y /I /E $(Platform)\$(Configuration)\$(TargetName).bsc diff --git a/source/main.c b/Airport/source/main.c similarity index 100% rename from source/main.c rename to Airport/source/main.c diff --git a/source/makefile b/Airport/source/makefile similarity index 100% rename from source/makefile rename to Airport/source/makefile diff --git a/Box b/Box deleted file mode 160000 index ed1da29..0000000 --- a/Box +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ed1da2918647fa393f62f564dead39f2f7ef9b13 diff --git a/assets/scripts/tilemap/renderer.toy b/assets/scripts/tilemap/renderer.toy index 80ba8cf..f3a6292 100644 --- a/assets/scripts/tilemap/renderer.toy +++ b/assets/scripts/tilemap/renderer.toy @@ -69,7 +69,7 @@ fn shadowCastOctant(node: opaque, x: int, y: int, dirX: int, dirY: int, depth: i //for each tile, cast its shadow, and see if its already obscured for (var j: int = 0; abs(j) < depth; j += dirY) { - for (var i: int = 0; abs(i) < depth; i += dirX) { + for (var i: int = 0; abs(i) < abs(j); i += dirX) { //make sure this tile can actually cast a shadow var CACHE_ITERATION: int const = (y + j) * MAP_GRID_WIDTH * 2 + (x + i) * 2; var ITERATION: int const = (y + j) * MAP_GRID_WIDTH * 3 + (x + i) * 3; @@ -87,6 +87,10 @@ fn shadowCastOctant(node: opaque, x: int, y: int, dirX: int, dirY: int, depth: i //cast the shadow var shadow = shadowCastTile(i + x, j + y, dirX, dirY, depth); + if (shadow == null) { + continue; + } + //merge shadows if needed var index: int = 0; @@ -127,12 +131,17 @@ fn shadowCastOctant(node: opaque, x: int, y: int, dirX: int, dirY: int, depth: i if (index > 0 && shadows.length() > index && shadows[index -1][1] > shadow[0]) { print "second bracket"; overlapping = true; - shadows[index-1][1] = shadow[1]; //extend the prev shadow + + print "MARK one"; + + shadows[index-1][1] = max(shadows[index-1][1], shadow[1]); //extend the prev shadow + + print "MARK two"; //see if the newly extended prev overlaps the shadow at "index" if (shadows[index-1][1] >= shadows[index][0]) { //merge the two - shadows[index-1][1] = shadows[index][1]; + shadows[index-1][1] = max(shadows[index-1][1], shadows[index][1]); shadows = shadows.remove(index); } } @@ -142,7 +151,7 @@ fn shadowCastOctant(node: opaque, x: int, y: int, dirX: int, dirY: int, depth: i print "third bracket"; overlapping = true; //extend the next shadow - shadows[index][1] = shadow[0]; + shadows[index][0] = min(shadows[index][0], shadow[0]); } if (!overlapping) { @@ -163,13 +172,22 @@ fn shadowCastTile(x: int, y: int, dirX: int, dirY: int, depth: int) { var start = abs(shadowCastPoint(x, y, depth)); var end = abs(shadowCastPoint(x + sign(dirX), y + sign(dirY), depth)); - return [start, end]; + if (checkIsNaN(start) || checkIsNaN(end)) { + return null; + } + + if (start < end) { + return [start, end]; + } + else { + return [end, start]; + } } fn shadowCastPoint(x: float, y: float, depth: int) { -// if (y == 0) { -// return sin(tan(INFINITY)); -// } + if (y == 0) { + return NAN; + } return sin(tan(x/y)) * depth; }