This site requires JavaScript, please enable it in your browser!
Greenfoot back
ArchMageGaming
ArchMageGaming wrote ...

2015/9/2

Making Randomly generated worlds

ArchMageGaming ArchMageGaming

2015/9/2

#
Im very new to greenfoot an would love some help on the game im making. Its like the binding of Isaac with a randomly generated dungeon every time you start a new game. But I need help on how to make saved progress files, and randomly generated dungeons and the things in them such as monsters, items, barriers, etc. Hope some one can point me in the right direction :):):)
Super_Hippo Super_Hippo

2015/9/2

#
For randomly generated world, do it like this: Step 1: Place those objects which are always at the same position, for example the 'interface' showing in what level you are and maybe other Counters (I don't know the game). The edges of the world are maybe also the same. Step 2: Place the other objects randomly. Use the 'Greenfoot.getRandomNumber' method to generate random numbers. Before placing it, check if it is a good position (it shouldn't start on some object placed in step 1 and enemies shouldn't start right in front of you). If not, generate a new position until you found a good one. This is basically what I did in my Bomberman game to generate random levels like positions of enemies, blocks, power ups and exit in the blocks. As I said, I don't know the game, but maybe this a bit like you want to do it. To save progress, use the 'UserInfo' class. You can save a total of 11 ints and 5 strings. Note that you can store more than one number in one slot if they are small numbers or booleans which you want to save.
ArchMageGaming ArchMageGaming

2015/9/2

#
thx for the help but I don't want levels, I want to have the computer randomly generate a dungeon with many rooms like in the binding of Isaac. I don't know what 2-D arrays are but I think they will be able to help in this situation.
Super_Hippo Super_Hippo

2015/9/2

#
It doesn't really matter if you want levels or not. It was just an example. You can also save the room in which the user currently is, things which he picked up or whatever. So you have a dungeon with many rooms and each room should be generated randomly. I think the best way to start is to create one room randomly. You could create your rooms with arrays or the dungeon as a whole. In the first case, you would split your room into squares. Then you want to place objects on these squares. So for example 0=nothing, 1=block, 2=player, 3=enemy. A room could look like this then: 1 1 1 0 1 1 1 1 3 0 0 0 0 1 1 0 0 0 3 0 1 1 0 0 0 0 0 0 1 0 2 0 0 0 1 1 1 0 1 1 1 1 If you create all your rooms at the beginning, you can save all rooms in an array. This can be helpful for traveling from one room to another with saving the progress in each room. (So if you clear out Room A, move to B and back to A, A will still be cleared and not a new random room.)
You need to login to post a reply.