oh-my-git/scenes/player.tscn

32 lines
789 B
Text
Raw Normal View History

2020-01-29 20:25:13 +01:00
[gd_scene load_steps=3 format=2]
2020-10-26 18:56:35 +01:00
[sub_resource type="GDScript" id=1]
2023-09-06 16:04:23 +02:00
script/source = "extends CharacterBody2D
2020-01-29 20:25:13 +01:00
2023-09-06 16:04:23 +02:00
@export var speed = 800
2020-10-26 18:56:35 +01:00
func _ready():
pass
func _process(delta):
var right = Input.get_action_strength(\"right\") - Input.get_action_strength(\"left\")
var down = Input.get_action_strength(\"down\") - Input.get_action_strength(\"up\")
2023-09-06 16:04:23 +02:00
set_velocity(Vector2(right, down).normalized()*speed)
move_and_slide()
2020-10-26 18:56:35 +01:00
"
[sub_resource type="RectangleShape2D" id=2]
2023-09-06 16:04:23 +02:00
size = Vector2( 50, 50 )
2020-01-29 20:25:13 +01:00
2023-09-06 16:04:23 +02:00
[node name="Player" type="CharacterBody2D"]
2020-10-26 18:56:35 +01:00
script = SubResource( 1 )
2020-01-29 20:25:13 +01:00
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
2020-10-26 18:56:35 +01:00
shape = SubResource( 2 )
2020-01-29 20:25:13 +01:00
[node name="Rect" type="ColorRect" parent="."]
2023-09-06 16:04:23 +02:00
offset_left = -50.0
offset_top = -50.0
offset_right = 50.0
offset_bottom = 50.0