17 lines
372 B
GDScript3
17 lines
372 B
GDScript3
|
|
extends CharacterBody2D
|
||
|
|
|
||
|
|
const SPEED = 500.0
|
||
|
|
|
||
|
|
func _physics_process(_delta: float) -> void:
|
||
|
|
var direction = 0
|
||
|
|
if Input.is_key_pressed(KEY_S):
|
||
|
|
direction += 1
|
||
|
|
if Input.is_key_pressed(KEY_W):
|
||
|
|
direction -= 1
|
||
|
|
|
||
|
|
velocity.y = direction * SPEED
|
||
|
|
move_and_slide()
|
||
|
|
|
||
|
|
# Begrenzung (angepasst an größere Schläger)
|
||
|
|
global_position.y = clamp(global_position.y, 54, 594)
|