channel-switcher/games/bullet_hell/bulletHellMovement.gd

29 lines
702 B
GDScript3
Raw Permalink Normal View History

2025-05-11 20:46:20 +10:00
extends CharacterBody2D
const SPEED = 200.0
#const JUMP_VELOCITY = -400.0
2025-05-11 20:46:20 +10:00
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var hDirection := Input.get_axis("hell_left", "hell_right")
var vDirection := Input.get_axis("hell_up", "hell_down")
if hDirection:
velocity.x = hDirection * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
if vDirection:
velocity.y = vDirection * SPEED
else:
velocity.y = move_toward(velocity.y, 0, SPEED)
move_and_slide()