1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

How do i make an enemy tower?

Discussion in 'Programming' started by GamingDragomachina, Jun 29, 2019.

  1. GamingDragomachina

    GamingDragomachina Member

    Joined:
    Jan 2, 2019
    Posts:
    15
    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.
     
  2. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,376
    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.
     
  3. Bayesian

    Bayesian Member

    Joined:
    Sep 13, 2016
    Posts:
    423
    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.
     
  4. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,376
    that is a bad and inefficient way of doing this
     
  5. GamingDragomachina

    GamingDragomachina Member

    Joined:
    Jan 2, 2019
    Posts:
    15
    Can you explain that a little more please..? ^^" i don't totally understand it.
     
  6. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,376
    how much do you know about coding anyway
     
  7. GamingDragomachina

    GamingDragomachina Member

    Joined:
    Jan 2, 2019
    Posts:
    15
    ... Almost none. Thats why i'm using drag and drop.
     
  8. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,376
    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
    }
     
  9. Bayesian

    Bayesian Member

    Joined:
    Sep 13, 2016
    Posts:
    423
    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
     
  10. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,376
    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.
     
  11. Bayesian

    Bayesian Member

    Joined:
    Sep 13, 2016
    Posts:
    423
    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
     
  12. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,376
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice