0 Favourites

Mario style: Jump on top of enemy to kill it

  • Just wondering how I'd make the enemy die when I jump on top of it, but let me die when I hit the sides.

    I just need a quick explanation of the code, can't for the life of me figure this out.

  • Maybe an event that says,

    IF player.Y is > Monster.Y

    AND IF player is overlapping monster

    -Destroy monster

    IF player.Y <= Monster.Y

    AND IF player is overlapping monster

    -Destroy player

    etc etc etc Refine as needed :) Of course, if you don't have the monster or the player bump back on a bad contact, you will murder the player instantly regardless of health.

    Also, my above sample doesn't take the angle of approach, so as long as the player is above and touching the monster, the monster is doomed.

  • A simple way:

    + Player collides with enemy

    + Player.Y < Enemy.Y (i.e. player is above enemy)

    -> Player has jumped on enemy's head, kill enemy...

    + Player collides with enemy

    + Player.Y >= Enemy.Y (i.e. player is not above enemy)

    -> Player has run in to enemy, take damage...

  • Thanks guys, makes sense! :)

  • This is roughly how I'd do it. Here's an explanation of how to do it:

    Create a small black platform and an enemy. Let's call the platform "GoombaTop" and the enemy "Goomba". Set the hotspot of the "Goomba" sprite to a little above his head. Set the initial visibility of "GoombaTop" to invisible. Now, go to the event sheet. (We'll call your character "Mario", who should have platform behavior, and the ability to jump, using 8-Direction Movement, or however you know how to make him jump.)

    Make this event: System->Every Tick.

    Make this action for the above event: GoombaTop->Set Position->X: Goomba.X Y: Goomba.Y

    (This makes it so that GoombaTop stays above Goomba's head.)

    Make this event: Mario->On Collision With Another Object->GoombaTop

    Make these actions for the above event: Goomba->Destroy

    GoombaTop->Destroy

    (This makes it so jumping on GoombaTop kills the Goomba)

    Make this event: Goomba->On Collision With Another Object->Mario

    Make these actions for the above event: Mario->Destroy

    System->Wait->1.0 Seconds

    System->Go To Layout->Layout 1

    (This makes it so that if Mario makes contact with the side of Goomba, he dies.)

    To make another Goomba, create "Goomba2" and "GoombaTop2", set the properties of "Goomba2" to those of "Goomba", set the properties of "GoombaTop2" to those of "GoombaTop", and create all of the same actions and events, except replacing "Goomba" with "Goomba2" and replacing "GoombaTop" with "GoombaTop2".

    Hope this helped!!

  • awesome8x, that's one way of doing it, but the other way saves you having to create and position those 'detector' objects.

  • Clever. But what happens, when the Player is major than the enemy?

  • this works

    player platform "isfalling"

    • on collison with enemy > destroy

    http://dl.dropbox.com/u/36224287/platform_jumpkill.capx

  • by "major" I understand "taller"

    That's not an issue if you put the origin at feet level

  • Damn. Your are right. <img src="smileys/smiley20.gif" border="0" align="middle" />

  • awesome8x, that's one way of doing it, but the other way saves you having to create and position those 'detector' objects.

    The benefit though is that the detector method allows you to have the enemy killed only at the point you desire. For instance many times you may be above the enemy but still hitting a part of the enemy that should hurt you (in this case, touching the side of the Goomba's face while you're falling should hurt you and not kill the Goomba).

  • woot this works. Isfalling is great.

    lol while messing around I figured out how to make your player bounce when he jumps on a target.

    add another action for the player and set the platform vector y to -500 or what ever desired result you want.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Ashley

    where do you find the expression

    Player.Y < Enemy.Y

    and

    Player.Y >= Enemy.Y

  • Weazl: Those are conditions.

    In your example, select the player and select "Compare Y position".

  • i would make 3 image points. Or 3 invisible boxes that are attached to the enemy. 2 boxes for the sides and 1 for the head. Once the player jumps on the head destroy enemy and maybe change the y vector in the plaform properties to make the main character jump a little. when the player touches the side of the enemy damage player or lose a life.

    I think that would be the easy way of doing it.

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