Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* added Toasty

* improved toasty code

* updated toasty.gd with actual numbers

* changed waluigi to gassy randal
  • Loading branch information
nknauth authored Apr 17, 2022
1 parent c60e534 commit 18f0429
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 1 deletion.
Binary file added audio/sfx/toasty.wav
Binary file not shown.
21 changes: 21 additions & 0 deletions audio/sfx/toasty.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/toasty.wav-c1c794e1490700823b450a21f101baa8.sample"

[deps]

source_file="res://audio/sfx/toasty.wav"
dest_files=[ "res://.import/toasty.wav-c1c794e1490700823b450a21f101baa8.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0
79 changes: 79 additions & 0 deletions scenes/ui/Toasty.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
extends Control

## Toasty.gd

# An homage to Mortal Kombat.
#
# Upon collecting 10 coins in 2 seconds, Gassy Randal appears in the bottom right
# corner of the screen and an audio clip plays saying "toasty" in a high-
# pitched voice.
#
# To avoid constant or repeated triggers, there's a five minute cooldown timer,
# the Cooldown node.
#
# In Mortal Kombat, if you pressed Down and Start while the "toasty guy" was on
# the screen, you would be transported to a secret level.
#
# As of now, this "toasty guy" doesn't have a secret, but there is a variable
# that controls whether or not a future secret feature can be activated.
#
# TODO: add a button combo that triggers the secret. It would probably go in an
# _input function or _process.


# The number of coins to be collected before CoinTimer runs out
export var target_coin_streak : int = 10

# While the "toasty guy" is on screen, allow a certain button combo to activate
# a secret. This value is toggled by the AnimationPlayer.
export var can_activate_secret : bool = false


# The current number of coins collected since the last time CoinTimer ran out
var coins_collected_streak : int = 0

# Whether or not the "toasty guy" can appear. On a cooldown defined by the Cooldown
# timer.
var can_toasty : bool = true


#func _init() -> void:
# pass


func _ready() -> void:
EventBus.connect("coin_collected", self, "_on_coin_collected")


func trigger_toasty() -> void:
can_toasty = false
$Cooldown.start()
$AnimationPlayer.play('toasty')


# Use this function when you add a secret trigger following a button combo.
func activate_secret() -> void:
if not can_activate_secret:
return
print('secret activated')


func _on_coin_collected(_data) -> void:
# Return early if it's too soon to toasty again:
if not can_toasty:
return

$CoinTimer.start()

coins_collected_streak += 1

if coins_collected_streak >= target_coin_streak:
trigger_toasty()


func _on_Cooldown_timeout() -> void:
coins_collected_streak = 0


func _on_CoinTimer_timeout() -> void:
coins_collected_streak = 0
86 changes: 86 additions & 0 deletions scenes/ui/Toasty.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[gd_scene load_steps=5 format=2]

[ext_resource path="res://sprites/large-gassy-randal.png" type="Texture" id=1]
[ext_resource path="res://scenes/ui/Toasty.gd" type="Script" id=2]
[ext_resource path="res://audio/sfx/toasty.wav" type="AudioStream" id=3]

[sub_resource type="Animation" id=1]
resource_name = "toasty"
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Randall:rect_position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.05, 0.95, 1 ),
"transitions": PoolRealArray( 0.6, 1, 1, 1 ),
"update": 0,
"values": [ Vector2( 1024, 472 ), Vector2( 896, 472 ), Vector2( 896, 472 ), Vector2( 1024, 472 ) ]
}
tracks/1/type = "audio"
tracks/1/path = NodePath("AudioStreamPlayer")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"clips": [ {
"end_offset": 0.0,
"start_offset": 0.0,
"stream": ExtResource( 3 )
} ],
"times": PoolRealArray( 0 )
}
tracks/2/type = "value"
tracks/2/path = NodePath(".:can_activate_secret")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ true, false ]
}

[node name="Toasty" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Randall" type="TextureRect" parent="."]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -128.0
margin_right = 128.0
rect_pivot_offset = Vector2( 0, 128 )
texture = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/toasty = SubResource( 1 )

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 3 )
bus = "sfx"

[node name="CoinTimer" type="Timer" parent="."]
wait_time = 2.0
one_shot = true

[node name="Cooldown" type="Timer" parent="."]
wait_time = 300.0
one_shot = true

[connection signal="timeout" from="CoinTimer" to="." method="_on_CoinTimer_timeout"]
[connection signal="timeout" from="Cooldown" to="." method="_on_Cooldown_timeout"]
6 changes: 5 additions & 1 deletion scenes/ui/UI.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[gd_scene load_steps=13 format=2]
[gd_scene load_steps=14 format=2]

[ext_resource path="res://scenes/ui/Themes/Default/DefaultFont.tres" type="DynamicFont" id=1]
[ext_resource path="res://scenes/ui/CoinCount.gd" type="Script" id=2]
[ext_resource path="res://scenes/ui/AchievementGet.gd" type="Script" id=3]
[ext_resource path="res://scenes/ui/LevelCount.gd" type="Script" id=4]
[ext_resource path="res://scenes/ui/Themes/Default/default.tres" type="Theme" id=5]
[ext_resource path="res://scenes/ui/Instructions.gd" type="Script" id=6]
[ext_resource path="res://scenes/ui/Toasty.tscn" type="PackedScene" id=7]
[ext_resource path="res://scenes/ui/HeartIconContainer.gd" type="Script" id=8]
[ext_resource path="res://scenes/ui/Heart.tscn" type="PackedScene" id=9]
[ext_resource path="res://scenes/ui/StarNotification.gd" type="Script" id=10]
Expand Down Expand Up @@ -147,6 +148,7 @@ scroll_active = false
script = ExtResource( 2 )

[node name="Instructions" type="RichTextLabel" parent="UI"]
visible = false
anchor_left = 0.03
anchor_top = 0.05
anchor_right = 0.481
Expand Down Expand Up @@ -274,3 +276,5 @@ scroll_active = false
[node name="AnimationPlayer" type="AnimationPlayer" parent="UI/PlayerDiedPanel"]
anims/Appear = SubResource( 1 )
anims/RESET = SubResource( 2 )

[node name="Toasty" parent="UI" instance=ExtResource( 7 )]

0 comments on commit 18f0429

Please sign in to comment.