-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Toasty! (a-little-org-called-mario#373)
* added Toasty * improved toasty code * updated toasty.gd with actual numbers * changed waluigi to gassy randal
- Loading branch information
Showing
5 changed files
with
191 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters