2022-07-20 04:28:30 +02:00
|
|
|
extends "res://objects/characters/character.gd"
|
|
|
|
|
2022-07-27 12:51:26 +02:00
|
|
|
enum PLAYER_STATES {
|
|
|
|
IDLE,
|
|
|
|
JUMP,
|
|
|
|
RUN,
|
|
|
|
INJURED
|
2022-07-20 04:28:30 +02:00
|
|
|
}
|
|
|
|
|
2022-07-27 12:51:26 +02:00
|
|
|
var player_state = PLAYER_STATES.IDLE
|
2022-07-20 04:28:30 +02:00
|
|
|
|
|
|
|
func _ready():
|
2022-07-27 12:51:26 +02:00
|
|
|
pass # Replace with function body.
|
2022-07-20 04:28:30 +02:00
|
|
|
|
2022-07-27 12:51:26 +02:00
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(delta):
|
|
|
|
# Movement
|
|
|
|
if Input.is_action_pressed("move_left") and not Input.is_action_pressed("move_right"):
|
|
|
|
velocity.x = -GlobalConfig.DEFAULT_SPEED.x * delta
|
|
|
|
elif Input.is_action_pressed("move_right") and not Input.is_action_pressed("move_left"):
|
|
|
|
velocity.x = GlobalConfig.DEFAULT_SPEED.x * delta
|
2022-07-20 04:28:30 +02:00
|
|
|
else:
|
|
|
|
velocity.x = 0
|
|
|
|
|
2022-07-27 12:51:26 +02:00
|
|
|
# Jump
|
|
|
|
if Input.is_action_just_pressed("jump") and _check_jump():
|
|
|
|
_disable_snap()
|
2022-07-20 04:28:30 +02:00
|
|
|
position.y += get_floor_velocity().y * get_physics_process_delta_time() \
|
2022-07-27 12:51:26 +02:00
|
|
|
- GlobalConfig.GRAVITY.y * get_physics_process_delta_time() - 3
|
|
|
|
velocity.y = GlobalConfig.DEFAULT_JUMP.y * delta
|