44 lines
887 B
GDScript
44 lines
887 B
GDScript
extends Node
|
|
var savePath :String ="user://user.save"
|
|
|
|
var score :int = 0
|
|
var highScores : Array = [0]
|
|
|
|
func playerPoScore():
|
|
score += 1
|
|
|
|
func hit(data):
|
|
if data == "Hit":
|
|
score -= 50
|
|
elif data == "power":
|
|
score += 30
|
|
|
|
|
|
func startGame():
|
|
score = 0
|
|
|
|
func playerDeath():
|
|
if FileAccess.file_exists("user://user.save"):
|
|
var file = FileAccess.open(savePath, FileAccess.READ)
|
|
if file.get_as_text():
|
|
print(highScores.min())
|
|
highScores = str_to_var(file.get_as_text())
|
|
if score > highScores.min():
|
|
highScores.append(score)
|
|
else:
|
|
highScores.append(score)
|
|
save()
|
|
|
|
func save():
|
|
var file = FileAccess.open(savePath, FileAccess.WRITE)
|
|
file.store_line(str(highScores))
|
|
|
|
|
|
func getHigh():
|
|
print("here")
|
|
if not FileAccess.file_exists("user://user.save"):
|
|
pass
|
|
var file = FileAccess.open(savePath, FileAccess.READ)
|
|
var data = file.get_as_text()
|
|
print(data)
|