minor optimization and bit more mechanics

title says all.
still need to do the connection between the player.gd and its components
breathing sounds weird becausae for some reason it stops playing the audiostream when it shouldnt???????????????? im really confused
This commit is contained in:
Balogh Krisztián 2026-07-29 13:52:14 +02:00
parent e0759c00ed
commit eb197412dd
14 changed files with 332 additions and 103 deletions

View file

@ -27,12 +27,12 @@
"state": {
"type": "markdown",
"state": {
"file": "game mechanics/Clipboard.md",
"file": "game mechanics/The upgrain shop.md",
"mode": "source",
"source": false
},
"icon": "lucide-file",
"title": "Clipboard"
"title": "The upgrain shop"
}
}
],
@ -211,6 +211,12 @@
},
"active": "cc30646b046d3148",
"lastOpenFiles": [
"game mechanics/The safe zone computer.md",
"game mechanics/The upgrain shop.md",
"thing groups/Player.md",
"game mechanics/Run.md",
"game mechanics/XP earning.md",
"game mechanics/Clipboard.md",
"game mechanics/Day cycle.md",
"game mechanics/Smartwatch.md",
"game mechanics/THE NARRATOR.md",
@ -225,10 +231,7 @@
"TLDR/MVP.md",
"TLDR",
"concepts and lore/Lore.md",
"thing groups/Player.md",
"game mechanics/Clipboard.md",
"game mechanics/The pawn shop.md",
"game mechanics/The safe zone computer.md",
"game mechanics/The safe zone.md",
"game mechanics/The PSA system.md",
"thing groups/Equippable.md",
@ -237,7 +240,6 @@
"thing groups/Entity.md",
"Pasted image 20260728145533.png",
"game mechanics",
"concepts and lore/Multiplayer (bredren).md",
"thing groups",
"concepts and lore",
"entities"

View file

@ -0,0 +1,8 @@
Each session is tracked as a run. Of course.
A run has different statistics after done:
- Total time
- Entity related stats
- How many [[Serbreads]] did you shoo away
- What did you get killed by
- How many times did you die

View file

@ -6,6 +6,7 @@ It is an old CRT monitor placed on top of an old pc case.
# The desktop
the desktop has 2 major apps:
- [[The pawn shop]]
- [[The upgrain shop]]
- The quota machine
## the quota machine

View file

@ -0,0 +1,23 @@
The upgrade and usables shop
this is where you can purchase upgrades and usables with your hard earned cash.
upgradables:
- charisma
- increases positive bidding chances for the player
- inventory size
- increases inventory size to a max of 5
- backpack
- lets you have extra inventory, but you can only access it if you slow down
- upgradable size
- exosuit
- increases carrying capability
- increases grabbing ability
- slows down stamina loss
usables:
- extra life
- brAID
- energy drink
-
-

View file

@ -0,0 +1,18 @@
You can earn XP from
- selling a thing instantly
- +10
- selling a thing through an auction
- $+10 \cdot \frac{\text{sell\_price}}{\text{item\_value}}$
- putting bread in the bread storage
- +5
- completing a quota
- $+ 100 \cdot \frac{\text{correct delivery}}{\text{{total delivery}}}$
- putting bread on a tray
- +5
- scaring [[Serbreads]]
- +2
- finishing a day
- $$+1000 \cdot \frac{\Sigma \text{correct delivery}}{\Sigma\text{{total delivery}}}$$
- nighttime earnings are **doubled** to encourage nighttime exploration
- add extra if you want to

View file

@ -42,3 +42,12 @@ Properties:
- influences the audio and what can and cant the player do (cannot run and walk at the same time)
- grabbing force
- if increased, you can move more bread on a tray or hold and drag heavier objects easier
- experience
- tracks how much XP the player has
- XP can be earned through different meant
- [[XP earning]]
- life
- a player starts with 3 lives
- they lose a life once they get jumped
- they respawn in the safe zone
- lives can be bought as upgrades

View file

@ -0,0 +1,119 @@
[gd_scene format=3 uid="uid://chykk2a3opu0d"]
[ext_resource type="PackedScene" uid="uid://kqq30y24c6kd" path="res://scenes/player/player.tscn" id="1_s8b7j"]
[ext_resource type="AudioStream" uid="uid://db0yck6trekrs" path="res://assets/sounds/ambiance/pc-fan-paulstretched.mp3" id="2_phkhq"]
[ext_resource type="Script" uid="uid://y8x4svl5kej2" path="res://addons/spatial_audio_3d/spatial_audio_3d.gd" id="4_yb1w3"]
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_g4v7s"]
[sub_resource type="PlaneMesh" id="PlaneMesh_g4v7s"]
[sub_resource type="BoxShape3D" id="BoxShape3D_g4v7s"]
[sub_resource type="BoxMesh" id="BoxMesh_g4v7s"]
[sub_resource type="BoxShape3D" id="BoxShape3D_yf5fn"]
[sub_resource type="BoxMesh" id="BoxMesh_yf5fn"]
[sub_resource type="BoxShape3D" id="BoxShape3D_57qmd"]
size = Vector3(20.447998, 11.038544, 1)
[node name="DevMap" type="Node3D" unique_id=471389571]
[node name="Plane" type="StaticBody3D" parent="." unique_id=1943923809]
collision_layer = 17
collision_mask = 17
[node name="CollisionShape3D" type="CollisionShape3D" parent="Plane" unique_id=2072732464]
shape = SubResource("WorldBoundaryShape3D_g4v7s")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Plane" unique_id=810695750]
transform = Transform3D(9.905844, 0, 0, 0, 1, 0, 0, 0, 9.900972, 0, 0, 0)
mesh = SubResource("PlaneMesh_g4v7s")
[node name="TestObject" type="RigidBody3D" parent="." unique_id=1889494210]
transform = Transform3D(0.9224609, 0.38609046, 0, -0.38609046, 0.9224609, 0, 0, 0, 1, 1.1603341, 0.9219521, -1.1464608)
collision_layer = 17
collision_mask = 17
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestObject" unique_id=507616212]
shape = SubResource("BoxShape3D_g4v7s")
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestObject" unique_id=1356474788]
mesh = SubResource("BoxMesh_g4v7s")
[node name="TestObjectGrabbable" type="RigidBody3D" parent="." unique_id=162241126 groups=["grabbable"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.776662, -3.2358055)
collision_layer = 17
collision_mask = 17
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestObjectGrabbable" unique_id=2049402651]
shape = SubResource("BoxShape3D_yf5fn")
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestObjectGrabbable" unique_id=1899834557]
mesh = SubResource("BoxMesh_yf5fn")
[node name="TestObjectEquippable" type="RigidBody3D" parent="." unique_id=1086000939]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.874709, 1.0290127, -3.1515453)
collision_layer = 17
collision_mask = 17
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestObjectEquippable" unique_id=740741417]
shape = SubResource("BoxShape3D_yf5fn")
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestObjectEquippable" unique_id=1967579265]
mesh = SubResource("BoxMesh_yf5fn")
[node name="Player" parent="." unique_id=423228143 instance=ExtResource("1_s8b7j")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.77974355, 1.137004)
UI_MOVEMENT_SENSITIVITY = 1.0
[node name="OmniLight3D" type="OmniLight3D" parent="." unique_id=1317582521]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.2949467, -3.755646)
[node name="SpatialAudio3D" type="AudioStreamPlayer3D" parent="." unique_id=351573539]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15.887349, 4.01754, -1.2293816)
stream = ExtResource("2_phkhq")
autoplay = true
max_distance = 1927.53
script = ExtResource("4_yb1w3")
occlusion_fadetime = 0.0
bass_proximity = 0
max_raycast_distance = 30
roomsize_multiplicator = 2.0
prox_reduction = 16.0
debug = true
metadata/_custom_type_script = "uid://y8x4svl5kej2"
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=1656249102]
transform = Transform3D(1, 0, -1.7484555e-07, 0, 1, 0, 1.7484555e-07, 0, 1, 10.053528, 0, 9.284716)
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" unique_id=1173755237]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.723999, 5.019272, 0)
shape = SubResource("BoxShape3D_57qmd")
[node name="StaticBody3D2" type="StaticBody3D" parent="." unique_id=23077148]
transform = Transform3D(-4.371138e-08, 0, -1, 0, 1, 0, 1, 0, -4.371138e-08, 10.053528, 0, 8.284716)
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D2" unique_id=1774765140]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.723999, 5.019272, 0)
shape = SubResource("BoxShape3D_57qmd")
[node name="StaticBody3D3" type="StaticBody3D" parent="." unique_id=2124365943]
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, -8.946472, 0, -10.715284)
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D3" unique_id=652377662]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.723999, 5.019272, 0)
shape = SubResource("BoxShape3D_57qmd")
[node name="StaticBody3D4" type="StaticBody3D" parent="." unique_id=942386107]
transform = Transform3D(1.3113416e-07, 0, 1, 0, 1, 0, -1, 0, 1.3113416e-07, -8.946472, 0, -10.715284)
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D4" unique_id=1055230632]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.723999, 5.019272, 0)
shape = SubResource("BoxShape3D_57qmd")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D4" unique_id=967910627]
transform = Transform3D(1, 1.3113416e-07, -1.3113416e-07, -1.3113416e-07, -4.371139e-08, -1, -1.3113416e-07, 1, -4.371137e-08, -9.723998, 10.984082, 10)
shape = SubResource("BoxShape3D_57qmd")

