Pages: 1
Topic closed
I wanna make a sort of platform game but I don't know how you make the sprite move using the arrow keys. Please answer! I'm sooo confused!
Offline
[blocks]
<forever>
<if><key[ right arrow ]pressed?>
<change x by(5
<end>
<if><key[ left arrow ]pressed?>
<change x by(-5
<end>
<if><key[ up arrow ]pressed?>
<change y by(5
<end>
<if><key[ down arrow ]pressed?>
<change y by(-5
<end>
<end>
[/blocks]
Hope this helps
Last edited by HD123 (2010-08-08 07:12:28)
Offline
Try downloading this project :
http://scratch.mit.edu/projects/brinkbrink/1236389
Hope it helps!
Offline
you can also do scrolling,
try this:
http://scratch.mit.edu/forums/viewtopic.php?id=2440
hope that helps.
Last edited by jman13 (2010-08-08 22:57:44)
Offline
herers one a bit different
[blocks]<when green flag clicked>
<forever>
<if><key[ up ]pressed?>
<move( 5 )steps>
<end>
<if><key[ right ]pressed?>
<turn cw( 5 )degrees>
<end>
<if><key[ left ]pressed?>
<turn cw( -5 )degrees>
<end>
<end>
sorry! they are always so messy!
Offline
In any event, try to steer clear of the [When key "right arrow" pressed] block. The movement methods suggested by previous posters are much better
Offline
Telemachus wrote:
In any event, try to steer clear of the [When key "right arrow" pressed] block. The movement methods suggested by previous posters are much better
![]()
Do you mean the hat blocks? Yeah, stay away from those.
Offline
Harakou wrote:
Telemachus wrote:
In any event, try to steer clear of the [When key "right arrow" pressed] block. The movement methods suggested by previous posters are much better
![]()
Do you mean the hat blocks? Yeah, stay away from those.
![]()
hat blocks? i'm confused...
and are you talking about me above?
Last edited by chipguy (2010-08-09 17:42:01)
Offline
By hat blocks he means things like:
<when green flag clicked>
<when I receive[
and<when[ ]key pressed>
It executes the script once the event happens. All legitimate scripts must have a hat block or else there's no way to start it while playing the game.
The first two are alright but don't use the last one unless you have to. It's off timing.
See what I mean by making a script for a sprite like this:
<when[ up arrow ]key pressed>
<change y by( 10 )
Now, hold the up arrow key down.
Offline
graham7sarah9 wrote:
By hat blocks he means things like:
<when green flag clicked>
<when I receive[
and<when[ ]key pressed>
It executes the script once the event happens. All legitimate scripts must have a hat block or else there's no way to start it while playing the game.
The first two are alright but don't use the last one unless you have to. It's off timing.
See what I mean by making a script for a sprite like this:
<when[ up arrow ]key pressed>
<change y by( 10 )
Now, hold the up arrow key down.
Ah, yes, when you press the up arrow in this script it will execute it once, but if you were to put a repeat until not up arrow pressed, then it will assume that you are going to be holding down the arrow for more smooth movement.
Offline
murpho wrote:
^^^^ yeah and that script is so annoying
What do you mean by that.
Offline
It never works my sprite keeps going right instead of left,up,or down.
Offline
Topic closed
Pages: 1