Browse Source

Adding grass block

pull/8/head
Ryan Reed 1 month ago
parent
commit
1d6937ee9f
6 changed files with 57 additions and 11 deletions
  1. +9
    -0
      assets/materials/grass.tres
  2. +2
    -1
      autoloads/db_items.gd
  3. +14
    -0
      resources/blocks/005_grass.tres
  4. +1
    -1
      scenes/ui/quick_slots.gd
  5. +30
    -8
      scenes/ui/quick_slots.tscn
  6. +1
    -1
      scenes/world/world.gd

+ 9
- 0
assets/materials/grass.tres View File

@ -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

+ 2
- 1
autoloads/db_items.gd View File

@ -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"),
}

+ 14
- 0
resources/blocks/005_grass.tres View File

@ -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"

+ 1
- 1
scenes/ui/quick_slots.gd View File

@ -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


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

@ -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")

+ 1
- 1
scenes/world/world.gd View File

@ -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))


Loading…
Cancel
Save