Browse Source

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.
master
Abheek Dhawan 4 years ago
parent
commit
250ea3c067
  1. 13
      Game Scenes/Game.tscn
  2. 5
      Scripts/Score.gd

13
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://Objects/Rocket.tscn" type="PackedScene" id=1]
[ext_resource path="res://Scripts/Rocket.gd" type="Script" id=2] [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://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/AsteroidSpawn.gd" type="Script" id=4]
[ext_resource path="res://Scripts/Score.gd" type="Script" id=5]
[node name="Game" type="Node2D"] [node name="Game" type="Node2D"]
script = ExtResource( 4 ) script = ExtResource( 4 )
@ -18,6 +19,16 @@ offset = Vector2( 0, -220 )
current = true current = true
smoothing_enabled = 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="ParallaxBackground" type="ParallaxBackground" parent="."]
[node name="ParallaxLayer" type="ParallaxLayer" parent="ParallaxBackground"] [node name="ParallaxLayer" type="ParallaxLayer" parent="ParallaxBackground"]

5
Scripts/Score.gd

@ -0,0 +1,5 @@
extends Label
func _process(delta):
var score = str(int(-get_parent().position.y/10))
text = score
Loading…
Cancel
Save