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

#1 2011-01-27 11:43:20

Scarstar999
Scratcher
Registered: 2010-05-23
Posts: 82

Help with Scrolling game

Hello!
I made my first scrolling game recently. Here is the link:
http://scratch.mit.edu/projects/Scarstar999/1557614
Someone suggested that I put in a script that says the sprite can jump only if it is touching black. I tried to do it, but it didn't quite work out. Will someone take a look at the scripts of my project and help me? The script looks like this:

http://i53.tinypic.com/ibexck.png

What did I do wrong?
Any advice will be appreciated! Thanks!

~Scarstar


http://i21.photobucket.com/albums/b263/edare9439/BelieveinStarClan.png
Go green, love nature, and stop animal cruelty! Be a Guardian of Ga'Hoole!

Offline

 

#2 2011-01-27 12:00:50

SAT3-H
New Scratcher
Registered: 2011-01-26
Posts: 8

Re: Help with Scrolling game

When green flag clicked
If touching color black
Forever
If key up arrow pressed and not not touching black
Change y by 10

Offline

 

#3 2011-01-27 12:06:15

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Help with Scrolling game

I would suggest doing it like this:
[blocks]<when green flag clicked>
<forever>
   <if><touching color[ black
      <if><key[ up arrow ]pressed?>
          <change y by( 10
      <end>
      <change y by( 1
   <else>
        <change y by( -1
   <end>
<end>[/blocks]
That way, it moves up if touching black, lots if jumping, and down if not.

Offline

 

#4 2011-01-27 20:53:33

nickbrickmaster
Scratcher
Registered: 2010-02-02
Posts: 500+

Re: Help with Scrolling game

You need a forever loop around it, or it just checks at the beginning to see if its touching black


Ask me what I'm doing, wait an hour than roll a die, if it's 4-6, I'm playing Skyrim, if it's 1, I'm eating, if it's 2-3 I'm programming.
Steam: nickbrickmaster | RotMG: PwnThemAll | Minecraft: nickbrickmaster | League Of Legends: BaneOfTitans

Offline

 

#5 2011-01-27 23:50:58

LordAwesome123
Scratcher
Registered: 2011-01-18
Posts: 100+

Re: Help with Scrolling game

Here is the script I use:

When flag is clicked
Forever
If key up arrow key is pressed
if touching color black
repeat 10
change y by 10

when flag is clicked
repeat untill tounching color black
change Y by -4


http://i672.photobucket.com/albums/vv82/coke457/cooltext538978807.png
When life gives you lemons... take them... free stuff is cool  smile

Offline

 

#6 2011-01-28 00:07:34

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Help with Scrolling game

you need to put forever around both (one around both)

or else it will check if black is there and then it will do forever or check if no black is there...

Offline

 

#7 2011-01-29 10:50:05

Scarstar999
Scratcher
Registered: 2010-05-23
Posts: 82

Re: Help with Scrolling game

nickbrickmaster wrote:

You need a forever loop around it, or it just checks at the beginning to see if its touching black

Yeah, I tried that, but it still jumps.  hmm


http://i21.photobucket.com/albums/b263/edare9439/BelieveinStarClan.png
Go green, love nature, and stop animal cruelty! Be a Guardian of Ga'Hoole!

Offline

 

#8 2011-01-30 06:15:42

HydraRancher
Scratcher
Registered: 2010-03-07
Posts: 9

Re: Help with Scrolling game

Do it like:

Code:

When Green Flag Pressed
   Forever
      If Up Arrow is Pressed
         Then
            If Touching Black
               Then
                   Change Y by 10
                Else
          Else

Offline

 

#9 2011-02-06 14:59:26

Scarstar999
Scratcher
Registered: 2010-05-23
Posts: 82

Re: Help with Scrolling game

Okay, thanks for evryone's help!!!


http://i21.photobucket.com/albums/b263/edare9439/BelieveinStarClan.png
Go green, love nature, and stop animal cruelty! Be a Guardian of Ga'Hoole!

Offline

 

Board footer