feat: choice system
This commit is contained in:
@ -11,17 +11,14 @@ var jump_velocity = 400.0
|
||||
@export_range(0, 10, 0.1, "or_greater")
|
||||
var gravity_modifier = 1
|
||||
|
||||
@onready var knight: AnimatedSprite2D = $Knight
|
||||
@onready var base: AnimatedSprite2D = $Base
|
||||
|
||||
var animated_sprites = []
|
||||
var current_sprite: AnimatedSprite2D
|
||||
|
||||
var is_in_cutscene = false # back to true on build
|
||||
var current_animation = "idle"
|
||||
|
||||
func play_anim():
|
||||
for sprite: AnimatedSprite2D in animated_sprites:
|
||||
sprite.play(current_animation)
|
||||
current_sprite.play(current_animation)
|
||||
|
||||
func play_anim_run():
|
||||
current_animation = "run"
|
||||
@ -31,31 +28,29 @@ func play_anim_idle():
|
||||
|
||||
func play_anim_jump():
|
||||
current_animation = "jump"
|
||||
|
||||
func play_anim_dance():
|
||||
current_animation = "dance"
|
||||
|
||||
func set_in_cutscene():
|
||||
is_in_cutscene = true
|
||||
play_anim_idle()
|
||||
|
||||
func set_in_play():
|
||||
is_in_cutscene = false
|
||||
|
||||
func look_left():
|
||||
for sprite in animated_sprites:
|
||||
sprite.flip_h = true
|
||||
current_sprite.flip_h = true
|
||||
|
||||
func look_right():
|
||||
for sprite in animated_sprites:
|
||||
sprite.flip_h = false
|
||||
current_sprite.flip_h = false
|
||||
|
||||
func _ready() -> void:
|
||||
animated_sprites = [
|
||||
knight,
|
||||
base
|
||||
]
|
||||
current_sprite = base
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
play_anim()
|
||||
if is_in_cutscene:
|
||||
play_anim_idle()
|
||||
velocity.x = move_toward(velocity.x, 0, speed)
|
||||
move_and_slide()
|
||||
return
|
||||
@ -70,7 +65,6 @@ func _physics_process(delta: float) -> void:
|
||||
if direction < 0 and is_on_floor():
|
||||
look_left()
|
||||
|
||||
|
||||
if not is_on_floor():
|
||||
current_animation = "got_hit"
|
||||
else:
|
||||
@ -94,3 +88,11 @@ func _on_dialogue_manager_dialogue_ended() -> void:
|
||||
|
||||
func _on_trigger_dialogue_body_entered(body: Node2D) -> void:
|
||||
set_in_cutscene()
|
||||
|
||||
func _on_start_dancing() -> void:
|
||||
play_anim_dance()
|
||||
|
||||
func _on_npc_shield_dialogue_dialogue_ended() -> void:
|
||||
set_in_play()
|
||||
print("jget shield")
|
||||
|
||||
|
Reference in New Issue
Block a user