saving and level list

This commit is contained in:
pennyrigate 2023-01-07 03:02:26 -05:00
parent 38ef040ae9
commit 39a7eb14b4
13 changed files with 128 additions and 52 deletions

View file

@ -1,3 +1,3 @@
source_md5="c0160f559a57791b0ab96a8c9ef45d0c"
dest_md5="a40b0bbf70fb2e4f0d971d734f832ac1"
source_md5="82f232cbd11bbebe6d1233db07f644d6"
dest_md5="5ae15f7f93ebb7667d6cf1268987bb99"

View file

@ -1,5 +1,5 @@
info face="2ndPubertyMono" size=16 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,2,1 spacing=-2,0
common lineHeight=20 base=12 scaleW=512 scaleH=512 pages=1 packed=0
common lineHeight=7 base=12 scaleW=512 scaleH=512 pages=1 packed=0
page id=0 file="2ndpuberty..png"
chars count=97
char id=0 x=108 y=20 width=8 height=20 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=0

3
fonts/2ndpuberty..tres Normal file
View file

@ -0,0 +1,3 @@
[gd_resource type="BitmapFont" format=2]
[resource]

38
game.gd
View file

@ -77,20 +77,34 @@ func clear_collectibles():
#Save
func save():
var save = ConfigFile.new()
save.set_value(str(current_level),"High Score",Game.score)
save.set_value(str(current_level),"Golds",Game.golds)
save.set_value(str(current_level),"Shard0",Game.shards_collected[0])
save.set_value(str(current_level),"Shard1",Game.shards_collected[1])
save.set_value(str(current_level),"Shard2",Game.shards_collected[2])
save.set_value(str(current_level),"Shard3",Game.shards_collected[3])
save.set_value(str(current_level),"Shard4",Game.shards_collected[4])
save.set_value(str(current_level),"Shard5",Game.shards_collected[5])
save.set_value(str(current_level),"Shard6",Game.shards_collected[6])
save.set_value(str(current_level),"Shard7",Game.shards_collected[7])
save.set_value(str(current_level),"Shard8",Game.shards_collected[8])
save.set_value(str(current_level),"Shard9",Game.shards_collected[9])
save.load(str("user://file") + str(Game.current_file) + str(".pr"))
if Game.shards == 5 && Game.golds == 50:
save.set_value(str(current_level),"100% High Score",Game.score)
save.set_value(str(current_level),"100% Time",Game.time)
else:
save.set_value(str(current_level),"Any% High Score",Game.score)
save.set_value(str(current_level),"Any% Time",Game.time)
if Game.shards_collected[0] == true: save.set_value(str(current_level),"Shard0",Game.shards_collected[0])
if Game.shards_collected[1] == true: save.set_value(str(current_level),"Shard1",Game.shards_collected[1])
if Game.shards_collected[2] == true: save.set_value(str(current_level),"Shard2",Game.shards_collected[2])
if Game.shards_collected[3] == true: save.set_value(str(current_level),"Shard3",Game.shards_collected[3])
if Game.shards_collected[4] == true: save.set_value(str(current_level),"Shard4",Game.shards_collected[4])
if Game.shards_collected[5] == true: save.set_value(str(current_level),"Shard5",Game.shards_collected[5])
if Game.shards_collected[6] == true: save.set_value(str(current_level),"Shard6",Game.shards_collected[6])
if Game.shards_collected[7] == true: save.set_value(str(current_level),"Shard7",Game.shards_collected[7])
if Game.shards_collected[8] == true: save.set_value(str(current_level),"Shard8",Game.shards_collected[8])
if Game.shards_collected[9] == true: save.set_value(str(current_level),"Shard9",Game.shards_collected[9])
save.save(str("user://file") + str(current_file) + str(".pr"))
func timeify(input):
var minutes = str(floor(input / 60))
var seconds = floor(fmod(input,60))
var milliseconds := floor(fmod(input, 1) * 100)
if input < 600:
return minutes + ":" + ("%02d" % seconds) + ":" + ("%02d" % milliseconds)
else:
return "9:59:99"
func _process(delta):
#CRT FILTER
if Input.is_action_just_pressed("crt"):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 734 B

After

Width:  |  Height:  |  Size: 736 B

Before After
Before After

View file

@ -6,6 +6,8 @@ onready var title = $Title
onready var shard_title = $ShardTitle
onready var shard_arrow = $ShardArrow
onready var high_score = $HighScore
onready var high_score_any = $HighScoreAny
onready var high_score_100 = $HighScore100
onready var golds = $Golds
onready var levelarrow_up = $LevelArrowUp
onready var levelarrow_down = $LevelArrowDown
@ -45,6 +47,7 @@ func change_current_shard(amount):
shard_arrow.position.x += 15 * amount
func change_current_level(amount):
#Change level
if current_level + amount != -1 && current_level + amount != levels.level.size(): #Check if in range
current_level += amount
#Show arrows or don't
@ -63,17 +66,22 @@ func change_current_level(amount):
#Load new data
var save = ConfigFile.new()
save.load(str("user://file") + str(Game.current_file) + str(".pr"))
var str_level = str(current_level)
#Draw score and golds
high_score.text = str("%06d" % save.get_value(str(current_level),"High Score",0))
golds.text = str("%02d" % save.get_value(str(current_level),"Golds",0))
# high_score.text = str("%04d" % save.get_value(str_level,"High Score",0))
# golds.text = str("%02d" % save.get_value(str_level,"Golds",0))
#Draw High Scores
print(str_level)
high_score_any.text = "Any%\n" + str("%05d" % save.get_value(str_level,"Any% High Score",0)) + "\n" + str(Game.timeify(save.get_value(str_level,"Any% Time",0)))
high_score_100.text = "100%\n" + str("%05d" % save.get_value(str_level,"100% High Score",0)) + "\n" + str(Game.timeify(save.get_value(str_level,"100% Time",0)))
#Draw shards collected
shard0.visible = save.get_value(str(current_level),"Shard0",false)
shard1.visible = save.get_value(str(current_level),"Shard1",false)
shard2.visible = save.get_value(str(current_level),"Shard2",false)
shard3.visible = save.get_value(str(current_level),"Shard3",false)
shard4.visible = save.get_value(str(current_level),"Shard4",false)
shard5.visible = save.get_value(str(current_level),"Shard5",false)
shard6.visible = save.get_value(str(current_level),"Shard6",false)
shard7.visible = save.get_value(str(current_level),"Shard7",false)
shard8.visible = save.get_value(str(current_level),"Shard8",false)
shard9.visible = save.get_value(str(current_level),"Shard9",false)
shard0.visible = save.get_value(str_level,"Shard0",false)
shard1.visible = save.get_value(str_level,"Shard1",false)
shard2.visible = save.get_value(str_level,"Shard2",false)
shard3.visible = save.get_value(str_level,"Shard3",false)
shard4.visible = save.get_value(str_level,"Shard4",false)
shard5.visible = save.get_value(str_level,"Shard5",false)
shard6.visible = save.get_value(str_level,"Shard6",false)
shard7.visible = save.get_value(str_level,"Shard7",false)
shard8.visible = save.get_value(str_level,"Shard8",false)
shard9.visible = save.get_value(str_level,"Shard9",false)

View file

