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

#1 2012-07-26 12:59:22

Kajunkat
Scratcher
Registered: 2012-06-30
Posts: 37

Help With Jumping!

Can someone download my game and make my horse sprite jump and come back down? PLEASE!!!!

Offline

 

#2 2012-07-26 16:15:54

Take2
Scratcher
Registered: 2012-07-25
Posts: 29

Re: Help With Jumping!

What key would you want to press to make it jump? Or do you want to make it jump when something happens?

Key Press script:

When [This Key v] Pressed
Change y by (10) //The number is how far you want it to jump
Wait (1) secs
Change y by (-10) //Add the " - " sign in front of your original number.
If something happens to make it jump:


When I Receive [Something Happens v]
Change y by (10) //The number is how far you want it to jump
Wait (1) secs
Change y by (-10) //Add the " - " sign in front of your original number.

Offline

 

#3 2012-07-26 16:18:56

Take2
Scratcher
Registered: 2012-07-25
Posts: 29

Re: Help With Jumping!

Wait, sorry. Here's the first script:


When [Space v] Pressed //Whatever key
Change y by (10) //The number is how far you want it to jump
Wait (1) secs
Change y by (-10) //Add the " - " sign in front of your original number.
By the way, that's just a choppy way to make it jump. There's this whole thing about gravity and velocity, and so forth that's really long. But this is just a beginner's way.

Also, I'm a test account. I'm not really a 'New Scratcher'.

Offline

 

#4 2012-07-26 23:55:55

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Help With Jumping!

It's late and I have to go to bed really soon, so I can't leave any script or look at your project (sorry), but I can leave you this link to the wiki article on jumping.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#5 2012-07-27 08:22:44

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help With Jumping!

The way I will show you uses gravity. I also added ways to glide, but you can easily remove them.
first make a variable named VelocityX and VelocityY

then implement this code.
Where it says a color, just add the color of your floor.  smile 


when gf clicked

forever  

if <key [left arrow v] pressed?> 

change [velocityX v] by (-1)

end

if <key [right arrow v] pressed?> 

change [velocityX v] by (1)

end

if <key [up arrow v] pressed?> 

set [velocityY v] to [10]

end

if <touching color [#636363]?> 

set [velocityY v] to [1]

end

change x by (velocityX)

change y by (velocityY)

set [velocityX v] to ((velocityX) * (0.9))

change [velocityY v] by (-1)

end

And if you do not want to glide, add this code.


when gf clicked

forever  

if <key [up arrow v] pressed?> 

set [velocityY v] to [10]

end

if <touching color [#636363]?> 

set [velocityY v] to [1]

end

change y by (velocityY)

change [velocityY v] by (-1)

end

This is how I genreally make my sprites jump.
I hope I helped  smile

Last edited by daniel_j (2012-07-27 08:24:14)


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

Board footer