This repository has been archived on 2024-08-28. You can view files and clone it, but cannot push or open issues or pull requests.
gmtk-2024/player.gd

20 lines
447 B
GDScript3
Raw Normal View History

2024-08-17 14:22:33 +00:00
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()