This commit is contained in:
2024-10-25 17:48:21 +02:00
parent ab6acac55b
commit 5dc5c305e3
7 changed files with 144 additions and 38 deletions

View File

@ -11,7 +11,7 @@ func _physics_process(delta: float) -> void:
velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
if (Input.is_action_just_pressed("ui_accept") or Input.is_action_just_pressed("ui_up")) and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.

18
scripts/slime.gd Normal file
View File

@ -0,0 +1,18 @@
extends Node2D
@onready var ray_cast_right: RayCast2D = $RayCastRight
@onready var ray_cast_left: RayCast2D = $RayCastLeft
@onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D
const speed = 60
var direction = 1
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if ray_cast_right.is_colliding():
direction = -1
animated_sprite_2d.flip_h = true
elif ray_cast_left.is_colliding():
direction = 1
animated_sprite_2d.flip_h = false
position.x += delta * speed * direction