contrib: spaceship scene #2
@@ -11,9 +11,33 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="arco"
|
||||
run/main_scene="uid://bljiu3udiypxw"
|
||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[input]
|
||||
|
||||
move_left={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_right={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_up={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_down={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[physics]
|
||||
|
||||
3d/physics_engine="Jolt Physics"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene format=3 uid="uid://bljiu3udiypxw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ev121glffa0v" path="res://scripts/spaceship.gd" id="1_yqmju"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ky2tl"]
|
||||
|
||||
[node name="Spaceship" type="CharacterBody2D" unique_id=1542800769]
|
||||
script = ExtResource("1_yqmju")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1103597978]
|
||||
shape = SubResource("CapsuleShape2D_ky2tl")
|
||||
@@ -0,0 +1,15 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var thrust := 500.0
|
||||
@export var friction := 0.98
|
||||
@export var max_speed := 1000.0
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var direction = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
#
|
||||
velocity += direction * thrust * delta
|
||||
velocity *= friction
|
||||
|
||||
velocity = velocity.limit_length(max_speed)
|
||||
move_and_slide()
|
||||
Reference in New Issue
Block a user