forked from newt/gmtk-2024
19 lines
447 B
GDScript
19 lines
447 B
GDScript
extends CharacterBody2D
|
|
|
|
@export var SPEED = 300
|
|
@export var GRAVITY = 30
|
|
@export var JUMP_FORCE = 500
|
|
|
|
func _physics_process(delta):
|
|
if !is_on_floor():
|
|
velocity.y += GRAVITY
|
|
if velocity.y > 1000:
|
|
velocity.y = 1000
|
|
|
|
if Input.is_action_just_pressed("jump") && is_on_floor():
|
|
velocity.y = -JUMP_FORCE
|
|
|
|
var horizontal_direction = Input.get_axis("move_left", "move_right")
|
|
velocity.x = SPEED * horizontal_direction
|
|
|
|
move_and_slide()
|