Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics

How did you get the enemies to spawn in not knowing where they would show up? In other words how do you check if the place they are spawning in is a valid spawn point?


Nothing major, really, I just capture all free spaces to an array and remove the start and end positions (from my case, the very first and the very last). After that, just take a few random positions for the enemies. I won't be able to work on the game for about two weeks (missing  the competition) because of a certification I'm studying for, but I managed to simplify the level creation.

I'll post my findings a bit later.

Awesome, Thank you! I'm excited to see what you come up with.

Hey SpencaSlim!

Here is the code I made up in my last revision before being sidetracked to my certification:

Put it in a controller object with it being fired on create event.

///Generate level

var sizeX = room_width / TILESIZE;
var sizeY = room_height / TILESIZE;

//Set starting position, excluding the borders
var startX = irandom_range(1, sizeX-1);
var startY = irandom_range(1, sizeY-1);

var cells;

for(y=0; y < sizeY; y++)
    for(x = 0; x < sizeX; x++)
        cells[x, y] = "1";

var dir = direction;


    if (scrChance(50))
        dir = choose(90,270,180,0);
    //Choose a direction at random
        case 90:
        case 270:
        case 180:
        case 0:
    //If we are going to a border, retreat
    if (startX < 1)     {startX = 1};
    if (startY < 1)     {startY = 1};
    if (startX >= 49)   {startX = 48};
    if (startY >= 37)   {startY = 36};

    //Mark this array position as free
    cells[startX, startY] = "0";
    var ground = instance_create(startX * TILESIZE, startY * TILESIZE, objGrass);
    ///Choose a random sub-image for added variety 
    ground.image_index = choose(0,1,2);
    //Do not animate
    ground.image_speed = 0;

Like I wrote previously, I just went on and placed my player on the first "0" array cell. And my exit point at the last "0" cell. Enemies, just get a few random "0" positions and drop them there.

Any morequestions, just let me know. Cheers.

Thanks brother, much appreciated. Good luck with your game. Keep us updated!