GRUP STEAM
game development help gamedevhelp
GRUP STEAM
game development help gamedevhelp
11
SEDANG BERMAIN
96
ONLINE
Dibentuk
28 Mei 2015
Bahasa
Bhs. Inggris
Menampilkan11-20 dari 21 kiriman
19
Need help with GML? Beginners look here!
3
Need Help? GM:S
Random gen is pretty simple when it comes down to it, you just need to know how it works (not code-wise but the general logic behind it). Top down level generation is the most simple generation (terraria style world generation is much more complicated), all you need is an object going in random directions and placing floor tiles, then make the floor tiles check if the space next to them is free and if so place a wall block there. Here's an example:

do
{
if !place_meeting(x,y,obj_ground) // we aren't currently on a floor block
{
tiles++; // number of tiles + 1
instance_create(x,y,obj_ground); // create a floor tile
if tiles = maxtiles // the last tile we created is the final tile to be placed
{
guard = instance_create(x,y+6,obj_enemy); // create an enemy to guard the loot
instance_deactivate_object(guard);
instance_create(x,y,obj_chest); // create a loot chest
}
}

do //pick a random direction until the direction we picked keeps us inside the room
{
dir = irandom(3); //choose a random direction
xdist = lengthdir_x(32, dir * 90);
ydist = lengthdir_y(32, dir * 90);
}
until x + xdist < room_width - 32 and x + xdist > 32 and y + ydist < room_height - 32 and y + ydist > 32
x += xdist; // move x
y += ydist; // move x
}
until tiles = maxtiles

This creates a random level in a single step, ofcourse there is some variable initialising before this (maxtiles,tiles and roomsize and x/y coordinates) and wall creation after it (also loot/prop/enemy/vegetation spawning) but as you see it is very simple!

To create more advanced level generation you could add a smaller chance to turn and rooms (basically place more floor tiles around yourself to create an open space).
1
[Game Maker] Character problem
1
Best way to learn coding for someone who lives in a place where there aren't any programming teachers?
19
Need help with GML? Beginners look here!
Menampilkan11-20 dari 21 kiriman