feat: basic dialogue system and opening cutscene
This commit is contained in:
@ -16,6 +16,36 @@ var gravity_modifier = 1
|
||||
|
||||
var animated_sprites = []
|
||||
|
||||
var is_in_cutscene = false
|
||||
var current_animation = "idle"
|
||||
|
||||
func play_anim():
|
||||
for sprite in animated_sprites:
|
||||
sprite.play(current_animation)
|
||||
|
||||
func play_anim_run():
|
||||
current_animation = "run"
|
||||
|
||||
func play_anim_idle():
|
||||
current_animation = "idle"
|
||||
|
||||
func play_anim_jump():
|
||||
current_animation = "jump"
|
||||
|
||||
func set_in_cutscene():
|
||||
is_in_cutscene = true
|
||||
|
||||
func set_in_play():
|
||||
is_in_cutscene = false
|
||||
|
||||
func look_left():
|
||||
for sprite in animated_sprites:
|
||||
sprite.flip_h = true
|
||||
|
||||
func look_right():
|
||||
for sprite in animated_sprites:
|
||||
sprite.flip_h = false
|
||||
|
||||
func _ready() -> void:
|
||||
animated_sprites = [
|
||||
knight,
|
||||
@ -23,6 +53,12 @@ func _ready() -> void:
|
||||
]
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
play_anim()
|
||||
if is_in_cutscene:
|
||||
move_and_slide()
|
||||
return
|
||||
|
||||
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta * gravity_modifier
|
||||
|
||||
@ -32,19 +68,14 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
var direction := Input.get_axis("move_left", "move_right")
|
||||
if direction > 0:
|
||||
for sprite in animated_sprites:
|
||||
sprite.flip_h = false
|
||||
|
||||
look_right()
|
||||
if direction < 0:
|
||||
for sprite in animated_sprites:
|
||||
sprite.flip_h = true
|
||||
look_left()
|
||||
|
||||
if velocity.x != 0:
|
||||
for sprite in animated_sprites:
|
||||
sprite.play("run")
|
||||
play_anim_run()
|
||||
else:
|
||||
for sprite in animated_sprites:
|
||||
sprite.play("idle")
|
||||
play_anim_idle()
|
||||
|
||||
if direction:
|
||||
var smoothed_speed = speed * smoothstep(0, 1, acceleration)
|
||||
@ -54,3 +85,7 @@ func _physics_process(delta: float) -> void:
|
||||
velocity.x = move_toward(velocity.x, 0, speed)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func _on_dialogue_manager_dialogue_ended() -> void:
|
||||
set_in_play()
|
||||
|
Reference in New Issue
Block a user