From 101dd3d5fc36c0a2171bf5fe70994eb3479ed4fa Mon Sep 17 00:00:00 2001 From: LaptopmanMann Date: Tue, 16 Sep 2025 16:49:17 +0200 Subject: [PATCH] added picture spots and basic follow path --- Florian/Entity/Animals/cat.tscn | 20 +++------- Florian/{ => Player}/PlayerRigidbody.tscn | 7 ++-- Florian/Player/cool_camera.gd | 39 ++++++++++++++++++++ Florian/{ => Player}/cool_camera.gd.uid | 0 Florian/{ => Player}/cool_camera.tscn | 2 +- Florian/{ => Player}/playerRigidbody.gd | 0 Florian/{ => Player}/playerRigidbody.gd.uid | 0 Florian/PointsLogic/PictureSpot.tscn | 6 +++ Florian/PointsLogic/picture_spot.gd | 15 ++++++++ Florian/PointsLogic/picture_spot.gd.uid | 1 + Florian/{ => PointsLogic}/point_thing.gd | 5 ++- Florian/{ => PointsLogic}/point_thing.gd.uid | 0 Florian/{ => PointsLogic}/point_thing.tscn | 2 +- Florian/cool_camera.gd | 14 ------- icon.svg.import | 13 ++++--- npc_path_follower.gd | 17 +++++++++ npc_path_follower.gd.uid | 1 + npc_path_follower.tscn | 6 +++ pathfinding_array.gd | 3 ++ picture_takeables_array.gd | 5 +++ 20 files changed, 115 insertions(+), 41 deletions(-) rename Florian/{ => Player}/PlayerRigidbody.tscn (92%) create mode 100644 Florian/Player/cool_camera.gd rename Florian/{ => Player}/cool_camera.gd.uid (100%) rename Florian/{ => Player}/cool_camera.tscn (92%) rename Florian/{ => Player}/playerRigidbody.gd (100%) rename Florian/{ => Player}/playerRigidbody.gd.uid (100%) create mode 100644 Florian/PointsLogic/PictureSpot.tscn create mode 100644 Florian/PointsLogic/picture_spot.gd create mode 100644 Florian/PointsLogic/picture_spot.gd.uid rename Florian/{ => PointsLogic}/point_thing.gd (82%) rename Florian/{ => PointsLogic}/point_thing.gd.uid (100%) rename Florian/{ => PointsLogic}/point_thing.tscn (93%) delete mode 100644 Florian/cool_camera.gd create mode 100644 npc_path_follower.gd create mode 100644 npc_path_follower.gd.uid create mode 100644 npc_path_follower.tscn diff --git a/Florian/Entity/Animals/cat.tscn b/Florian/Entity/Animals/cat.tscn index 11406b8..57492da 100644 --- a/Florian/Entity/Animals/cat.tscn +++ b/Florian/Entity/Animals/cat.tscn @@ -1,18 +1,10 @@ -[gd_scene load_steps=4 format=3 uid="uid://xa3ee14whqj6"] +[gd_scene load_steps=3 format=3 uid="uid://ctj6v4t55qr61"] -[ext_resource type="PackedScene" uid="uid://c8gnb0kut2n5h" path="res://Florian/point_thing.tscn" id="1_ths60"] -[ext_resource type="Texture2D" uid="uid://b3y733ngio1nx" path="res://Florian/Sprites/cat.jpg" id="2_f6meo"] +[ext_resource type="Script" uid="uid://bgolfgrq66diw" path="res://npc_path_follower.gd" id="1_f6meo"] +[ext_resource type="PackedScene" uid="uid://c8gnb0kut2n5h" path="res://Florian/PointsLogic/point_thing.tscn" id="1_ths60"] -[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_vea6b"] - -[node name="Cat" type="RigidBody3D"] +[node name="Cat" type="PathFollow3D"] +script = ExtResource("1_f6meo") +metadata/_custom_type_script = "uid://bgolfgrq66diw" [node name="PointThing" parent="." instance=ExtResource("1_ths60")] - -[node name="Sprite3D" type="Sprite3D" parent="."] -texture = ExtResource("2_f6meo") - -[node name="CollisionShape3D" type="CollisionShape3D" parent="."] -shape = SubResource("CapsuleShape3D_vea6b") - -[node name="PathFollow3D" type="PathFollow3D" parent="."] diff --git a/Florian/PlayerRigidbody.tscn b/Florian/Player/PlayerRigidbody.tscn similarity index 92% rename from Florian/PlayerRigidbody.tscn rename to Florian/Player/PlayerRigidbody.tscn index 12c2d63..00f09ec 100644 --- a/Florian/PlayerRigidbody.tscn +++ b/Florian/Player/PlayerRigidbody.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=6 format=3 uid="uid://crrco762ow56c"] -[ext_resource type="Script" uid="uid://c35h32dniya44" path="res://Florian/playerRigidbody.gd" id="1_7u3v3"] -[ext_resource type="PackedScene" uid="uid://4hac7s0wvoye" path="res://Florian/cool_camera.tscn" id="2_leq5j"] +[ext_resource type="Script" uid="uid://c35h32dniya44" path="res://Florian/Player/playerRigidbody.gd" id="1_7u3v3"] +[ext_resource type="PackedScene" uid="uid://4hac7s0wvoye" path="res://Florian/Player/cool_camera.tscn" id="2_leq5j"] [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_jbuyh"] friction = 0.0 @@ -36,7 +36,8 @@ collide_with_areas = true collide_with_bodies = false debug_shape_thickness = 1 -[node name="CoolCamera" parent="BoundingBox/RotationHelper" instance=ExtResource("2_leq5j")] +[node name="CoolCamera" parent="BoundingBox/RotationHelper" node_paths=PackedStringArray("player") instance=ExtResource("2_leq5j")] +player = NodePath("../../..") [node name="ThirdPerson" type="Node3D" parent="BoundingBox"] transform = Transform3D(1, 0, 0, 0, 0.965926, 0.258819, 0, -0.258819, 0.965926, 0, 1.94907, 3) diff --git a/Florian/Player/cool_camera.gd b/Florian/Player/cool_camera.gd new file mode 100644 index 0000000..e5d383f --- /dev/null +++ b/Florian/Player/cool_camera.gd @@ -0,0 +1,39 @@ +extends Node3D +@onready var label: Label = $Control/Label +@export var player : PlayerRB = null + +func _input(event: InputEvent) -> void: + if event.is_action_pressed("take_picture"): + _take_picture() + +func _take_picture(): + _calculate_points() + pass + +var points_string = "" +var total_points = 0 +var total_points_multipliers = 1 + +func _calculate_points(): + points_string = "" + total_points = 0 + total_points_multipliers = 1 + print("Taking Picture!!!") + _calculate_picture_objects() + _calculate_picture_spots() + label.text = "%s\nTotal points: %d x %.2f = %.2f" % [points_string, total_points, total_points_multipliers, total_points * total_points_multipliers] + +func _calculate_picture_objects(): + for takeable in PictureTakeablesArray.picture_takables: + print("Checking takeable") + if takeable.picture_taken(): + points_string += "{name} {points}\n".format({"name" : takeable.points_name, "points": str(takeable.points_worth)}) + total_points += takeable.points_worth + total_points_multipliers *= takeable.points_multiplier + +func _calculate_picture_spots(): + for spot in PictureTakeablesArray.picture_spots: + if spot.picture_taken(player): + points_string += "{name} {points}\n".format({"name" : spot.points_name, "points": str(spot.points_worth)}) + total_points += spot.points_worth + total_points_multipliers *= spot.points_multiplier diff --git a/Florian/cool_camera.gd.uid b/Florian/Player/cool_camera.gd.uid similarity index 100% rename from Florian/cool_camera.gd.uid rename to Florian/Player/cool_camera.gd.uid diff --git a/Florian/cool_camera.tscn b/Florian/Player/cool_camera.tscn similarity index 92% rename from Florian/cool_camera.tscn rename to Florian/Player/cool_camera.tscn index 9269a8b..8dabe96 100644 --- a/Florian/cool_camera.tscn +++ b/Florian/Player/cool_camera.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://4hac7s0wvoye"] -[ext_resource type="Script" uid="uid://dff1mtnypemb4" path="res://Florian/cool_camera.gd" id="1_87r7f"] +[ext_resource type="Script" uid="uid://dff1mtnypemb4" path="res://Florian/Player/cool_camera.gd" id="1_87r7f"] [node name="CoolCamera" type="Node3D"] script = ExtResource("1_87r7f") diff --git a/Florian/playerRigidbody.gd b/Florian/Player/playerRigidbody.gd similarity index 100% rename from Florian/playerRigidbody.gd rename to Florian/Player/playerRigidbody.gd diff --git a/Florian/playerRigidbody.gd.uid b/Florian/Player/playerRigidbody.gd.uid similarity index 100% rename from Florian/playerRigidbody.gd.uid rename to Florian/Player/playerRigidbody.gd.uid diff --git a/Florian/PointsLogic/PictureSpot.tscn b/Florian/PointsLogic/PictureSpot.tscn new file mode 100644 index 0000000..cc219dd --- /dev/null +++ b/Florian/PointsLogic/PictureSpot.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://bw73kprk7ptvn"] + +[ext_resource type="Script" uid="uid://44ieb2gc6uff" path="res://Florian/PointsLogic/picture_spot.gd" id="1_r37ay"] + +[node name="PictureSpot" type="Area3D"] +script = ExtResource("1_r37ay") diff --git a/Florian/PointsLogic/picture_spot.gd b/Florian/PointsLogic/picture_spot.gd new file mode 100644 index 0000000..cb7595a --- /dev/null +++ b/Florian/PointsLogic/picture_spot.gd @@ -0,0 +1,15 @@ +class_name PictureSpot +extends Area3D + +@export var points_multiplier := 1 +@export var points_worth := 10 +@export var points_name := "Debug Points Area" + +func _ready() -> void: + PictureTakeablesArray._add_picture_spot(self) + +func picture_taken(player: PlayerRB) -> bool: + var bodies = get_overlapping_bodies() + if player in bodies: + return true + return false diff --git a/Florian/PointsLogic/picture_spot.gd.uid b/Florian/PointsLogic/picture_spot.gd.uid new file mode 100644 index 0000000..b4023d7 --- /dev/null +++ b/Florian/PointsLogic/picture_spot.gd.uid @@ -0,0 +1 @@ +uid://44ieb2gc6uff diff --git a/Florian/point_thing.gd b/Florian/PointsLogic/point_thing.gd similarity index 82% rename from Florian/point_thing.gd rename to Florian/PointsLogic/point_thing.gd index 8711a15..cf09551 100644 --- a/Florian/point_thing.gd +++ b/Florian/PointsLogic/point_thing.gd @@ -3,8 +3,9 @@ extends Node3D @onready var red_circle: Sprite3D = $RedCircle @onready var on_screen: VisibleOnScreenNotifier3D = $VisibleOnScreenNotifier3D -@export var points_worth = 10 -@export var point_id = "Debug Object" +@export var points_worth : int= 10 +@export var points_name = "Debug Object" +@export var points_multiplier : float = 1 func _ready() -> void: PictureTakeablesArray._add_point_picture(self) diff --git a/Florian/point_thing.gd.uid b/Florian/PointsLogic/point_thing.gd.uid similarity index 100% rename from Florian/point_thing.gd.uid rename to Florian/PointsLogic/point_thing.gd.uid diff --git a/Florian/point_thing.tscn b/Florian/PointsLogic/point_thing.tscn similarity index 93% rename from Florian/point_thing.tscn rename to Florian/PointsLogic/point_thing.tscn index dd5fabb..29aeb8a 100644 --- a/Florian/point_thing.tscn +++ b/Florian/PointsLogic/point_thing.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://c8gnb0kut2n5h"] -[ext_resource type="Script" uid="uid://cyw0eu5pqd3wm" path="res://Florian/point_thing.gd" id="1_hr556"] +[ext_resource type="Script" uid="uid://cyw0eu5pqd3wm" path="res://Florian/PointsLogic/point_thing.gd" id="1_hr556"] [ext_resource type="Texture2D" uid="uid://bpqf3a8f2fp7q" path="res://Florian/Sprites/red_circle.png" id="2_wfrpx"] [sub_resource type="BoxMesh" id="BoxMesh_hr556"] diff --git a/Florian/cool_camera.gd b/Florian/cool_camera.gd deleted file mode 100644 index c283d2e..0000000 --- a/Florian/cool_camera.gd +++ /dev/null @@ -1,14 +0,0 @@ -extends Node3D -@onready var label: Label = $Control/Label - -func _input(event: InputEvent) -> void: - if event.is_action_pressed("take_picture"): - print("Taking Picture!!!") - var points_string = "" - var total_points = 0 - for takeable in PictureTakeablesArray.picture_takables: - print("Checking takeable") - if takeable.picture_taken(): - points_string += "%s %d\n" % [str(takeable.point_id), int(takeable.points_worth)] - total_points += takeable.points_worth - label.text = "%s\nTotal points: %d" % [points_string, total_points] diff --git a/icon.svg.import b/icon.svg.import index 46dc779..9f87114 100644 --- a/icon.svg.import +++ b/icon.svg.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://dv401srtwuvtg" -path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://icon.svg" -dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,7 +32,7 @@ process/normal_map_invert_y=false process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 -detect_3d/compress_to=1 +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/npc_path_follower.gd b/npc_path_follower.gd new file mode 100644 index 0000000..197294a --- /dev/null +++ b/npc_path_follower.gd @@ -0,0 +1,17 @@ +class_name NPCPathFollower +extends PathFollow3D + +@export var speed = 3 +@export var path : Path3D = null + +func _ready(): + if path == null: + path = get_parent() + +func _process(delta: float): + # Move along the path + self.progress += speed * delta + + # Loop the path if we reach the end + if self.progress >= path.curve.get_baked_length(): + self.progress = 0 diff --git a/npc_path_follower.gd.uid b/npc_path_follower.gd.uid new file mode 100644 index 0000000..b25e78d --- /dev/null +++ b/npc_path_follower.gd.uid @@ -0,0 +1 @@ +uid://bgolfgrq66diw diff --git a/npc_path_follower.tscn b/npc_path_follower.tscn new file mode 100644 index 0000000..6795772 --- /dev/null +++ b/npc_path_follower.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://snif6gs2ssjr"] + +[ext_resource type="Script" uid="uid://bgolfgrq66diw" path="res://npc_path_follower.gd" id="1_ihrgw"] + +[node name="NPCPathFollower" type="PathFollow3D"] +script = ExtResource("1_ihrgw") diff --git a/pathfinding_array.gd b/pathfinding_array.gd index ff0b8d4..eb2e920 100644 --- a/pathfinding_array.gd +++ b/pathfinding_array.gd @@ -1,3 +1,6 @@ extends Node @export var path_3d_array : Array[Path3D] = [] + +func add_path(path: Path3D): + path_3d_array.append(path) diff --git a/picture_takeables_array.gd b/picture_takeables_array.gd index 845f56a..b19722a 100644 --- a/picture_takeables_array.gd +++ b/picture_takeables_array.gd @@ -1,8 +1,13 @@ extends Node var picture_takables : Array[PointPicture] = [] +var picture_spots: Array[PictureSpot] = [] func _add_point_picture(point_picture: PointPicture): print("Adding picture takeable") picture_takables.append(point_picture) print(len(picture_takables)) + +func _add_picture_spot(picture_spot: PictureSpot): + print("Adding picture Spot") + picture_spots.append(picture_spot)