This week Monolith took a big leap forward! One thing that is critical to all roguelikes has been properly added, and it looks pretty nice, so without further ado…
I completely redid the level generation this week, and put some time to make it really special. The basic idea of picking a random size and trying to fit the room stayed mostly the same, but now there a ton of more option for each room, but before I get into specifics, here is what a basic 100×100 level looks like now…
As you can see, this is not your father’s dungeon.
So the way this method creates a unique style to the level is that each room has a different type, and the chance of each type appearing on a given level is controlled by the Level type, which is chosen at random based on how high of a chance it has to be chosen.
Example: The ‘Normal’ type level has a 70% chance of being generated. For the Normal level type, a normal level may have a 80% chance of creating a rectangular room as it’s next room, and a 15% chance of creating a circular room as it’s next room. This goes on to every type of room…
On top of just picking a random number for width and height, certain rooms use a type of random number called ‘Perlin Noise’, an example can be seen below:
So as you can see, this creates a random effect that isn’t so random, meaning it has a bit of a pattern, so that a high number (represented by the light color) is not next to a low number (represented by the dark colors) without having to go a few numbers between the two numbers. This is the exact randomness that is perfect for map generation in video games.
There are 6 level types:
- Overworld (only can be generated if the level is on the first or second floor [increasing floor level to be implemented…] )
The rooms they contain will become fairly obvious as I tell you the room types.
- This is a basic rectangular room, nothing special, just like all rooms were previous to the new level generation.
- This is a rectangular room with 2 boxes of random width and height have been removed from it, occasionally giving an effect of appearing to be multiple rooms
- This a circular room, all hallways going to and from this room must be in the center of the wall they are connected to
- This room is filled with water, and has some bits of land based on if the perlin noise reaches a certain number
- This room has dirt mixed in with the stone using perlin noise. A room could be almost entirely dirt and grass or have very little depending on the noise in it’s area.
- This room’s shape is depended on perlin noise in the area it is placed. If the noise is too high / not high enough, no tile is placed, giving it an unpredictable and natural look
- This room is is close to a natural room, but the limit for not placing a tile is much lower, so only a small amount of the room may be missing. Around the missing bits of the room, dirt is placed to suggest that the room collapsed, revealing the dirt from the ground above it.
- This room is basically a combination of collapsed and overgrown
- This room is a large room that appears only as the final room for each level. [Not yet implemented.]
So that’s the level generation, it really adds a nice feel to the game, giving the player a bit more curiosity of what each room contains other than another bunch of baddies to battle… speaking of which…
I added an outline effect to Monolith, meaning that when added, adds a border of whatever color and size the method is passed. I added it to give enemies an outline to make them appear more obvious to the player.
This, however, is not applied to the player. I didn’t like how that looked, so limited the outline to just enemies.
Monolith now has the option to toggle fullscreen by pressing F11 at any time. Unfortunately for the time being only the main display is supported for fullscreen (an error is thrown when trying to turn on fullscreen with the window in a different display).
I added a fun little visual effect, that will render the game with a certain palette that can be set to any colors. It works by finding the difference from the pixel’s color and every color in the palette, and replacing the pixel with the color with the lowest difference (meaning it chooses the most mathematically similar color). The game runs really slow with this effect on (A lot of calculating must go into each pixel in the window, and there are a lot of pixels in the window)
I tried a few palettes, here’s a few examples of the game with different palettes:
Gray-scale and a deep red
That’s all for this week! The game definitely feels a lot more like a game thanks to the new level generation. Thanks for reading!