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

#1 2011-04-05 11:21:06

littlebird2472
Scratcher
Registered: 2010-03-05
Posts: 42

Lesson 1- Scrolling platformer game (Drewo8899)

Hi drew, I said i'd teach you to use scratch. First lesson: Scrolling(x) platformer game.

First, make your player and make a sprite called terrain0. make a variable called scrollX. Then, add this script to your terrain:
<when green flag clicked>
<forever>
<set x to( (( <{ ScrollX }> <+> (( 480 <*> 0 )) ))
<end>

That will make the platform scroll left and right when you move. Now add some more terrain but make sure the first terrain is 0. Do the same for other terrains and number them 1,2,3 etc. and in the scripts make 0 the terrain number. eg.

terrain 0 is the one above, 1 would be:
<when green flag clicked>
<forever>
<set x to( (( <{ ScrollX }> <+> (( 480 <*> 1 )) ))
<end>
. Notice how the last number changes? put the last number equal to terrain number. Start at 0, though!

Movement and jumping:

now, go to your player. Make this script for moving:

<when green flag clicked>
<forever>
<if> <key[ left arrow ]pressed?>
<change{ ScrollX }by( 10 )
<end>
<if> <key[ right arrow ]pressed?>
<change{ ScrollX }by( -10 )
<end>
<end>
If the player goes the opposite direction when an arrow is pressed, change the numbers around (10 - -10) and you can change the speed.
Now the jumping. (I will stop using the actual blocks):

When flag clicked
Forever
If Not touching colour (ground colour)
Change Y by -5
Else
If Key up(or space) key pressed
repeat 15   (can change to jump lower or higher)
change y by 5


Now test! If any errors, comment here!
Remember:
<forever>
<{ Imagine }>
<<  Program  >>
<Share>
<end>


http://dragcave.net/image/MoLDl.gif Please click and help my dragon survive!

Offline

 

Board footer