View file

@ -55,22 +55,3 @@ class_name PlayerCharacter
@onready var input_controller: Node = %InputController
@onready var player_state: Node = %PlayerState
@onready var player_properties: Node = %PlayerProperties
func _process(_delta: float) -> void:
if Input.is_action_just_pressed("next_item"):
ui_handler.next_item()
if Input.is_action_just_pressed("prev_item"):
ui_handler.prev_item()
if Input.is_action_just_pressed("select_item_1"):
ui_handler.select_item(0)
if Input.is_action_just_pressed("select_item_2"):
ui_handler.select_item(1)
if Input.is_action_just_pressed("select_item_3"):
ui_handler.select_item(2)
func _ready() -> void:
ui_handler.select_item(0)

View file

@ -3,20 +3,64 @@ extends Node
@export_category("Inventory")
@export var INVENTORY_MAX = 3 ##max number of items that can be in the player's inventory
@export var INVENTORY_ITEMS: Array = [] ##the items in the player's inventory
@onready var ui_handler: Node = %UiHandler
var stamina: float = 100.0
var selected_item: int = 0
var stamina_recharge: bool = true
var inventory: Array[PackedScene] = []
signal selected_item_changed
func next_item():
if selected_item + 1 > INVENTORY_MAX - 1:
selected_item = 0
else:
selected_item += 1
select_item(selected_item)
func prev_item():
if selected_item - 1 < 0:
selected_item = INVENTORY_MAX - 1
else:
selected_item -= 1
select_item(selected_item)
func select_item(index:int):
selected_item = index
ui_handler.update_inventory_ui()
emit_signal("selected_item_changed")
func get_selected_item() -> PackedScene:
return inventory[selected_item]
func stamina_recharge_off():
stamina_recharge = false
func select_item(index:int):
selected_item = index
func _on_stamina_reset_timeout() -> void:
stamina_recharge = true
func _ready() -> void:
select_item(0)
func _process(delta: float) -> void:
if stamina_recharge:
stamina = move_toward(stamina, 100, .5)
func _on_stamina_reset_timeout() -> void:
stamina_recharge = true
if Input.is_action_just_pressed("next_item"):
next_item()
if Input.is_action_just_pressed("prev_item"):
prev_item()
func _input(event: InputEvent) -> void:
if Input.is_action_just_pressed("select_item_1"):
select_item(0)
if Input.is_action_just_pressed("select_item_2"):
select_item(1)
if Input.is_action_just_pressed("select_item_3"):
select_item(2)

View file

@ -13,6 +13,7 @@ offset_transform_enabled = true
script = ExtResource("1_32d7b")
[node name="StaminaBar" type="ProgressBar" parent="." unique_id=1844702202]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.05
@ -43,6 +44,7 @@ layout_mode = 2
size_flags_horizontal = 3
[node name="InvSlot1" type="ColorRect" parent="InventoryPanels/Inv1" unique_id=497482827]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
size_flags_horizontal = 3
@ -53,6 +55,7 @@ layout_mode = 2
size_flags_horizontal = 3
[node name="InvSlot2" type="ColorRect" parent="InventoryPanels/Inv2" unique_id=340220249]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
size_flags_horizontal = 3
@ -63,6 +66,7 @@ layout_mode = 2
size_flags_horizontal = 3
[node name="InvSlot3" type="ColorRect" parent="InventoryPanels/Inv3" unique_id=398133665]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
size_flags_horizontal = 3

View file

@ -1,31 +1,32 @@
extends Control
@onready var stamina_bar = $StaminaBar
@onready var inventory_slots_panels: Array = [$InventoryPanels/Inv1/InvSlot1, $InventoryPanels/Inv2/InvSlot2, $InventoryPanels/Inv3/InvSlot3]
@onready var stamina_bar: ProgressBar = %StaminaBar
@onready var inventory_slots_panels: Array = [%InvSlot1, %InvSlot2, %InvSlot3]
var inventory: Array = [null,null,null]
var stamina: float = 100
var selected_item: int = 0
const SELECTED_COLOR = 0xcfcfcf78
const UNSELECTED_COLOR = 0x3d3d3d78
func set_stamina_bar(value:float):
stamina = value
func get_selected_item() -> PackedScene:
return inventory[selected_item]
func select_item(index: int):
inventory_slots_panels[selected_item].color = Color.hex(UNSELECTED_COLOR)
selected_item = index
inventory_slots_panels[index].color = Color.hex(SELECTED_COLOR)
func put_item(index: int, item: PackedScene):
inventory[index] = item
func _process(delta: float) -> void:
stamina_bar.value = lerpf(stamina_bar.value, stamina, delta * 5)
func set_ui_scale(scale:float) -> void:
pass
#var inventory: Array = [null,null,null]
#
#var stamina: float = 100
#var selected_item: int = 0
#
#const SELECTED_COLOR = 0xcfcfcf78
#const UNSELECTED_COLOR = 0x3d3d3d78
#
#func set_stamina_bar(value:float):
#stamina = value
#
#func get_selected_item() -> PackedScene:
#return inventory[selected_item]
#
#func select_item(index: int):
#inventory_slots_panels[selected_item].color = Color.hex(UNSELECTED_COLOR)
#selected_item = index
#inventory_slots_panels[index].color = Color.hex(SELECTED_COLOR)
#
#func put_item(index: int, item: PackedScene):
#inventory[index] = item
#
#func _process(delta: float) -> void:
#stamina_bar.value = lerpf(stamina_bar.value, stamina, delta * 5)
#
#func set_ui_scale(scale:float) -> void:
#pass

View file

@ -20,22 +20,34 @@ extends Node
@onready var ui: Control = %PlayerUi
@onready var player_properties: Node = %PlayerProperties
@onready var ui_base_position = ui.position
@onready var ui_handler: Node = %UiHandler
var t_bob: float = 0.0
var last_bob_y: float = 0.0
var t_breath: float = 0.0
var last_breath_y: float = 0.0
var _camera_original_position: Vector3 = Vector3(0,.75,0)
var _mouse_motion: Vector2 = Vector2.ZERO
var _mouse_motion_delta: Vector2 = Vector2.ZERO
var _last_camera_global_position: Vector3 = Vector3.ZERO
var _breathing: bool = true
func _ready() -> void:
_last_camera_global_position = camera.global_position
func _process(delta: float) -> void:
if player.is_on_floor():
_breathing = true
else:
_breathing = false
camera_breathing(delta)
func do(delta):
ui.offset_transform_scale *= UI_SCALE
ui_movement_handling(delta)
ui.set_stamina_bar(player_properties.stamina)
ui_handler.set_stamina_bar(player_properties.stamina)
var horizontal_speed = Vector3(player.velocity.x, player.velocity.y, player.velocity.z).length()
var current_sin_pos = sin(t_bob * CAMERA_BOB_FREQUENCY)
@ -52,22 +64,6 @@ func do(delta):
camera_bobbing(t_bob)
#idle breathing
elif player.is_on_floor() and horizontal_speed < 0.05:
t_bob += delta * (100 / (40 + player_properties.stamina))
camera_breathing(t_bob)
if last_bob_y <= -.60 and current_sin_pos > -.60:
sound_controller.play_breath_sound(true)
if last_bob_y >= .60 and current_sin_pos < .60:
sound_controller.play_breath_sound(false)
last_bob_y = current_sin_pos
else:
camera.rotation.z = lerpf(camera.rotation.z,0, delta * 0.004)
camera.transform.origin.y = lerpf(camera.transform.origin.y, _camera_original_position.y, delta * 5.0)
@ -105,5 +101,18 @@ func camera_bobbing(time: float):
camera.rotation.z += sin(time * CAMERA_BOB_FREQUENCY * .5) * CAMERA_SIDEWAYS_BOB_AMPLITUDE
func camera_breathing(time: float):
if _breathing:
t_breath += time * (100 / (40 + player_properties.stamina))
var current_sin_pos = sin(t_breath * CAMERA_BOB_FREQUENCY)
if last_breath_y <= -.60 and current_sin_pos > -.60:
sound_controller.play_breath_sound(true)
if last_breath_y >= .60 and current_sin_pos < .60:
sound_controller.play_breath_sound(false)
last_breath_y = current_sin_pos
camera.transform.origin.y = sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE + .75
camera.rotation.x += sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_SIDEWAYS_BOB_AMPLITUDE

