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

#1 2008-12-03 23:13:04

L-GamesInc
Scratcher
Registered: 2008-12-02
Posts: 10

How to do this?

How can I get a sprite, in a game, to only go to a specific x position and the sprite can't go past it. How can I do this using Scratch?


I like cream cheese and video games (including programming them with scratch!)

Offline

 

#2 2008-12-04 06:04:21

bhz
Scratcher
Registered: 2008-07-06
Posts: 100+

Re: How to do this?

Sprite does not go to the right of x:150

<if><( 150 <<> <x position> )>
<set x to( 150
<end>[/blocks]

Sprite does not go to left of x:-150

<if><( <x position> <<> -150 )>
<set x to( -150
<end>[/blocks]

Offline

 

#3 2008-12-04 11:46:33

L-GamesInc
Scratcher
Registered: 2008-12-02
Posts: 10

Re: How to do this?

How can I make a sprite die if the other sprite jumps on it, but if it touches the sprite without jumping, it loses a live? Would I do this:
<when green flag clicked>
<forever if><<<touching[ Sprite1 ]  <and>  <(<{ Sprite1-X }>  <>>  <x position>)>>>
<hide>
<end>


I like cream cheese and video games (including programming them with scratch!)

Offline

 

#4 2008-12-04 13:36:42

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: How to do this?

If your sprite changes costume when it jumps, then you could check for "If touching" AND "Costume 2"


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#5 2008-12-04 17:42:08

bhz
Scratcher
Registered: 2008-07-06
Posts: 100+

Re: How to do this?

Mayhem wrote:

If your sprite changes costume when it jumps, then you could check for "If touching" AND "Costume 2"

If not, make the feet a different color. And in the enemy:

<if><touching color[ feet color
<hide>
<else>
<if><touching[ player
<change{ lives }by( -1
<end>
<end>

Last edited by bhz (2008-12-04 17:44:45)

Offline

 

#6 2008-12-05 23:01:32

tharvoil
Scratcher
Registered: 2008-10-24
Posts: 24

Re: How to do this?

Hm Id prob have a varible to use for this e.g
When jumping costumes ect happen add:
<set{ jumping }to( 1)>
then when he lands
<set{ jumping }to( 0)>

In the other code:
<if><( <{ jumping }> <=> 1 )>
<hide>
<else>
<change{ damage }by( 1)>

Offline

 

#7 2008-12-06 04:05:26

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: How to do this?

tharvoil wrote:

Hm Id prob have a varible to use for this e.g
When jumping costumes ect happen add:
<set{ jumping }to( 1)>
then when he lands
<set{ jumping }to( 0)>

In the other code:
<if><( <{ jumping }> <=> 1 )>
<hide>
<else>
<change{ damage }by( 1)>

That was my first thought, but if the characters costume changes you can, in fact, use it just like a variable, saving yourself the need to create an extra one.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

Board footer