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

#1 2012-08-22 17:21:39

Pitusky12
Scratcher
Registered: 2011-09-21
Posts: 500+

Go to left ,right,jump but affected by gravity.

How do I make my sprite move to the left ,right,jump,  but affected by gravity?
Post below a script.


Scratch 2.0 Beta Tester  wink

Offline

 

#2 2012-08-22 17:47:45

powerpoint56
Scratcher
Registered: 2012-04-19
Posts: 500+

Re: Go to left ,right,jump but affected by gravity.

Try this:

when gf clicked
forever
if <<key [up-arrow v] pressed?> and <touching [ground v]?>>
set [y-velocity v] to (10) // or any other positive num. you want
end
if <not<touching [ground v]?>>
change [y-velocity v] by (-0.4) // or any other negative num. you want
end
if <key [right-arrow v] pressed?>
change [x-velocity v] by (0.2) // top comment
end
if <key [left-arrow v] pressed?>
change [x-velocity v] by (-0.2) // second-to-top comment
end
set [x-velocity v] to ((x-velocity) * (0.9))
set [y-velocity v] to ((y-velocity) * (0.96))
change x by (x-velocity)
change y by (y-velocity)
end
Hope this helps!

(Check out this wiki article; it's very helpful)

Last edited by powerpoint56 (2012-08-22 20:26:00)


http://i48.tinypic.com/2072ctw.gif

Offline

 

#3 2012-08-22 18:01:51

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Go to left ,right,jump but affected by gravity.

powerpoint56 wrote:

Try this:

when gf clicked
forever
if <<key [up-arrow v] pressed?> and <touching [ground v]?>>
set [y-velocity v] to (10) // or any other positive num. you want
end
if <not<touching [ground v]?>>
change [y-velocity v] by (-0.4) // or any other negative num. you want
end
if <key [right-arrow v] pressed?>
change [x-velocity v] by (0.2) // top comment
end
if <key [left-arrow v] pressed?>
change [x-velocity v] by (-0.2) // second-to-top comment
end
set [x-velocity v] to ((x-velocity) * (0.9))
set [y-velocity v] to ((y-velocity) * (0.96))
change x by (x-velocity)
change y by (y-velocity)
Hope this helps!

(Check out this wiki article; it's very helpful)

Added/changed a few things.


http://i46.tinypic.com/35ismmc.png

Offline

 

#4 2012-08-22 19:42:57

Pitusky12
Scratcher
Registered: 2011-09-21
Posts: 500+

Re: Go to left ,right,jump but affected by gravity.

ErnieParke wrote:

powerpoint56 wrote:

Try this:

when gf clicked
forever
if <<key [up-arrow v] pressed?> and <touching [ground v]?>>
set [y-velocity v] to (10) // or any other positive num. you want
end
if <not<touching [ground v]?>>
change [y-velocity v] by (-0.4) // or any other negative num. you want
end
if <key [right-arrow v] pressed?>
change [x-velocity v] by (0.2) // top comment
end
if <key [left-arrow v] pressed?>
change [x-velocity v] by (-0.2) // second-to-top comment
end
set [x-velocity v] to ((x-velocity) * (0.9))
set [y-velocity v] to ((y-velocity) * (0.96))
change x by (x-velocity)
change y by (y-velocity)
Hope this helps!

(Check out this wiki article; it's very helpful)

Added/changed a few things.

Thanks!


Scratch 2.0 Beta Tester  wink

Offline

 

Board footer