From Graph to Map: Procedural Room Design in Action
Rooms
This week, we developed basic rooms that can appear randomly on the map from the available list of options. The rooms implemented include a trap room and a healing room. Below are some images of the rooms created:
While these rooms may not be the most creative, they effectively demonstrate the structure of the generated level.
Walls and Doors
When the graph indicates that an edge contains a door, the door must appear on the map, along with a key to unlock it. In the level structure shown below, the key is located near the entrance but behind a door. Therefore, the last node before reconnecting the cycle must contain two keys: one to unlock the door leading out of the cycle and another to unlock the door upon returning.
To implement this logic, walls were added to all rooms, which are removed dynamically based on the graph’s instructions:
private void removeWalls() {
foreach (Edge edge in m_graph.edges) {
if (edge.EdgeType != EdgeType.OpenConnection) {
continue;
}
Node nodeFrom = edge.From;
Node nodeTo = edge.To;
Vector2 distance = nodeTo.Position - nodeFrom.Position;
GameObject fromRoom = m_grid[nodeFrom.Position.x, nodeFrom.Position.y];
GameObject toRoom = m_grid[nodeTo.Position.x, nodeTo.Position.y];
RoomDirection direction = RoomDirection.East;
if (distance.x != 0) {
direction = distance.x < 0 ? RoomDirection.West : RoomDirection.East;
} else if (distance.y != 0) {
direction = distance.y < 0 ? RoomDirection.South : RoomDirection.North;
}
toggleWall(fromRoom, direction, false);
toggleWall(toRoom, oppositeDirection(direction), false);
}
}
Here are the results:
Cuartos
Esta semana se desarrollaron cuartos básicos que pueden aparecer aleatoriamente en el mapa a partir de la lista de opciones disponibles. Los cuartos implementados incluyen uno de trampas y otro de curación. A continuación, se presentan algunas imágenes de los cuartos creados:
Aunque estos cuartos no destacan por ser los más creativos, cumplen con su propósito al ejemplificar la estructura del nivel generado.
Paredes y Puertas
Cuando el grafo indica que una arista tiene una puerta, esta debe aparecer en el mapa junto con una llave que permita abrirla. Tomando como referencia la estructura del nivel que se muestra a continuación, podemos observar que la llave está cerca de la entrada, pero al otro lado de una puerta. Por lo tanto, el último nodo antes de cerrar el ciclo necesita tener dos llaves: una para abrir la puerta que permite salir del ciclo y otra para abrir la puerta de regreso.
Para lograr esto, se añadieron paredes a todos los cuartos. Dependiendo de lo que indique el grafo, las paredes se eliminan dinámicamente:
private void removeWalls() {
foreach (Edge edge in m_graph.edges) {
if (edge.EdgeType != EdgeType.OpenConnection) {
continue;
}
Node nodeFrom = edge.From;
Node nodeTo = edge.To;
Vector2 distance = nodeTo.Position - nodeFrom.Position;
GameObject fromRoom = m_grid[nodeFrom.Position.x, nodeFrom.Position.y];
GameObject toRoom = m_grid[nodeTo.Position.x, nodeTo.Position.y];
RoomDirection direction = RoomDirection.East;
if (distance.x != 0) {
direction = distance.x < 0 ? RoomDirection.West : RoomDirection.East;
} else if (distance.y != 0) {
direction = distance.y < 0 ? RoomDirection.South : RoomDirection.North;
}
toggleWall(fromRoom, direction, false);
toggleWall(toRoom, oppositeDirection(direction), false);
}
}
A continuación, se muestran los resultados obtenidos:
Get Dungeon of the Forgotten Cycle
Dungeon of the Forgotten Cycle
Status | In development |
Author | Lorenz Equihua |
Genre | Action |
More posts
- Small Details, Big Reveal: The Demo is Ready for Action26 days ago
- Health Systems and Treasure Rooms: Enhancing Player Interaction33 days ago
- Gameplay Foundations: First Build and Early Enemy Encounters40 days ago
- From Graphs to Gameplay: A Deep Dive into Cyclic Dungeon Generation56 days ago
- Development Roadmap: Planning the Journey Ahead57 days ago
- Thesis Project: Exploring Procedural Dungeon Design57 days ago
Leave a comment
Log in with itch.io to leave a comment.