diff --git a/2d/gameover.gd b/2d/gameover.gd index bbd5fa4..4081fcb 100644 --- a/2d/gameover.gd +++ b/2d/gameover.gd @@ -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() @@ -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" @@ -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() diff --git a/2d/gameover.tscn b/2d/gameover.tscn index 90ac298..4cf7976 100644 --- a/2d/gameover.tscn +++ b/2d/gameover.tscn @@ -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 } diff --git a/script/Boss.gd b/script/Boss.gd index 9a64384..ce290bd 100644 --- a/script/Boss.gd +++ b/script/Boss.gd @@ -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"): diff --git a/script/game.gd b/script/game.gd index 545e2bf..e874c42 100644 --- a/script/game.gd +++ b/script/game.gd @@ -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") diff --git a/script/global.gd b/script/global.gd index f3f1aa4..f40ed12 100644 --- a/script/global.gd +++ b/script/global.gd @@ -1,5 +1,5 @@ extends Node -const GAME_NAME = "ShapebornTest" +const GAME_NAME = "Shapeborn" var start_time = 0