bugfixes for saving and layout

This commit is contained in:
zoe 2021-11-28 16:02:25 +01:00
parent c30cc4589e
commit 44d47888ca
11 changed files with 26 additions and 32 deletions

View File

@ -15,7 +15,7 @@ func _ready():
cameraTransform.position = Vector2.ZERO cameraTransform.position = Vector2.ZERO
animation.play("reset") animation.play("reset")
GameStats.balls_left = GameStats.max_balls 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): func _physics_process(_delta):
match state: match state:

View File

@ -1,6 +1,6 @@
extends KinematicBody2D extends KinematicBody2D
signal level_just_won signal level_just_won()
enum {IDLE, MOVEUP, MOVEDOWN} enum {IDLE, MOVEUP, MOVEDOWN}
var state = IDLE var state = IDLE
@ -32,5 +32,7 @@ func _on_ZoneDetection_area_entered(_area):
if (state == MOVEUP): if (state == MOVEUP):
state = MOVEDOWN state = MOVEDOWN
if GameStats.level_won: if GameStats.level_won:
call_deferred("emit_signal", "level_just_won")
emit_signal("level_just_won") emit_signal("level_just_won")
print("finished")
else: state = IDLE else: state = IDLE

View File

@ -1,8 +1,8 @@
extends PanelContainer extends PanelContainer
onready var stage_label = $CenterContainer/HBoxContainer/VBoxContainer/StageName onready var stage_label = $VBoxContainer/StageName
onready var score = $CenterContainer/HBoxContainer/VBoxContainer/ScoreLabel onready var score = $VBoxContainer/ScoreLabel
onready var play = $CenterContainer/HBoxContainer/VBoxContainer/PlayButton onready var play = $VBoxContainer/PlayButton
func _ready(): func _ready():
var _game_stats = GameStats.connect("current_stage_changed", self, "update_info") var _game_stats = GameStats.connect("current_stage_changed", self, "update_info")

View File

@ -9,8 +9,11 @@
bg_color = Color( 0.6, 0.6, 0.6, 0 ) bg_color = Color( 0.6, 0.6, 0.6, 0 )
[node name="LevelInfo" type="PanelContainer"] [node name="LevelInfo" type="PanelContainer"]
anchor_right = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_top = -216.0
margin_right = 117.0
margin_bottom = -104.0
theme = ExtResource( 2 ) theme = ExtResource( 2 )
custom_styles/panel = SubResource( 1 ) custom_styles/panel = SubResource( 1 )
script = ExtResource( 1 ) script = ExtResource( 1 )
@ -18,27 +21,17 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="CenterContainer" type="CenterContainer" parent="."] [node name="VBoxContainer" type="VBoxContainer" 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"]
margin_right = 117.0 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_right = 117.0
margin_bottom = 18.0 margin_bottom = 18.0
text = "XP: " text = "XP: "
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="StageName" type="Label" parent="CenterContainer/HBoxContainer/VBoxContainer"] [node name="StageName" type="Label" parent="VBoxContainer"]
margin_top = 22.0 margin_top = 22.0
margin_right = 117.0 margin_right = 117.0
margin_bottom = 40.0 margin_bottom = 40.0
@ -46,7 +39,7 @@ theme = ExtResource( 2 )
text = "select stage" text = "select stage"
valign = 3 valign = 3
[node name="ScoreLabel" type="Label" parent="CenterContainer/HBoxContainer/VBoxContainer"] [node name="ScoreLabel" type="Label" parent="VBoxContainer"]
margin_top = 44.0 margin_top = 44.0
margin_right = 117.0 margin_right = 117.0
margin_bottom = 62.0 margin_bottom = 62.0
@ -57,7 +50,7 @@ __meta__ = {
"_edit_use_anchors_": false "_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_left = 0.0
anchor_top = 0.0 anchor_top = 0.0
anchor_right = 0.0 anchor_right = 0.0

View File

@ -26,7 +26,7 @@ anchor_right = 0.0
anchor_bottom = 0.0 anchor_bottom = 0.0
margin_right = 168.0 margin_right = 168.0
margin_bottom = 40.0 margin_bottom = 40.0
text = "> Heart" text = "> heart"
icon = ExtResource( 2 ) icon = ExtResource( 2 )
scene = "res://Stages/Heart.tscn" scene = "res://Stages/Heart.tscn"

View File

@ -11,3 +11,4 @@ func _on_AnimationPlayer_animation_finished(_anim_name):
$Congratulations.visible = false $Congratulations.visible = false
$Congratulations2.visible = false $Congratulations2.visible = false
$Control.visible = true $Control.visible = true
GameStats.emit_signal("win_animation_finished")

View File

@ -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/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/Theme.tres" type="Theme" id=3]
[ext_resource path="res://Menu/WinScreen.gd" type="Script" id=4] [ext_resource path="res://Menu/WinScreen.gd" type="Script" id=4]
[ext_resource path="res://Menu/Buttons/LevelSelectIconButton.tscn" type="PackedScene" id=5] [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_right = 117.0
margin_bottom = 76.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 )] [node name="LevelSelectIconButton" parent="Control/Panel2/Panel/CenterContainer/GridContainer/HBoxContainer" instance=ExtResource( 5 )]
margin_left = 36.0 margin_right = 32.0
margin_right = 68.0
margin_bottom = 32.0 margin_bottom = 32.0
texture_normal = ExtResource( 6 ) texture_normal = ExtResource( 6 )
texture_pressed = ExtResource( 8 ) texture_pressed = ExtResource( 8 )

View File

@ -146,6 +146,7 @@ extents = Vector2( 192, 10 )
[node name="World" type="Node2D"] [node name="World" type="Node2D"]
script = ExtResource( 10 ) script = ExtResource( 10 )
already_beaten = true
[node name="Transition" parent="." instance=ExtResource( 11 )] [node name="Transition" parent="." instance=ExtResource( 11 )]

View File

@ -6,7 +6,7 @@
[ext_resource path="res://Pegs/Purple/PurplePeg.tscn" type="PackedScene" id=4] [ext_resource path="res://Pegs/Purple/PurplePeg.tscn" type="PackedScene" id=4]
[node name="World" instance=ExtResource( 1 )] [node name="World" instance=ExtResource( 1 )]
stage_name = "Heart" stage_name = "heart"
powerup_card = "res://Pegs/Yellow/PowerupCards/Scattershot.tscn" powerup_card = "res://Pegs/Yellow/PowerupCards/Scattershot.tscn"
[node name="PinkPeg" parent="Pegs" index="0" instance=ExtResource( 2 )] [node name="PinkPeg" parent="Pegs" index="0" instance=ExtResource( 2 )]

View File

@ -7,7 +7,7 @@ export var powerup_card = "res://Pegs/Yellow/PowerupCards/ExtraBall.tscn"
func _ready(): func _ready():
load_level() 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 GameStats.multiplier = 1
func _physics_process(_delta): func _physics_process(_delta):

View File

@ -8,6 +8,7 @@ signal powerup_picked()
signal recount_pink() signal recount_pink()
signal pink_changed(value) signal pink_changed(value)
signal game_won() signal game_won()
signal win_animation_finished()
var unlock_points = 10 var unlock_points = 10
var max_balls = 3 var max_balls = 3
@ -78,6 +79,7 @@ func reset_board():
func set_current_scene(stage): func set_current_scene(stage):
current_stage = stage current_stage = stage
emit_signal("current_stage_changed", current_stage) emit_signal("current_stage_changed", current_stage)
print(stage)
func add_to_multiplier(value): func add_to_multiplier(value):
if value + GameStats.multiplier > GameStats.multiplier: if value + GameStats.multiplier > GameStats.multiplier: