Skip to content

Commit

Permalink
part 14 - fixes and polish
Browse files Browse the repository at this point in the history
  • Loading branch information
cbscribe committed Jun 28, 2019
1 parent d94f6bd commit 24588fb
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 41 deletions.
15 changes: 9 additions & 6 deletions Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 10 additions & 3 deletions UI/AboutScreen.tscn
Original file line number Diff line number Diff line change
@@ -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 )

Expand All @@ -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]
Expand Down
16 changes: 12 additions & 4 deletions UI/HUD.gd
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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))
83 changes: 56 additions & 27 deletions UI/HUD.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"

Expand All @@ -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"]
2 changes: 1 addition & 1 deletion objects/Circle.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 24588fb

Please sign in to comment.