From 645eae7c747feec16c795cc0e1e20cf87a4cff6c Mon Sep 17 00:00:00 2001 From: kdx Date: Tue, 31 Oct 2023 01:51:57 +0100 Subject: banger --- Globals.gd | 9 ++++++++- dicaprio.gd | 1 + game.tscn | 2 ++ project_time_traker.json | 8 ++++---- score_points.gd | 39 +++++++++++++++++++++++++++++++++++++++ score_points.tscn | 28 +++++++++++++++++++++++++++- 6 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 score_points.gd diff --git a/Globals.gd b/Globals.gd index 9078635..bc4513c 100644 --- a/Globals.gd +++ b/Globals.gd @@ -8,11 +8,18 @@ const LIMITS_MAX = LIMITS / 2 var FUN = false @onready var _primogem: PackedScene = load("res://coin.tscn") +@onready var _scorepoints: PackedScene = load("res://score_points.tscn") func _ready() -> void: randomize() func spawn_primogem(pos: Vector2) -> void: var e: Area2D = _primogem.instantiate() - e.position = Vector2(pos.x, pos.y) + e.position = pos get_node("../Game/Coins").add_child(e) + + +func spawn_scorepoints(pos: Vector2) -> void: + var e: Node2D = _scorepoints.instantiate() + e.position = pos + get_node("../Game/ScorePoints").add_child(e) diff --git a/dicaprio.gd b/dicaprio.gd index fa298b7..1fc38f7 100644 --- a/dicaprio.gd +++ b/dicaprio.gd @@ -26,6 +26,7 @@ func _on_area_entered(area: Area2D) -> void: func damage(x: float) -> void: life -= x + Globals.spawn_scorepoints(position) if life <= 0: Globals.spawn_primogem(position) queue_free() diff --git a/game.tscn b/game.tscn index 0680806..0c1a2ea 100644 --- a/game.tscn +++ b/game.tscn @@ -74,6 +74,8 @@ autoplay = true [node name="Coins" type="Node" parent="."] +[node name="ScorePoints" type="Node" parent="."] + [node name="SpawnPath" type="Path2D" parent="."] curve = SubResource("Curve2D_txqas") diff --git a/project_time_traker.json b/project_time_traker.json index eeeb7f6..a7913ff 100644 --- a/project_time_traker.json +++ b/project_time_traker.json @@ -1,6 +1,6 @@ { - "2D": 502.171649932862, - "3D": 35.9101521968841, - "Editor": 2798.63270664215, - "Script": 2260.5509045124 + "2D": 740.17781996727, + "3D": 40.4429991245269, + "Editor": 4751.15114212035, + "Script": 3970.53032302856 } \ No newline at end of file diff --git a/score_points.gd b/score_points.gd new file mode 100644 index 0000000..5f6c560 --- /dev/null +++ b/score_points.gd @@ -0,0 +1,39 @@ +extends Node2D + + +const funny_numbers := [ + 69, + 420, + 1337, + 911, + 666, + 777, + 3630, + 51, + 255, + 13, + 9001, + 713705, + 127001, + 160, + -1 +] + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + if randi_range(0, 2) == 2: + $Label.text = str(funny_numbers[randi_range(0, len(funny_numbers) - 1)]) + else: + $Label.text = str(randi_range(999, 9999)) + modulate.a *= 2 + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _physics_process(_delta: float) -> void: + modulate.r = randi_range(0, 1) + modulate.g = randi_range(0, 1) + modulate.b = randi_range(0, 1) + position.y -= 2 + modulate.a *= 0.98 + if modulate.a < 0.0001: queue_free() diff --git a/score_points.tscn b/score_points.tscn index 14cc060..6a73ef7 100644 --- a/score_points.tscn +++ b/score_points.tscn @@ -1,3 +1,29 @@ -[gd_scene format=3 uid="uid://d0kjmjo87gpv3"] +[gd_scene load_steps=4 format=3 uid="uid://d0kjmjo87gpv3"] + +[ext_resource type="Script" path="res://score_points.gd" id="1_btf3r"] +[ext_resource type="FontFile" uid="uid://bickqwuayvvpb" path="res://Helvetica.ttf" id="1_twadh"] + +[sub_resource type="LabelSettings" id="LabelSettings_kbfpe"] +font = ExtResource("1_twadh") +font_size = 64 [node name="ScorePoints" type="Node2D"] +script = ExtResource("1_btf3r") + +[node name="Label" type="Label" parent="."] +z_index = 2 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -11.5 +offset_right = 20.0 +offset_bottom = 11.5 +grow_horizontal = 2 +grow_vertical = 2 +text = "69" +label_settings = SubResource("LabelSettings_kbfpe") +horizontal_alignment = 1 +vertical_alignment = 1 -- cgit v1.2.3