Hi im new and gained an understanding, but how can i apply gravity effects to a sprite, so in school i was messing about with a hang glider and these naturally want to fall down, how can i get an object to naturally fall but still have full control over the sprite to allow to move "up" again,
also for games like "kitty cannon" where you fire an object and see how far they travel, but i cant make to object fall back down again.
Thanks
Offline
For simple gravity, just make it change y by -1, unless it is touching the mouse and the mouse is down (it is being dragged), or it is touching the bottom.
For realistic gravity, you'll need to create a variable. Just keep changing this variable by 1, and moving down by some squared relationship of it, such as:
<forever>
|<if><< << <mouse down?> <and> <touching[ mouse ]> >> <or> <touching[ edge ]> >>
||<set{ n }to( 0 )>
|<else>
||<change{ n }by( 1 )>
||<change y by( (( <{ n }>(( <*> <{ n }> )) <*> -1 )) )>
|<end>
<end>
The -1 can be increased or decreased to simulate a greater or lesser mass/wind resistance. (It must be negative, though; other wise, it will fall up!)
Note also that this simulates an object falling through a vacuum; the more complex aerodynamic calculations needed to let it reach a terminal velocity are redundant, given the height of the screen.
Offline