TGC Codebase Backup



Basic Gravity Principles by MikeS

26th Feb 2004 20:47
Summary

Basic gravity function.(Db/dbp)



Description

Basic gravity function.(Db/dbp)



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` This tutorial was created by Yellow -Mike- 2-26-04
` Although not necessary, it would be nice to be credited and
` notified at yellow1dbp@hotmail.com if this was used in a game
` Thanks, and I hope the tutorial helps.

` Welcome to the gravity tutorial
` This will provide a basic tutorial on gravity

`We first name our function gravity(Pull).
`Pull will determine how strong the gravity is on objects.
`We then list the objects we want to check for gravity.
`Currently, we're checking for 500 objects if they exist, and then pulling them down.
`Then, we check if there position is greater than 0, and if it is, we pull it down
`You can now apply this to your game, and have a basic physics applied.


`Pull tells how much effect gravity has on objects
function gravity(Pull)
for a = 1 to 500
 if object exist(a)
  if object position y(a)>0 then move object down a,Pull
 endif
next a
endfunction