diff --git a/microgame_example/my_cool_microgame.tres b/microgame_example/my_cool_microgame.tres index d365d6e..8f0f386 100644 --- a/microgame_example/my_cool_microgame.tres +++ b/microgame_example/my_cool_microgame.tres @@ -7,3 +7,4 @@ script = ExtResource( 1 ) name = "My Cool Microgame" scene = ExtResource( 2 ) +hint_verb = "Mash!" diff --git a/microgames/cupcake_game/Cupcake.tres b/microgames/cupcake_game/Cupcake.tres index 43263e5..d1cef55 100644 --- a/microgames/cupcake_game/Cupcake.tres +++ b/microgames/cupcake_game/Cupcake.tres @@ -7,3 +7,4 @@ script = ExtResource( 1 ) name = "Cupcake" scene = ExtResource( 2 ) +hint_verb = "Decorate!" diff --git a/microgames/cupcake_game/cupcake_game.tscn b/microgames/cupcake_game/cupcake_game.tscn index 83fdfc1..778a855 100644 --- a/microgames/cupcake_game/cupcake_game.tscn +++ b/microgames/cupcake_game/cupcake_game.tscn @@ -50,7 +50,6 @@ animation = "closed" [node name="cherry" type="Area2D" parent="hand"] position = Vector2( 69.3333, 80.6667 ) -scale = Vector2( 1, 1 ) script = ExtResource( 6 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="hand/cherry"] diff --git a/microgames/hotdog_game/Hotdog.tres b/microgames/hotdog_game/Hotdog.tres index 75a9c6e..370ea6d 100644 --- a/microgames/hotdog_game/Hotdog.tres +++ b/microgames/hotdog_game/Hotdog.tres @@ -7,3 +7,4 @@ script = ExtResource( 1 ) name = "Hotdog" scene = ExtResource( 2 ) +hint_verb = "Catch!" diff --git a/microgames/pixelart/Pixelart.tres b/microgames/pixelart/Pixelart.tres index a0186dd..331a754 100644 --- a/microgames/pixelart/Pixelart.tres +++ b/microgames/pixelart/Pixelart.tres @@ -7,3 +7,4 @@ script = ExtResource( 1 ) name = "Pixelart" scene = ExtResource( 2 ) +hint_verb = "Pick the Color!" diff --git a/microgames/pixelart/src/pixelart_game.gd b/microgames/pixelart/src/pixelart_game.gd index 1ede02c..1435e4f 100644 --- a/microgames/pixelart/src/pixelart_game.gd +++ b/microgames/pixelart/src/pixelart_game.gd @@ -30,4 +30,3 @@ func _on_Pencil_drawing_done() -> void: $Camera2D, "zoom", $Camera2D.zoom, $FinalCamera.zoom, 0.4, Tween.TRANS_BACK, Tween.EASE_OUT ) $CameraTween.start() - yield(get_tree().create_timer(0.5), "timeout") diff --git a/microgames/press_key/PressKey.tres b/microgames/press_key/PressKey.tres index 2ba9ae9..58f2ea5 100644 --- a/microgames/press_key/PressKey.tres +++ b/microgames/press_key/PressKey.tres @@ -7,3 +7,4 @@ script = ExtResource( 1 ) name = "Press Key" scene = ExtResource( 2 ) +hint_verb = "Press!" diff --git a/src/core/game_state.gd b/src/core/game_state.gd index d2c69cc..79a33a6 100644 --- a/src/core/game_state.gd +++ b/src/core/game_state.gd @@ -10,4 +10,4 @@ export var speed: float = 1 export var level_up_interval: int = 10 export var speed_up_interval: int = 3 -var current_score : int = 0 \ No newline at end of file +var current_score : int = 0 diff --git a/src/microgame/mg_instructions.gd b/src/core/intermission/instructions.gd similarity index 100% rename from src/microgame/mg_instructions.gd rename to src/core/intermission/instructions.gd diff --git a/src/microgame/mg_instructions.tscn b/src/core/intermission/instructions.tscn similarity index 97% rename from src/microgame/mg_instructions.tscn rename to src/core/intermission/instructions.tscn index a4fe8b3..f7cbd4c 100644 --- a/src/microgame/mg_instructions.tscn +++ b/src/core/intermission/instructions.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=8 format=2] [ext_resource path="res://fonts/Wariowareincv2-2OOBw.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://src/microgame/mg_instructions.gd" type="Script" id=2] +[ext_resource path="res://src/core/intermission/instructions.gd" type="Script" id=2] [sub_resource type="DynamicFont" id=17] size = 64 diff --git a/src/core/intermission.gd b/src/core/intermission/intermission.gd similarity index 69% rename from src/core/intermission.gd rename to src/core/intermission/intermission.gd index a1e4094..8979f12 100644 --- a/src/core/intermission.gd +++ b/src/core/intermission/intermission.gd @@ -5,12 +5,18 @@ extends Control signal intermission_completed +onready var instructions_scene = preload("res://src/core/intermission/instructions.tscn") + onready var timer : Timer = $Timer onready var score_display: RichTextLabel = $ScoreDisplay onready var status_up: AnimatedSprite = $StatusUp onready var sfx_success: AudioStreamPlayer2D = $SuccessSFX onready var sfx_failure: AudioStreamPlayer2D = $FailureSFX onready var sfx_start: AudioStreamPlayer2D = $StartSFX +onready var instructions_layer : CanvasLayer = $Instructions +onready var instructions_timer : Timer = $InstructionsTimer + +var current_microgame_def : MicrogameDefinition func _ready() -> void: @@ -24,6 +30,7 @@ func _ready() -> void: if game_state.lives <= 0: Engine.time_scale = 1 timer.wait_time = 5 + instructions_timer.wait_time = 1 $GameOver.visible = true timer.start() sfx_failure.play() @@ -48,13 +55,24 @@ func _ready() -> void: sfx_start.play() timer.start() + instructions_timer.start() func on_Timer_timeout() -> void: - emit_signal("intermission_completed") + emit_signal("intermission_completed", current_microgame_def) func _show_modifier_update(type: String) -> void: status_up.animation = type status_up.visible = true timer.wait_time *= 2 + instructions_timer.wait_time *= 2 + + +func _on_InstructionsTimer_timeout(): + current_microgame_def = Utility.get_random_microgame(Session.microgame_pool) + # wait for instructions to finish showing before adding timer + var instructions = instructions_scene.instance() + instructions_layer.add_child(instructions) + instructions.prompt.text = current_microgame_def.hint_verb + instructions.start() diff --git a/src/core/intermission.tscn b/src/core/intermission/intermission.tscn similarity index 75% rename from src/core/intermission.tscn rename to src/core/intermission/intermission.tscn index 098ff76..d8772fb 100644 --- a/src/core/intermission.tscn +++ b/src/core/intermission/intermission.tscn @@ -1,55 +1,55 @@ [gd_scene load_steps=18 format=2] -[ext_resource path="res://graphics/icon.png" type="Texture" id=1] -[ext_resource path="res://graphics/level_up_spritesheet.png" type="Texture" id=2] -[ext_resource path="res://audio/tat-tat-92592.wav" type="AudioStream" id=3] -[ext_resource path="res://graphics/speed_up_spritesheet.png" type="Texture" id=4] -[ext_resource path="res://graphics/game_over_spritesheet.png" type="Texture" id=5] -[ext_resource path="res://audio/tada-fanfare-a-6313.wav" type="AudioStream" id=6] -[ext_resource path="res://audio/failfare-86009.wav" type="AudioStream" id=7] -[ext_resource path="res://src/core/life.gd" type="Script" id=8] -[ext_resource path="res://src/core/intermission.gd" type="Script" id=9] - -[sub_resource type="AtlasTexture" id=1] -atlas = ExtResource( 2 ) +[ext_resource path="res://audio/failfare-86009.wav" type="AudioStream" id=1] +[ext_resource path="res://graphics/game_over_spritesheet.png" type="Texture" id=2] +[ext_resource path="res://audio/tada-fanfare-a-6313.wav" type="AudioStream" id=3] +[ext_resource path="res://graphics/icon.png" type="Texture" id=4] +[ext_resource path="res://graphics/speed_up_spritesheet.png" type="Texture" id=5] +[ext_resource path="res://audio/tat-tat-92592.wav" type="AudioStream" id=6] +[ext_resource path="res://src/core/life.gd" type="Script" id=7] +[ext_resource path="res://src/core/intermission/intermission.gd" type="Script" id=8] +[ext_resource path="res://graphics/level_up_spritesheet.png" type="Texture" id=9] + +[sub_resource type="AtlasTexture" id=9] +atlas = ExtResource( 9 ) region = Rect2( 0, 0, 512, 128 ) -[sub_resource type="AtlasTexture" id=2] -atlas = ExtResource( 2 ) +[sub_resource type="AtlasTexture" id=10] +atlas = ExtResource( 9 ) region = Rect2( 512, 0, 512, 128 ) -[sub_resource type="AtlasTexture" id=3] -atlas = ExtResource( 4 ) +[sub_resource type="AtlasTexture" id=11] +atlas = ExtResource( 5 ) region = Rect2( 0, 0, 512, 128 ) -[sub_resource type="AtlasTexture" id=4] -atlas = ExtResource( 4 ) +[sub_resource type="AtlasTexture" id=12] +atlas = ExtResource( 5 ) region = Rect2( 512, 0, 512, 128 ) [sub_resource type="SpriteFrames" id=5] animations = [ { -"frames": [ SubResource( 1 ), SubResource( 2 ) ], +"frames": [ SubResource( 9 ), SubResource( 10 ) ], "loop": true, "name": "level_up", "speed": 5.0 }, { -"frames": [ SubResource( 3 ), SubResource( 4 ) ], +"frames": [ SubResource( 11 ), SubResource( 12 ) ], "loop": true, "name": "speed_up", "speed": 5.0 } ] -[sub_resource type="AtlasTexture" id=6] -atlas = ExtResource( 5 ) +[sub_resource type="AtlasTexture" id=13] +atlas = ExtResource( 2 ) region = Rect2( 0, 0, 512, 256 ) -[sub_resource type="AtlasTexture" id=7] -atlas = ExtResource( 5 ) +[sub_resource type="AtlasTexture" id=14] +atlas = ExtResource( 2 ) region = Rect2( 512, 0, 512, 256 ) [sub_resource type="SpriteFrames" id=8] animations = [ { -"frames": [ SubResource( 6 ), SubResource( 7 ) ], +"frames": [ SubResource( 13 ), SubResource( 14 ) ], "loop": true, "name": "default", "speed": 5.0 @@ -60,7 +60,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 margin_top = 3.0 margin_bottom = 3.0 -script = ExtResource( 9 ) +script = ExtResource( 8 ) [node name="VBoxContainer" type="VBoxContainer" parent="."] anchor_left = 0.5 @@ -82,9 +82,9 @@ size_flags_horizontal = 3 [node name="TextureRect" type="TextureRect" parent="VBoxContainer/HBoxContainer/MarginContainer"] margin_right = 94.0 margin_bottom = 64.0 -texture = ExtResource( 1 ) +texture = ExtResource( 4 ) stretch_mode = 6 -script = ExtResource( 8 ) +script = ExtResource( 7 ) [node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer/HBoxContainer"] margin_left = 98.0 @@ -95,9 +95,9 @@ size_flags_horizontal = 3 [node name="TextureRect" type="TextureRect" parent="VBoxContainer/HBoxContainer/MarginContainer2"] margin_right = 95.0 margin_bottom = 64.0 -texture = ExtResource( 1 ) +texture = ExtResource( 4 ) stretch_mode = 6 -script = ExtResource( 8 ) +script = ExtResource( 7 ) index = 1 [node name="MarginContainer3" type="MarginContainer" parent="VBoxContainer/HBoxContainer"] @@ -109,9 +109,9 @@ size_flags_horizontal = 3 [node name="TextureRect" type="TextureRect" parent="VBoxContainer/HBoxContainer/MarginContainer3"] margin_right = 94.0 margin_bottom = 64.0 -texture = ExtResource( 1 ) +texture = ExtResource( 4 ) stretch_mode = 6 -script = ExtResource( 8 ) +script = ExtResource( 7 ) index = 2 [node name="MarginContainer4" type="MarginContainer" parent="VBoxContainer/HBoxContainer"] @@ -123,9 +123,9 @@ size_flags_horizontal = 3 [node name="TextureRect" type="TextureRect" parent="VBoxContainer/HBoxContainer/MarginContainer4"] margin_right = 95.0 margin_bottom = 64.0 -texture = ExtResource( 1 ) +texture = ExtResource( 4 ) stretch_mode = 6 -script = ExtResource( 8 ) +script = ExtResource( 7 ) index = 3 [node name="ScoreDisplay" type="RichTextLabel" parent="."] @@ -143,7 +143,7 @@ one_shot = true [node name="StatusUp" type="AnimatedSprite" parent="."] visible = false -position = Vector2( 528, 248 ) +position = Vector2( 528, 184 ) frames = SubResource( 5 ) animation = "level_up" playing = true @@ -157,17 +157,24 @@ playing = true [node name="SuccessSFX" type="AudioStreamPlayer2D" parent="."] position = Vector2( 518, 279 ) -stream = ExtResource( 6 ) +stream = ExtResource( 3 ) bus = "Session" [node name="FailureSFX" type="AudioStreamPlayer2D" parent="."] position = Vector2( 518, 279 ) -stream = ExtResource( 7 ) +stream = ExtResource( 1 ) bus = "Session" [node name="StartSFX" type="AudioStreamPlayer2D" parent="."] position = Vector2( 518, 279 ) -stream = ExtResource( 3 ) +stream = ExtResource( 6 ) bus = "Session" +[node name="InstructionsTimer" type="Timer" parent="."] +one_shot = true + +[node name="Instructions" type="CanvasLayer" parent="."] +layer = 2 + [connection signal="timeout" from="Timer" to="." method="on_Timer_timeout"] +[connection signal="timeout" from="InstructionsTimer" to="." method="_on_InstructionsTimer_timeout"] diff --git a/src/core/modes/mode_standard.tres b/src/core/modes/mode_standard.tres index 7ae0bf4..a311361 100644 --- a/src/core/modes/mode_standard.tres +++ b/src/core/modes/mode_standard.tres @@ -3,6 +3,7 @@ [ext_resource path="res://src/core/game_state.gd" type="Script" id=1] [resource] +resource_local_to_scene = true script = ExtResource( 1 ) name = "standard" lives = 4 diff --git a/src/core/session.gd b/src/core/session.gd index 0d6f446..4f9fedf 100644 --- a/src/core/session.gd +++ b/src/core/session.gd @@ -7,7 +7,7 @@ const GAME_MODE : Dictionary = { "STANDARD": preload("res://src/core/modes/mode_standard.tres"), "DEBUG": preload("res://src/core/modes/mode_debug.tres"), } -const INTERMISSION_SCENE: PackedScene = preload("res://src/core/intermission.tscn") +const INTERMISSION_SCENE: PackedScene = preload("res://src/core/intermission/intermission.tscn") const MENU_SCENE : PackedScene = preload("res://src/menu/menu.tscn") var game_state : GameState @@ -21,13 +21,13 @@ func _ready(): connect("speed_up_requested", self, "_on_speed_up_requested") # if microgame is being previewed directly, loop it - var microgame_scene: String = "" + var microgame_def: String = "" for arg in OS.get_cmdline_args(): - if arg.begins_with("res://") and arg.ends_with(".tscn"): - microgame_scene = arg - if microgame_scene.length() > 0 or not OS.has_feature("editor"): + if arg.begins_with("res://") and arg.ends_with(".tres"): + microgame_def = arg + if microgame_def.length() > 0 or not OS.has_feature("editor"): game_state = GAME_MODE.DEBUG - microgame_pool = [load(microgame_scene)] + microgame_pool = [microgame_def] func start_mode(game_mode : GameState): @@ -41,14 +41,11 @@ func _play_intermission() -> void: get_tree().change_scene_to(INTERMISSION_SCENE) -func _on_intermission_completed() -> void: +func _on_intermission_completed(new_microgame : MicrogameDefinition) -> void: if game_state.lives > 0: - get_tree().change_scene_to( - Utility.get_random_microgame(microgame_pool) - ) + get_tree().change_scene_to(new_microgame.scene) else: Scores.save_score_for(game_state.name, game_state.current_score) - queue_free() get_tree().change_scene_to(MENU_SCENE) diff --git a/src/core/utility.gd b/src/core/utility.gd index 91e16a8..552425a 100644 --- a/src/core/utility.gd +++ b/src/core/utility.gd @@ -3,8 +3,8 @@ class_name Utility # Common helper functions -static func get_random_microgame(microgame_scenes : Array) -> PackedScene: - return microgame_scenes[randi() % microgame_scenes.size()] +static func get_random_microgame(microgame_definitions : Array) -> MicrogameDefinition: + return microgame_definitions[randi() % microgame_definitions.size()] static func find_by_class(node: Node, className: String, result: Array) -> void: @@ -15,14 +15,14 @@ static func find_by_class(node: Node, className: String, result: Array) -> void: static func get_microgames() -> Array: - var microgame_scenes := [] + var microgame_defs := [] for file in find_microgame_definitions(): var definition: Resource = load(file) if definition is MicrogameDefinition: - microgame_scenes.append(definition.scene) + microgame_defs.append(definition) - return microgame_scenes + return microgame_defs static func find_microgame_definitions() -> Array: diff --git a/src/microgame/mg_definition.gd b/src/microgame/mg_definition.gd index 5b83c71..bf98af8 100644 --- a/src/microgame/mg_definition.gd +++ b/src/microgame/mg_definition.gd @@ -3,3 +3,4 @@ class_name MicrogameDefinition export var name: String export var scene: PackedScene +export var hint_verb : String diff --git a/src/microgame/microgame.gd b/src/microgame/microgame.gd index 20db080..e3422cc 100644 --- a/src/microgame/microgame.gd +++ b/src/microgame/microgame.gd @@ -4,7 +4,6 @@ class_name Microgame # Custom microgames should extend this const UI_SCENES : Dictionary = { - "Instructions": preload("res://src/microgame/mg_instructions.tscn"), "Timer": preload("res://src/microgame/mg_timer.tscn"), } @@ -39,15 +38,8 @@ func _ready() -> void: # add additional UI elements var timer = UI_SCENES.Timer.instance() - var instructions = UI_SCENES.Instructions.instance() var ui_parent = CanvasLayer.new() add_child(ui_parent) - - # wait for instructions to finish showing before adding timer - ui_parent.add_child(instructions) - instructions.prompt.text = hint_verb - instructions.start() - yield(instructions, "timeout") timer.connect("timeout", self, "_on_Timer_timeout") ui_parent.add_child(timer) is_timer_running = true