From f8ceccc5391a7fa51be7ac8f1d4080fb786f6e1c Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Thu, 5 Mar 2026 19:31:28 +0100 Subject: [PATCH] feat: Add bonus time pickup w/ logic --- assets/Images/time-add-svgrepo-com.svg | 3 ++ assets/Images/time-add-svgrepo-com.svg.import | 44 ++++++++++++++++++ cc.txt | 1 + level.gd | 6 +++ pickup/bonus_time.tscn | 46 +++++++++++++++++++ player.gd | 3 ++ 6 files changed, 103 insertions(+) create mode 100644 assets/Images/time-add-svgrepo-com.svg create mode 100644 assets/Images/time-add-svgrepo-com.svg.import create mode 100644 pickup/bonus_time.tscn diff --git a/assets/Images/time-add-svgrepo-com.svg b/assets/Images/time-add-svgrepo-com.svg new file mode 100644 index 0000000..45a3709 --- /dev/null +++ b/assets/Images/time-add-svgrepo-com.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62f0af01fecc91c2e28f5490499243add7532fd6a6ff9f29643ea54da6b5bd28 +size 563 diff --git a/assets/Images/time-add-svgrepo-com.svg.import b/assets/Images/time-add-svgrepo-com.svg.import new file mode 100644 index 0000000..42ed14e --- /dev/null +++ b/assets/Images/time-add-svgrepo-com.svg.import @@ -0,0 +1,44 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://jc723dycmkud" +path.s3tc="res://.godot/imported/time-add-svgrepo-com.svg-74e89ddd2f8c60e8e7715f5bb5a2c57b.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://assets/Images/time-add-svgrepo-com.svg" +dest_files=["res://.godot/imported/time-add-svgrepo-com.svg-74e89ddd2f8c60e8e7715f5bb5a2c57b.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/cc.txt b/cc.txt index 75df320..97e4613 100644 --- a/cc.txt +++ b/cc.txt @@ -1,2 +1,3 @@ Rails by dook [CC-BY] (https://creativecommons.org/licenses/by/3.0/) via Poly Pizza (https://poly.pizza/m/5JTOJuMHJw) Jim the Linux Penguin by Rebekah Yoder is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. +Drink Tea SVG Vector by Zlatko Najdenovski is licensed under a Creative COmmons Attribution International License. diff --git a/level.gd b/level.gd index 74bfe41..6a28a11 100644 --- a/level.gd +++ b/level.gd @@ -13,6 +13,7 @@ var pedestrian_scn = preload("res://pedestrian.tscn") var chunk_scn = preload("res://chunk.tscn") var station_scn = preload("res://station.tscn") var spawn_scn = preload("res://spawn.tscn") +var bonus_time_scn = preload("res://pickup/bonus_time.tscn") func dir_to_vector(dir: int) -> Vector2i: assert(dir >= 0 and dir <= 3) @@ -49,6 +50,11 @@ func initialize_world() -> void: $Player.position.x = spawn.x * Global.chunk_size $Player.position.z = spawn.y * Global.chunk_size + var bt = bonus_time_scn.instantiate() + bt.position.x = spawn.x * Global.chunk_size + 50 + bt.position.z = spawn.y * Global.chunk_size + 50 + add_child(bt) + # ---- Generate the paths ---- var paths: Array = [] for path_idx in range(path_count): diff --git a/pickup/bonus_time.tscn b/pickup/bonus_time.tscn new file mode 100644 index 0000000..0510518 --- /dev/null +++ b/pickup/bonus_time.tscn @@ -0,0 +1,46 @@ +[gd_scene format=3 uid="uid://dhlgypwxsdvi1"] + +[ext_resource type="Texture2D" uid="uid://jc723dycmkud" path="res://assets/Images/time-add-svgrepo-com.svg" id="1_rqnpm"] + +[sub_resource type="GDScript" id="GDScript_rqnpm"] +script/source = "extends Node3D + +func _on_area_entered(area: Area3D) -> void: + if area.name != \"Hurtbox\": + return + + var parent = area.get_parent() + + if parent.name == \"Player\": + var timer: Timer = parent.get_node(\"TimeLimit\") + timer.start(timer.time_left + parent.bonus_time_amount) + queue_free() + +" + +[sub_resource type="PlaneMesh" id="PlaneMesh_b5fwd"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cumbd"] +transparency = 1 +albedo_texture = ExtResource("1_rqnpm") + +[sub_resource type="CylinderShape3D" id="CylinderShape3D_rqnpm"] +height = 2.5239258 +radius = 2.3896484 + +[node name="BonusTime" type="Node3D" unique_id=2030295907] +script = SubResource("GDScript_rqnpm") + +[node name="Cartell" type="MeshInstance3D" parent="." unique_id=1340947697] +transform = Transform3D(2.0101042, 0, 0, 0, 2.0101042, 0, 0, 0, 2.0101042, 0, 0.28158534, 0) +mesh = SubResource("PlaneMesh_b5fwd") +surface_material_override/0 = SubResource("StandardMaterial3D_cumbd") + +[node name="BonusTimeArea" type="Area3D" parent="." unique_id=2068048094] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.28158534, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="BonusTimeArea" unique_id=62431841] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.2619629, 0) +shape = SubResource("CylinderShape3D_rqnpm") + +[connection signal="area_entered" from="BonusTimeArea" to="." method="_on_area_entered"] diff --git a/player.gd b/player.gd index ce6edaf..eb7cf0f 100644 --- a/player.gd +++ b/player.gd @@ -21,6 +21,9 @@ var pedestrian_area_count = 0 var max_stamina: float = BASE_STAMINA var stamina: float = max_stamina +const BASE_BONUS_TIME_AMOUNT = 30 +var bonus_time_amount: float = BASE_BONUS_TIME_AMOUNT # seconds + var stage_counter: int = 0 var is_active: bool = true