From 370424a6966b4539af128c635efae0af4e2dcacd Mon Sep 17 00:00:00 2001 From: root Date: Mon, 15 Sep 2025 19:15:43 +0200 Subject: [PATCH] Initial Player Scene --- earth.tscn | 4 ++-- main.tscn | 12 ++++++++++++ player.gd | 18 ++++++++++++++++++ player.gd.uid | 1 + player.tscn | 17 +++++++++++++++++ project.godot | 2 +- 6 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 main.tscn create mode 100644 player.gd create mode 100644 player.gd.uid create mode 100644 player.tscn diff --git a/earth.tscn b/earth.tscn index 20f0afd..bef74f5 100644 --- a/earth.tscn +++ b/earth.tscn @@ -1,7 +1,7 @@ -[gd_scene load_steps=4 format=3 uid="uid://33k5v6skcbsm"] +[gd_scene load_steps=4 format=3 uid="uid://jjoyj1ldafkf"] [ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_qbwya"] -[ext_resource type="Script" uid="uid://b5fhsy1xlreco" path="res://draw_circle.gd" id="2_2bhor"] +[ext_resource type="Script" path="res://draw_circle.gd" id="2_2bhor"] [sub_resource type="CircleShape2D" id="CircleShape2D_5i67w"] radius = 3000.0 diff --git a/main.tscn b/main.tscn new file mode 100644 index 0000000..9c4b74d --- /dev/null +++ b/main.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=3 format=3 uid="uid://cxo6bq26huau7"] + +[ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player.tscn" id="2_1bvp3"] +[ext_resource type="PackedScene" uid="uid://jjoyj1ldafkf" path="res://earth.tscn" id="3_lquwl"] + +[node name="main" type="Node2D"] + +[node name="Player" parent="." instance=ExtResource("2_1bvp3")] +position = Vector2(0, -3100) +scale = Vector2(3, 3) + +[node name="Earth" parent="." instance=ExtResource("3_lquwl")] diff --git a/player.gd b/player.gd new file mode 100644 index 0000000..358554c --- /dev/null +++ b/player.gd @@ -0,0 +1,18 @@ +extends Node2D +var body : CharacterBody2D; +var earth_center = Vector2.ZERO; +var gravity = 500; + +func _ready() -> void: + body = get_parent().get_node("Player") + +func _physics_process(delta: float) -> void: + var local_velocity = Vector2.ZERO + body.up_direction = (self.position - earth_center).normalized(); + local_velocity += Vector2(0, gravity) + body.velocity = global_from_local(local_velocity) + print(body.velocity) + body.move_and_slide() + +func global_from_local (_velocity: Vector2) -> Vector2: + return _velocity # Placeholder diff --git a/player.gd.uid b/player.gd.uid new file mode 100644 index 0000000..6496f8a --- /dev/null +++ b/player.gd.uid @@ -0,0 +1 @@ +uid://ddidj1uau28ck diff --git a/player.tscn b/player.tscn new file mode 100644 index 0000000..ebffb48 --- /dev/null +++ b/player.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=4 format=3 uid="uid://cmaovvr15b3qk"] + +[ext_resource type="Script" uid="uid://ddidj1uau28ck" path="res://player.gd" id="1_4flbx"] +[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_onrkg"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_onrkg"] + +[node name="Player" type="CharacterBody2D"] +script = ExtResource("1_4flbx") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CapsuleShape2D_onrkg") + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(5.96046e-08, 0) +scale = Vector2(0.15625, 0.234375) +texture = ExtResource("2_onrkg") diff --git a/project.godot b/project.godot index ea99ec8..682ae6b 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="The Dark Side of Earth" -run/main_scene="res://earth.tscn" +run/main_scene="uid://cxo6bq26huau7" config/features=PackedStringArray("4.4", "Forward Plus") config/icon="res://icon.svg"