extends CharacterBody2D

@export var gravity = 400
@export var playerSpeed = 200
@export var jumpforce = 200
var clampedYVelocity = 500


@onready var animated_sprite = $AnimatedSprite2D

func _process(delta):	
	if Input.is_action_just_pressed("move_right"):
		animated_sprite.play("Run")
		if velocity.y > clampedYVelocity:
			velocity.y = clampedYVelocity


func _physics_process(delta):
	if is_on_floor() == false:
		velocity.y += gravity * delta
	
	if Input.is_action_just_pressed("jump") && is_on_floor():
		velocity.y += -jumpforce 
	
	var direction = Input.get_axis("move_left","move_right")
	velocity.x = direction * playerSpeed 
	move_and_slide()
	
	
	#and &&
	#or ||
	#not ! (Like != not equal to)

func _ready():
	pass
	
	
