diff --git a/block/Scenes/player.gd b/block/Scenes/player.gd index 0cbac16..7c6d508 100644 --- a/block/Scenes/player.gd +++ b/block/Scenes/player.gd @@ -2,25 +2,17 @@ extends CharacterBody2D const SPEED = 300.0 -const JUMP_VELOCITY = -400.0 -## Default Template is used - -func _physics_process(delta: float) -> void: - # Add the gravity. - #if not is_on_floor(): - # velocity += get_gravity() * delta - - # Handle jump. - if Input.is_action_just_pressed("ui_accept") and is_on_floor(): - velocity.y = JUMP_VELOCITY - - # Get the input direction and handle the movement/deceleration. - # As good practice, you should replace UI actions with custom gameplay actions. - var direction := Input.get_axis("ui_left", "ui_right") - if direction: - velocity.x = direction * SPEED - else: - velocity.x = move_toward(velocity.x, 0, SPEED) +func _process(_delta: float) -> void: + + var dirX := Input.get_axis("move_left", "move_right") + var dirY := Input.get_axis("move_up", "move_down") + + var dir := Vector2(dirX, dirY) + dir = dir.normalized() * SPEED + + velocity.x = dir.x + velocity.y = dir.y + move_and_slide() diff --git a/block/project.godot b/block/project.godot index f0339aa..b20b420 100644 --- a/block/project.godot +++ b/block/project.godot @@ -15,6 +15,33 @@ run/main_scene="uid://du7hapc7kscm6" config/features=PackedStringArray("4.6", "Forward Plus") config/icon="res://icon.svg" +[input] + +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) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null) +] +} +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) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"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) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"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) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null) +] +} + [physics] 3d/physics_engine="Jolt Physics"