Erster Prototyp

This commit is contained in:
Exobyt 2024-08-17 19:46:21 +02:00
parent 2da5af8954
commit 885351b624
48 changed files with 1350 additions and 0 deletions

37
scenes/Grid/grid.gd Normal file
View file

@ -0,0 +1,37 @@
extends Node2D
@onready var spawnpoint = $Spawnpoint
var nextBlocks = []
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
fillNextBlocks()
spawnBlock()
func spawnBlock() -> void:
var block = nextBlocks[0]
GLOBAL.currentBlock = block
spawnpoint.add_child(block)
nextBlocks.pop_at(0)
if nextBlocks.size() < 2:
fillNextBlocks()
func _physics_process(delta: float) -> void:
if GLOBAL.currentBlock != null:
if GLOBAL.currentBlock.stopped:
spawnBlock()
func fillNextBlocks():
var newBlocks = []
for i in GLOBAL.BLOCKS:
var block = load(GLOBAL.BLOCKS[i]).instantiate()
block.setId(GLOBAL.getNewId())
block.setType(GLOBAL.BLOCKTYPES.LIGHT)
newBlocks.append(block)
newBlocks.shuffle()
newBlocks[0].setType(GLOBAL.BLOCKTYPES.HEAVY)
newBlocks.shuffle()
nextBlocks.append_array(newBlocks)