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

#1 2011-05-16 20:05:09

Ralfiyell
New Scratcher
Registered: 2010-07-04
Posts: 7

How do I make it so Characters Can't go through Levels.

Could you please post the Script (and possibly explain how it works) That keeps characters from going through the the ground or other objects, without stopping movement scripts.

Thanks.

Offline

 

#2 2011-05-16 20:42:18

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: How do I make it so Characters Can't go through Levels.

Try something like this:

[forever]
[][if <key [right arrow] pressed?>]
[][][change x by (5)]
[][][if <touching color [terrain color]?>]
[][][][change x by (-5)]
[][][end if]
[][end if]
[end forever]


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#3 2011-05-16 20:58:55

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: How do I make it so Characters Can't go through Levels.

For the ground

[forever]
[][if <touching color [ground color]?>]
[][][change y by (1)]
[][else]
[][][change y by -1]
[][end if-else]
[end forever]

Try that. Its basically saying, if touching ground go up but if not then go down (gravity) and if touching ground go up but if not then go down... etc. etc. etc. (hence the forever).


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#4 2011-05-18 19:46:12

TehGuyYourStalking
New Scratcher
Registered: 2011-02-08
Posts: 3

Re: How do I make it so Characters Can't go through Levels.

For the ground, do this:

[when flag clicked]
[if <not <touching color [ground color]> >]
[change y by (-[Number. Higher the number, faster you fall.]) ]

Then make a jumping script:

[when [up arrow] key pressed]
[if <touching color [ground color]
[repeat (number)]
[change y by [number] ]

The above scripts will let you jump, and let you fall back down onto the ground.

It's a very simple script, but if you want to make it more complicated, you can change the jumping script so that it seems like there is gravity.

Hope this helped.  wink

Offline

 

Board footer