View file

@ -65,8 +65,10 @@ func _ready() -> void:
var is_right_leg := func () -> SpatialAudio3D:
if _current_leg_is_right:
_current_leg_is_right = !_current_leg_is_right
return right_foot
else:
_current_leg_is_right = !_current_leg_is_right
return left_foot
##only use for sparse effects
@ -92,6 +94,7 @@ func create_spatial_audio_sphere(pos:Vector3, audio:AudioStream, pitch:float = 1
spatial_audio.queue_free()
func play_stream_on_player(player:SpatialAudio3D, audio:AudioStream, pitch: float = randf_range(.8, 1.2)):
if player.finished:
player.process_mode = Node.PROCESS_MODE_INHERIT
player.do_set_stream(audio)
player.pitch_scale = pitch
@ -101,7 +104,6 @@ func play_stream_on_player(player:SpatialAudio3D, audio:AudioStream, pitch: floa
func play_breath_sound(breathe_in:bool = true):
var play_sound
if breathe_in:
play_sound = _current_breath_in_sound
while play_sound == _current_breath_in_sound:
@ -152,7 +154,7 @@ func play_jump_sound(start:bool = true):
var sound_to_play_foot: AudioStream = null
var sound_to_play_breath: AudioStream = null
match player.is_on_floor():
match start:
true:
while sound_to_play_foot == _current_jump_start_sound:
sound_to_play_foot = JUMP_STARTING_SOUNDS.pick_random()
@ -187,4 +189,3 @@ func play_footstep_sound():
_current_footstep_sound = sound_to_play
play_stream_on_player(is_right_leg.call(), sound_to_play)
_current_leg_is_right = !_current_leg_is_right

View file

@ -17,6 +17,9 @@ extends Node
@onready var cursor: TextureRect = %Cursor
@onready var player_camera: Camera3D = %PlayerCamera
const SELECTED_COLOR = 0xcfcfcf78
const UNSELECTED_COLOR = 0x3d3d3d78
var grabbable_panel = null
var grabbable_panel_body = null
@ -32,7 +35,15 @@ func _on_grabbable_finder_body_exited(body: Node3D) -> void:
grabbable_panel = null
grabbable_panel_body = null
func update_inventory_ui():
set_selected_item(player_properties.selected_item)
func _ready() -> void:
player_properties.selected_item_changed.connect(update_inventory_ui)
update_inventory_ui()
func _process(delta: float) -> void:
ui.stamina_bar.value = lerpf(ui.stamina_bar.value, player_properties.stamina, delta * 5)
if grabbable_panel != null:
var target_position = cursor.position - player_camera.unproject_position(grabbable_panel_body.global_position)
grabbable_panel.position = grabbable_panel.position.lerp(-target_position / 2, delta * 50)
@ -53,20 +64,18 @@ func toggle_menu():
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
player_state.in_menu = false
func next_item():
if player_properties.selected_item + 1 > player_properties.INVENTORY_MAX - 1:
player_properties.selected_item = 0
else:
player_properties.selected_item += 1
ui.select_item(player_properties.selected_item)
func set_stamina_bar(value:float):
ui.stamina_bar.value = value
func prev_item():
if player_properties.selected_item - 1 < 0:
player_properties.selected_item = player_properties.INVENTORY_MAX - 1
func set_selected_item(index: int):
for i in len(ui.inventory_slots_panels):
if i == player_properties.selected_item:
ui.inventory_slots_panels[i].color = Color.hex(SELECTED_COLOR)
else:
player_properties.selected_item -= 1
ui.select_item(player_properties.selected_item)
ui.inventory_slots_panels[i].color = Color.hex(UNSELECTED_COLOR)
func select_item(index: int):
player_properties.select_item(index)
ui.select_item(index)
func put_item(index: int, item: PackedScene):
player_properties.inventory[index] = item
func set_ui_scale(scale:float) -> void:
pass