I'm trying to make a scrolling game that when you jump on an enemy, it kills him, but if you touch him from the sides, it kills YOU. Just like Mario. Can anyone tell me how to do that without useing any costume sencing?
Offline
Measure the height of the sprite. Lets say that the top of the sprite is 12y at (0,0). So what you would do is you would have something along the lines of:
if touching player
{
playerX > x position && playerX < 16
{
squish code
}
else
{
player losing code
}
}
Edit: and by the way, I think he/she means sensing if it's jumping by looking at the costume it's using.
Last edited by graham7sarah9 (2010-08-09 18:54:05)
Offline
Or you can:
Forever
If touching sprite Enemy
If sprite Player's X position > sprite Enemy's X position
Broadcast Kill enemy
Else
Broadcast Die.
Offline
except it's Y not X
Offline
Oops sorry!
Offline
Harakou wrote:
Here you go:
http://i33.tinypic.com/j7x3ia.gif
I think it needs to be >y of enemy plus a bit.
(You could use half the height of your character plus half the height of the enemy.)
Offline
AtomicBawm3 wrote:
Harakou wrote:
Here you go:
http://i33.tinypic.com/j7x3ia.gifI think it needs to be >y of enemy plus a bit.
(You could use half the height of your character plus half the height of the enemy.)
Not necessarily. The sprite may not be on the correctly centered.
BTW I'm pretty sure there's a mistake in my code sample.
murpho wrote:
Wouldn't a sensor sprite be so much easier?
True, or of course he could make the sprite move so that there isn't as much lag due to threading as there is because of code size. That's what I always do anyways. Of course, if the code is asynchronous, it would be buggy. I always control everything with one script which delegates all the work everywhere.
Last edited by graham7sarah9 (2010-08-10 21:59:41)
Offline
Harakou wrote:
Here you go:
http://i33.tinypic.com/j7x3ia.gif
Wow, thanks! it works!
Offline
No problem. Thank helltank for the script.
Offline