extends Label
const SAVE_FILE_PATH = "user://savedata.save"
const score_text = "SCORE: "
const high_score_text = "HIGH SCORE: "
var highscore = 0
func _ready():
load_score()
func load_score():
var load_data = File.new()
if load_data.file_exists(SAVE_FILE_PATH):
load_data.open_encrypted_with_pass(SAVE_FILE_PATH,File.READ,"cokolwiek")
var content = load_data.get_as_text()
highscore = int(content)
load_data.close()
text = score_text+str(0)+"\n"+high_score_text+str(highscore)
func save_score():
var save_data = File.new()
save_data.open_encrypted_with_pass(SAVE_FILE_PATH,File.WRITE,"cokolwiek")
save_data.store_string(str(highscore))
save_data.close()
func update_score(score):
text = score_text+str(score)+"\n"+high_score_text+str(highscore)
func check_highscore(score):
if score>highscore:
highscore = score
save_score()
text = score_text+str(score)+"\n"+high_score_text+str(highscore)