Nothing personnel, milliseconds...
This commit is contained in:
parent
b8d9a9e935
commit
314b365f7f
6 changed files with 23 additions and 10 deletions
|
@ -47,6 +47,7 @@ var is_easy_mode: bool = false # whether to do easy-specific behaviors
|
|||
var use_lives: bool = false
|
||||
var can_pause: bool = true
|
||||
var current_palette: String = "default"
|
||||
var still_playing: bool = false
|
||||
|
||||
|
||||
func _ready():
|
||||
|
@ -122,10 +123,10 @@ func tally_scores() -> void:
|
|||
shards_collected[6] = true
|
||||
# life bonus
|
||||
if deaths == 0:
|
||||
life_bonus = 500
|
||||
life_bonus = 1500
|
||||
shards_collected[7] = true
|
||||
elif deaths == 1:
|
||||
life_bonus = 1500
|
||||
life_bonus = 500
|
||||
# perfect bonus
|
||||
if shards_collected[5] and shards_collected[6] and shards_collected[7]:
|
||||
perfect_bonus += 1000
|
||||
|
@ -199,7 +200,7 @@ func save():
|
|||
Save.current_file.save_to_file()
|
||||
|
||||
|
||||
#Convert seconds into M:SS:MS
|
||||
# !!DEPRECATED!! convert milliseconds into M:SS:MS
|
||||
func timeify(input):
|
||||
if input <= 5999099:
|
||||
var seconds = fmod(Game.time / 1000,60)
|
||||
|
@ -211,6 +212,17 @@ func timeify(input):
|
|||
else:
|
||||
return "99:59.99"
|
||||
|
||||
# convert seconds into M:SS.MS
|
||||
func format_time(seconds: float) -> String:
|
||||
if is_inf(seconds) or is_nan(seconds): # infinite
|
||||
return "-:--.--"
|
||||
elif seconds >= 600.0: # 10 minutes or greater
|
||||
return "9:99.99"
|
||||
else:
|
||||
var minutes = floor(seconds / 60.0)
|
||||
var centiseconds = fmod(floor(seconds * 100.0), 100.0)
|
||||
return "%01d:%02d.%02d" % [minutes, fmod(seconds, 60.0), centiseconds]
|
||||
|
||||
#Restart level
|
||||
func restart_level():
|
||||
clear_collectibles()
|
||||
|
|
|
@ -85,12 +85,12 @@ func change_current_level(amount):
|
|||
# set any% scores
|
||||
high_score_any.text = "Any%%\n%05d\n%s" % [
|
||||
save_data.score_any,
|
||||
Game.timeify(save_data.time_any)
|
||||
Game.format_time(save_data.time_any)
|
||||
]
|
||||
# set 100% scores
|
||||
high_score_100.text = "100%%\n%05d\n%s" % [
|
||||
save_data.score_100,
|
||||
Game.timeify(save_data.time_100)
|
||||
Game.format_time(save_data.time_100)
|
||||
]
|
||||
# set collected shards
|
||||
for i in 8:
|
||||
|
|
|
@ -20,9 +20,11 @@ func _ready():
|
|||
Fade.connect("fade_finished", Game, "set", ["can_pause", true], CONNECT_ONESHOT)
|
||||
Audio.play_music(music)
|
||||
Game.time = 0.0
|
||||
Game.still_playing = true
|
||||
|
||||
func _physics_process(delta):
|
||||
Game.time += delta
|
||||
if Game.still_playing:
|
||||
Game.time += delta
|
||||
if Debug.entry == false && Game.can_pause:
|
||||
#Pause
|
||||
if Input.is_action_just_pressed("pause") && !get_tree().paused:
|
||||
|
|
|
@ -29,7 +29,7 @@ func _ready() -> void:
|
|||
var shard = shards.get_child(i)
|
||||
shard.get_node("Title").text = level.shard_titles[i]
|
||||
score.text = str("SCORE:") + "%05d" % Game.score
|
||||
time.text = str("TIME: ") + Game.timeify(Game.time)
|
||||
time.text = str("TIME: ") + Game.format_time(Game.time)
|
||||
#Determine score bonuses
|
||||
collection_bonus_score.text = str("+") + str(Game.collection_bonus)
|
||||
time_bonus_score.text = str("+") + str(Game.time_bonus)
|
||||
|
|
|
@ -21,6 +21,7 @@ func _physics_process(delta):
|
|||
|
||||
func _on_Area2D_area_entered(area):
|
||||
if area.is_in_group("player_hitbox"):
|
||||
Game.still_playing = false
|
||||
var player = area.get_parent()
|
||||
player.state_chart.send_event("start_teleport")
|
||||
player.connect("teleport_finished", self, "_on_player_teleport_finished")
|
||||
|
|
|
@ -14,7 +14,6 @@ onready var high_counter = $HighCounter
|
|||
onready var time_counter = $TimeCounter
|
||||
onready var oxygen = $Oxygen
|
||||
onready var oxygen_meter = $Oxygen/OxygenMeter
|
||||
onready var start_time = Time.get_ticks_msec()
|
||||
|
||||
export var song_name = "♫Music"
|
||||
export (Color) var bonus_color
|
||||
|
@ -78,8 +77,7 @@ func _physics_process(delta):
|
|||
else:
|
||||
lives_counter.modulate = Color.white
|
||||
##Timer
|
||||
Game.time = Time.get_ticks_msec() - start_time
|
||||
time_counter.text = Game.timeify(Game.time)
|
||||
time_counter.text = Game.format_time(Game.time)
|
||||
#Time bonus counter
|
||||
if (Game.has_collection_bonus() && Game.time <= Game.get_map().target_time_100) or (!Game.has_collection_bonus() && Game.time <= Game.get_map().target_time_any):
|
||||
time_counter.modulate = bonus_color
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue