diff --git a/PixelEngine/Config.cs b/PixelEngine/Config.cs new file mode 100644 index 0000000..b09736a --- /dev/null +++ b/PixelEngine/Config.cs @@ -0,0 +1,7 @@ +namespace PixelEngine; + +public class Config +{ + public List Densities { get; set; } + public List Velocities { get; set; } +} \ No newline at end of file diff --git a/PixelEngine/Config.json b/PixelEngine/Config.json new file mode 100644 index 0000000..7419a09 --- /dev/null +++ b/PixelEngine/Config.json @@ -0,0 +1,62 @@ +{ + "Densities":[ + { + "x":64, + "y":64, + "amount":200 + } + ], + "Velocities":[ + { + "x":32, + "y":64, + "amountX":0.1, + "amountY":-0.1 + }, + { + "x":96, + "y":64, + "amountX":-0.1, + "amountY":0.1 + }, + { + "x":64, + "y":32, + "amountX":0.1, + "amountY":0.1 + }, + { + "x":64, + "y":96, + "amountX":-0.1, + "amountY":-0.1 + }, + + + + { + "x":64, + "y":64, + "amountX":0.1, + "amountY":-0.1 + }, + { + "x":64, + "y":64, + "amountX":-0.1, + "amountY":0.1 + }, + { + "x":64, + "y":64, + "amountX":0.1, + "amountY":0.1 + }, + { + "x":64, + "y":64, + "amountX":-0.1, + "amountY":-0.1 + } + ] +} \ No newline at end of file diff --git a/PixelEngine/Density.cs b/PixelEngine/Density.cs new file mode 100644 index 0000000..3b43515 --- /dev/null +++ b/PixelEngine/Density.cs @@ -0,0 +1,8 @@ +namespace PixelEngine; + +public class Density +{ + public int x { get; set; } + public int y{ get; set; } + public float amount { get; set; } +} \ No newline at end of file diff --git a/PixelEngine/Fluid.cs b/PixelEngine/Fluid.cs index 76c5f8f..28f83a3 100644 --- a/PixelEngine/Fluid.cs +++ b/PixelEngine/Fluid.cs @@ -77,7 +77,8 @@ public class Fluid } } - public void renderD() { + public void renderD() + { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { int x = i * scale; @@ -211,11 +212,11 @@ public class Fluid if (x < 0.5f) x = 0.5f; if (x > Nfloat + 0.5f) x = Nfloat + 0.5f; - i0 = RayMath.floorf(x); + i0 = floorf(x); i1 = i0 + 1.0f; if (y < 0.5f) y = 0.5f; if (y > Nfloat + 0.5f) y = Nfloat + 0.5f; - j0 = RayMath.floorf(y); + j0 = floorf(y); j1 = j0 + 1.0f; s1 = x - i0; diff --git a/PixelEngine/Game.cs b/PixelEngine/Game.cs index b791522..2162656 100644 --- a/PixelEngine/Game.cs +++ b/PixelEngine/Game.cs @@ -1,4 +1,5 @@ using System.Numerics; +using Newtonsoft.Json; using static Raylib_CsLo.Raylib; using static Raylib_CsLo.RayGui; using Raylib_CsLo; @@ -7,8 +8,8 @@ namespace PixelEngine; public class Game { - private const int Size = 256; - private const int Scale = 2; + private const int Size = 128; + private const int Scale = 7; private const int Iter = 10; private const float Dt = 0.2f; private const float Diffusion = 0f; @@ -27,12 +28,26 @@ public class Game InitWindow(Size * Scale, Size * Scale, WindowTitle); SetTargetFPS(TargetFps); + } public void HandleInput() { + var config = JsonConvert.DeserializeObject(File.ReadAllText("Config.json")); + foreach (var configVelocity in config.Velocities) + { + DrawCircle(configVelocity.x * Scale, configVelocity.y *Scale, 5, RED); + DrawLine(configVelocity.x * Scale,configVelocity.y *Scale, (int) ((configVelocity.x * Scale) + (configVelocity.amountX)),(int) ((configVelocity.y * Scale) + (configVelocity.amountY)), RED); + _fluid.addVelocity(configVelocity.x, configVelocity.y, configVelocity.amountX, configVelocity.amountY); + } + + foreach (var configDensity in config.Densities) + { + _fluid.addDensity(configDensity.x, configDensity.y, configDensity.amount); + } + // Add Density if (IsMouseButtonDown(MouseButton.MOUSE_BUTTON_LEFT)) { @@ -61,7 +76,7 @@ public class Game PMouse = GetMousePosition(); } - + } diff --git a/PixelEngine/PixelEngine.csproj b/PixelEngine/PixelEngine.csproj index 05fe3e4..ffb14d2 100644 --- a/PixelEngine/PixelEngine.csproj +++ b/PixelEngine/PixelEngine.csproj @@ -9,7 +9,12 @@ + + + + + diff --git a/PixelEngine/Velocity.cs b/PixelEngine/Velocity.cs new file mode 100644 index 0000000..71ce4c5 --- /dev/null +++ b/PixelEngine/Velocity.cs @@ -0,0 +1,10 @@ +namespace PixelEngine; + +public class Velocity +{ + public int x { get; set; } + public int y { get; set; } + public float amountX { get; set; } + public float amountY { get; set; } + +} \ No newline at end of file