Skip to content

Commit d94f6bd

Browse files
committed
part 13 - bonus multiplier
1 parent a73f9d3 commit d94f6bd

File tree

13 files changed

+184
-29
lines changed

13 files changed

+184
-29
lines changed

Main.gd

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ var Jumper = preload("res://objects/Jumper.tscn")
66
var player
77
var score = 0 setget set_score
88
var highscore = 0
9+
var new_highscore = false
910
var level = 0
11+
var bonus = 0 setget set_bonus
1012

1113
func _ready():
1214
randomize()
1315
load_score()
1416
$HUD.hide()
17+
$Background/ColorRect.color = settings.theme["background"]
1518

1619
func new_game():
20+
new_highscore = false
1721
settings.hide_ad_banner()
1822
self.score = 0
23+
self.bonus = 0
1924
level = 1
2025
$HUD.update_score(score)
2126
$Camera2D.position = $StartPosition.position
@@ -28,6 +33,7 @@ func new_game():
2833
$HUD.show()
2934
$HUD.show_message("Go!")
3035
if settings.enable_music:
36+
$Music.volume_db = 0
3137
$Music.play()
3238

3339
func spawn_circle(_position=null):
@@ -37,16 +43,21 @@ func spawn_circle(_position=null):
3743
var y = rand_range(-500, -400)
3844
_position = player.target.position + Vector2(x, y)
3945
add_child(c)
46+
c.connect("full_orbit", self, "set_bonus", [1])
4047
c.init(_position, level)
4148

4249
func _on_Jumper_captured(object):
4350
$Camera2D.position = object.position
4451
object.capture(player)
4552
call_deferred("spawn_circle")
46-
self.score += 1
53+
self.score += 1 * bonus
54+
self.bonus += 1
4755

4856
func set_score(value):
4957
score = value
58+
if score > highscore and !new_highscore:
59+
$HUD.show_message("New Record!")
60+
new_highscore = true
5061
$HUD.update_score(score)
5162
if score > 0 and score % settings.circles_per_level == 0:
5263
level += 1
@@ -60,7 +71,7 @@ func _on_Jumper_died():
6071
$Screens.game_over(score, highscore)
6172
$HUD.hide()
6273
if settings.enable_music:
63-
$Music.stop()
74+
fade_music()
6475
settings.show_ad_interstitial()
6576

6677
func load_score():
@@ -76,6 +87,13 @@ func save_score():
7687
f.store_var(highscore)
7788
f.close()
7889

90+
func fade_music():
91+
$MusicFade.interpolate_property($Music, "volume_db",
92+
0, -50, 1.0, Tween.TRANS_SINE, Tween.EASE_IN)
93+
$MusicFade.start()
94+
yield($MusicFade, "tween_all_completed")
95+
$Music.stop()
7996

80-
81-
97+
func set_bonus(value):
98+
bonus = value
99+
$HUD.update_bonus(bonus)

Main.tscn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ smoothing_speed = 8.0
2727
stream = ExtResource( 4 )
2828

2929
[node name="Background" parent="." instance=ExtResource( 5 )]
30+
31+
[node name="MusicFade" type="Tween" parent="."]
3032
[connection signal="start_game" from="Screens" to="." method="new_game"]

UI/Background.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ layer = -1
99
anchor_right = 1.0
1010
anchor_bottom = 1.0
1111
mouse_filter = 2
12-
color = Color( 0, 0, 0, 1 )
12+
color = Color( 0.3, 0.33, 0.37, 1 )
1313

1414
[node name="CPUParticles2D" type="CPUParticles2D" parent="."]
1515
modulate = Color( 1, 1, 1, 0.396078 )

UI/BaseScreen.tscn

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ margin_left = 20.0
2121
margin_top = 20.0
2222
margin_right = 460.0
2323
margin_bottom = 834.0
24-
custom_constants/separation = 150
24+
custom_constants/separation = 125
2525

2626
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
2727
margin_right = 440.0
@@ -31,23 +31,23 @@ text = "Title"
3131
align = 1
3232

