diff --git a/Main.tscn b/Main.tscn deleted file mode 100644 index 1accfe4..0000000 --- a/Main.tscn +++ /dev/null @@ -1,5 +0,0 @@ -[gd_scene format=3 uid="uid://dackb8ekt4sk6"] - -[node name="Main" type="Node2D" unique_id=1194367579] - -[node name="Overworld" type="Node2D" parent="." unique_id=1249792834] diff --git a/Player.tscn b/Player.tscn deleted file mode 100644 index e1222a9..0000000 --- a/Player.tscn +++ /dev/null @@ -1,10 +0,0 @@ -[gd_scene format=3 uid="uid://bjt15rm720w5g"] - -[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_0rwas"] - -[node name="Player" type="CharacterBody2D" unique_id=1675096620] - -[node name="Sprite2D" type="Sprite2D" parent="." unique_id=554119030] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1337429488] -shape = SubResource("CapsuleShape2D_0rwas") diff --git a/project.godot b/project.godot index 1407107..22396a2 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,8 @@ config_version=5 [application] config/name="ocker" -config/features=PackedStringArray("4.6", "GL Compatibility") +run/main_scene="uid://dackb8ekt4sk6" +config/features=PackedStringArray("4.6", "C#", "GL Compatibility") config/icon="res://icon.svg" [dotnet] diff --git a/scenes/Main.tscn b/scenes/Main.tscn new file mode 100644 index 0000000..8d84c04 --- /dev/null +++ b/scenes/Main.tscn @@ -0,0 +1,10 @@ +[gd_scene format=3 uid="uid://dackb8ekt4sk6"] + +[ext_resource type="PackedScene" uid="uid://bjt15rm720w5g" path="res://scenes/Player.tscn" id="1_elqb8"] + +[node name="Main" type="Node2D" unique_id=1194367579] + +[node name="Overworld" type="Node2D" parent="." unique_id=1249792834] + +[node name="Player" parent="." unique_id=1675096620 instance=ExtResource("1_elqb8")] +position = Vector2(-34, -36) diff --git a/scenes/Player.tscn b/scenes/Player.tscn new file mode 100644 index 0000000..8e80370 --- /dev/null +++ b/scenes/Player.tscn @@ -0,0 +1,32 @@ +[gd_scene format=3 uid="uid://bjt15rm720w5g"] + +[ext_resource type="Script" uid="uid://duf0vlr2yin8l" path="res://scripts/Player.cs" id="1_p0vlq"] +[ext_resource type="Script" uid="uid://b25o2r2lf6nst" path="res://scripts/Visual.cs" id="2_v6fml"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_v6fml"] + +[node name="Player" type="CharacterBody2D" unique_id=1675096620] +script = ExtResource("1_p0vlq") + +[node name="Sprite2D" type="Sprite2D" parent="." unique_id=554119030] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1337429488] +position = Vector2(-15, -16) +shape = SubResource("CircleShape2D_v6fml") + +[node name="ColorRect" type="ColorRect" parent="CollisionShape2D" unique_id=2088988808] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -8.0 +offset_top = -8.0 +offset_right = 8.0 +offset_bottom = 8.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.13958341, 0.81406105, 0, 1) + +[node name="Visual" type="Node2D" parent="." unique_id=630351727] +script = ExtResource("2_v6fml") diff --git a/scripts/Player.cs b/scripts/Player.cs new file mode 100644 index 0000000..fc78319 --- /dev/null +++ b/scripts/Player.cs @@ -0,0 +1,18 @@ +/// +/// Moves the player using top-down controls. +/// + +using Godot; +//using System; + +public partial class Player : CharacterBody2D +{ + [Export] public float Speed = 220f; + + public override void _PhysicsProcess(double delta) + { + Vector2 input = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down"); + Velocity = input * Speed; + MoveAndSlide(); + } +} diff --git a/scripts/Player.cs.uid b/scripts/Player.cs.uid new file mode 100644 index 0000000..30cd5cd --- /dev/null +++ b/scripts/Player.cs.uid @@ -0,0 +1 @@ +uid://duf0vlr2yin8l diff --git a/scripts/Visual.cs b/scripts/Visual.cs new file mode 100644 index 0000000..7e4a134 --- /dev/null +++ b/scripts/Visual.cs @@ -0,0 +1,16 @@ +using Godot; + +public partial class PlayerVisual : Node2D +{ + [Export] public float Radius = 8f; + + public override void _Draw() + { + DrawCircle(Vector2.Zero, Radius, new Color(0.2f, 0.8f, 1.0f)); + } + + public override void _Ready() + { + QueueRedraw(); + } +} diff --git a/scripts/Visual.cs.uid b/scripts/Visual.cs.uid new file mode 100644 index 0000000..91aefe6 --- /dev/null +++ b/scripts/Visual.cs.uid @@ -0,0 +1 @@ +uid://b25o2r2lf6nst