class_name World
|
|
extends Node3D
|
|
|
|
|
|
const BLOCK_PREFAB: PackedScene = preload("res://scenes/blocks/block.tscn")
|
|
|
|
|
|
func _ready() -> void:
|
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
_initialize_ground()
|
|
|
|
|
|
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.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 ground_position: Vector3 = Vector3(x, 0, z)
|
|
|
|
var random: int = randi_range(0, 1)
|
|
if random:
|
|
create_block("001", ground_position)
|
|
else:
|
|
create_block("002", ground_position)
|