Initial Player Scene
This commit is contained in:
parent
8b07000d46
commit
370424a696
6 changed files with 51 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
12
main.tscn
Normal file
12
main.tscn
Normal file
|
|
@ -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")]
|
||||
18
player.gd
Normal file
18
player.gd
Normal file
|
|
@ -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
|
||||
1
player.gd.uid
Normal file
1
player.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ddidj1uau28ck
|
||||
17
player.tscn
Normal file
17
player.tscn
Normal file
|
|
@ -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")
|
||||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue