Browse Source

Moving UI to the left and adding the held block

pull/13/head
Ryan Reed 1 month ago
parent
commit
57484a4576
3 changed files with 23 additions and 12 deletions
  1. +10
    -0
      scenes/player/player.gd
  2. +5
    -1
      scenes/player/player.tscn
  3. +8
    -11
      scenes/ui/quick_slots.tscn

+ 10
- 0
scenes/player/player.gd View File

@ -19,6 +19,7 @@ extends CharacterBody3D
@export var walk_speed: float = 5.0
@onready var camera: Camera3D = $Head/Camera3D
@onready var block_mesh: BlockMesh = $Head/Camera3D/BlockMesh
@onready var head: Node3D = $Head
@onready var collision_shape_standing: CollisionShape3D = $CollisionShapeStanding
@onready var collision_shape_crouching: CollisionShape3D = $CollisionShapeCrouching
@ -53,6 +54,9 @@ func _physics_process(delta: float) -> void:
func _ready() -> void:
GameSettingsManager.graphics_fov_changed.connect(_on_graphics_fov_changed)
InventoryManager.quick_slot_item_changed.connect(_on_quick_slot_item_changed)
_update_held_block_mesh(InventoryManager.quick_slot_item_id)
func _apply_gravity(delta: float) -> void:
@ -123,6 +127,12 @@ func _set_is_sprinting() -> void:
else:
is_sprinting = Input.is_action_pressed("run")
func _update_held_block_mesh(item_id: String) -> void:
block_mesh.apply_material(DBItems.data[item_id].material_texture)
func _on_graphics_fov_changed(fov: int) -> void:
camera.fov = fov
func _on_quick_slot_item_changed(item_id: String) -> void:
_update_held_block_mesh(item_id)

+ 5
- 1
scenes/player/player.tscn View File

@ -1,7 +1,8 @@
[gd_scene load_steps=7 format=3 uid="uid://beu1b4leqwgh3"]
[gd_scene load_steps=8 format=3 uid="uid://beu1b4leqwgh3"]
[ext_resource type="Script" uid="uid://daly0bs0oat3j" path="res://scenes/player/player.gd" id="1_7sql3"]
[ext_resource type="Script" uid="uid://bruuttf8j7wet" path="res://scenes/player/ray_cast_look.gd" id="2_dovo2"]
[ext_resource type="PackedScene" uid="uid://c8dch55d3txns" path="res://scenes/blocks/block_mesh.tscn" id="2_p47bc"]
[ext_resource type="PackedScene" uid="uid://baki8rbf1ti0r" path="res://save_load/components/save_data_component.tscn" id="3_lvxji"]
[ext_resource type="Resource" uid="uid://bvsurbn5xgchr" path="res://save_load/resources/node_types/player_data_resource.tres" id="4_p47bc"]
@ -33,6 +34,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8, 0)
[node name="Camera3D" type="Camera3D" parent="Head"]
[node name="BlockMesh" parent="Head/Camera3D" instance=ExtResource("2_p47bc")]
transform = Transform3D(1, 0, 0, 0, 0.965926, -0.258819, 0, 0.258819, 0.965926, 0, -0.680035, -1.7196)
[node name="RayCastLook" type="RayCast3D" parent="Head"]
target_position = Vector3(0, 0, -10)
debug_shape_custom_color = Color(0.753415, 4.77457e-05, 0.578804, 1)


+ 8
- 11
scenes/ui/quick_slots.tscn View File

@ -10,16 +10,14 @@
[ext_resource type="Texture2D" uid="uid://cpllegyqnfnrh" path="res://assets/textures/glass.png" id="8_bup65"]
[node name="QuickSlots" type="MarginContainer"]
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -20.0
offset_top = -40.0
offset_right = 20.0
grow_horizontal = 2
grow_vertical = 0
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_top = -220.0
offset_right = 80.0
offset_bottom = 220.0
grow_vertical = 2
size_flags_horizontal = 0
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
@ -31,7 +29,6 @@ highlight_theme = ExtResource("2_ps55n")
layout_mode = 2
theme_override_constants/h_separation = 8
theme_override_constants/v_separation = 8
columns = 10
[node name="Slot0" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)


Loading…
Cancel
Save