Added a score system

This commit is contained in:
Puppet committed 2025-08-28 23:48:06 -07:00
1 parent bee846c3ba
commit 87bbaafb75
5 files changed
+70 -1

No files matched your search

+49 -1
View File
@@ -1,8 +1,10 @@
[gd_scene load_steps=5 format=3 uid="uid://bgt46l5p8qrwc"] [gd_scene load_steps=7 format=3 uid="uid://bgt46l5p8qrwc"]
[ext_resource type="Script" uid="uid://dfv3cmvcskd6t" path="res://Scripts/Player.cs" id="1_gl6un"] [ext_resource type="Script" uid="uid://dfv3cmvcskd6t" path="res://Scripts/Player.cs" id="1_gl6un"]
[ext_resource type="Texture2D" uid="uid://5ecdlqnn0u6g" path="res://Textures/Icons/Bird1.png" id="1_iukft"] [ext_resource type="Texture2D" uid="uid://5ecdlqnn0u6g" path="res://Textures/Icons/Bird1.png" id="1_iukft"]
[ext_resource type="Script" uid="uid://bdwdadvx0axam" path="res://Scripts/Berries.cs" id="1_kldst"] [ext_resource type="Script" uid="uid://bdwdadvx0axam" path="res://Scripts/Berries.cs" id="1_kldst"]
[ext_resource type="Script" uid="uid://drbmu7lilwrec" path="res://Scripts/ScoreText.cs" id="4_b2bpf"]
[ext_resource type="FontFile" uid="uid://dq7nkk7n7wrq4" path="res://Fonts/Lexend.ttf" id="4_kldst"]
[sub_resource type="CircleShape2D" id="CircleShape2D_j5yw3"] [sub_resource type="CircleShape2D" id="CircleShape2D_j5yw3"]
radius = 117.004 radius = 117.004
@@ -30,3 +32,49 @@ position = Vector2(-5, 23)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player/Hitbox"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Player/Hitbox"]
shape = SubResource("CircleShape2D_j5yw3") shape = SubResource("CircleShape2D_j5yw3")
debug_color = Color(1, 1, 1, 0.188235) debug_color = Color(1, 1, 1, 0.188235)
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="ScoreText" type="Control" parent="CanvasLayer"]
layout_mode = 3
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -20.0
offset_right = 20.0
offset_bottom = 40.0
grow_horizontal = 2
script = ExtResource("4_b2bpf")
[node name="ScoreLabel" type="Label" parent="CanvasLayer/ScoreText"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -228.0
offset_right = 720.0
offset_bottom = 308.0
grow_horizontal = 2
scale = Vector2(0.48, 0.48)
theme_override_fonts/font = ExtResource("4_kldst")
theme_override_font_sizes/font_size = 246
text = "Score: 0"
horizontal_alignment = 1
vertical_alignment = 1
[node name="HighScoreLabel" type="Label" parent="CanvasLayer/ScoreText"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -257.0
offset_top = 148.0
offset_right = 812.0
offset_bottom = 361.0
grow_horizontal = 2
scale = Vector2(0.48, 0.48)
theme_override_fonts/font = ExtResource("4_kldst")
theme_override_font_sizes/font_size = 156
text = "High Score: 0"
horizontal_alignment = 1
vertical_alignment = 1
+5
View File
@@ -3,6 +3,11 @@ using System;
public partial class BerryLogic : Node2D { public partial class BerryLogic : Node2D {
private void _on_hitbox_area_entered(Area2D area) { private void _on_hitbox_area_entered(Area2D area) {
Globals.Score += 1;
if (Globals.Score > Globals.HighScore) {
Globals.HighScore += 1;
}
QueueFree(); QueueFree();
} }
} }
+3
View File
@@ -5,4 +5,7 @@ public partial class Globals : Node {
public static string LatestVersion = ""; public static string LatestVersion = "";
public static string AccessLevel = ""; public static string AccessLevel = "";
public static bool VersionChecked = false; public static bool VersionChecked = false;
public static int Score = 0;
public static int HighScore = 0;
} }
+12
View File
@@ -0,0 +1,12 @@
using Godot;
using System;
public partial class ScoreText : Control {
public override void _Process(double delta) {
Label ScoreText = GetNode<Label>("ScoreLabel");
Label HighScoreText = GetNode<Label>("HighScoreLabel");
ScoreText.Text = "Score: " + Globals.Score;
HighScoreText.Text = "High Score: " + Globals.HighScore;
}
}
+1
View File
@@ -0,0 +1 @@
uid://drbmu7lilwrec