Mario style: Jump on top of enemy to kill it Forum Home > Construct 2 General > How do I....? |
Post Reply
|
Page 12> |
| Author | |
Post Options
Quote Reply
Topic: Mario style: Jump on top of enemy to kill itPosted: 10 Sep 2011 at 11:04pm |
|
|
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. |
|
![]() |
|
Post Options
Quote Reply
Posted: 10 Sep 2011 at 11:25pm |
|
|
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. |
|
![]() |
|
Post Options
Quote Reply
Posted: 10 Sep 2011 at 11:25pm |
|
|
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... |
|
![]() |
|
Post Options
Quote Reply
Posted: 10 Sep 2011 at 11:30pm |
|
|
Thanks guys, makes sense! :)
|
|
![]() |
|
Post Options
Quote Reply
Posted: 11 Sep 2011 at 12:07am |
|
|
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!! Edited by awesome8x - 11 Sep 2011 at 12:13am |
|
![]() |
|
Post Options
Quote Reply
Posted: 11 Sep 2011 at 1:15am |
|
|
@awesome8x, that's one way of doing it, but the other way saves you having to create and position those 'detector' objects.
|
|
![]() |
|
Post Options
Quote Reply
Posted: 06 Nov 2011 at 9:46pm |
|
|
Clever. But what happens, when the Player is major than the enemy?
|
|
![]() |
|
Post Options
Quote Reply
Posted: 06 Nov 2011 at 10:23pm |
|
|
this works
player platform "isfalling" - on collison with enemy > destroy http://dl.dropbox.com/u/36224287/platform_jumpkill.capx Edited by Tom - 15 Jan 2012 at 7:39pm |
|
![]() |
|
Post Options
Quote Reply
Posted: 06 Nov 2011 at 10:24pm |
|
|
by "major" I understand "taller"
That's not an issue if you put the origin at feet level |
|
![]() |
|
Post Options
Quote Reply
Posted: 07 Nov 2011 at 8:34am |
|
|
Damn. Your are right.
|
|
![]() |
|
Post Reply
|
Page 12> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |