Please help, not clear!
Offline
Offline
no one likes answering gravity questions properly...... with sceen shots..... same happened to me,,,,,
Offline
Fine, I'll answer it "properly". What sort of gravity? Like Earth-and-moon or person-and-Earth?
Offline
Normally it's like this:
when gf clicked set [yvel v] to [0] forever if <touching [ground v]?> if <(0?) = [1]> //only necessary if you have jumping. set [yvel v] to [0] //or 1 if you're not using the nice slope physics. end set [0? v] to [0] //again only if there's jumping involved else change [yvel v] by [-1] //or whatever set [0? v] to [1]If you set yvel to 1, you might not need "0?".
if <<touching [ground v]?> and <key [up arrow v] pressed?>> //or whatever controls set [yvel v] to (Jumpspeed)
Last edited by Splodgey (2012-03-16 10:03:45)
Offline
Here's a formula I like to use for gravity and friction:
when gf clicked forever if <key [right arrow v] pressed?> change [xvel v] by (1) end if <key [left arrow v] pressed?> change [xvel v] by (-1) end set [xvel v] to ((xvel) * (.87)) change x by (xvel) if <touching [level v]?> change x by ((0)-(xvel)) set [xvel v] to (0) end if <key [up arrow v] pressed?> change y by (-1) if <touching [level v]?> set [yvel v] to (10) end change y by (1) end if <(yvel) < [3]> change y by (-1) if <not<touching [level v]?>> change (yvel) by (-1) end change [yvel v] by (1) end set [yvel v] to ((yvel) * (0.9)) change y by (yvel) if <touching [level v]?> change y by ((0) - (yvel)) set [yvel v] to (0) end end
Last edited by chanmanpartyman (2012-03-18 13:07:43)
Offline
chanmanpartyman wrote:
Here's a formula I like to use for gravity and friction:
when gf clicked forever if <key [right arrow v] pressed?> change [xvel v] by (1) end if <key [left arrow v] pressed?> change [xvel v] by (-1) end set [xvel v] to ((xvel) * (.87)) change x by (xvel) if <touching [level v]?> change x by ((0)-(xvel)) set [xvel v] to (0) end if <key [up arrow v] pressed?> change y by (-1) if <touching [level v]?> set [yvel v] to (10) end change y by (1) end if <(yvel) < [3]> change y by (-1) if <not<touching [level v]?>> change [yvel v] by (-1) end change [yvel v] by (1) end set [yvel v] to ((yvel) * (0.9)) change y by (yvel) if <touching [level v]?> change y by ((0) - (yvel)) set [yvel v] to (0) end endNow some of the stuff showed up red, but you probably know what they mean
you forgot the question marks in some of the blocks
I put them in for you
Last edited by joefarebrother (2012-03-16 12:59:50)
Offline
joefarebrother wrote:
chanmanpartyman wrote:
Here's a formula I like to use for gravity and friction:
when gf clicked forever if <key [right arrow v] pressed?> change [xvel v] by (1) end if <key [left arrow v] pressed?> change [xvel v] by (-1) end set [xvel v] to ((xvel) * (.87)) change x by (xvel) if <touching [level v]?> change x by ((0)-(xvel)) set [xvel v] to (0) end if <key [up arrow v] pressed?> change y by (-1) if <touching [level v]?> set [yvel v] to (10) end change y by (1) end if <(yvel) < [3]> change y by (-1) if <not<touching [level v]?>> change [yvel v] by (-1) end change [yvel v] by (1) end set [yvel v] to ((yvel) * (0.9)) change y by (yvel) if <touching [level v]?> change y by ((0) - (yvel)) set [yvel v] to (0) end endNow some of the stuff showed up red, but you probably know what they meanyou forgot the question marks in some of the blocks
I put them in for you
Oh, that's what it was, I don't do this often Thanks!
Offline
There are so many gravity topics. They should all be put in one folder.
Offline
This is how I do it:
when gf clicked forever change y by ( (0)-(gravity) ) endIf you are using scrollY, don't use the "()-()" block. Just place in the variable "gravity".
when [up arrow v] key pressed repeat (10) change y by (10) end wait until (sprite touching ground)
when gf clicked forever wait until <(touching ground)=(false)> set [gravity v] to (0) repeat until <(touching ground)=(true)> change [gravity v] by (0.5) end set [gravity v] to (0) endReplace the "touching ground" with whatever you like: a color sensor, a variable, whatever.
Offline