Does anybody have an idea for gravity scripts
Offline
ftf841 wrote:
when gf clicked forever if <not <touching [ground v]?> > change y by (-something)
Scratchblocks fixed.
Offline
This should do it
When gf clicked set [y-vel] to (0) forever if<([abs] of (y-vel)) < (0.1)> change y by (-1) if<not <touching [ground v]?> > change [y-vel] by (-0.2) end change y by (1) else change y by (y-vel) if<touching [ground v]?> set [y-vel] to ((y-vel)*(-0.5)) change y by (y-vel) if<touching [ground v]?> change y by (y-vel) end end end end
Last edited by MoreGamesNow (2012-03-25 12:50:59)
Offline
MoreGamesNow wrote:
This should do it
When gf clicked set [y-vel] to (0) forever if<([abs] of (y-vel)) < (0.1)> change y by (-1) if<not <touching [ground v]?> > change [y-vel] by (-0.2) end change y by (1) else change y by (y-vel) if<touching [ground v]?> set [y-vel] to ((y-vel)*(-0.5)) change y by (y-vel) if<touching [ground v]?> change y by (y-vel) end end end end
Velocity isn't required, considering the question.
Offline
bobbybee wrote:
Velocity isn't required, considering the question.
Doesn't "gravity scripts" imply acceleration and velocity? In any case, I would prefer "gravity" with acceleration to a constant falling speed, and presumed that killersnowgoon1 would too.
Last edited by MoreGamesNow (2012-03-25 13:18:24)
Offline
Velocity is probably better. If you can do it a better way, why not do it?
Offline
Greenatic wrote:
Velocity is probably better. If you can do it a better way, why not do it?
Well, the first script was a quarter of the size of the velocity script...
Offline
bobbybee wrote:
Greenatic wrote:
Velocity is probably better. If you can do it a better way, why not do it?
Well, the first script was a quarter of the size of the velocity script...
And will also get the sprite stuck in the ground, as well as falling at a constant velocity Just because my script is longer doesn't mean it is less effective or an incorrect answer.
Offline
MoreGamesNow wrote:
bobbybee wrote:
Greenatic wrote:
Velocity is probably better. If you can do it a better way, why not do it?
Well, the first script was a quarter of the size of the velocity script...
And will also get the sprite stuck in the ground, as well as falling at a constant velocity Just because my script is longer doesn't mean it is less effective or an incorrect answer.
it works perfectly for me
Offline
ftf841 wrote:
it works perfectly for me
It does work if your goal is to make your sprite move downward until it hits the floor. But you'll end up "inside" the floor (you stop falling after you hit the ground), and you don't accelerate. Since the original post asked for gravity, I assumed acceleration.
Offline
If you are doing angry birds game, check out my "Help with parabolas, sine, cosine, and tangents" forum post under "help with scripts." It explains how to create gravity and shooting power.
Offline
forever if <touching color [#000000]?> // ground colour set [yvel v] to [0] else if <(yvel) > [-20]> //so you cant fall faster than 20 pixels per step change [yvel v] by (-0.1) //the higher this value, the faster you will fall. Experiment. end change y by (yvel) end when i receive [jump v] if <touching color [#000000]?> set [yvel v] to (20) change y by (20) //otherwise you will still be touching the ground and it won't work
Last edited by joefarebrother (2012-04-11 10:45:58)
Offline