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.
 

30 lines
855 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()
#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:
var block: Block = BLOCK_PREFAB.instantiate()
block.position = block_position
block.name = "%s" % [block_position]
block.type = block_type
block.apply_material()
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)