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

2018/8/8

Writing a proper randomly generated map

Xolkiyr Xolkiyr

2018/8/8

#
This is the code I'm currently using to generate my world.
        for(int y = 1080 * -3; y < 1080 *3; y += 60){
            for(int x = 600 * -3; x < 600 *3; x += 60){
                int r = Greenfoot.getRandomNumber(10);
                if(r >= 0 && r <= 2){
                    addObject(new Water(), x, y);
                }else if(r == 3){
                    addObject(new Sand(), x, y);
                }else if(r >= 4){
                    addObject(new Grass(), x, y);
                }
            }
        }
Is there any way to make this more uniform so it generates a more believable landmass? I'm using a tile generation sort of system.
Super_Hippo Super_Hippo

2018/8/8

#
You could start with all Grass. Then randomly choose a few points and around those points, you add some tiles of water. Around those tiles of water, you create sand.
Xolkiyr Xolkiyr

2018/8/8

#
That works somewhat, but then I run into the issue that I get almost no water, lol.
Super_Hippo Super_Hippo

2018/8/8

#
What did you try?
You need to login to post a reply.