feat: WIP level generation

This commit is contained in:
Dusk 2026-03-01 20:40:29 +01:00
parent 12aafa654c
commit 95fe9c334f
2 changed files with 54 additions and 5 deletions

View File

@ -3,11 +3,61 @@ extends Node3D
@export var dimension: int = 10 @export var dimension: int = 10
func _ready() -> void: func _ready() -> void:
var chunks = Array[Array[Array[bool]]] randomize()
seed( 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([[], [], [], []])
# 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. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void: func _process(delta: float) -> void:

View File

@ -3,7 +3,7 @@
[ext_resource type="Script" uid="uid://dj0cgqed5n3ys" path="res://level.gd" id="1_0b4ue"] [ext_resource type="Script" uid="uid://dj0cgqed5n3ys" path="res://level.gd" id="1_0b4ue"]
[ext_resource type="PackedScene" uid="uid://cmb3b7xrlboy3" path="res://player.tscn" id="1_u52ul"] [ext_resource type="PackedScene" uid="uid://cmb3b7xrlboy3" path="res://player.tscn" id="1_u52ul"]
[ext_resource type="Script" uid="uid://b5ebibi08tjvd" path="res://camera_3d.gd" id="2_vonw3"] [ext_resource type="Script" uid="uid://b5ebibi08tjvd" path="res://camera_3d.gd" id="2_vonw3"]
[ext_resource type="PackedScene" uid="uid://x0nufa1wdu4j" path="res://chunk.tscn" id="3_f2txt"] [ext_resource type="PackedScene" path="res://chunk.tscn" id="3_f2txt"]
[sub_resource type="Environment" id="Environment_vonw3"] [sub_resource type="Environment" id="Environment_vonw3"]
ambient_light_source = 2 ambient_light_source = 2
@ -17,7 +17,6 @@ size = Vector3(10, 7.5, 10)
[node name="Level" type="Node3D" unique_id=1248504413] [node name="Level" type="Node3D" unique_id=1248504413]
script = ExtResource("1_0b4ue") script = ExtResource("1_0b4ue")
dimension = null
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=2012504496] [node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=2012504496]
environment = SubResource("Environment_vonw3") environment = SubResource("Environment_vonw3")