diff options
author | Jacob Janzen <jacob.a.s.janzen@gmail.com> | 2024-11-16 16:38:29 -0600 |
---|---|---|
committer | Jacob Janzen <jacob.a.s.janzen@gmail.com> | 2024-11-16 16:38:29 -0600 |
commit | 1e4c8bc17404ab9a22f94a22430c57dbffc354c0 (patch) | |
tree | 710eaf39ffe0fe6297365566332ef45e8ac35982 | |
parent | 614d5811cf43f2d35658a74cb3d6ea7215266f15 (diff) |
add complete fishing minigame
-rw-r--r-- | UI/MousePrompt.png | bin | 0 -> 13309 bytes | |||
-rw-r--r-- | UI/MousePrompt.png.import | 34 | ||||
-rw-r--r-- | UI/MousePrompt.xcf | bin | 0 -> 87260 bytes | |||
-rw-r--r-- | UI/MousePrompt2.png | bin | 0 -> 13959 bytes | |||
-rw-r--r-- | UI/MousePrompt2.png.import | 34 | ||||
-rw-r--r-- | libs/shake_pivot.gd | 55 | ||||
-rw-r--r-- | scenes/microgames/fishin/Kibbby.png | bin | 0 -> 9264 bytes | |||
-rw-r--r-- | scenes/microgames/fishin/Kibbby.png.import | 34 | ||||
-rw-r--r-- | scenes/microgames/fishin/Kibbby.xcf | bin | 0 -> 90677 bytes | |||
-rw-r--r-- | scenes/microgames/fishin/Kibbby2.xcf | bin | 0 -> 53157 bytes | |||
-rw-r--r-- | scenes/microgames/fishin/KibbbyHappy.png | bin | 0 -> 9082 bytes | |||
-rw-r--r-- | scenes/microgames/fishin/KibbbyHappy.png.import | 34 | ||||
-rw-r--r-- | scenes/microgames/fishin/KibbbyPulling.png | bin | 0 -> 13551 bytes | |||
-rw-r--r-- | scenes/microgames/fishin/KibbbyPulling.png.import | 34 | ||||
-rw-r--r-- | scenes/microgames/fishin/KibbbySad.png | bin | 0 -> 9267 bytes | |||
-rw-r--r-- | scenes/microgames/fishin/KibbbySad.png.import | 34 | ||||
-rw-r--r-- | scenes/microgames/fishin/fishin.gd | 112 | ||||
-rw-r--r-- | scenes/microgames/fishin/node_2d.tscn | 130 |
18 files changed, 501 insertions, 0 deletions
diff --git a/UI/MousePrompt.png b/UI/MousePrompt.png Binary files differnew file mode 100644 index 0000000..51265cd --- /dev/null +++ b/UI/MousePrompt.png diff --git a/UI/MousePrompt.png.import b/UI/MousePrompt.png.import new file mode 100644 index 0000000..57f457c --- /dev/null +++ b/UI/MousePrompt.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://is20ioxt1vtm" +path="res://.godot/imported/MousePrompt.png-ed9ca78d2e5824537b7a8763755c2eae.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/MousePrompt.png" +dest_files=["res://.godot/imported/MousePrompt.png-ed9ca78d2e5824537b7a8763755c2eae.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/UI/MousePrompt.xcf b/UI/MousePrompt.xcf Binary files differnew file mode 100644 index 0000000..0031fde --- /dev/null +++ b/UI/MousePrompt.xcf diff --git a/UI/MousePrompt2.png b/UI/MousePrompt2.png Binary files differnew file mode 100644 index 0000000..636f271 --- /dev/null +++ b/UI/MousePrompt2.png diff --git a/UI/MousePrompt2.png.import b/UI/MousePrompt2.png.import new file mode 100644 index 0000000..57e3b88 --- /dev/null +++ b/UI/MousePrompt2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://us0sonuda24u" +path="res://.godot/imported/MousePrompt2.png-c917e8205ae3985a502b0999c84ef600.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/MousePrompt2.png" +dest_files=["res://.godot/imported/MousePrompt2.png-c917e8205ae3985a502b0999c84ef600.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/libs/shake_pivot.gd b/libs/shake_pivot.gd new file mode 100644 index 0000000..5794ca0 --- /dev/null +++ b/libs/shake_pivot.gd @@ -0,0 +1,55 @@ +class_name ShakePivot +extends Node2D +## Shakes on command. Use this node as the parent of a sprite or a camera to make it shake! +## Adapted from https://shaggydev.com/2022/02/23/screen-shake-godot/. + +## How quickly to move through the noise. +@export var NOISE_SHAKE_SPEED: float = 20.0 +## How much to multiply the noise values (which are in the range (-1, 1)) by. +@export var NOISE_SHAKE_STRENGTH: float = 15.0 +## Multiplier for lerping the shake strength to zero. +@export var SHAKE_DECAY_RATE: float = 10.0 + +## Object that creates random noise to make for a nice shaking motion. +@onready var _noise := FastNoiseLite.new() + +## Used to keep track of where we are in the noise so we can smoothly move through it. +var noise_i: float = 0.0 +## Value taken from the noise to calculate the shaking node's position. +var shake_strength: float = 0.0 + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + # Set noise type to simplex, since the tutorial I'm copying (uh I mean taking inspiration from) + # is for an older version of Godot that had a dedicated simplex noise class + _noise.noise_type = FastNoiseLite.TYPE_SIMPLEX + # Randomize the generated noise + _noise.seed = randi() + # Period affects how quickly the noise changes values + _noise.frequency = 0.5 + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + # Fade out the intensity over time + shake_strength = lerp(shake_strength, 0.0, SHAKE_DECAY_RATE * delta) + + # Shake by adjusting position so we can move the object around + position = get_noise_offset(delta) + + +## Uses noise to generate a random 2D vector +func get_noise_offset(delta: float) -> Vector2: + noise_i += delta * NOISE_SHAKE_SPEED + # Set the x values of each call to 'get_noise_2d' to a different value so that our x and y + # vectors will read from unrelated areas of noise + return Vector2( + _noise.get_noise_2d(1, noise_i) * shake_strength, + _noise.get_noise_2d(100, noise_i) * shake_strength + ) + + +## Sets the strength to its initial value. +func shake() -> void: + shake_strength = NOISE_SHAKE_STRENGTH diff --git a/scenes/microgames/fishin/Kibbby.png b/scenes/microgames/fishin/Kibbby.png Binary files differnew file mode 100644 index 0000000..2631003 --- /dev/null +++ b/scenes/microgames/fishin/Kibbby.png diff --git a/scenes/microgames/fishin/Kibbby.png.import b/scenes/microgames/fishin/Kibbby.png.import new file mode 100644 index 0000000..d58c2cb --- /dev/null +++ b/scenes/microgames/fishin/Kibbby.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://crpp1qfyk4tv7" +path="res://.godot/imported/Kibbby.png-a5e7e28c8f175ffac07cfcdb8f612803.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/microgames/fishin/Kibbby.png" +dest_files=["res://.godot/imported/Kibbby.png-a5e7e28c8f175ffac07cfcdb8f612803.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/microgames/fishin/Kibbby.xcf b/scenes/microgames/fishin/Kibbby.xcf Binary files differnew file mode 100644 index 0000000..c080cc2 --- /dev/null +++ b/scenes/microgames/fishin/Kibbby.xcf diff --git a/scenes/microgames/fishin/Kibbby2.xcf b/scenes/microgames/fishin/Kibbby2.xcf Binary files differnew file mode 100644 index 0000000..9aaf4dc --- /dev/null +++ b/scenes/microgames/fishin/Kibbby2.xcf diff --git a/scenes/microgames/fishin/KibbbyHappy.png b/scenes/microgames/fishin/KibbbyHappy.png Binary files differnew file mode 100644 index 0000000..b9756cd --- /dev/null +++ b/scenes/microgames/fishin/KibbbyHappy.png diff --git a/scenes/microgames/fishin/KibbbyHappy.png.import b/scenes/microgames/fishin/KibbbyHappy.png.import new file mode 100644 index 0000000..071e612 --- /dev/null +++ b/scenes/microgames/fishin/KibbbyHappy.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dcvie7ynwdfui" +path="res://.godot/imported/KibbbyHappy.png-2f6e79d205df1bdf038b3aa13617c533.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/microgames/fishin/KibbbyHappy.png" +dest_files=["res://.godot/imported/KibbbyHappy.png-2f6e79d205df1bdf038b3aa13617c533.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/microgames/fishin/KibbbyPulling.png b/scenes/microgames/fishin/KibbbyPulling.png Binary files differnew file mode 100644 index 0000000..a6bc22b --- /dev/null +++ b/scenes/microgames/fishin/KibbbyPulling.png diff --git a/scenes/microgames/fishin/KibbbyPulling.png.import b/scenes/microgames/fishin/KibbbyPulling.png.import new file mode 100644 index 0000000..dc61ec1 --- /dev/null +++ b/scenes/microgames/fishin/KibbbyPulling.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://br3jiit0v6jes" +path="res://.godot/imported/KibbbyPulling.png-351fdd0a725255d7bbe5dd2e3b228f38.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/microgames/fishin/KibbbyPulling.png" +dest_files=["res://.godot/imported/KibbbyPulling.png-351fdd0a725255d7bbe5dd2e3b228f38.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/microgames/fishin/KibbbySad.png b/scenes/microgames/fishin/KibbbySad.png Binary files differnew file mode 100644 index 0000000..091f77b --- /dev/null +++ b/scenes/microgames/fishin/KibbbySad.png diff --git a/scenes/microgames/fishin/KibbbySad.png.import b/scenes/microgames/fishin/KibbbySad.png.import new file mode 100644 index 0000000..2fedff6 --- /dev/null +++ b/scenes/microgames/fishin/KibbbySad.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d4kyih3ivlqqc" +path="res://.godot/imported/KibbbySad.png-583f604f245d5791b483e626ccda4f31.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/microgames/fishin/KibbbySad.png" +dest_files=["res://.godot/imported/KibbbySad.png-583f604f245d5791b483e626ccda4f31.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/microgames/fishin/fishin.gd b/scenes/microgames/fishin/fishin.gd new file mode 100644 index 0000000..7e1ae3c --- /dev/null +++ b/scenes/microgames/fishin/fishin.gd @@ -0,0 +1,112 @@ +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,20) + + +# 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() diff --git a/scenes/microgames/fishin/node_2d.tscn b/scenes/microgames/fishin/node_2d.tscn new file mode 100644 index 0000000..94dbecb --- /dev/null +++ b/scenes/microgames/fishin/node_2d.tscn @@ -0,0 +1,130 @@ +[gd_scene load_steps=14 format=3 uid="uid://c4s4pigu4pr48"] + +[ext_resource type="Texture2D" uid="uid://voruypgyi77e" path="res://scenes/stockticker/UI-Background-Colour.png" id="1_cxqat"] +[ext_resource type="Script" path="res://scenes/microgames/fishin/fishin.gd" id="1_srw8b"] +[ext_resource type="Texture2D" uid="uid://crpp1qfyk4tv7" path="res://scenes/microgames/fishin/Kibbby.png" id="2_atppo"] +[ext_resource type="Texture2D" uid="uid://br3jiit0v6jes" path="res://scenes/microgames/fishin/KibbbyPulling.png" id="3_don82"] +[ext_resource type="Theme" uid="uid://ve18rbkeiwti" path="res://UI/text.tres" id="5_7qce4"] +[ext_resource type="Texture2D" uid="uid://is20ioxt1vtm" path="res://UI/MousePrompt.png" id="6_7ls0g"] +[ext_resource type="Texture2D" uid="uid://us0sonuda24u" path="res://UI/MousePrompt2.png" id="7_qpcgm"] +[ext_resource type="Script" path="res://libs/shake_pivot.gd" id="7_vnrfy"] +[ext_resource type="Texture2D" uid="uid://d4kyih3ivlqqc" path="res://scenes/microgames/fishin/KibbbySad.png" id="9_blola"] +[ext_resource type="Texture2D" uid="uid://dcvie7ynwdfui" path="res://scenes/microgames/fishin/KibbbyHappy.png" id="10_1il5r"] + +[sub_resource type="Animation" id="Animation_fxbt5"] +resource_name = "mash" +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ShakePivot3/Mouse:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0.0333334, 0.466667), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [ExtResource("6_7ls0g"), ExtResource("7_qpcgm")] +} + +[sub_resource type="Animation" id="Animation_bep6n"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ShakePivot3/Mouse:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [null] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_7e725"] +_data = { +"RESET": SubResource("Animation_bep6n"), +"mash": SubResource("Animation_fxbt5") +} + +[node name="Node2D" type="Window"] +position = Vector2i(0, 36) +size = Vector2i(930, 560) +unresizable = true +script = ExtResource("1_srw8b") + +[node name="background" type="Sprite2D" parent="."] +modulate = Color(0.42, 0.700333, 1, 1) +position = Vector2(649.75, 362.25) +scale = Vector2(1300.5, 725.5) +texture = ExtResource("1_cxqat") + +[node name="you!" type="Sprite2D" parent="."] +position = Vector2(535, 300) +texture = ExtResource("2_atppo") + +[node name="TextureButton" type="TextureButton" parent="."] +offset_right = 1298.0 +offset_bottom = 728.0 + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_7e725") +} +autoplay = "mash" +speed_scale = 8.0 + +[node name="ShakePivot" type="Node2D" parent="."] +script = ExtResource("7_vnrfy") + +[node name="pulling" type="Sprite2D" parent="ShakePivot"] +visible = false +position = Vector2(535, 300) +texture = ExtResource("3_don82") + +[node name="ShakePivot2" type="Node2D" parent="."] +script = ExtResource("7_vnrfy") + +[node name="MASH" type="Label" parent="ShakePivot2"] +visible = false +offset_left = 150.0 +offset_top = 358.0 +offset_right = 570.0 +offset_bottom = 598.0 +theme = ExtResource("5_7qce4") +theme_override_colors/font_color = Color(1, 0, 0, 1) +theme_override_font_sizes/font_size = 60 +text = "MASH!!!" + +[node name="ShakePivot3" type="Node2D" parent="."] +script = ExtResource("7_vnrfy") + +[node name="Mouse" type="Sprite2D" parent="ShakePivot3"] +visible = false +position = Vector2(412, 532) +scale = Vector2(0.216276, 0.249769) + +[node name="StartGame" type="Timer" parent="."] +autostart = true + +[node name="InGame" type="Timer" parent="."] +wait_time = 10.0 + +[node name="SAD" type="Sprite2D" parent="."] +visible = false +position = Vector2(535, 300) +texture = ExtResource("9_blola") + +[node name="Happy" type="Sprite2D" parent="."] +visible = false +position = Vector2(535, 300) +texture = ExtResource("10_1il5r") + +[node name="SuccessFail" type="Timer" parent="."] +wait_time = 2.0 + +[connection signal="button_up" from="TextureButton" to="." method="_on_texture_button_button_up"] +[connection signal="timeout" from="StartGame" to="." method="_on_start_game_timeout"] +[connection signal="timeout" from="InGame" to="." method="_on_in_game_timeout"] +[connection signal="timeout" from="SuccessFail" to="." method="_on_success_fail_timeout"] |