From 44d47888cabed296b7bf4200a84d457dbb949d36 Mon Sep 17 00:00:00 2001 From: zoe Date: Sun, 28 Nov 2021 16:02:25 +0100 Subject: [PATCH] bugfixes for saving and layout --- Ball/Ball.gd | 2 +- ControlElements/Killzone.gd | 4 +++- Menu/LevelInfo.gd | 6 +++--- Menu/LevelInfo.tscn | 27 ++++++++++----------------- Menu/LevelList.tscn | 2 +- Menu/WinScreen.gd | 1 + Menu/WinScreen.tscn | 9 ++------- Stages/EmptyStage.tscn | 1 + Stages/Heart.tscn | 2 +- Stages/World.gd | 2 +- Stats/GameStats.gd | 2 ++ 11 files changed, 26 insertions(+), 32 deletions(-) diff --git a/Ball/Ball.gd b/Ball/Ball.gd index 967439b..5868c4f 100644 --- a/Ball/Ball.gd +++ b/Ball/Ball.gd @@ -15,7 +15,7 @@ func _ready(): cameraTransform.position = Vector2.ZERO animation.play("reset") GameStats.balls_left = GameStats.max_balls - GameStats.connect("game_won", self, "queue_free") + var _connect = GameStats.connect("game_won", self, "queue_free") func _physics_process(_delta): match state: diff --git a/ControlElements/Killzone.gd b/ControlElements/Killzone.gd index 670f862..f6108be 100644 --- a/ControlElements/Killzone.gd +++ b/ControlElements/Killzone.gd @@ -1,6 +1,6 @@ extends KinematicBody2D -signal level_just_won +signal level_just_won() enum {IDLE, MOVEUP, MOVEDOWN} var state = IDLE @@ -32,5 +32,7 @@ func _on_ZoneDetection_area_entered(_area): if (state == MOVEUP): state = MOVEDOWN if GameStats.level_won: + call_deferred("emit_signal", "level_just_won") emit_signal("level_just_won") + print("finished") else: state = IDLE diff --git a/Menu/LevelInfo.gd b/Menu/LevelInfo.gd index 3d81b41..67e149e 100644 --- a/Menu/LevelInfo.gd +++ b/Menu/LevelInfo.gd @@ -1,8 +1,8 @@ extends PanelContainer -onready var stage_label = $CenterContainer/HBoxContainer/VBoxContainer/StageName -onready var score = $CenterContainer/HBoxContainer/VBoxContainer/ScoreLabel -onready var play = $CenterContainer/HBoxContainer/VBoxContainer/PlayButton +onready var stage_label = $VBoxContainer/StageName +onready var score = $VBoxContainer/ScoreLabel +onready var play = $VBoxContainer/PlayButton func _ready(): var _game_stats = GameStats.connect("current_stage_changed", self, "update_info") diff --git a/Menu/LevelInfo.tscn b/Menu/LevelInfo.tscn index f06a5ce..eb00390 100644 --- a/Menu/LevelInfo.tscn +++ b/Menu/LevelInfo.tscn @@ -9,8 +9,11 @@ bg_color = Color( 0.6, 0.6, 0.6, 0 ) [node name="LevelInfo" type="PanelContainer"] -anchor_right = 1.0 +anchor_top = 1.0 anchor_bottom = 1.0 +margin_top = -216.0 +margin_right = 117.0 +margin_bottom = -104.0 theme = ExtResource( 2 ) custom_styles/panel = SubResource( 1 ) script = ExtResource( 1 ) @@ -18,27 +21,17 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="CenterContainer" type="CenterContainer" parent="."] -margin_right = 384.0 -margin_bottom = 216.0 - -[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer"] -margin_left = 133.0 -margin_top = 59.0 -margin_right = 250.0 -margin_bottom = 157.0 - -[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/HBoxContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="."] margin_right = 117.0 -margin_bottom = 98.0 +margin_bottom = 112.0 -[node name="XPLabel" type="Label" parent="CenterContainer/HBoxContainer/VBoxContainer"] +[node name="XPLabel" type="Label" parent="VBoxContainer"] margin_right = 117.0 margin_bottom = 18.0 text = "XP: " script = ExtResource( 3 ) -[node name="StageName" type="Label" parent="CenterContainer/HBoxContainer/VBoxContainer"] +[node name="StageName" type="Label" parent="VBoxContainer"] margin_top = 22.0 margin_right = 117.0 margin_bottom = 40.0 @@ -46,7 +39,7 @@ theme = ExtResource( 2 ) text = "select stage" valign = 3 -[node name="ScoreLabel" type="Label" parent="CenterContainer/HBoxContainer/VBoxContainer"] +[node name="ScoreLabel" type="Label" parent="VBoxContainer"] margin_top = 44.0 margin_right = 117.0 margin_bottom = 62.0 @@ -57,7 +50,7 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="PlayButton" parent="CenterContainer/HBoxContainer/VBoxContainer" instance=ExtResource( 6 )] +[node name="PlayButton" parent="VBoxContainer" instance=ExtResource( 6 )] anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 diff --git a/Menu/LevelList.tscn b/Menu/LevelList.tscn index 4e87d9d..6a36831 100644 --- a/Menu/LevelList.tscn +++ b/Menu/LevelList.tscn @@ -26,7 +26,7 @@ anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 168.0 margin_bottom = 40.0 -text = "> Heart" +text = "> heart" icon = ExtResource( 2 ) scene = "res://Stages/Heart.tscn" diff --git a/Menu/WinScreen.gd b/Menu/WinScreen.gd index 6d2c970..d01b998 100644 --- a/Menu/WinScreen.gd +++ b/Menu/WinScreen.gd @@ -11,3 +11,4 @@ func _on_AnimationPlayer_animation_finished(_anim_name): $Congratulations.visible = false $Congratulations2.visible = false $Control.visible = true + GameStats.emit_signal("win_animation_finished") diff --git a/Menu/WinScreen.tscn b/Menu/WinScreen.tscn index 53a513b..7770e69 100644 --- a/Menu/WinScreen.tscn +++ b/Menu/WinScreen.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=12 format=2] [ext_resource path="res://Menu/LevelInfo.tscn" type="PackedScene" id=1] -[ext_resource path="res://Menu/Buttons/RestartButton.tscn" type="PackedScene" id=2] [ext_resource path="res://Menu/Theme.tres" type="Theme" id=3] [ext_resource path="res://Menu/WinScreen.gd" type="Script" id=4] [ext_resource path="res://Menu/Buttons/LevelSelectIconButton.tscn" type="PackedScene" id=5] @@ -114,12 +113,8 @@ margin_top = 44.0 margin_right = 117.0 margin_bottom = 76.0 -[node name="RestartButton" parent="Control/Panel2/Panel/CenterContainer/GridContainer/HBoxContainer" instance=ExtResource( 2 )] -margin_bottom = 32.0 - [node name="LevelSelectIconButton" parent="Control/Panel2/Panel/CenterContainer/GridContainer/HBoxContainer" instance=ExtResource( 5 )] -margin_left = 36.0 -margin_right = 68.0 +margin_right = 32.0 margin_bottom = 32.0 texture_normal = ExtResource( 6 ) texture_pressed = ExtResource( 8 ) diff --git a/Stages/EmptyStage.tscn b/Stages/EmptyStage.tscn index b55fdb8..7587ccf 100644 --- a/Stages/EmptyStage.tscn +++ b/Stages/EmptyStage.tscn @@ -146,6 +146,7 @@ extents = Vector2( 192, 10 ) [node name="World" type="Node2D"] script = ExtResource( 10 ) +already_beaten = true [node name="Transition" parent="." instance=ExtResource( 11 )] diff --git a/Stages/Heart.tscn b/Stages/Heart.tscn index 6f74391..80183b2 100644 --- a/Stages/Heart.tscn +++ b/Stages/Heart.tscn @@ -6,7 +6,7 @@ [ext_resource path="res://Pegs/Purple/PurplePeg.tscn" type="PackedScene" id=4] [node name="World" instance=ExtResource( 1 )] -stage_name = "Heart" +stage_name = "heart" powerup_card = "res://Pegs/Yellow/PowerupCards/Scattershot.tscn" [node name="PinkPeg" parent="Pegs" index="0" instance=ExtResource( 2 )] diff --git a/Stages/World.gd b/Stages/World.gd index e7a1c9e..842a9bd 100644 --- a/Stages/World.gd +++ b/Stages/World.gd @@ -7,7 +7,7 @@ export var powerup_card = "res://Pegs/Yellow/PowerupCards/ExtraBall.tscn" func _ready(): load_level() - var _killzone_connec = $Killzone.connect("level_just_won", self, "save_level") + var _killzone_connec = GameStats.connect("win_animation_finished", self, "save_level") GameStats.multiplier = 1 func _physics_process(_delta): diff --git a/Stats/GameStats.gd b/Stats/GameStats.gd index 087f87f..b4fddbb 100644 --- a/Stats/GameStats.gd +++ b/Stats/GameStats.gd @@ -8,6 +8,7 @@ signal powerup_picked() signal recount_pink() signal pink_changed(value) signal game_won() +signal win_animation_finished() var unlock_points = 10 var max_balls = 3 @@ -78,6 +79,7 @@ func reset_board(): func set_current_scene(stage): current_stage = stage emit_signal("current_stage_changed", current_stage) + print(stage) func add_to_multiplier(value): if value + GameStats.multiplier > GameStats.multiplier: