Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+2)

thank you

I read about the level gen in Dereks Yu's book on the developmnet of spelunky.

You create a grid, let’s say 4x4, and each cell represent a room.

Then you assign a random cell in the top and bottom row to be the start and exit room.

now randomly move left,right or down from the start-room iterating until you reach the exit-room and that will be your straight path from start to exit. you’ll end up with something like this:

[0] [2] [1] [S]

[0] [3] [1] [2]

[0] [0] [0] [3]

[E] [1] [1] [3]

The numbers represent different types of rooms. For instance, 1 would be a room with openings to the right and left side, 2 an opening at the bottom, 0 can be any type of room and so on.

Loop through the grid and for each type of room you draw from a pool of premade layouts which is just arrays of numbers like this:

[ 1,1,1,1,1,1,1,1,1,1,

1,0,0,0,0,0,0,0,0,1,

0,0,0,0,0,0,0,0,0,0,

0,0,0,0,0,2,0,0,0,0,

0,0,0,0,1,1,0,0,0,0,

0,0,0,0,1,1,0,0,0,0,

1,0,0,1,1,1,1,0,0,1,

1,1,1,1,1,1,1,1,1,1]

1 is a wall tile, 0 is void, 2 is en enemy etc.

Loop through the array as a grid with array_index = x_cell + y_cell*room_width.

Then draw to x,y position with

x = (x_cell_room_grid*room_width+x_cell_room_lay_ut)*tile_size

y = (y_cell_room_grid*room_height+y_cell_room_layout)*tile_size

hopefully that made any sense and im not just making it sound more complicated than it is.

this is awesome! Im kinda bad at math but i'll try to make sense out of this and try it out myself. Thank you very much for sharing this!!