How do I make Super Mario Bros 2 styled throwing system?

0 favourites
  • 9 posts
From the Asset Store
A collection of various characters spritesheets for creating a 2D top down, RPG, tower defense, or other similar game.
  • Hi,

    Like topic says, I'm currently making smb2 styled game, where player can pick up items/things or enemies and throw them. I have implemented throw -mechanic in the game and it is working fine :)

    Now I'm implementing destroying -mechanic. Throwing an item against an enemy will destroy the enemy. That was an easy task to make to implement BUT I'm having a hard time figuring out how to do the same with the enemy. I mean, when player throw an enemy against another enemy, both of them should be destroyed (like in smb2). I can destroy the enemy which was thrown, because I have set an boolean variable, which tells when enemy is picked up (actually picked up in-game) but I can't destroy the other enemy (the one which receive the hit and is on the ground).

    I'm using families on items and enemies. Both are in their own families. I know I have to tell construct 2 which enemy is receiving the hit and that is the problem. I can't figure out how I can pick that enemy, who was walking on the ground. I feel like I have tried everything. I have tried to put destroying -mechanic into a function, set another boolean, pick nearest enemy which was not thrown etc and nothing works like I want to.

    My current events looks something like this:

    1# items -family: is picked up, on collision with enemies -family = destroy enemies -family.

    2# enemies -family: is picked up, on collision with enemies -family = destroy enemies -family.

    I hope my mumbling makes sense. Anyone want to help me out with this one? I would really appreciate any kind of help ^^

  • there should an easier way, but should be able this way:

    create a global variable - destroy

    enemy on collision with enemy

    -- enemy is picked up

    system set destroy to "yes"

    -- destroy is "yes"

    enemy destroy

    -- system every tick (or empty subevent)

    set destroy to "no"

    where -- stands for subevent

  • Thank you, it's working ^^

  • LittleStain, you code is working perfectly. Currently I'm trying to improve the mechanics. When I throw an enemy against another enemy, that thrown enemy is be able to destroy multiple enemies (like in smb2) after thrown.

    I'm having another problem with the collision checks and pretty much with everything :/

    My current code is like this:

    I checker this forum post and I tried to implement that example scirra.com/tutorials/797/how-to-handle-instances-of-same-sprite-collision-colliding into my project. I made it to work but it's still doing the same as previously: both enemies are destroyed.

    Code for this like so:

    So my question is: how I make that thrown enemy can hit multiple enemies when thrown? Clearly I'm missing something here (again) and (again) any kind of help would be highly appreciated.

  • What was wrong with the code in your first example?

    Forgive me if I'm wrong, but I don't see need for using instance1 and instance0 in this case for they are easily distinguishable by their instance variables..

  • There's nothing wrong with the code itself. Currently, when an enemy collides with another enemy, both are destroyed. Which was fine. Now, like I mentioned earlier, I'm trying to do mechanic that when an enemy is thrown and collides with another enemy both are killed BUT the enemy which was thrown, can collide with another enemy and kill it. Like a chain reaction kind of thing.

    And mont probably I'm trying to do everything in a overcomplicated way :/

  • In your first example I don't see any actions destroying your smallenemies..

    All I see is a set collisions disabled action, which you could remove for the isthrown instance and it would still collide with another smallenemies instance..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I figured it out

    Thank you for your capx -example. I will check it after I backup all my project files and upgrade construct2.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)