From 24588fb5dcf190d2e3a48cd57e65235fb717f5a9 Mon Sep 17 00:00:00 2001 From: Chris Bradfield Date: Thu, 27 Jun 2019 23:28:08 -0700 Subject: [PATCH] part 14 - fixes and polish --- Main.gd | 15 ++++---- UI/AboutScreen.tscn | 13 +++++-- UI/HUD.gd | 16 ++++++--- UI/HUD.tscn | 83 ++++++++++++++++++++++++++++++--------------- objects/Circle.gd | 2 +- 5 files changed, 88 insertions(+), 41 deletions(-) diff --git a/Main.gd b/Main.gd index 0c4fa40..bd87b7a 100644 --- a/Main.gd +++ b/Main.gd @@ -5,6 +5,7 @@ var Jumper = preload("res://objects/Jumper.tscn") var player var score = 0 setget set_score +var num_circles = 0 var highscore = 0 var new_highscore = false var level = 0 @@ -21,8 +22,9 @@ func new_game(): settings.hide_ad_banner() self.score = 0 self.bonus = 0 + num_circles = 0 level = 1 - $HUD.update_score(score) + $HUD.update_score(score, 0) $Camera2D.position = $StartPosition.position player = Jumper.instance() player.position = $StartPosition.position @@ -52,16 +54,17 @@ func _on_Jumper_captured(object): call_deferred("spawn_circle") self.score += 1 * bonus self.bonus += 1 + num_circles += 1 + if num_circles > 0 and num_circles % settings.circles_per_level == 0: + level += 1 + $HUD.show_message("Level %s" % str(level)) func set_score(value): + $HUD.update_score(score, value) score = value if score > highscore and !new_highscore: - $HUD.show_message("New Record!") + $HUD.show_message("New\nRecord!") new_highscore = true - $HUD.update_score(score) - if score > 0 and score % settings.circles_per_level == 0: - level += 1 - $HUD.show_message("Level %s" % str(level)) func _on_Jumper_died(): if score > highscore: diff --git a/UI/AboutScreen.tscn b/UI/AboutScreen.tscn index 7555fc7..7fd10b0 100644 --- a/UI/AboutScreen.tscn +++ b/UI/AboutScreen.tscn @@ -1,10 +1,15 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://UI/BaseScreen.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/fonts/Xolonium-Regular.ttf" type="DynamicFontData" id=2] [ext_resource path="res://assets/images/buttons/return.png" type="Texture" id=3] -[sub_resource type="DynamicFont" id=1] +[sub_resource type="StyleBoxFlat" id=1] + +[sub_resource type="StyleBoxFlat" id=2] +bg_color = Color( 0.15, 0.15, 0.15, 0.48 ) + +[sub_resource type="DynamicFont" id=3] size = 20 font_data = ExtResource( 2 ) @@ -24,7 +29,9 @@ margin_right = 440.0 margin_bottom = 710.0 size_flags_horizontal = 3 size_flags_vertical = 3 -custom_fonts/normal_font = SubResource( 1 ) +custom_styles/focus = SubResource( 1 ) +custom_styles/normal = SubResource( 2 ) +custom_fonts/normal_font = SubResource( 3 ) bbcode_enabled = true bbcode_text = "[center][u]Circle Jump[/u] diff --git a/UI/HUD.gd b/UI/HUD.gd index a55288b..817badb 100644 --- a/UI/HUD.gd +++ b/UI/HUD.gd @@ -1,11 +1,13 @@ extends CanvasLayer +var score = 0 + func _ready(): $Message.rect_pivot_offset = $Message.rect_size / 2 func show_message(text): $Message.text = text - $AnimationPlayer.play("show_message") + $MessageAnimation.play("show_message") func hide(): $ScoreBox.hide() @@ -15,11 +17,17 @@ func show(): $ScoreBox.show() $BonusBox.show() -func update_score(value): - $ScoreBox/HBoxContainer/Score.text = str(value) +func update_score(score, value): + $Tween.interpolate_property(self, "score", score, + value, 0.25, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) + $Tween.start() + $ScoreAnimation.play("score") +# $ScoreBox/HBoxContainer/Score.text = str(value) func update_bonus(value): $BonusBox/Bonus.text = str(value) + "x" if value > 1: - $AnimationPlayer.play("bonus") + $BonusAnimation.play("bonus") +func _on_Tween_tween_step(object, key, elapsed, value): + $ScoreBox/HBoxContainer/Score.text = str(int(value)) diff --git a/UI/HUD.tscn b/UI/HUD.tscn index 3650c5b..24c84c1 100644 --- a/UI/HUD.tscn +++ b/UI/HUD.tscn @@ -9,15 +9,11 @@ size = 32 extra_spacing_top = 10 font_data = ExtResource( 2 ) -[sub_resource type="DynamicFont" id=5] -size = 48 -font_data = ExtResource( 2 ) - [sub_resource type="DynamicFont" id=2] size = 69 font_data = ExtResource( 2 ) -[sub_resource type="Animation" id=6] +[sub_resource type="Animation" id=3] resource_name = "bonus" length = 0.15 step = 0.01 @@ -46,35 +42,52 @@ tracks/1/keys = { "values": [ Color( 1, 1, 1, 1 ), Color( 1, 0, 0, 1 ), Color( 1, 1, 1, 1 ) ] } -[sub_resource type="Animation" id=3] -resource_name = "init" -length = 0.1 +[sub_resource type="Animation" id=4] +resource_name = "score" +length = 0.25 +step = 0.01 tracks/0/type = "value" -tracks/0/path = NodePath("Message:custom_fonts/font:size") +tracks/0/path = NodePath("ScoreBox/HBoxContainer/Score:rect_scale") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 1, -"values": [ 80 ] +"times": PoolRealArray( 0, 0.12, 0.25 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Vector2( 1, 1 ), Vector2( 1.25, 1.25 ), Vector2( 1, 1 ) ] } tracks/1/type = "value" -tracks/1/path = NodePath("Message:visible") +tracks/1/path = NodePath("ScoreBox/HBoxContainer/Score:custom_colors/font_color") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/imported = false tracks/1/enabled = true tracks/1/keys = { +"times": PoolRealArray( 0, 0.12, 0.25 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 1 ), Color( 1, 0, 0, 1 ), Color( 1, 1, 1, 1 ) ] +} + +[sub_resource type="Animation" id=6] +resource_name = "init" +length = 0.1 +tracks/0/type = "value" +tracks/0/path = NodePath("Message:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { "times": PoolRealArray( 0 ), "transitions": PoolRealArray( 1 ), "update": 1, "values": [ false ] } -[sub_resource type="Animation" id=4] +[sub_resource type="Animation" id=5] resource_name = "show_message" length = 0.75 step = 0.01 @@ -112,7 +125,7 @@ tracks/2/keys = { "times": PoolRealArray( 0, 0.75 ), "transitions": PoolRealArray( 1, 1 ), "update": 0, -"values": [ Vector2( 1, 1 ), Vector2( 2, 2 ) ] +"values": [ Vector2( 1, 1 ), Vector2( 1.5, 1.5 ) ] } [node name="HUD" type="CanvasLayer"] @@ -123,6 +136,8 @@ anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 margin_top = -118.0 +grow_horizontal = 0 +grow_vertical = 0 custom_constants/margin_right = 20 custom_constants/margin_top = 20 custom_constants/margin_left = 20 @@ -133,24 +148,29 @@ margin_left = 20.0 margin_top = 20.0 margin_right = 460.0 margin_bottom = 98.0 +grow_horizontal = 0 +grow_vertical = 0 custom_constants/separation = 10 alignment = 2 [node name="Label" type="Label" parent="ScoreBox/HBoxContainer"] -margin_left = 199.0 -margin_right = 295.0 +margin_left = 289.0 +margin_right = 385.0 margin_bottom = 78.0 size_flags_vertical = 5 custom_fonts/font = SubResource( 1 ) text = "Score" [node name="Score" type="Label" parent="ScoreBox/HBoxContainer"] -margin_left = 305.0 +margin_left = 395.0 margin_right = 440.0 margin_bottom = 78.0 +grow_horizontal = 0 +grow_vertical = 0 size_flags_vertical = 5 custom_fonts/font = ExtResource( 3 ) -text = "100" +custom_colors/font_color = Color( 1, 1, 1, 1 ) +text = "0" [node name="BonusBox" type="MarginContainer" parent="."] anchor_right = 1.0 @@ -164,9 +184,9 @@ custom_constants/margin_bottom = 20 margin_left = 20.0 margin_top = 20.0 margin_right = 460.0 -margin_bottom = 78.0 +margin_bottom = 104.0 size_flags_vertical = 5 -custom_fonts/font = SubResource( 5 ) +custom_fonts/font = SubResource( 2 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) text = "1x" @@ -177,14 +197,23 @@ anchor_bottom = 0.5 margin_top = -39.0 margin_bottom = 39.0 grow_vertical = 2 -custom_fonts/font = SubResource( 2 ) +custom_fonts/font = ExtResource( 3 ) text = "Message" align = 1 valign = 1 clip_text = true -[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +[node name="BonusAnimation" type="AnimationPlayer" parent="."] autoplay = "init" -anims/bonus = SubResource( 6 ) -anims/init = SubResource( 3 ) -anims/show_message = SubResource( 4 ) +anims/bonus = SubResource( 3 ) + +[node name="ScoreAnimation" type="AnimationPlayer" parent="."] +anims/score = SubResource( 4 ) + +[node name="MessageAnimation" type="AnimationPlayer" parent="."] +autoplay = "init" +anims/init = SubResource( 6 ) +anims/show_message = SubResource( 5 ) + +[node name="Tween" type="Tween" parent="."] +[connection signal="tween_step" from="Tween" to="." method="_on_Tween_tween_step"] diff --git a/objects/Circle.gd b/objects/Circle.gd index c8f61f3..c220676 100644 --- a/objects/Circle.gd +++ b/objects/Circle.gd @@ -65,7 +65,7 @@ func check_orbits(): if settings.enable_sound: $Beep.play() $Label.text = str(num_orbits - current_orbits) - if current_orbits <= 0: + if current_orbits >= num_orbits: jumper.die() jumper = null implode()