Fancy meeting you here!


Life got in the way for a bit, so I didn’t get the chance to work on this in the last few days. Fortunately, the brain never stops and despite not working, some ideas get polished.

Well then, the next obvious step is to add a few more sentient beings along the level. The way I did it was to trust the random deity and just get all the available empty spaces and use them as valid spots. I get this fairly often, because the number of enemies is also within a certain range:


Sometimes, enemies get clumped up together, or very near the player, but that’s just how it is. Sometimes you just wake up and happen to have something unpleasant near you. Sounds good enough and I’ll stick to that. If it’s random, random it shall be.

Next up, I decided to make it so that enemies get “activated” when the player gets in a certain range, like if the enemies would listen or see the player when he’d get near. It would be easy to just make the enemies rush towards the player immediately, but it is just better to let them behave a bit more fairly.

Currently, this is the full enemy AI script:

///Follow Player
  
if (distance_to_object(objPlayer)<200)
{
    xx1 = x;
    yy1 = y;
    if (mp_grid_path(global.grid, path, x, y, objPlayer.x + 8, objPlayer.y + 8, false))
    {
        xx1 = path_get_point_x(path, 1);
        yy1 = path_get_point_y(path, 1);
       
        if (position_empty(xx1, yy1))
        {
            x = xx1 - 8;
            y = yy1 - 8;
        }   
    }
}

 There is no combat logic and the pathfinding is basic as seen in the following picture:

The enemies just follow a straight line and stop until there’s enough room to move. Not having more spaces, they just stand there, not looking to get closer. I’ll have to fix that later.

Next, I’ll be adding the pickups, but first, a bit of an inventory needs to be put in place, and fortunately, I’ve already devoted some thought cycles into it. 😊

As previously posted, I want to make this simple, so there’s no need to create an immense list of gear, items, etc. for the player to find. I’ll just try to plug it in in a day or two, because there’s a lot of work to be done still.

Read you soon!

Comments

Log in with itch.io to leave a comment.

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?

-Spencer

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
TILESIZE = 16;
randomize();

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;

repeat(2500)

    if (scrChance(50))
    {
        dir = choose(90,270,180,0);
    }
    //Choose a direction at random
    switch(dir)
    {
        case 90:
            startY--;
            break;
        case 270:
            startY++;
            break;
        case 180:
            startX--;
            break;
        case 0:
            startX++;
            break;
    }
    //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!