summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/.gitattributes2
-rw-r--r--client/.gitignore3
-rw-r--r--client/Djup.csproj15
-rw-r--r--client/Djup.sln19
-rw-r--r--client/Root.cs74
-rw-r--r--client/icon.svg1
-rw-r--r--client/icon.svg.import37
-rw-r--r--client/project.godot24
-rw-r--r--client/root.tscn6
9 files changed, 181 insertions, 0 deletions
diff --git a/client/.gitattributes b/client/.gitattributes
new file mode 100644
index 0000000..8ad74f7
--- /dev/null
+++ b/client/.gitattributes
@@ -0,0 +1,2 @@
+# Normalize EOL for all files that Git considers text files.
+* text=auto eol=lf
diff --git a/client/.gitignore b/client/.gitignore
new file mode 100644
index 0000000..0af181c
--- /dev/null
+++ b/client/.gitignore
@@ -0,0 +1,3 @@
+# Godot 4+ specific ignores
+.godot/
+/android/
diff --git a/client/Djup.csproj b/client/Djup.csproj
new file mode 100644
index 0000000..0e34542
--- /dev/null
+++ b/client/Djup.csproj
@@ -0,0 +1,15 @@
+<Project Sdk="Godot.NET.Sdk/4.3.0">
+ <PropertyGroup>
+ <TargetFramework>net8.0</TargetFramework>
+ <TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework>
+ <TargetFramework Condition=" '$(GodotTargetPlatform)' == 'ios' ">net8.0</TargetFramework>
+ <EnableDynamicLoading>true</EnableDynamicLoading>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Djup.Native\Djup.Native.csproj" />
+ </ItemGroup>
+
+ <Import Project="../Djup.Native/AddRuntimeTargetsToDepsJson.targets" />
+</Project>
diff --git a/client/Djup.sln b/client/Djup.sln
new file mode 100644
index 0000000..fc24000
--- /dev/null
+++ b/client/Djup.sln
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Djup", "Djup.csproj", "{77DE270B-0994-425F-9CA2-4E664136B608}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ ExportDebug|Any CPU = ExportDebug|Any CPU
+ ExportRelease|Any CPU = ExportRelease|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {77DE270B-0994-425F-9CA2-4E664136B608}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {77DE270B-0994-425F-9CA2-4E664136B608}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {77DE270B-0994-425F-9CA2-4E664136B608}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
+ {77DE270B-0994-425F-9CA2-4E664136B608}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
+ {77DE270B-0994-425F-9CA2-4E664136B608}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
+ {77DE270B-0994-425F-9CA2-4E664136B608}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/client/Root.cs b/client/Root.cs
new file mode 100644
index 0000000..e39a485
--- /dev/null
+++ b/client/Root.cs
@@ -0,0 +1,74 @@
+using Godot;
+using System;
+using Djup.Native;
+
+public partial class Root : Node2D
+{
+ private IntPtr native_world;
+ private int[] balls = new int[100];
+ private Random rng = new();
+ private const double Tps = 1d/60d;
+
+ // Called when the node enters the scene tree for the first time.
+ public unsafe override void _Ready()
+ {
+ RenderingServer.SetDefaultClearColor(Colors.LightGray);
+
+ native_world = LibDjup.world_create();
+ for (int i = 0; i < balls.Length; i++)
+ {
+ int id = LibDjup.world_create_entity(native_world, EntityKind.Ball);
+ if (id < 0)
+ {
+ throw new Exception("Failed to create entity");
+ }
+ balls[i] = id;
+ Entity *ent;
+ var pos = new Vec2(5f * rng.Next(10), 5f * rng.Next(20));
+ var vel = new Vec2(50f + 5f * rng.Next(10), 50f);
+ ent = LibDjup.world_find_entity(native_world, balls[i]);
+ ent->ball.Position = pos;
+ ent->ball.Velocity = vel;
+ }
+ }
+
+ public override void _ExitTree()
+ {
+ LibDjup.world_free(native_world);
+ }
+
+ private void DrawBall(Ball ball)
+ {
+ //Color color = rng.Next(5) switch
+ //{
+ //0 => Colors.Black,
+ //1 => Colors.Blue,
+ //2 => Colors.Red,
+ //3 => Colors.Green,
+ //4 => Colors.Pink
+ //};
+ Color color = Colors.Blue;
+ this.DrawCircle(new Vector2(ball.Position.X, ball.Position.Y), 5f, color, antialiased: true);
+ }
+
+ public unsafe override void _Draw()
+ {
+ for (int i = 0; i < balls.Length; i++)
+ {
+ DrawBall(LibDjup.world_find_entity(native_world, balls[i])->ball);
+ }
+ }
+
+ public override void _Process(double delta)
+ {
+ this.QueueRedraw();
+ }
+
+ public override void _PhysicsProcess(double delta)
+ {
+ if (LibDjup.world_tick(native_world, Tps) != 0)
+ {
+ GD.Print("world_tick failed");
+ }
+ }
+}
diff --git a/client/icon.svg b/client/icon.svg
new file mode 100644
index 0000000..9d8b7fa
--- /dev/null
+++ b/client/icon.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg> \ No newline at end of file
diff --git a/client/icon.svg.import b/client/icon.svg.import
new file mode 100644
index 0000000..57c75ba
--- /dev/null
+++ b/client/icon.svg.import
@@ -0,0 +1,37 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://cg5s4tfihtewl"
+path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://icon.svg"
+dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
+svg/scale=1.0
+editor/scale_with_editor_scale=false
+editor/convert_colors_with_editor_theme=false
diff --git a/client/project.godot b/client/project.godot
new file mode 100644
index 0000000..6107d87
--- /dev/null
+++ b/client/project.godot
@@ -0,0 +1,24 @@
+; Engine configuration file.
+; It's best edited using the editor UI and not directly,
+; since the parameters that go here are not all obvious.
+;
+; Format:
+; [section] ; section goes between []
+; param=value ; assign values to parameters
+
+config_version=5
+
+[application]
+
+config/name="Djup"
+run/main_scene="res://root.tscn"
+config/features=PackedStringArray("4.3", "C#", "Forward Plus")
+config/icon="res://icon.svg"
+
+[display]
+
+window/stretch/mode="canvas_items"
+
+[dotnet]
+
+project/assembly_name="Djup"
diff --git a/client/root.tscn b/client/root.tscn
new file mode 100644
index 0000000..ded95a0
--- /dev/null
+++ b/client/root.tscn
@@ -0,0 +1,6 @@
+[gd_scene load_steps=2 format=3 uid="uid://drdk1by1fun2q"]
+
+[ext_resource type="Script" path="res://Root.cs" id="1_p5oo0"]
+
+[node name="Root" type="Node2D"]
+script = ExtResource("1_p5oo0")