• 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!

How do i make an enemy tower?

G

GamingDragomachina

Guest
Me... again.. I am completely lost on how to program stackable enemies. I want to be able to stack my enemies, similar to how goombas stack in Mario. Where they all move as one tower of enemies. I'm using drag and drop to make my platforming game, and i tried looking for this information online but i couldn't find anything about making enemies stack like this. Again, Any help is appreciated.
 
Z

zendraw

Guest
you can make a variable which holds the ID of the goomba below and if there is such a goomba set this goomb`s X to the goomba X that you have storet its ID, and this goombas Y to that goomba`s Y- certain amount of pixels.
 
B

Bayesian

Guest
Have the goomba check for collision with other goombas below it and if there is collision stop moving down and disable all its movement code. Then you need to check if there is collision above the goomba and if there is carry that top goomba when the bottom goomba moves using a with statement for the top goomba. You can make the collision check and carry code a script and put it inside itself so that it chains all the way up the tower of goombas.
 
G

GamingDragomachina

Guest
you can make a variable which holds the ID of the goomba below and if there is such a goomba set this goomb`s X to the goomba X that you have storet its ID, and this goombas Y to that goomba`s Y- certain amount of pixels.
Can you explain that a little more please..? ^^" i don't totally understand it.
 
Z

zendraw

Guest
a variable holds information,
every instance in the game like your goombas have an information which is theyr ID
you set that variable to whatever is below your goomba, and if there is a goomba you just stick your goombas position relative to that below

if (instance_exists(goomba))
{
x=goomba.x;//so we are on the same place horizontally
y=goomba.y-64;//so we are 64 pixels above the goomba
} else
{
//whatever code your goomba has. we dont want it to use that code if it is attached to the goomba tower
}
 
B

Bayesian

Guest
that is a bad and inefficient way of doing this
How?

Code:
if (instance_exists(goomba))
{
x=goomba.x;//so we are on the same place horizontally
y=goomba.y-64;//so we are 64 pixels above the goomba
} else
{
//whatever code your goomba has. we dont want it to use that code if it is attached to the goomba tower
}
x=goomba.x needs to be an ID of the goomba that's below you. You can't do this top to bottom anyway because then they will slide around. The bottom goomba need to finish moving then move the top goobmas

Code:
var inst = instance_place(x,y-1,oGoomba);
var dif = x - inst.x;
dif = Approach(dif,0,1);
inst.x=x+dif;
Code:
/// Approach(start, end, shift);

if (argument0 < argument1)
   return min(argument0 + argument2, argument1);
else
   return max(argument0 - argument2, argument1);
Put that in a script and chain it up the tower
 
Z

zendraw

Guest
well he will get the id of the goomba below... and wether he does it top to bottom or bottom to top it doesnt matter, maybe he wants them to slide abit. your way is still not good. if he wants them to move like a column then when he gets the id of the goomba below, he doesnt get the id of the goomba below, but asks if that goomba has an OWNER variable set to a goomba and if it doesnt it sets its own OWNER variable to that goomba, but if it does have an owner it sets its owner to that owner and so all goombas no matter where they are set theyr variables based on the bottom goomba.

PS: this to work in all scenarios needs more code but the idea is there. and the basic idea is to save ids and not bottleneck the game with collisions and unnececery code.
 
B

Bayesian

Guest
wether he does it top to bottom or bottom to top it doesnt matter, maybe he wants them to slide abit.
It does matter because like I said they will slide around when they change directions. He probably doesn't want that to happen.

Your method isn't compatible with smoothly center aligning the tower. You need to get the offset for each layer
 
Z

zendraw

Guest
It does matter because like I said they will slide around when they change directions. He probably doesn't want that to happen.

Your method isn't compatible with smoothly center aligning the tower. You need to get the offset for each layer
well read my method again, its most simple and most accurate, you need the offset only if the offset is diffrent for every single goomba, which is not a problem, there is a variable for that and its a simple and obvious calculation, which generally is a detail that the programmer will take into account when he gets to work, its not a method changer.
 
Top