A dungeon delver roguelike using Pathfinder 2nd edition rules
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added code to generate dungeon and load 3d scene

+256
+4
.editorconfig
··· 1 + root = true 2 + 3 + [*] 4 + charset = utf-8
+2
.gitattributes
··· 1 + # Normalize EOL for all files that Git considers text files. 2 + * text=auto eol=lf
+124
dungeonGenerator/dungeon.gd
··· 1 + class_name Dungeon 2 + 3 + extends Node 4 + 5 + @export var grid: PackedByteArray = [] 6 + @export var width: int = 6 7 + @export var height: int = 6 8 + @export var entrance: int = -1 9 + @export var init: bool = false 10 + 11 + const BitUsedRoom: int = 0x01 12 + const BitEntrance: int = 0x02 13 + const BitDoorNorth: int = 0x04 14 + const BitDoorEast: int = 0x08 15 + const BitDoorSouth: int = 0x10 16 + const BitDoorWest: int = 0x20 17 + const BitStairBelow: int = 0x40 18 + const BitStairUp: int = 0x80 19 + 20 + const Neighbors: int = BitDoorNorth | BitDoorEast | BitDoorSouth | BitDoorWest 21 + 22 + var rng: RandomNumberGenerator = RandomNumberGenerator.new() 23 + 24 + func _ready() -> void: 25 + if init: 26 + generate() 27 + var nextScene: Node3D = preload("res://dungeonRoom/dungeonRoom.tscn").instantiate() 28 + get_node("/root/Main").call_deferred("add_child", nextScene) 29 + 30 + func fillArray(r: Array, size: int): 31 + for i in range(size): 32 + r.append(0) 33 + 34 + func fillByteArray(r: PackedByteArray, size: int): 35 + for i in range(size): 36 + r.append(0) 37 + 38 + func generate(): 39 + var dungeonArea: int = width * height 40 + fillByteArray(grid, dungeonArea) 41 + var generatedCellsNum: int = 0 42 + var generatedCells: Array[int] 43 + fillArray(generatedCells, dungeonArea) 44 + var i = 0 45 + 46 + while ((generatedCellsNum < dungeonArea) and ((i == 0) or (i < generatedCellsNum))): 47 + if (i == 0) and (generatedCellsNum == 0): 48 + entrance = rng.randi_range(0, dungeonArea - 1) 49 + generatedCells[0] = entrance 50 + grid[entrance] = BitEntrance | BitUsedRoom 51 + generatedCellsNum = 1 52 + 53 + var generatedCellsRef: Array[int] = [generatedCellsNum] 54 + generateRoom(i, generatedCells, generatedCellsRef) 55 + generatedCellsNum = generatedCellsRef[0] 56 + 57 + if !(grid[generatedCells[i]] & BitUsedRoom): 58 + grid[generatedCells[i]] |= BitUsedRoom 59 + 60 + if (i == (generatedCellsNum - 1)) and (generatedCellsNum < (dungeonArea * 0.75)): 61 + i = -1 62 + 63 + i += 1 64 + 65 + func generateRoom(cellIndexQueue: int, cellsQueue: Array[int], queueSize: Array[int]) -> void: 66 + var potentialDoors: int = rng.randi_range(0, Neighbors - 1) 67 + var cellIndex: int = cellsQueue[cellIndexQueue] 68 + 69 + var door: int = 1 70 + var oppositeDoor: int 71 + 72 + while door <= Neighbors: 73 + if ((door & Neighbors) != door) or (grid[cellIndex] & door): 74 + door <<= 1 75 + continue 76 + 77 + var neighborRoom: int = getNeighborRoomIndex(cellIndex, door) 78 + 79 + if (!~neighborRoom) or (grid[neighborRoom] & BitUsedRoom): 80 + door <<= 1 81 + continue 82 + 83 + oppositeDoor = getOppositeDirectionBit(door) 84 + 85 + if (door & potentialDoors) == door: 86 + grid[cellIndex] |= door 87 + grid[neighborRoom] |= oppositeDoor 88 + 89 + if grid[neighborRoom] == oppositeDoor: 90 + cellsQueue[queueSize[0]] = neighborRoom 91 + queueSize[0] += 1 92 + 93 + door <<= 1 94 + 95 + func getNeighborRoomIndex(currentRoom: int, direction: int) -> int: 96 + var neighborRoom: int 97 + 98 + if direction == BitDoorNorth: 99 + neighborRoom = currentRoom - width 100 + elif direction == BitDoorEast: 101 + neighborRoom = currentRoom + 1 102 + elif direction == BitDoorSouth: 103 + neighborRoom = currentRoom + width 104 + elif direction == BitDoorWest: 105 + neighborRoom = currentRoom - 1 106 + 107 + if ((direction == BitDoorNorth) and (neighborRoom >= 0)) or ((direction == BitDoorSouth) and (neighborRoom < (width * height))) or ((direction == BitDoorEast) and ((neighborRoom % width) > 0)) or ((direction == BitDoorWest) and ((neighborRoom % width) < (width - 1))): 108 + return neighborRoom 109 + 110 + return -1 111 + 112 + func getOppositeDirectionBit(direction: int) -> int: 113 + var oppositeDirection: int = -1 114 + 115 + if direction == BitDoorNorth: 116 + oppositeDirection = BitDoorSouth 117 + elif direction == BitDoorEast: 118 + oppositeDirection = BitDoorWest 119 + elif direction == BitDoorSouth: 120 + oppositeDirection = BitDoorNorth 121 + elif direction == BitDoorWest: 122 + oppositeDirection = BitDoorEast 123 + 124 + return oppositeDirection
+1
dungeonGenerator/dungeon.gd.uid
··· 1 + uid://bj1iov1sgi7bo
+12
dungeonGenerator/dungeonGenerator.tscn
··· 1 + [gd_scene load_steps=2 format=3 uid="uid://cerkgsgcxogxa"] 2 + 3 + [ext_resource type="Script" uid="uid://bj1iov1sgi7bo" path="res://dungeonGenerator/dungeon.gd" id="1_bt1uu"] 4 + 5 + [node name="Main" type="Control"] 6 + layout_mode = 3 7 + anchors_preset = 0 8 + 9 + [node name="Dungeon" type="Node" parent="."] 10 + script = ExtResource("1_bt1uu") 11 + init = true 12 + metadata/_custom_type_script = "uid://bj1iov1sgi7bo"
+1
dungeonRoom/dungeonRoom.gd
··· 1 + extends Node3D
+1
dungeonRoom/dungeonRoom.gd.uid
··· 1 + uid://do7carntf751h
+6
dungeonRoom/dungeonRoom.tscn
··· 1 + [gd_scene load_steps=2 format=3 uid="uid://yk65ut0rtska"] 2 + 3 + [ext_resource type="Script" uid="uid://do7carntf751h" path="res://dungeonRoom/dungeonRoom.gd" id="1_emgf8"] 4 + 5 + [node name="DungeonRoom" type="Node3D"] 6 + script = ExtResource("1_emgf8")
+1
icon.svg
··· 1 + <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>
+37
icon.svg.import
··· 1 + [remap] 2 + 3 + importer="texture" 4 + type="CompressedTexture2D" 5 + uid="uid://c3gihvabedr76" 6 + path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" 7 + metadata={ 8 + "vram_texture": false 9 + } 10 + 11 + [deps] 12 + 13 + source_file="res://icon.svg" 14 + dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] 15 + 16 + [params] 17 + 18 + compress/mode=0 19 + compress/high_quality=false 20 + compress/lossy_quality=0.7 21 + compress/hdr_compression=1 22 + compress/normal_map=0 23 + compress/channel_pack=0 24 + mipmaps/generate=false 25 + mipmaps/limit=-1 26 + roughness/mode=0 27 + roughness/src_normal="" 28 + process/fix_alpha_border=true 29 + process/premult_alpha=false 30 + process/normal_map_invert_y=false 31 + process/hdr_as_srgb=false 32 + process/hdr_clamp_exposure=false 33 + process/size_limit=0 34 + detect_3d/compress_to=1 35 + svg/scale=1.0 36 + editor/scale_with_editor_scale=false 37 + editor/convert_colors_with_editor_theme=false
+16
project.godot
··· 1 + ; Engine configuration file. 2 + ; It's best edited using the editor UI and not directly, 3 + ; since the parameters that go here are not all obvious. 4 + ; 5 + ; Format: 6 + ; [section] ; section goes between [] 7 + ; param=value ; assign values to parameters 8 + 9 + config_version=5 10 + 11 + [application] 12 + 13 + config/name="Dungeoner" 14 + run/main_scene="uid://dk700xxolt8x6" 15 + config/features=PackedStringArray("4.4", "Forward Plus") 16 + config/icon="res://icon.svg"
+8
start/start.gd
··· 1 + extends Node 2 + 3 + 4 + func _on_new_game_pressed() -> void: 5 + get_tree().change_scene_to_file("res://dungeonGenerator/dungeonGenerator.tscn") 6 + 7 + func _on_quit_pressed() -> void: 8 + get_tree().quit()
+1
start/start.gd.uid
··· 1 + uid://drdqx5u4ful3g
+42
start/start.tscn
··· 1 + [gd_scene load_steps=2 format=3 uid="uid://dk700xxolt8x6"] 2 + 3 + [ext_resource type="Script" uid="uid://drdqx5u4ful3g" path="res://start/start.gd" id="1_hdi1w"] 4 + 5 + [node name="Main" type="Control"] 6 + layout_mode = 3 7 + anchors_preset = 15 8 + anchor_right = 1.0 9 + anchor_bottom = 1.0 10 + grow_horizontal = 2 11 + grow_vertical = 2 12 + script = ExtResource("1_hdi1w") 13 + 14 + [node name="Title" type="Label" parent="."] 15 + layout_mode = 1 16 + anchors_preset = -1 17 + anchor_top = 0.285 18 + anchor_right = 1.0 19 + anchor_bottom = 0.32 20 + text = "Dungeoner" 21 + horizontal_alignment = 1 22 + 23 + [node name="New Game" type="Button" parent="."] 24 + layout_mode = 1 25 + anchors_preset = -1 26 + anchor_left = 0.232 27 + anchor_top = 0.345 28 + anchor_right = 0.768 29 + anchor_bottom = 0.393 30 + text = "New Game" 31 + 32 + [node name="Quit" type="Button" parent="."] 33 + layout_mode = 1 34 + anchors_preset = -1 35 + anchor_left = 0.232 36 + anchor_top = 0.418 37 + anchor_right = 0.768 38 + anchor_bottom = 0.418 39 + text = "Quit" 40 + 41 + [connection signal="pressed" from="New Game" to="." method="_on_new_game_pressed"] 42 + [connection signal="pressed" from="Quit" to="." method="_on_quit_pressed"]