diff --git a/OpenDiablo2.Common/Interfaces/IRenderTarget.cs b/OpenDiablo2.Common/Interfaces/IRenderTarget.cs
deleted file mode 100644
index ac436bcf..00000000
--- a/OpenDiablo2.Common/Interfaces/IRenderTarget.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace OpenDiablo2.Common.Interfaces
-{
- public interface IRenderTarget
- {
- void Draw(ISprite sprite);
- }
-}
diff --git a/OpenDiablo2.Common/Interfaces/IRenderWindow.cs b/OpenDiablo2.Common/Interfaces/IRenderWindow.cs
index efa21e06..e7849595 100644
--- a/OpenDiablo2.Common/Interfaces/IRenderWindow.cs
+++ b/OpenDiablo2.Common/Interfaces/IRenderWindow.cs
@@ -11,6 +11,7 @@ namespace OpenDiablo2.Common.Interfaces
void Clear();
void Sync();
void Quit();
+ uint GetTicks();
ISprite LoadSprite(string resourcePath, string palette, Point location);
ISprite LoadSprite(string resourcePath, string palette);
IFont LoadFont(string resourcePath, string palette);
diff --git a/OpenDiablo2.Common/OpenDiablo2.Common.csproj b/OpenDiablo2.Common/OpenDiablo2.Common.csproj
index 748279df..ede763df 100644
--- a/OpenDiablo2.Common/OpenDiablo2.Common.csproj
+++ b/OpenDiablo2.Common/OpenDiablo2.Common.csproj
@@ -13,23 +13,6 @@
512
true
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\
@@ -92,7 +75,6 @@
-
diff --git a/OpenDiablo2.Core/GameEngine.cs b/OpenDiablo2.Core/GameEngine.cs
index e1ba28f2..8e79d8d1 100644
--- a/OpenDiablo2.Core/GameEngine.cs
+++ b/OpenDiablo2.Core/GameEngine.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
+using System.Threading;
using OpenDiablo2.Common;
using OpenDiablo2.Common.Interfaces;
using OpenDiablo2.Common.Models;
@@ -29,7 +30,6 @@ namespace OpenDiablo2.Core
private Dictionary soundTable = new Dictionary();
public Dictionary PaletteTable { get; private set; } = new Dictionary();
- private Stopwatch sw = new Stopwatch();
public GameEngine(
@@ -95,19 +95,30 @@ namespace OpenDiablo2.Core
}
currentScene = getScene("Main Menu");
- sw.Start();
+ var lastTicks = renderWindow.GetTicks();
while (getRenderWindow().IsRunning)
{
- var ms = sw.ElapsedMilliseconds;
- sw.Restart();
+ var curTicks = renderWindow.GetTicks();
+ var ms = curTicks - lastTicks;
+
+ if (ms < 0)
+ continue;
+
+ if (ms < 33)
+ {
+ Thread.Sleep(33 - (int)ms);
+ continue;
+ }
// Prevent falco-punch updates
if (ms > 1000)
{
- sw.Restart();
+ lastTicks = renderWindow.GetTicks();
continue;
}
+ lastTicks = curTicks;
+
getGameState().Update(ms);
getRenderWindow().Update();
currentScene.Update(ms);
diff --git a/OpenDiablo2.Core/GameState/GameState.cs b/OpenDiablo2.Core/GameState/GameState.cs
index 75480ee4..8a676571 100644
--- a/OpenDiablo2.Core/GameState/GameState.cs
+++ b/OpenDiablo2.Core/GameState/GameState.cs
@@ -5,6 +5,7 @@ using System.Linq;
using OpenDiablo2.Common.Enums;
using OpenDiablo2.Common.Interfaces;
using OpenDiablo2.Common.Models;
+using OpenDiablo2.Core.Map_Engine;
namespace OpenDiablo2.Core.GameState_
{
diff --git a/OpenDiablo2.Core/MapGenerator.cs b/OpenDiablo2.Core/Map Engine/MapGenerator.cs
similarity index 94%
rename from OpenDiablo2.Core/MapGenerator.cs
rename to OpenDiablo2.Core/Map Engine/MapGenerator.cs
index f07218a9..796b1122 100644
--- a/OpenDiablo2.Core/MapGenerator.cs
+++ b/OpenDiablo2.Core/Map Engine/MapGenerator.cs
@@ -1,14 +1,9 @@
using System;
-using System.Collections.Generic;
using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using OpenDiablo2.Common.Enums;
using OpenDiablo2.Common.Interfaces;
-using OpenDiablo2.Common.Models;
-namespace OpenDiablo2.Core
+namespace OpenDiablo2.Core.Map_Engine
{
public sealed class MapGenerator
{
diff --git a/OpenDiablo2.Core/OpenDiablo2.Core.csproj b/OpenDiablo2.Core/OpenDiablo2.Core.csproj
index 4a9fccb7..a2809855 100644
--- a/OpenDiablo2.Core/OpenDiablo2.Core.csproj
+++ b/OpenDiablo2.Core/OpenDiablo2.Core.csproj
@@ -13,23 +13,6 @@
512
true
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\
@@ -77,7 +60,7 @@
-
+
diff --git a/OpenDiablo2.SDL2/OpenDiablo2.SDL2.csproj b/OpenDiablo2.SDL2/OpenDiablo2.SDL2.csproj
index 282fd33e..ad0078a0 100644
--- a/OpenDiablo2.SDL2/OpenDiablo2.SDL2.csproj
+++ b/OpenDiablo2.SDL2/OpenDiablo2.SDL2.csproj
@@ -13,24 +13,6 @@
512
true
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- true
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\
diff --git a/OpenDiablo2.SDL2/SDL2RenderWindow.cs b/OpenDiablo2.SDL2/SDL2RenderWindow.cs
index d0a8411f..84106ae7 100644
--- a/OpenDiablo2.SDL2/SDL2RenderWindow.cs
+++ b/OpenDiablo2.SDL2/SDL2RenderWindow.cs
@@ -8,7 +8,7 @@ using SDL2;
namespace OpenDiablo2.SDL2_
{
- public sealed class SDL2RenderWindow : IRenderWindow, IRenderTarget, IMouseInfoProvider, IKeyboardInfoProvider
+ public sealed class SDL2RenderWindow : IRenderWindow, IMouseInfoProvider, IKeyboardInfoProvider
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@@ -50,11 +50,12 @@ namespace OpenDiablo2.SDL2_
if (SDL.SDL_SetHint(SDL.SDL_HINT_RENDER_SCALE_QUALITY, "0") == SDL.SDL_bool.SDL_FALSE)
throw new ApplicationException($"Unable to Init hinting: {SDL.SDL_GetError()}");
- window = SDL.SDL_CreateWindow("OpenDiablo2", SDL.SDL_WINDOWPOS_UNDEFINED, SDL.SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN);
+ window = SDL.SDL_CreateWindow("OpenDiablo2", SDL.SDL_WINDOWPOS_UNDEFINED, SDL.SDL_WINDOWPOS_UNDEFINED, 800, 600,
+ SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN | SDL.SDL_WindowFlags.SDL_WINDOW_VULKAN);
if (window == IntPtr.Zero)
throw new ApplicationException($"Unable to create SDL Window: {SDL.SDL_GetError()}");
- renderer = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RendererFlags.SDL_RENDERER_SOFTWARE);
+ renderer = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED | SDL.SDL_RendererFlags.SDL_RENDERER_PRESENTVSYNC);
if (renderer == IntPtr.Zero)
throw new ApplicationException($"Unable to create SDL Window: {SDL.SDL_GetError()}");
@@ -396,5 +397,7 @@ namespace OpenDiablo2.SDL2_
SDL.SDL_SetCursor((mouseCursor as SDL2MouseCursor).Surface);
}
+
+ public uint GetTicks() => SDL.SDL_GetTicks();
}
}
diff --git a/OpenDiablo2.TestConsole/OpenDiablo2.TestConsole.csproj b/OpenDiablo2.TestConsole/OpenDiablo2.TestConsole.csproj
index 60a95a84..a47a15e0 100644
--- a/OpenDiablo2.TestConsole/OpenDiablo2.TestConsole.csproj
+++ b/OpenDiablo2.TestConsole/OpenDiablo2.TestConsole.csproj
@@ -12,25 +12,6 @@
512
true
-
- x64
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\
diff --git a/OpenDiablo2.sln b/OpenDiablo2.sln
index da7827b7..ea71aad5 100644
--- a/OpenDiablo2.sln
+++ b/OpenDiablo2.sln
@@ -19,58 +19,34 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
- Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {2B0CF1AC-06DD-4322-AE8B-FF8A8C70A3CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2B0CF1AC-06DD-4322-AE8B-FF8A8C70A3CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B0CF1AC-06DD-4322-AE8B-FF8A8C70A3CD}.Debug|x64.ActiveCfg = Debug|x64
{2B0CF1AC-06DD-4322-AE8B-FF8A8C70A3CD}.Debug|x64.Build.0 = Debug|x64
- {2B0CF1AC-06DD-4322-AE8B-FF8A8C70A3CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2B0CF1AC-06DD-4322-AE8B-FF8A8C70A3CD}.Release|Any CPU.Build.0 = Release|Any CPU
{2B0CF1AC-06DD-4322-AE8B-FF8A8C70A3CD}.Release|x64.ActiveCfg = Release|x64
{2B0CF1AC-06DD-4322-AE8B-FF8A8C70A3CD}.Release|x64.Build.0 = Release|x64
- {B743160E-A0BB-45DC-9998-967A85E50562}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B743160E-A0BB-45DC-9998-967A85E50562}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B743160E-A0BB-45DC-9998-967A85E50562}.Debug|x64.ActiveCfg = Debug|x64
{B743160E-A0BB-45DC-9998-967A85E50562}.Debug|x64.Build.0 = Debug|x64
- {B743160E-A0BB-45DC-9998-967A85E50562}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B743160E-A0BB-45DC-9998-967A85E50562}.Release|Any CPU.Build.0 = Release|Any CPU
{B743160E-A0BB-45DC-9998-967A85E50562}.Release|x64.ActiveCfg = Release|x64
{B743160E-A0BB-45DC-9998-967A85E50562}.Release|x64.Build.0 = Release|x64
- {8FC6BF7D-835A-47C1-A6B2-125495FA0900}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8FC6BF7D-835A-47C1-A6B2-125495FA0900}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FC6BF7D-835A-47C1-A6B2-125495FA0900}.Debug|x64.ActiveCfg = Debug|x64
{8FC6BF7D-835A-47C1-A6B2-125495FA0900}.Debug|x64.Build.0 = Debug|x64
- {8FC6BF7D-835A-47C1-A6B2-125495FA0900}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8FC6BF7D-835A-47C1-A6B2-125495FA0900}.Release|Any CPU.Build.0 = Release|Any CPU
{8FC6BF7D-835A-47C1-A6B2-125495FA0900}.Release|x64.ActiveCfg = Release|x64
{8FC6BF7D-835A-47C1-A6B2-125495FA0900}.Release|x64.Build.0 = Release|x64
- {1F8731D5-393B-4561-9CEA-887A2F466576}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1F8731D5-393B-4561-9CEA-887A2F466576}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F8731D5-393B-4561-9CEA-887A2F466576}.Debug|x64.ActiveCfg = Debug|x64
{1F8731D5-393B-4561-9CEA-887A2F466576}.Debug|x64.Build.0 = Debug|x64
- {1F8731D5-393B-4561-9CEA-887A2F466576}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1F8731D5-393B-4561-9CEA-887A2F466576}.Release|Any CPU.Build.0 = Release|Any CPU
{1F8731D5-393B-4561-9CEA-887A2F466576}.Release|x64.ActiveCfg = Release|x64
{1F8731D5-393B-4561-9CEA-887A2F466576}.Release|x64.Build.0 = Release|x64
- {05224FE7-293F-4184-B1D6-89F5171B60E0}.Debug|Any CPU.ActiveCfg = Debug|x64
{05224FE7-293F-4184-B1D6-89F5171B60E0}.Debug|x64.ActiveCfg = Debug|x64
{05224FE7-293F-4184-B1D6-89F5171B60E0}.Debug|x64.Build.0 = Debug|x64
- {05224FE7-293F-4184-B1D6-89F5171B60E0}.Release|Any CPU.ActiveCfg = Release|x64
{05224FE7-293F-4184-B1D6-89F5171B60E0}.Release|x64.ActiveCfg = Release|x64
{05224FE7-293F-4184-B1D6-89F5171B60E0}.Release|x64.Build.0 = Release|x64
- {40BD2DDE-DC6F-4F6D-9050-9B423C631192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {40BD2DDE-DC6F-4F6D-9050-9B423C631192}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40BD2DDE-DC6F-4F6D-9050-9B423C631192}.Debug|x64.ActiveCfg = Debug|x64
{40BD2DDE-DC6F-4F6D-9050-9B423C631192}.Debug|x64.Build.0 = Debug|x64
- {40BD2DDE-DC6F-4F6D-9050-9B423C631192}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {40BD2DDE-DC6F-4F6D-9050-9B423C631192}.Release|Any CPU.Build.0 = Release|Any CPU
- {40BD2DDE-DC6F-4F6D-9050-9B423C631192}.Release|x64.ActiveCfg = Release|Any CPU
- {40BD2DDE-DC6F-4F6D-9050-9B423C631192}.Release|x64.Build.0 = Release|Any CPU
+ {40BD2DDE-DC6F-4F6D-9050-9B423C631192}.Release|x64.ActiveCfg = Release|x64
+ {40BD2DDE-DC6F-4F6D-9050-9B423C631192}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/OpenDiablo2/OpenDiablo2.csproj b/OpenDiablo2/OpenDiablo2.csproj
index b89c0a8a..8ff3c26c 100644
--- a/OpenDiablo2/OpenDiablo2.csproj
+++ b/OpenDiablo2/OpenDiablo2.csproj
@@ -28,25 +28,6 @@
false
true
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\