@ -65,10 +65,12 @@ margin_top = 48.0
margin_right = 184.0
margin_bottom = 68.0
theme = ExtResource( 1 )
text = "test text"
text = "test text
"
align = 1
[node name="Golds" type="Label" parent="."]
visible = false
margin_left = 120.0
margin_top = 88.0
margin_right = 136.0
@ -79,14 +81,41 @@ align = 1
[node name="HighScoreText" type="Label" parent="."]
margin_left = 56.0
margin_top = 64.0
margin_top = 62.0
margin_right = 200.0
margin_bottom = 96.0
margin_bottom = 94.0
theme = ExtResource( 1 )
text = "High Score:"
text = "High SCORE:
"
align = 1
[node name="HighScoreAny" type="Label" parent="."]
margin_left = 21.0
margin_top = 74.0
margin_right = 165.0
margin_bottom = 111.0
theme = ExtResource( 1 )
text = "any%
0000
0:00:00
"
align = 1
[node name="HighScore100" type="Label" parent="."]
margin_left = 84.0
margin_top = 74.0
margin_right = 228.0
margin_bottom = 111.0
theme = ExtResource( 1 )
text = "100%
0000
0:00:00
"
align = 1
[node name="HighScore" type="Label" parent="."]
visible = false
margin_left = 56.0
margin_top = 76.0
margin_right = 200.0
@ -97,15 +126,16 @@ align = 1
[node name="ShardTitle" type="Label" parent="."]
margin_left = 43.0
margin_top = 124.0
margin_top = 129.0
margin_right = 213.0
margin_bottom = 167.0
margin_bottom = 172.0
theme = ExtResource( 1 )
text = "Collect all coins
"
align = 1
[node name="ShardGraphics" type="Node2D" parent="."]
position = Vector2( 0, 7 )
[node name="Shard11" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
@ -198,10 +228,11 @@ position = Vector2( 176, 115 )
position = Vector2( 191, 115 )
[node name="Gold" parent="." instance=ExtResource( 5 )]
visible = false
position = Vector2( 111, 91 )
[node name="ShardArrow" type="Sprite" parent="."]
position = Vector2( 61, 106 )
position = Vector2( 61, 113 )
texture = ExtResource( 4 )
[node name="LevelArrowUp" type="Sprite" parent="."]

View file

@ -1,4 +1,6 @@
extends Node2D
export var target_time_any = 0
export var target_time_100 = 0
func _ready():
Game.play_sound(load("res://audio/music/rumble_loop.mp3"),Game.ac_music)

View file

@ -25,6 +25,8 @@ extents = Vector2( 8, 128 )
[node name="Map" type="Node2D"]
script = ExtResource( 18 )
target_time_any = 70
target_time_100 = 180
[node name="Camera2D" parent="." instance=ExtResource( 8 )]
smoothing_enabled = false

View file

@ -3,6 +3,7 @@ extends Node2D
export var cost = 0
onready var label = $Label
onready var anims = $AnimationPlayer
onready var map = get_owner()
func _ready():
anims.play("closed")
@ -16,5 +17,21 @@ func _physics_process(delta):
func _on_Area2D_area_entered(area):
if area.is_in_group("player"):
if Game.score > Game.high_score: Game.high_score = Game.score
#BONUSES
#Time bonus
if Game.golds == 50 && Game.shards == 5:
if Game.time < map.target_time_100: Game.score += floor(2500 * (Game.time / map.target_time_100))
else:
if Game.time < map.target_time_any: Game.score += floor(2500 * (Game.time / map.target_time_any))
#Collection bonus
if Game.golds == 50: Game.score += 500
if Game.shards == 5: Game.score += 500
if Game.golds == 50 && Game.shards == 5: Game.score += 250
#Life bonus
if Game.lives == 1: Game.score += 500
if Game.lives == 2: Game.score += 1500
#Perfect bonus
if Game.lives == 2 && Game.golds == 50 && Game.shards == 5 && Game.time < map.target_time_100:
Game.score += 1000
Game.save()
Game.change_map(load("res://maps/level_select.tscn"))

View file

@ -20,7 +20,7 @@ func _physics_process(delta):
#Gold Counter
gold_counter.text = "%02d" % Game.golds
#Shard Counter
shard_counter.text = "%02d" % Game.shards
shard_counter.text = str(Game.shards)
#Star Counter
red_star.visible = Game.stars[0]
yellow_star.visible = Game.stars[1]
@ -28,7 +28,7 @@ func _physics_process(delta):
blue_star.visible = Game.stars[3]
magenta_star.visible = Game.stars[4]
#Score Counter
score_counter.text = "%06d" % Game.score
score_counter.text = "%05d" % Game.score
#Arrow Counter
arrow_counter.text = str(Game.arrows)
##TOUCH UP LATER
@ -38,10 +38,4 @@ func _physics_process(delta):
high_counter.text = str("HIGH:") + str("%06d" % Game.high_score)
##Timer
Game.time += delta
var minutes = str(floor(Game.time / 60))
var seconds = floor(fmod(Game.time,60))
var milliseconds := floor(fmod(Game.time, 1) * 100)
if Game.time < 600:
time_counter.text = minutes + ":" + ("%02d" % seconds) + ":" + ("%02d" % milliseconds)
else:
time_counter.text = "9:59:99"
time_counter.text = Game.timeify(Game.time)

View file

@ -36,36 +36,41 @@ margin_top = -2.0
margin_right = 81.0
margin_bottom = 18.0
theme = ExtResource( 10 )
text = "00"
text = "0"
[node name="RedStar" type="Sprite" parent="HUD"]
visible = false
material = SubResource( 1 )
position = Vector2( 86, 5 )
position = Vector2( 83, 5 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 0, 8, 8 )
[node name="YellowStar" type="Sprite" parent="HUD"]
visible = false
material = SubResource( 2 )
position = Vector2( 96, 5 )
position = Vector2( 93, 5 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 8, 0, 8, 8 )
[node name="GreenStar" type="Sprite" parent="HUD"]
position = Vector2( 106, 5 )
visible = false
position = Vector2( 103, 5 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 16, 0, 8, 8 )
[node name="BlueStar" type="Sprite" parent="HUD"]
position = Vector2( 116, 5 )
visible = false
position = Vector2( 113, 5 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 24, 0, 8, 8 )
[node name="MagentaStar" type="Sprite" parent="HUD"]
position = Vector2( 126, 5 )
visible = false
position = Vector2( 123, 5 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 32, 0, 8, 8 )
@ -84,7 +89,7 @@ margin_top = -2.0
margin_right = 263.0
margin_bottom = 18.0
theme = ExtResource( 10 )
text = "000000"
text = "00000"
[node name="HighCounter" type="Label" parent="HUD"]
visible = false
@ -104,9 +109,9 @@ theme = ExtResource( 10 )
text = "2"
[node name="ArrowCounter" type="Label" parent="HUD"]
margin_left = 68.0
margin_left = 61.0
margin_top = -2.0
margin_right = 152.0
margin_right = 145.0
margin_bottom = 18.0
theme = ExtResource( 10 )
text = "0"