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

#1 2009-03-02 15:24:20

Flashan
Scratcher
Registered: 2009-03-02
Posts: 4

Please HELP!

For my I.T Homework I need to design a game. I am quite good with computers but new to scratch. I have designed my game but need a little help with the programming. I want a character to walk off the screen and change the stage background. I have a sprite called "wall" that when touched, will change the stage.
Here is my code so far:

<when green flag clicked>
<forever>
<if><touching[ Wall

Thank You,

Flashan

Offline

 

#2 2009-03-02 18:00:44

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Please HELP!

Flashan wrote:

For my I.T Homework I need to design a game. I am quite good with computers but new to scratch. I have designed my game but need a little help with the programming. I want a character to walk off the screen and change the stage background. I have a sprite called "wall" that when touched, will change the stage.
Here is my code so far:

<when green flag clicked>
<forever>
<if><touching[ Wall

Thank You,

Flashan

After
<when green flag clicked>
<forever>
<if><touching[ Wall

Try adding a broadcast block like this:
<broadcast[ change stage

The stage can then receive the message with

<when I receive[ change stage
<next costume>

Offline

 

#3 2009-03-02 19:42:51

bosox397
Scratcher
Registered: 2008-02-17
Posts: 1000+

Re: Please HELP!

or if there are different stages u need a swith to costume block. But it would work better if ur script is this

<when green flag clicked>
<wait until><touching[ wall
<broadcast[ switch

and then the stages script:

<when I receive[ switch
<switch to costume[ costume2

Last edited by bosox397 (2009-03-02 19:44:34)


Dear Scratch Users,
I'm done with scratch, or at least making projects. I have made one last big game, thats both fun and teaches a lesson about water. It'd mean a lot if you gave me feedback.                              http://scratch.mit.edu/projects/bosox397/569201

Offline

 

#4 2009-03-03 06:56:32

yambanshee
Scratcher
Registered: 2007-11-06
Posts: 500+

Re: Please HELP!

refrain from broadcasts. Rather do something like
[blocks]
<when green flag clicked>
<forever>
  <if><touching[ wall ]>
    <set{ Background }to( 1 )
  <end>
<end>

and then the stage's script:

<when green flag clicked>
<forever>
   <switch to costume[ <{ Background }>
<end>
[/blocks]
this way, many diffrent broadcasts can be replaced by 1 variable

Last edited by yambanshee (2009-03-03 06:58:03)

Offline

 

#5 2009-03-03 09:46:02

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Please HELP!

No, none of these will work.  sad   The script does not wait until the sprite doesn't touch the edge of the screen, and goes on forever.  Here is the correct way(with variables):

"Wall" Sprite: [blocks]
<when green flag clicked>
<forever>
<if><touching[ character ]>
<wait until> <<  <not> <touching[ wall ]>  >>
<set{ bg }to( any )>
<end>
<end> [/blocks]

For "Character" Sprite:
<when green flag clicked>
<forever>
<if> <touching[ wall ]>
<go to x sad  any )y sad  any )>
<end>
<end>

For the Background: [blocks]
<when green flag clicked>
<forever>
<switch to costume[ <{ bg }> ]>
<end>

Last edited by Greatdane (2009-03-03 09:50:32)


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#6 2009-03-03 09:49:46

Flashan
Scratcher
Registered: 2009-03-02
Posts: 4

Re: Please HELP!

Thanks,
You have helped me alot with my I.T HomeWork.

Flashan

Offline

 

#7 2009-03-03 09:50:59

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Please HELP!

You're welcome. (For whatever I did, anyways  tongue )


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#8 2009-03-03 18:19:34

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Please HELP!

Greatdane wrote:

No, none of these will work.  sad   The script does not wait until the sprite doesn't touch the edge of the screen, and goes on forever.  Here is the correct way(with variables):

"Wall" Sprite: [blocks]
<when green flag clicked>
<forever>
<if><touching[ character ]>
<wait until> <<  <not> <touching[ wall ]>  >>
<set{ bg }to( any )>
<end>
<end> [/blocks]

For "Character" Sprite:
<when green flag clicked>
<forever>
<if> <touching[ wall ]>
<go to x sad  any )y sad  any )>
<end>
<end>

For the Background: [blocks]
<when green flag clicked>
<forever>
<switch to costume[ <{ bg }> ]>
<end>

Why won't ours work? He just wants the background to change when a sprite touches the screen. I think that your method with variables is way better, but on the wall sprite, you said <wait until><<  <not> <touching[ character >> .
Shouldn't it be <<  <not> <touching[ character >>  ?

Anyways . . .

Offline

 

#9 2009-03-16 13:32:02

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Please HELP!

Oh, sorry. It's a long and complicated script, and everyone makes a few typos sometimes.  smile

Last edited by Greatdane (2009-03-16 13:33:50)


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#10 2009-03-16 13:34:35

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Please HELP!

And I guess I was thinking the wrong way... You are saying it does not switch to the NEXT background, but rather to A background.


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#11 2009-03-16 18:17:55

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Please HELP!

Greatdane wrote:

No, none of these will work.  sad   The script does not wait until the sprite doesn't touch the edge of the screen, and goes on forever.  Here is the correct way(with variables):

"Wall" Sprite: [blocks]
<when green flag clicked>
<forever>
<if><touching[ character ]>
<wait until> <<  <not> <touching[ wall ]>  >>
<set{ bg }to( any )>
<end>
<end> [/blocks]

It'd be better as:

[blocks]
<when green flag clicked>
<forever>
<if><touching[ character ]>
<set{ bg }to( any )>
<wait until> <<  <not> <touching[ wall ]>  >>
<end>
<end> [/blocks]

So it executes the code inmediately, but to execute it again, the player has to move and touch it again. Rather than waiting for the player to stop touching the wall to execute.


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

Board footer