diff --git a/growth/level.tscn b/growth/level.tscn index 24352d2..211829d 100644 --- a/growth/level.tscn +++ b/growth/level.tscn @@ -4,8 +4,8 @@ [ext_resource type="PackedScene" uid="uid://bsv3h2lpv7h77" path="res://virus.tscn" id="2_oi3di"] [ext_resource type="PackedScene" uid="uid://bldi3fw0vmlu3" path="res://music.tscn" id="3_oi3di"] [ext_resource type="TileSet" uid="uid://c20bl25rqyf68" path="res://assets/tiles/new_tile_set.tres" id="4_0b4ue"] -[ext_resource type="PackedScene" uid="uid://co8jnr2dew5ts" path="res://hand.tscn" id="5_f2txt"] -[ext_resource type="Script" uid="uid://dycpk6lxabn1l" path="res://virus_spawner.gd" id="6_1ainy"] +[ext_resource type="PackedScene" uid="uid://cpp7v4jp8kt74" path="res://hand.tscn" id="5_f2txt"] +[ext_resource type="Script" path="res://virus_spawner.gd" id="6_1ainy"] [node name="Level" type="Node2D"] @@ -25,6 +25,17 @@ scale = Vector2(2, 2) [node name="Hand" parent="CanvasLayer" instance=ExtResource("5_f2txt")] unique_name_in_owner = true +[node name="ScoreCounter" type="RichTextLabel" parent="CanvasLayer"] +unique_name_in_owner = true +offset_left = 16.0 +offset_top = 19.0 +offset_right = 117.0 +offset_bottom = 65.0 +text = "Score: 0 +High Score: 0" +fit_content = true +autowrap_mode = 0 + [node name="VirusSpawner" type="Node" parent="."] script = ExtResource("6_1ainy") Virus = ExtResource("2_oi3di") diff --git a/growth/player.gd b/growth/player.gd index 606000a..33d04eb 100644 --- a/growth/player.gd +++ b/growth/player.gd @@ -10,6 +10,11 @@ enum MoveState {Still, Moving, Dashing, Knockback} @onready var camera: Camera2D = %PlayerCamera @onready var sprite: AnimatedSprite2D = $PlayerSprite @onready var hand: Control = %Hand; +@onready var shield: Sprite2D = $Shield +@onready var score_counter: RichTextLabel = %ScoreCounter + +var score = 0; +var high_score = 0; var shield_active = true; var move_direction = Vector2.ZERO; @@ -118,6 +123,16 @@ func take_hit(_damage, knockback_vector, knockback_strength = 1): else: reboot(); +func add_to_score(amount): + score += amount; + if score > high_score: + high_score = score; + score_counter.text = "Score: %d\nHigh Score: %d" % [score, high_score] + +func reset_score(): + score = 0; + score_counter.text = "Score: %d\nHigh Score: %d" % [score, high_score] + func reboot(): # Called when the player dies # For now, just reset position and state @@ -126,4 +141,5 @@ func reboot(): move_state = MoveState.Still; shield_active = true; $Shield.visible = true; + reset_score(); # hand.discard_all(); diff --git a/growth/virus.gd b/growth/virus.gd index 4c2315d..04e65ab 100644 --- a/growth/virus.gd +++ b/growth/virus.gd @@ -70,6 +70,7 @@ func take_hit(damage, knockback_vector, knockback_strength = 1): else: health -= damage if health <= 0: + get_node("../../Player").add_to_score(1); queue_free() elif knockback_strength > 0: knockback = -knockback_vector;