Create character and player scripts, import character tilesets

This commit is contained in:
2026-03-27 17:56:45 +01:00
parent 41e86c99da
commit 1a306b53a4
18 changed files with 718 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
extends Character
var screen_size
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
screen_size = get_viewport_rect().size
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
super._process(delta)
# Read keyboard input and adjust player state
if Input.is_action_pressed("move_right"):
player_state = Global.CHARACTERSTATES.WALK_RIGHT
velocity.x += 1
elif Input.is_action_pressed("move_left"):
player_state = Global.CHARACTERSTATES.WALK_LEFT
velocity.x -= 1
elif Input.is_action_pressed("move_down"):
player_state = Global.CHARACTERSTATES.WALK_DOWN
velocity.y += 1
elif Input.is_action_pressed("move_up"):
player_state = Global.CHARACTERSTATES.WALK_UP
velocity.y -= 1
else:
match(player_state):
Global.CHARACTERSTATES.WALK_RIGHT: player_state = Global.CHARACTERSTATES.IDLE_RIGHT
Global.CHARACTERSTATES.WALK_LEFT: player_state = Global.CHARACTERSTATES.IDLE_LEFT
Global.CHARACTERSTATES.WALK_UP: player_state = Global.CHARACTERSTATES.IDLE_UP
Global.CHARACTERSTATES.WALK_DOWN: player_state = Global.CHARACTERSTATES.IDLE_DOWN
super.animate()