From 474ef692613f298ab05bbb65ad85625f178b63cc Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 28 Dec 2024 15:08:23 +0100 Subject: next commit --- player/player.gd | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'player/player.gd') diff --git a/player/player.gd b/player/player.gd index 4257f2a..9d1d6ee 100644 --- a/player/player.gd +++ b/player/player.gd @@ -4,6 +4,8 @@ extends Character var is_invincible := false +var mobile_controls: MobileControls + @onready var camera := $Camera2D @@ -14,25 +16,7 @@ func _ready() -> void: func _process(_delta: float) -> void: - if current_state == State.Idle: - if Input.is_action_pressed("ui_left"): - walk(Direction.Left) - elif Input.is_action_pressed("ui_right"): - walk(Direction.Right) - else: - idle() - - if Input.is_action_pressed("ui_up"): - jump() - if Input.is_action_pressed("ui_down"): - if not is_on_bottom_floor(): - fall() - - if not is_on_floor(): - fall() - - - elif current_state == State.Walk: + if current_state == State.Idle or current_state == State.Walk: if Input.is_action_pressed("ui_left"): walk(Direction.Left) elif Input.is_action_pressed("ui_right"): @@ -63,6 +47,11 @@ func invincible(duration: float): await tween.finished is_invincible = false + + (func(): # re-trigger area entered + $Collision.monitoring = false + $Collision.monitoring = true + ).call_deferred() enum Result { @@ -101,10 +90,13 @@ func _on_collision_area_entered(area: Area2D) -> void: var opponent: Character = area.get_parent() var result := Player.is_rock_paper_scissors_win(self, opponent) + if result == Result.Draw: type_change_finished.connect(func(): change_type_random() + invincible(1.0) ) + is_invincible = true animate_type_change() elif result == Result.Win: @@ -116,6 +108,7 @@ func _on_collision_area_entered(area: Area2D) -> void: change_type_random() invincible(1.0) ) + is_invincible = true animate_type_change() opponent.process_mode = Node.PROCESS_MODE_DISABLED @@ -145,4 +138,5 @@ func _on_collision_area_entered(area: Area2D) -> void: await $AnimatedSprite2D.animation_finished SoundManager.get_node("PlayerKO").stop() visible = false + await get_tree().create_timer(0.3).timeout get_tree().change_scene_to_file("res://stage/stage_01.tscn") -- cgit v1.2.3