Gravity
- Gravity is acceleration
Acceleration is change in speed
var board := ♻ game → start var sprite := board → create picture (✿ Something Amazing) board → on every frame do sprite → set speed y(sprite → speed y + 10) end
- Sprite’s downward speed get faster and faster, like it is falling
- Can ajust the amount it increases by to increase the strength of gravity
- But it goes right off the screen
So set it to a negative speed when the user touches the screen
if board → touched then sprite → set speed y(-100) else do nothing end if
- Can decrease what it is set to to increase the jump amount
- You can also hold down your finger, which may not be desireable
If we just want to change speed on a tap, there is a function
board → on tap(tapped) where tapped(x : Number , y : Number) is sprite → set speed y( - 100) end end end function