From 1d6937ee9fe0220e57d018344f8626783810e919 Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Fri, 21 Mar 2025 21:49:17 -0400 Subject: [PATCH] Adding grass block --- assets/materials/grass.tres | 9 ++++++++ autoloads/db_items.gd | 3 ++- resources/blocks/005_grass.tres | 14 ++++++++++++ scenes/ui/quick_slots.gd | 2 +- scenes/ui/quick_slots.tscn | 38 ++++++++++++++++++++++++++------- scenes/world/world.gd | 2 +- 6 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 assets/materials/grass.tres create mode 100644 resources/blocks/005_grass.tres diff --git a/assets/materials/grass.tres b/assets/materials/grass.tres new file mode 100644 index 0000000..22c9ede --- /dev/null +++ b/assets/materials/grass.tres @@ -0,0 +1,9 @@ +[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://b4wrf3quiaa1b"] + +[ext_resource type="Texture2D" uid="uid://dsvk3faenewrl" path="res://assets/textures/grass-block.png" id="1_prref"] + +[resource] +albedo_texture = ExtResource("1_prref") +metallic_specular = 0.0 +roughness = 0.0 +texture_filter = 0 diff --git a/autoloads/db_items.gd b/autoloads/db_items.gd index 8f224bf..9149021 100644 --- a/autoloads/db_items.gd +++ b/autoloads/db_items.gd @@ -1,9 +1,10 @@ extends Node -@onready var data: Dictionary = { +@onready var data: Dictionary[String, Resource] = { "001": preload("res://resources/blocks/001_dirt.tres"), "002": preload("res://resources/blocks/002_stone.tres"), "003": preload("res://resources/blocks/003_wood.tres"), "004": preload("res://resources/blocks/004_leaves.tres"), + "005": preload("res://resources/blocks/005_grass.tres"), } diff --git a/resources/blocks/005_grass.tres b/resources/blocks/005_grass.tres new file mode 100644 index 0000000..3be7b92 --- /dev/null +++ b/resources/blocks/005_grass.tres @@ -0,0 +1,14 @@ +[gd_resource type="Resource" script_class="BlockResource" load_steps=3 format=3 uid="uid://b50yyok6ddux4"] + +[ext_resource type="Material" uid="uid://b4wrf3quiaa1b" path="res://assets/materials/grass.tres" id="1_n4fyn"] +[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://resources/block_resource.gd" id="2_0urks"] + +[resource] +script = ExtResource("2_0urks") +material_texture = ExtResource("1_n4fyn") +id = "005" +name = "Grass" +amount = 0 +description = "Block of grass and dirt" +item_texture = "uid://li36txj7oweq" +metadata/_custom_type_script = "uid://dwrmy4mx0mw18" diff --git a/scenes/ui/quick_slots.gd b/scenes/ui/quick_slots.gd index 693b9b5..bc82775 100644 --- a/scenes/ui/quick_slots.gd +++ b/scenes/ui/quick_slots.gd @@ -2,7 +2,7 @@ class_name QuickSlots extends Node -var _items: Array[String] = ["001", "002", "003", "004"] +var _items: Array[String] = ["001", "005", "002", "003", "004"] var _selected_item: int = 0 diff --git a/scenes/ui/quick_slots.tscn b/scenes/ui/quick_slots.tscn index 1d1ab07..57977c5 100644 --- a/scenes/ui/quick_slots.tscn +++ b/scenes/ui/quick_slots.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=6 format=3 uid="uid://cbiygbgpfk220"] +[gd_scene load_steps=7 format=3 uid="uid://cbiygbgpfk220"] [ext_resource type="Script" uid="uid://bcq6vexsmyeol" path="res://scenes/ui/quick_slots.gd" id="1_cqw2g"] [ext_resource type="Texture2D" uid="uid://li36txj7oweq" path="res://assets/textures/dirt.png" id="2_kotkb"] [ext_resource type="Texture2D" uid="uid://ct1iawpfkdf5l" path="res://assets/textures/stone.png" id="3_cqw2g"] +[ext_resource type="Texture2D" uid="uid://bgo4mb3atmbot" path="res://assets/textures/grass.png" id="3_yyyxx"] [ext_resource type="Texture2D" uid="uid://0mw651622h01" path="res://assets/textures/wood.png" id="4_yyyxx"] [ext_resource type="Texture2D" uid="uid://goygbpyqhych" path="res://assets/textures/leaves.png" id="5_ps55n"] @@ -27,7 +28,7 @@ script = ExtResource("1_cqw2g") layout_mode = 2 theme_override_constants/h_separation = 8 theme_override_constants/v_separation = 8 -columns = 4 +columns = 5 [node name="Slot0" type="Panel" parent="GridContainer"] custom_minimum_size = Vector2(64, 64) @@ -69,13 +70,34 @@ theme_override_constants/margin_bottom = 4 [node name="TextureRect" type="TextureRect" parent="GridContainer/Slot1/MarginContainer"] texture_filter = 1 layout_mode = 2 +texture = ExtResource("3_yyyxx") + +[node name="Slot3" type="Panel" parent="GridContainer"] +custom_minimum_size = Vector2(64, 64) +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot3"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 4 +theme_override_constants/margin_top = 4 +theme_override_constants/margin_right = 4 +theme_override_constants/margin_bottom = 4 + +[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot3/MarginContainer"] +texture_filter = 1 +layout_mode = 2 texture = ExtResource("3_cqw2g") -[node name="Slot2" type="Panel" parent="GridContainer"] +[node name="Slot4" type="Panel" parent="GridContainer"] custom_minimum_size = Vector2(64, 64) layout_mode = 2 -[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot2"] +[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot4"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -87,16 +109,16 @@ theme_override_constants/margin_top = 4 theme_override_constants/margin_right = 4 theme_override_constants/margin_bottom = 4 -[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot2/MarginContainer"] +[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot4/MarginContainer"] texture_filter = 1 layout_mode = 2 texture = ExtResource("4_yyyxx") -[node name="Slot3" type="Panel" parent="GridContainer"] +[node name="Slot5" type="Panel" parent="GridContainer"] custom_minimum_size = Vector2(64, 64) layout_mode = 2 -[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot3"] +[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot5"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -108,7 +130,7 @@ theme_override_constants/margin_top = 4 theme_override_constants/margin_right = 4 theme_override_constants/margin_bottom = 4 -[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot3/MarginContainer"] +[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot5/MarginContainer"] texture_filter = 1 layout_mode = 2 texture = ExtResource("5_ps55n") diff --git a/scenes/world/world.gd b/scenes/world/world.gd index 0dde3c0..5a04e9d 100644 --- a/scenes/world/world.gd +++ b/scenes/world/world.gd @@ -38,7 +38,7 @@ func _create_dropped_block(id: String, block_position: Vector3) -> void: block.initialize(id, block_position) func _create_test_blocks() -> void: - var test_blocks: Array = ["001", "002", "003", "004"] + var test_blocks: Array = ["001", "002", "003", "004", "005"] for index: int in range(1, test_blocks.size() + 1): _create_block("00" + str(index), Vector3(index, 1, -3)) _create_block("00" + str(index), Vector3(index, 2, -4))