channel-switcher/games/bullet_hell/bulletHellMovement.gd

28 lines
702 B
GDScript

extends CharacterBody2D
const SPEED = 200.0
#const JUMP_VELOCITY = -400.0
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()