Compare commits

..

No commits in common. "47aa35a4c7313366cd30671824257946de3012ad" and "e161eb1117e3a94601eff6f0d5e75124ad4b85a0" have entirely different histories.

7 changed files with 12 additions and 37 deletions

View file

@ -45,10 +45,10 @@ func match_state(exclude: Array[StringName] = []) -> StringName:
return ""
func watch_state(exclude: Array[StringName] = [], data: Dictionary[StringName, Variant] = {}) -> bool:
func watch_state(exclude: Array[StringName] = []) -> bool:
var next_state: StringName = match_state(exclude)
if next_state != "":
finished.emit(next_state, data)
finished.emit(next_state)
return true
return false

View file

@ -12,7 +12,7 @@ dest_files=["res://.godot/imported/yukotsuki.aseprite-2775b59c70c8f83084c0d15003
[params]
layer/exclude_layers_pattern="ref"
layer/exclude_layers_pattern=""
layer/only_visible_layers=false
sheet/sheet_type="packed"
sheet/sheet_columns=12

View file

@ -8,31 +8,8 @@ const DEADZONE = 0.1
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
@onready var state_machine: StateMachine = $StateMachine
var h_press_tick: int = 0 ## last time horizontal axis was pressed
var v_press_tick: int = 0 ## last time vertical axis was pressed
func _input(event: InputEvent) -> void:
if event.is_action_pressed("move_left") or event.is_action_pressed("move_right"):
h_press_tick = Time.get_ticks_msec()
if event.is_action_pressed("move_up") or event.is_action_pressed("move_down"):
v_press_tick = Time.get_ticks_msec()
func get_movement_vector() -> Vector2:
var x_strength: float = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
var y_strength: float = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
if abs(x_strength) < DEADZONE and abs(y_strength) < DEADZONE:
return Vector2.ZERO
if abs(x_strength) < DEADZONE:
return Vector2(0, signf(y_strength))
if abs(y_strength) < DEADZONE:
return Vector2(signf(x_strength), 0)
# use most recent axis press
if h_press_tick > v_press_tick:
return Vector2(signf(x_strength), 0)
else:
return Vector2(0, signf(y_strength))
var x_mov: float = Input.get_action_strength('move_right') - Input.get_action_strength('move_left')
var y_mov: float = Input.get_action_strength('move_down') - Input.get_action_strength('move_up')
return Vector2(x_mov, y_mov)

View file

@ -31,7 +31,6 @@ metadata/_custom_type_script = "uid://bebe1y51hwns8"
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(0, -16)
sprite_frames = ExtResource("2_dovo2")
animation = &"idle"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -7)

View file

@ -6,10 +6,11 @@ var next_state: StringName
func _enter(_previous_state_path: String, _data: Dictionary[StringName, Variant] = {}) -> void:
print('entering idle')
player.velocity = Vector2.ZERO
player.move_and_slide()
player.sprite.play("idle")
# TODO: animations
print('entered')

View file

@ -10,15 +10,13 @@ func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
func _state_physics_update(_delta: float) -> void:
var direction: Vector2 = player.get_movement_vector()
direction = direction.normalized()
var movement_vector: Vector2 = player.get_movement_vector()
var direction: Vector2 = movement_vector.normalized()
player.velocity = direction * player.max_speed
player.move_and_slide()
if watch_state([WALKING]): return
if direction.y > 0:
player.sprite.play("walk_down")
if direction.y < 0:
player.sprite.play("walk_up")
# TODO: animations
#player.sprite.play(player.anim_dir)