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

#1 2013-01-15 20:47:54

cwoz
New Scratcher
Registered: 2013-01-12
Posts: 4

Move and jump at the same time?

Hi. I'm making a platform game, and I need some help. In one of the levels, the character has to jump over something. Right now, I have:

when gf clicked
forever
if <key [space v] pressed?>
change y by (30)
wait (1.5) secs
change y by (-30)
end
end
This allows me to jump, but I can't move left or right while jumping, so that I can jumper over the obstacle. If I do:
when [space v] key pressed
change y by (30)
wait (1.5) secs
change y by (-30)
then it lets me jump, "walk" on the air, and then fall back down at the designated time

How can I fix this problem?

Offline

 

#2 2013-01-15 21:54:40

chimoo5
New Scratcher
Registered: 2013-01-08
Posts: 18

Re: Move and jump at the same time?

You need your x position to change. I'm assuming you have a right and left  key pressed sprite.

when [right arrow v] key pressed 
repeat until <<key [rightarrow v] pressed ?> = [false]>
change x by [30]
wait [1.5] secs
change x by [30]
If not you can just put it in the jump and change nothing.

when gf clicked
forever
if <key [rightarrow v] pressed ?> 
change y by [30]
change x by [30]
wait [1.5] secs
change y by [-30]
change x by [30]
Change your values of x to your choice of course.

Offline

 

#3 2013-01-15 21:58:08

chimoo5
New Scratcher
Registered: 2013-01-08
Posts: 18

Re: Move and jump at the same time?

Sorry meant the second code to be

if <key [space v] pressed ?>

Offline

 

#4 2013-01-15 22:02:05

numberonegamers
Scratcher
Registered: 2012-07-12
Posts: 100+

Re: Move and jump at the same time?

When gf clicked
Forever
 If <key [space v] pressed>
  Repeat [50]
   Change y by [2]
    If <key [rightarrow v] pressed>
     Change x by [5]
    End
    If <key [leftarrow v] pressed>
     Change x by [-5]
    End
  End
  Repeat until <touching [floor v]>
   Change y by [-2]
    If <key [rightarrow v] pressed>
     Change x by [5]
    End
    If <key [leftarrow v] pressed>
     Change x by [-5]
    End
   End
  End

Hope that helps

Last edited by numberonegamers (2013-01-15 22:07:55)

Offline

 

#5 2013-01-15 22:17:19

undefeatedgames
Scratcher
Registered: 2011-05-22
Posts: 1000+

Re: Move and jump at the same time?

I'm guessing you want to use the one button to move and jump at the same time...

So...

when gf clicked
forever
if <key [space v] pressed?>
change x by (10)
change y by (30)
wait (1.5) secs
change y by (-30)


Please call me udg or bearsfan, not undefeated.
Scratch and Misc.! Click here for Misc.'s Successorhttps://lh3.googleusercontent.com/-jkhes3yzmQk/T7G_BnxT9xI/AAAAAAAABYI/xhoN1Jk2M08/s513/sigp1.gif

Offline

 

#6 2013-01-15 22:21:42

cwoz
New Scratcher
Registered: 2013-01-12
Posts: 4

Re: Move and jump at the same time?

What I need is:
Space = jump straight up
Right/ left arrow key = move right or left
Space + right/ left arrow = diagonal

I can do each one separately, but they won't work when done together...

Offline

 

#7 2013-01-17 12:11:28

Sqervay
New Scratcher
Registered: 2012-10-28
Posts: 52

Re: Move and jump at the same time?

You have to make all the [if 'key pressed'] in ONE [forever] block, then they work when you press them togethter. I would show you it, but I don't know how to make scratch blocks... I hoped this helps

Offline

 

Board footer