2D Tile Based Random Map Generator
Disclaimer:
This is a humble approach for creating a random map generator for my game. Please notice that I did not try my best here and this could definitely be way better...I just wanted to have some fun while creating a random map generator. I will provide links to the code used here if you want to take a look. Also, feedback is really appreciated :).
My approach for this tool was the following:
- Create an X times Y grid.
- Fill the grid with random objects(obstacles).
- Based on how many obstacles you want, remove the extra ones.
- Shuffle the grid.
Here's the code that does that:
For shuffling the grid:
https://gist.github.com/MerliMejia/26a9a61efc9cea80155ea129f83619d0#file-mapgenerator-cs-L54
For generating the random data on the grid:
https://gist.github.com/MerliMejia/26a9a61efc9cea80155ea129f83619d0#file-mapgenerator-cs-L71
You can use Unity's Gizmos system to get an early visualization:
https://gist.github.com/MerliMejia/26a9a61efc9cea80155ea129f83619d0#file-mapgenerator-cs-L175
You can use Scriptable Objects to know what to draw and how many it should draw:
https://gist.github.com/MerliMejia/26a9a61efc9cea80155ea129f83619d0#file-obstacles-cs-L7
After that, you just need to draw the tiles based on the random grid data and that's it!
https://gist.github.com/MerliMejia/26a9a61efc9cea80155ea129f83619d0#file-mapgenerator-cs-L148
Here's all the code used in this tool:
https://gist.github.com/MerliMejia/26a9a61efc9cea80155ea129f83619d0
Dog Waddle
A mobile 📱 puzzle game in which you're a cute little dog 🐶 that needs to feed your children 🐕.
Status | In development |
Author | Mejia Tavarez Software and More |
Genre | Puzzle |
Tags | 2D, Cute, Pixel Art, Singleplayer, Unity |
Leave a comment
Log in with itch.io to leave a comment.