Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
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).
Hey thanks man! I needed help with that! Now i can start moving on by using that
I'll keep this as first comment to keep it in file!
By the way the code I showed you is from my new project, no name yet but you can check the blog if you'd like that ( https://lousydev.wordpress.com/ ).