2024-02-22 20:33:20 -05:00
|
|
|
extends Node
|
2024-03-04 20:35:09 -05:00
|
|
|
var savePath :String ="user://user.save"
|
2024-02-22 20:33:20 -05:00
|
|
|
|
2024-03-04 20:35:09 -05:00
|
|
|
var score :int = 0
|
|
|
|
var highScores : Array = [0]
|
2024-02-22 20:33:20 -05:00
|
|
|
|
|
|
|
func playerPoScore():
|
|
|
|
score += 1
|
|
|
|
|
2024-02-28 20:21:50 -05:00
|
|
|
func hit(data):
|
|
|
|
if data == "Hit":
|
|
|
|
score -= 50
|
|
|
|
elif data == "power":
|
|
|
|
score += 30
|
|
|
|
|
2024-03-04 20:35:09 -05:00
|
|
|
|
|
|
|
func startGame():
|
2024-02-28 20:21:50 -05:00
|
|
|
score = 0
|
2024-03-04 20:35:09 -05:00
|
|
|
|
|
|
|
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)
|