A student asked me about a gravity variable. I told him he could imply the weight of an object by the time it took to rise or land but I did not know of a gravity variable.
Has anyone used a gravity variable? How does it work? Can it consistently make a sprite heavier or lighter?
thanks
Thank you I will look this over and help the young man who was asking. Much appreciated!
Hi Johanna,
Just make a variable and name it Gravity. Set the value to: -0.981 (it´s actually 9.81 m/s2, but it´s too fast for the small screen). Place the variable [Change Y by Gravity] in a Forever loop, and then you must change the Gravity value [Change Gravity by -0.981]. And the Sprite fall down with increasing speed. And it´s all over in a short eyeblink... ;-)
BUT
If you draw a colored thick line in the Background (Stage) then you can change Gravity to positive 0.981(experiment with other values) when the Sprite touches the colored line. And it kind of bounces...
---------------------------------------------
When Green Flag is Clicked
[Go to X:0 Y:180] (Go to starting point)
[Set Gravity to -0.981] (Set the value of the variable)
[Forever (Loop)
[Change Y by Gravity] (The Sprite moves down )
If Touching Color (If you have drawn a colored line)
[Change Gravity by 0.981] (This increases the Gravity and the Sprite is moving up)
Else
[Change Gravity by -0.981] (This decreases the Gravity variable and the speed down doubles)
End Forever]
--------------------------------------------------
Probably are there many other and better ways to deal with gravity... and better... I´m not an expert in programming.
/Anders
A small experiment
scratch.mit.edu/projects/Skola2015/1161518