diff --git a/.gitignore b/.gitignore index 21e0d85..3706029 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ .import/ export.cfg export_presets.cfg +*.gd.uid # Imported translations (automatically generated from CSV files) *.translation diff --git a/project.godot b/project.godot index a3ab20e..881dac6 100644 --- a/project.godot +++ b/project.godot @@ -11,9 +11,28 @@ config_version=5 [application] config/name="novast" +run/main_scene="uid://cc2rcjjhxub7p" 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) +] +} +jump={ +"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":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +] +} + [physics] 3d/physics_engine="Jolt Physics" diff --git a/scenes/player/player.tscn b/scenes/player/player.tscn new file mode 100644 index 0000000..17248f2 --- /dev/null +++ b/scenes/player/player.tscn @@ -0,0 +1,16 @@ +[gd_scene format=3 uid="uid://cc2rcjjhxub7p"] + +[ext_resource type="Script" uid="uid://nqa2egumodp5" path="res://scripts/player/player.gd" id="1_8afob"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_o8nba"] + +[node name="Player" type="CharacterBody2D" unique_id=1801952962] +script = ExtResource("1_8afob") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=925020035] +shape = SubResource("CapsuleShape2D_o8nba") + +[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1313216180] + +[node name="Camera2D" type="Camera2D" parent="." unique_id=209519618] +visible = false diff --git a/scripts/player/player.gd b/scripts/player/player.gd new file mode 100644 index 0000000..b42299f --- /dev/null +++ b/scripts/player/player.gd @@ -0,0 +1,20 @@ +extends CharacterBody2D + +const SPEED = 300.0 +const JUMP_VELOCITY = -400.0 + + +func _physics_process(delta: float) -> void: + if not is_on_floor(): + velocity += get_gravity() * delta + + if Input.is_action_just_pressed("jump") and is_on_floor(): + velocity.y = JUMP_VELOCITY + + var direction := Input.get_axis("move_left", "move_right") + if direction: + velocity.x = direction * SPEED + else: + velocity.x = move_toward(velocity.x, 0, SPEED) + + move_and_slide()