|
|
@ -8,23 +8,19 @@ const BLOCK_PREFAB: PackedScene = preload("res://scenes/blocks/block.tscn") |
|
|
|
func _ready() -> void: |
|
|
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED |
|
|
|
_initialize_ground() |
|
|
|
#create_block(Block.Types.DIRT, Vector3.ZERO) |
|
|
|
#create_block(Block.Types.STONE, Vector3.ONE) |
|
|
|
|
|
|
|
|
|
|
|
func create_block(block_type: Block.Types, block_position: Vector3) -> void: |
|
|
|
func create_block(id: String, block_position: Vector3) -> void: |
|
|
|
var block: Block = BLOCK_PREFAB.instantiate() |
|
|
|
block.position = block_position |
|
|
|
block.name = "%s" % [block_position] |
|
|
|
block.type = block_type |
|
|
|
block.apply_material() |
|
|
|
block.set_id(id) |
|
|
|
|
|
|
|
add_child(block) |
|
|
|
|
|
|
|
|
|
|
|
func _initialize_ground() -> void: |
|
|
|
for x: int in range(-10, 11): |
|
|
|
for z: int in range(-10, 11): |
|
|
|
var random_type: int = randi_range(0 ,1) |
|
|
|
var ground_position: Vector3 = Vector3(x, 0, z) |
|
|
|
create_block(random_type, ground_position) |
|
|
|
#create_block(Block.Types.STONE, ground_position) |
|
|
|
create_block("001", ground_position) |