• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Help with a concept

I need help with developing a shooting system for an array of enemy similar to that of a space invaders game. I need an adaptive system that can shoot in 4 cardinal directions based on player position. Say we have an array of 10x10

+++++++++
+++++++++
+++++++++
+++++++++
+++++++++
+++++++++
+++++++++
+++++++++
+++++++++
+++++++++


Now only the "bottom" most enemies must fire. I already have detections for where the player is. Now the player can destroy any of these enemies from different angles. This creates holes in the pattern. What I need is a way for the enemies to be able to fire and not hit into each other, akin to the space invaders game. I am having difficulty in figuring out how to do the appropriate checks for this.
 
N

NeZvers

Guest
@Siolfor the Jackal but what if there`s a gap bigger than 1?
I'd suggest to have for loop checking up to 9 times below and if it finds other invader sets variable that doesn't allow shooting and use break; to get out of for loop.
 
T

TimothyAllen

Guest
given you have an array, I would go with the for loop suggestion as it should be more efficient... in a controller object, pseudo
Code:
// Fire down
for x, 0 to array_width - 1:
    for y, array_height - 1 to 0:
        enemy = array[xx, yy]
        if enemy:
            enemy.fire(270)
            break
 
Top