Skip to content

Commit

Permalink
integrate highscore correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Dec 17, 2020
1 parent b7a401a commit 5473b30
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions 2d/gameover.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var loading = false
var score

func _ready():
score = OS.get_ticks_msec() - Global.start_time
score = int((OS.get_ticks_msec() - Global.start_time) / 1000)
$score.text = str(score)
$TextEdit.grab_focus()

Expand All @@ -28,7 +28,7 @@ func send_highscore(game: String, player: String, score: int):
remove_child(http_request)

var res = JSON.parse(response[3].get_string_from_utf8()).result
get_tree().change_scene("res://scenes/newgame.tscn")

if res.has("position"):
var position = res["position"]
$Button2.text = "Retry"
Expand All @@ -40,7 +40,7 @@ func send_my_highscore():
if !loading && len($TextEdit.text) > 0:
loading = true
$Button.disabled = true
send_highscore(Global.GAME_NAME, $TextEdit.text, score)
send_highscore(Global.GAME_NAME, $TextEdit.text, -score)

func _on_Button_pressed():
send_my_highscore()
Expand Down
2 changes: 1 addition & 1 deletion 2d/gameover.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ margin_left = 266.317
margin_top = 149.292
margin_right = 522.317
margin_bottom = 170.292
text = "Congratulations! Your score:"
text = "Congratulations! You finished in (seconds):"
__meta__ = {
"_edit_use_anchors_": false
}
Expand Down
2 changes: 2 additions & 0 deletions script/Boss.gd
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ func die():
visible = false
running = false
$"../Win".visible = true

get_tree().change_scene("res://2d/gameover.tscn")

func _on_hitbox_body_entered(body):
if body.is_in_group("player"):
Expand Down
4 changes: 0 additions & 4 deletions script/game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ func set_zoom_strength(val):
$ViewportContainer.material.set_shader_param(
"ZoomStrength",
val)

func _process(delta):
if Input.is_action_just_pressed("ui_left"):
get_tree().change_scene("res://2d/gameover.tscn")
2 changes: 1 addition & 1 deletion script/global.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extends Node

const GAME_NAME = "ShapebornTest"
const GAME_NAME = "Shapeborn"

var start_time = 0

0 comments on commit 5473b30

Please sign in to comment.