From 250ea3c067d90e3935f30dcad4b9bead3c630c5a Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Sat, 31 Oct 2020 18:30:55 -0500 Subject: [PATCH] Added score next to rocket There was no way to track how far the rocket had gone so an arbitrary fraction of the height was added. Still no saving yet though. --- Game Scenes/Game.tscn | 13 ++++++++++++- Scripts/Score.gd | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 Scripts/Score.gd diff --git a/Game Scenes/Game.tscn b/Game Scenes/Game.tscn index 586fff5..91742e3 100644 --- a/Game Scenes/Game.tscn +++ b/Game Scenes/Game.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://Objects/Rocket.tscn" type="PackedScene" id=1] [ext_resource path="res://Scripts/Rocket.gd" type="Script" id=2] [ext_resource path="res://Images and Anims/In Game/background.png" type="Texture" id=3] [ext_resource path="res://Scripts/AsteroidSpawn.gd" type="Script" id=4] +[ext_resource path="res://Scripts/Score.gd" type="Script" id=5] [node name="Game" type="Node2D"] script = ExtResource( 4 ) @@ -18,6 +19,16 @@ offset = Vector2( 0, -220 ) current = true smoothing_enabled = true +[node name="Label" type="Label" parent="Rocket"] +margin_left = 13.0 +margin_top = 9.0 +margin_right = 44.0 +margin_bottom = 27.0 +script = ExtResource( 5 ) +__meta__ = { +"_edit_use_anchors_": false +} + [node name="ParallaxBackground" type="ParallaxBackground" parent="."] [node name="ParallaxLayer" type="ParallaxLayer" parent="ParallaxBackground"] diff --git a/Scripts/Score.gd b/Scripts/Score.gd new file mode 100644 index 0000000..24b8e39 --- /dev/null +++ b/Scripts/Score.gd @@ -0,0 +1,5 @@ +extends Label + +func _process(delta): + var score = str(int(-get_parent().position.y/10)) + text = score