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

#1 2013-02-27 23:51:41

Chaemi
New Scratcher
Registered: 2013-02-27
Posts: 1

Arrow Keys

How can I make thing jump while making a game?

Offline

 

#2 2013-02-28 01:57:26

derpbread
New Scratcher
Registered: 2013-02-28
Posts: 2

Re: Arrow Keys

obviously starting with 'when X key pressed';
you can try modelling gravity (need to use your own variables, quite complicated) or you could do it a simple way with something like
'when up arrow key pressed'
'move 50 in y direction'
'wait 0.1 seconds'
'move -50 in y direction'

Offline

 

#3 2013-02-28 11:55:47

sunmount
New Scratcher
Registered: 2013-02-28
Posts: 2

Re: Arrow Keys

you can also do this:

when [up arrow] key pressed
point in direction [0]
move [10] steps
or, if you want to go down,

when [down arrow] key pressed
point in direction [180]
move [10] steps
left is this:

when [left arrow] key pressed
point in direction [-90]
move [10] steps
and right is this:

when [right arrow] key pressed
point in direction [90]
move [10] steps
hope this helps!

Offline

 

#4 2013-02-28 19:30:18

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Arrow Keys

Here's a way to do a gravity way, and it's not complicated.  smile

Just do this:

For gravity:

when gf clicked
forever
change y by (-5)
end
And then for the character:



when gf clicked
if <key [up arrow v] pressed?>
repeat (10)
change y by (10)
end
end
That should work.

Hope that helps,

CAA14

Last edited by CAA14 (2013-02-28 19:30:35)

Offline

 

#5 2013-02-28 19:32:27

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Arrow Keys

sunmount wrote:

you can also do this:

when [up arrow] key pressed
point in direction [0]
move [10] steps
or, if you want to go down,

when [down arrow] key pressed
point in direction [180]
move [10] steps
left is this:

when [left arrow] key pressed
point in direction [-90]
move [10] steps
and right is this:

when [right arrow] key pressed
point in direction [90]
move [10] steps
hope this helps!

That's a good script, but not for jumping. The problem with this is that the character would be able to "jump" as high as they wanted to and never come down. This is good when you are making an overhead game.  smile

Regards,

CAA14

Offline

 

Board footer