How to Create a Randomly Generated Game Board

 

This How to will show you how to create a randomly generated 8×8 map using C# code. The code does require some sprites to be useful, but any sprite will be able to be used to make your own version!

Hope this helps!

  1. Create your variables as public GameObject[] (name);. This will allow you to assign sprites to each individual group and will place them appropriately throughout the game board.
  2. Now, using for loops to prepare to generate a new board
  3. Now run a script, preperably named apprioprately (boardSetup), and set up a new GameObject to be the board. Then use for loops to fill in the outsides and insides of the board.
  4. Next, run a command that allows us to randomly layout objects, with a minimum and maximum set, which should be set as varibles at the beginning of the script. (ex. Public int maximum = 8;)
  5. Now we will actually be creating the board by calling the functions we created above and also adding how many enemies will be on per level, with a mathematic equation.
  6. Once done with the script, go to Unity and create a empty child under the GameObject tab. Rename the object GameManager and add the script to it.
  7. Then select the desired sprites for each category (outside wall, floor, food, enemy) and using shirt + click or cntl + click, drag and drop the prefabs onto the script.
  8. After filling in all the categories, drag the GameManager object into the prefabs folder and delete the object for the hierarchy.

Finished Roguelike 2D Game

The (should be) finished version of the game is linked below. After playing the game, if you could take the survey to give me some feedback that would be awesome! Thanks 🙂

To play the game ask me, (Im wearing the Iowa State t shirt), and I can have you play the game on the computer next to mine. Unfortunately the file size was too large to directly link. Sorry 🙁

Survey: https://goo.gl/forms/jheK5WK9LzX9QxB12

Gracias!

The Good and Bad of Games

Good: Good story line, made with the intention of helping the community or providing entertainment instead of purely for profit. The game should be fun to play and not to expensive. Also the game should be able to be enjoyed fully without having to purchase extra DLC. Ex: Crossy road.

Lame: Negative story line, poorly made to possibly scam people, not polished, holes in the story line.