diff options
author | Zoey Kitt <zoey.kitt@outlook.com> | 2024-11-16 17:31:04 -0600 |
---|---|---|
committer | Zoey Kitt <zoey.kitt@outlook.com> | 2024-11-16 17:31:04 -0600 |
commit | 9f505c69edd093b807e6924d708993db253b2c92 (patch) | |
tree | 5b2ece4559b2cdc6cbb39a704aee1960c1a08e65 /scenes/microgames/fishin/fishin.gd | |
parent | a4a7851542db91d93b75bd42aa1c1df0edca0e90 (diff) | |
parent | 0806d809557c4c1bff35707b825e3475c816d0e6 (diff) |
Merge branch 'main' into main-window
Diffstat (limited to 'scenes/microgames/fishin/fishin.gd')
-rw-r--r-- | scenes/microgames/fishin/fishin.gd | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/scenes/microgames/fishin/fishin.gd b/scenes/microgames/fishin/fishin.gd new file mode 100644 index 0000000..44b60db --- /dev/null +++ b/scenes/microgames/fishin/fishin.gd @@ -0,0 +1,113 @@ +extends MicrogameWindow + +const IN_GAME_WAIT_TIME = 10 + +var pulling: Sprite2D +var mash: Label +var you: Sprite2D +var sad: Sprite2D +var happy: Sprite2D +var mouse: Sprite2D +var shake: ShakePivot +var shake2: ShakePivot +var shake3: ShakePivot +var start_game_timer: Timer +var in_game_timer: Timer +var succfail_timer: Timer + +var in_minigame = false +var num_clicks = 0 + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pulling = $ShakePivot/pulling + you = $"you!" + mash = $ShakePivot2/MASH + mouse = $ShakePivot3/Mouse + shake = $ShakePivot + shake2 = $ShakePivot2 + shake3 = $ShakePivot3 + sad = $SAD + happy = $Happy + start_game_timer = $StartGame + in_game_timer = $InGame + succfail_timer = $SuccessFail + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_texture_button_button_up() -> void: + shake.shake() + shake2.shake() + shake3.shake() + + if in_minigame: + num_clicks -= 1 + + # YOU WIN + if num_clicks == 0: + in_minigame = false + + # hide non-happy cats + pulling.visible = false + mash.visible = false + mouse.visible = false + sad.visible = false + you.visible = false + + # show happy cat + happy.visible = true + + in_game_timer.stop() + in_game_timer.wait_time = IN_GAME_WAIT_TIME + succfail_timer.start() + + +func _on_start_game_timeout() -> void: + if randf() < 0.1: + start_game_timer.stop() + in_game_timer.start() + + in_minigame = true + + # hide passive cats + you.visible = false + sad.visible = false + happy.visible = false + + # show active cat + pulling.visible = true + mash.visible = true + mouse.visible = true + + num_clicks = randi_range(5,21) + num_clicks = 21 + + +# YOU LOSE +func _on_in_game_timeout() -> void: + in_minigame = false + + # hide non-sad cats + you.visible = false + happy.visible = false + pulling.visible = false + mash.visible = false + mouse.visible = false + + # show sad cat + sad.visible = true + + in_game_timer.stop() + succfail_timer.start() + + +func _on_success_fail_timeout() -> void: + sad.visible = false + happy.visible = false + you.visible = true + succfail_timer.stop() + start_game_timer.start() |