From 2a73a9cad088baf35d9b8eb778e7238a773fec51 Mon Sep 17 00:00:00 2001 From: dukantic Date: Fri, 18 Oct 2024 20:59:51 +0200 Subject: [PATCH] files --- Mal-Adresse.csproj | 9 +++++++++ Mal-Adresse.sln | 19 +++++++++++++++++++ project.godot | 5 +++++ scene/city.tscn | 3 +++ scene/player.tscn | 16 ++++++++++++++++ script/Player.cs | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 86 insertions(+) create mode 100644 Mal-Adresse.csproj create mode 100644 Mal-Adresse.sln create mode 100644 scene/city.tscn create mode 100644 scene/player.tscn create mode 100644 script/Player.cs diff --git a/Mal-Adresse.csproj b/Mal-Adresse.csproj new file mode 100644 index 0000000..ce064d7 --- /dev/null +++ b/Mal-Adresse.csproj @@ -0,0 +1,9 @@ + + + net6.0 + net7.0 + net8.0 + true + MalAdresse + + \ No newline at end of file diff --git a/Mal-Adresse.sln b/Mal-Adresse.sln new file mode 100644 index 0000000..5789974 --- /dev/null +++ b/Mal-Adresse.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mal-Adresse", "Mal-Adresse.csproj", "{4E1911F5-B16F-455B-B3BB-FC9BBCC6D57E}" +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 + {4E1911F5-B16F-455B-B3BB-FC9BBCC6D57E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E1911F5-B16F-455B-B3BB-FC9BBCC6D57E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E1911F5-B16F-455B-B3BB-FC9BBCC6D57E}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {4E1911F5-B16F-455B-B3BB-FC9BBCC6D57E}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {4E1911F5-B16F-455B-B3BB-FC9BBCC6D57E}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {4E1911F5-B16F-455B-B3BB-FC9BBCC6D57E}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/project.godot b/project.godot index ff92ddf..3cf8f92 100644 --- a/project.godot +++ b/project.godot @@ -14,6 +14,11 @@ config/name="Mal-Adresse" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icon.svg" +[display] + +window/size/viewport_width=266 +window/size/viewport_height=200 + [dotnet] project/assembly_name="Mal-Adresse" diff --git a/scene/city.tscn b/scene/city.tscn new file mode 100644 index 0000000..8d03a64 --- /dev/null +++ b/scene/city.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://1tfopbwug3ht"] + +[node name="city" type="Node2D"] diff --git a/scene/player.tscn b/scene/player.tscn new file mode 100644 index 0000000..098b6a6 --- /dev/null +++ b/scene/player.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=4 format=3 uid="uid://4ubk6w44h4s2"] + +[ext_resource type="Script" path="res://script/Player.cs" id="1_gmlsd"] +[ext_resource type="Texture2D" uid="uid://c0vb33qqa2u1u" path="res://icon.svg" id="2_7ko2y"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_5g3cc"] + +[node name="CharacterBody2D" type="CharacterBody2D"] +script = ExtResource("1_gmlsd") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_5g3cc") + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(1, 0) +texture = ExtResource("2_7ko2y") diff --git a/script/Player.cs b/script/Player.cs new file mode 100644 index 0000000..b20495c --- /dev/null +++ b/script/Player.cs @@ -0,0 +1,34 @@ +using Godot; +using System; + +public partial class Player : CharacterBody2D +{ + public const float Speed = 300.0f; + public const float JumpVelocity = -400.0f; + + public override void _PhysicsProcess(double delta) + { + Vector2 velocity = Velocity; + + // Handle Jump. + if (Input.IsActionJustPressed("ui_accept") && IsOnFloor()) + { + velocity.Y = JumpVelocity; + } + + // Get the input direction and handle the movement/deceleration. + // As good practice, you should replace UI actions with custom gameplay actions. + Vector2 direction = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down"); + if (direction != Vector2.Zero) + { + velocity.X = direction.X * Speed; + } + else + { + velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed); + } + + Velocity = velocity; + MoveAndSlide(); + } +}