A Minecraft style clone in Godot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

31 lines
720 B

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)