3333
[node name="Buttons" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
34-
margin_top = 228.0
34+
margin_top = 203.0
3535
margin_right = 440.0
36-
margin_bottom = 228.0
36+
margin_bottom = 203.0
3737
custom_constants/separation = 75
3838
alignment = 1
3939

4040
[node name="Buttons3" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
41-
margin_top = 378.0
41+
margin_top = 328.0
4242
margin_right = 440.0
43-
margin_bottom = 378.0
43+
margin_bottom = 328.0
4444
custom_constants/separation = 75
4545
alignment = 1
4646

4747
[node name="Buttons2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
48-
margin_top = 528.0
48+
margin_top = 453.0
4949
margin_right = 440.0
50-
margin_bottom = 528.0
50+
margin_bottom = 453.0
5151
custom_constants/separation = 75
5252
alignment = 1
5353

UI/HUD.gd

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@ func show_message(text):
99

1010
func hide():
1111
$ScoreBox.hide()
12+
$BonusBox.hide()
1213

1314
func show():
1415
$ScoreBox.show()
16+
$BonusBox.show()
1517

1618
func update_score(value):
17-
$ScoreBox/HBoxContainer/Score.text = str(value)
19+
$ScoreBox/HBoxContainer/Score.text = str(value)
20+
21+
func update_bonus(value):
22+
$BonusBox/Bonus.text = str(value) + "x"
23+
if value > 1:
24+
$AnimationPlayer.play("bonus")
25+

UI/HUD.tscn

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=8 format=2]
1+
[gd_scene load_steps=10 format=2]
22

33
[ext_resource path="res://UI/HUD.gd" type="Script" id=1]
44
[ext_resource path="res://assets/fonts/Xolonium-Regular.ttf" type="DynamicFontData" id=2]
@@ -9,10 +9,43 @@ size = 32
99
extra_spacing_top = 10
1010
font_data = ExtResource( 2 )
1111

12+
[sub_resource type="DynamicFont" id=5]
13+
size = 48
14+
font_data = ExtResource( 2 )
15+
1216
[sub_resource type="DynamicFont" id=2]
1317
size = 69
1418
font_data = ExtResource( 2 )
1519

20+
[sub_resource type="Animation" id=6]
21+
resource_name = "bonus"
22+
length = 0.15
23+
step = 0.01
24+
tracks/0/type = "value"
25+
tracks/0/path = NodePath("BonusBox/Bonus:rect_scale")
26+
tracks/0/interp = 1
27+
tracks/0/loop_wrap = true
28+
tracks/0/imported = false
29+
tracks/0/enabled = true
30+
tracks/0/keys = {
31+
"times": PoolRealArray( 0, 0.07, 0.15 ),
32+
"transitions": PoolRealArray( 1, 1, 1 ),
33+
"update": 0,
34+
"values": [ Vector2( 1, 1 ), Vector2( 1.25, 1.25 ), Vector2( 1, 1 ) ]
35+
}
36+
tracks/1/type = "value"
37+
tracks/1/path = NodePath("BonusBox/Bonus:custom_colors/font_color")
38+
tracks/1/interp = 1
39+
tracks/1/loop_wrap = true
40+
tracks/1/imported = false
41+
tracks/1/enabled = true
42+
tracks/1/keys = {
43+
"times": PoolRealArray( 0, 0.07, 0.15 ),
44+
"transitions": PoolRealArray( 1, 1, 1 ),
45+
"update": 0,
46+
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 0, 0, 1 ), Color( 1, 1, 1, 1 ) ]
47+
}
48+
1649
[sub_resource type="Animation" id=3]
1750
resource_name = "init"
1851
length = 0.1
@@ -119,6 +152,24 @@ size_flags_vertical = 5
119152
custom_fonts/font = ExtResource( 3 )
120153
text = "100"
121154

155+
[node name="BonusBox" type="MarginContainer" parent="."]
156+
anchor_right = 1.0
157+
margin_bottom = 40.0
158+
custom_constants/margin_right = 20
159+
custom_constants/margin_top = 20
160+
custom_constants/margin_left = 20
161+
custom_constants/margin_bottom = 20
162+
163+
[node name="Bonus" type="Label" parent="BonusBox"]
164+
margin_left = 20.0
165+
margin_top = 20.0
166+
margin_right = 460.0
167+
margin_bottom = 78.0
168+
size_flags_vertical = 5
169+
custom_fonts/font = SubResource( 5 )
170+
custom_colors/font_color = Color( 1, 1, 1, 1 )
171+
text = "1x"
172+
122173
[node name="Message" type="Label" parent="."]
123174
anchor_top = 0.5
124175
anchor_right = 1.0
@@ -134,5 +185,6 @@ clip_text = true
134185

135186
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
136187
autoplay = "init"
188+
anims/bonus = SubResource( 6 )
137189
anims/init = SubResource( 3 )
138190
anims/show_message = SubResource( 4 )

logo1_64.png

9.8 KB
Loading

logo1_64.png.import

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/logo1_64.png-8fba6b5cdfc29fca6cc5d8faf01e4fe9.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://logo1_64.png"
13+
dest_files=[ "res://.import/logo1_64.png-8fba6b5cdfc29fca6cc5d8faf01e4fe9.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

logo2_64.png

6 KB
Loading

logo2_64.png.import

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/logo2_64.png-480a88e14b461ba68e5087b7b3af8a34.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://logo2_64.png"
13+
dest_files=[ "res://.import/logo2_64.png-480a88e14b461ba68e5087b7b3af8a34.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

0 commit comments

Comments
 (0)