This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-08-09 16:46:13

scratchU8
Scratcher
Registered: 2009-09-08
Posts: 100+

Scrolling Game-Squishable Enemy?

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

 

#2 2010-08-09 16:51:18

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Scrolling Game-Squishable Enemy?

What do you mean by costume sensing? You don't want to use a sensor sprite?


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2010-08-09 18:52:59

graham7sarah9
Scratcher
Registered: 2009-07-19
Posts: 28

Re: Scrolling Game-Squishable Enemy?

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

 

#4 2010-08-10 01:44:16

helltank
Scratcher
Registered: 2010-05-21
Posts: 1000+

Re: Scrolling Game-Squishable Enemy?

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.


Error:Signature could not load. Please wait for an indefinite amount of time, until you realize you're gullible and go off to look for another potentially interesting signature to stare at.

Offline

 

#5 2010-08-10 02:38:17

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Scrolling Game-Squishable Enemy?

Yup! Helltank's meathod probably works better...  hmm


Hai.

Offline

 

#6 2010-08-10 02:50:56

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Scrolling Game-Squishable Enemy?

except it's Y not X

Offline

 

#7 2010-08-10 04:44:49

helltank
Scratcher
Registered: 2010-05-21
Posts: 1000+

Re: Scrolling Game-Squishable Enemy?

Oops sorry!


Error:Signature could not load. Please wait for an indefinite amount of time, until you realize you're gullible and go off to look for another potentially interesting signature to stare at.

Offline

 

#8 2010-08-10 11:21:58

scratchU8
Scratcher
Registered: 2009-09-08
Posts: 100+

Re: Scrolling Game-Squishable Enemy?

Sorry to bother you, but how would that go into blocks?

Offline

 

#9 2010-08-10 14:35:13

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Scrolling Game-Squishable Enemy?

Here you go:

http://i33.tinypic.com/j7x3ia.gif

Last edited by Harakou (2010-08-10 14:35:40)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#10 2010-08-10 14:48:21

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Scrolling Game-Squishable Enemy?

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.)


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#11 2010-08-10 18:16:57

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Scrolling Game-Squishable Enemy?

Wouldn't a sensor sprite be so much easier?


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#12 2010-08-10 21:59:15

graham7sarah9
Scratcher
Registered: 2009-07-19
Posts: 28

Re: Scrolling Game-Squishable Enemy?

AtomicBawm3 wrote:

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.)

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

 

#13 2010-08-10 22:09:09

scratchU8
Scratcher
Registered: 2009-09-08
Posts: 100+

Re: Scrolling Game-Squishable Enemy?

Harakou wrote:

Here you go:

http://i33.tinypic.com/j7x3ia.gif

Wow, thanks! it works!

Offline

 

#14 2010-08-10 22:12:04

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Scrolling Game-Squishable Enemy?

scratchU8 wrote:

Harakou wrote:

Here you go:

http://i33.tinypic.com/j7x3ia.gif

Wow, thanks! it works!

No problem. Thank helltank for the script.  smile


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer