valencia-rail-rush/level.gd

70 lines
1.6 KiB
GDScript

extends Node3D
@export var dimension: int = 10
func _ready() -> void:
randomize()
var chunks: Array
# Populate the array with [dimension(x)][dimension(y)][4]bool
for x in range(dimension):
for y in range(dimension):
chunks.append([
randi() % 2 == 0,
randi() % 2 == 0,
randi() % 2 == 0,
randi() % 2 == 0,
])
# Decide position of station & spawn
var station = Vector2i(randi() % dimension, 0)
var spawn = Vector2i(dimension - station.x - 1, dimension - 1)
#for pathNum in range(2): # Create paths
#var iPosition = station
#iPosition.y += 1 # Station always is entered from below
#var i = 1
#while true:
#var path = [false, true, false, false]
#
#while true: # select a random neighbour until it's a new one
#var nextDir = randi() % 4
#var nextPosition = iPosition
#
#if nextDir > 1:
#nextPosition.x += (nextDir % 2) * 2 - 1
#else:
#nextPosition.y += (nextDir % 2) * 2 - 1
#
#var passedPrevPath = false
#for prevPos in path:
#if prevPos == nextPosition:
#true
#
#if not passedPrevPath:
#break
#
#if iPosition.x == spawn.x and iPosition.y == spawn.y:
#break # Path finished
#
#i += 1
#
#while true:
#chunks[iPosition.x][iPosition.y] = [
#randi() % 2 == 0,
#randi() % 2 == 0,
#randi() % 2 == 0,
#randi() % 2 == 0,
#]
#
#var openDoorCount = chunks[iPosition.x][iPosition.y].filter(func(isOpen): return isOpen).size()
#if openDoorCount == 2:
#break
#print(chunks)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass