Lighting, Fluids, Platforms & Random Rooms
This is the 4th post in the dev update series. The last two weeks have been pretty productive and a couple new features have been implemented.
Liquid fluids have been implemented to support lava and water to hinder the player in his quest to exit the dungeons. Lava for example, when fallen in, will hurt the player badly. The player will need to somehow cross the lava (if possible). The cool thing about the liquids are that they can flood areas. You can tell the flooding control to start filling from X,Y position and it will try to fill up everything from start point to largest X on current Y.
Some rooms are dark and require an illumination source. It’s harder to spot enemies and other dangerous obstacles.
In dev update #3 I mentioned that Suit Guy’s Levels (levels are not to be mistaken for rooms) are randomly generated. At that time I still had to create rooms by hand with the RandEditor, which was annoying (I’m also lazy). And because it was the initial plan; I created a random room generator which can create a room any size, height or width. The largest room created so far is a 8*1500 tile room. The editor can now be used to create specific rooms for specific needs such as bossfight, special room types, etc.
How does it work
The room generation code works in several stages:
- Generate a 2d array of given size and mark all as ‘filled with sprite’
- Cut a random line until you’ve reached the other side (it cuts from left to right). This will serve as the bottom.
- Do the same but this time for the ceiling (there’s some code involved which does pass-way checking.
- Open up the cave from ceiling to bottom.
- Generate the actual tiles in the level
- Generate an outline around the level
- Mark parts of the cave as corridors (there’s an algorithm involved to determine wether something is a corridor or not)
- Decorate cave & flood areas
- Determine the light intensity of the area.
When it completed its generation it’s then handed over to a room class and presented in game.
In a later post I’ll write up more in-depth blog post about the room generation.
If you like the development of Suit Guy and would like to get rid of your Bitcoins or Litecoins; feel free to donate on one of the following addresses: