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

#1 2011-05-27 14:36:47

kglavan
New Scratcher
Registered: 2011-05-27
Posts: 1

game scripts

My class is in the middle of creating scratch games. The problem we have right now is that a student has a sprite that he wants to climb over a stone, say it is a black color and the sprite is a grey color. Is there an easy script to get it to stay on the black instead of bouncing off of it?

Offline

 

#2 2011-05-27 17:36:32

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

Re: game scripts

That's a little confusing...but I think what you mean is you want to have the sprite stop and climb the black rock instead of bouncing off?


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

Offline

 

#3 2011-05-27 19:50:21

jslomba
Scratcher
Registered: 2009-09-25
Posts: 1000+

Re: game scripts

kglavan wrote:

My class is in the middle of creating scratch games. The problem we have right now is that a student has a sprite that he wants to climb over a stone, say it is a black color and the sprite is a grey color. Is there an easy script to get it to stay on the black instead of bouncing off of it?

<when green flag clicked>
<forever>
<if><touching color[ black
<repeat until><<  <not> <touching color[ black >>
<change y by( 1
<end>
<end>
<end>

should work. I have a second, more advanced platformer engine if you want.

Last edited by jslomba (2011-05-27 19:54:28)


the the the the the

Offline

 

#4 2011-05-27 19:57:48

jslomba
Scratcher
Registered: 2009-09-25
Posts: 1000+

Re: game scripts

and if the goal is green, this would be a good script to put in the stage:

<when green flag clicked>
<forever if><color[ green ]is over[ gray
<next costume>
<end>

(except since the script is for the stage, it would be 'next background')


the the the the the

Offline

 

#5 2011-05-27 20:07:48

jslomba
Scratcher
Registered: 2009-09-25
Posts: 1000+

Re: game scripts

and if the ground is, let's say, brown, this would be a good script for the sprite:

<when green flag clicked>
<forever>
<if><< <touching color[ brown <and> <<  <not> <key[ up arrow ]pressed?> >> >>
<set y to( <y position>
<else>
<if><<  <not> <touching color[ brown >>
<change y by( -1
<if> << <touching color[ brown <and> << <key[ up arrow ]pressed?> >> >>
<repeat( 150
<change y by( 1
<end>
<repeat( 150
<change y by( -1
<end>
<end>
<end>

this would be if the up arrow was used to jump. Sorry about the unaligned scripts for this one, just do it like you normally would on scratch.

Last edited by jslomba (2011-05-27 20:09:58)


the the the the the

Offline

 

Board footer