TGC Codebase Backup



jumping mod by Omicron

6th Aug 2005 12:51
Summary

this is a mod of someones jumping code it has a few tweaks to make it more usable



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    sync on

make object sphere 1, 100

gravity = 0
y = 0
jumpstatus$ = "on ground"
jumpspeed = 2
do

rem when the spacebar is pressed, start the jumping cycle
if spacekey()=1 and jumpstatus$="on ground" then jumpstatus$ = "jumping"

rem jump status
print jumpstatus$

rem the gravity cycle
rem Gravity cycle: 1. Start Jumping. 2. when the jump is peaked, start falling. 3. fall faster than the speed of which you jumped. 4. land on the ground
if jumpstatus$ = "jumping" then gravity = gravity + jumpspeed
if gravity = 100 then jumpstatus$ = "falling"
if gravity > 0 and jumpstatus$ = "falling" then gravity = gravity - (jumpspeed + 4)
if gravity = 0 then jumpstatus$ = "on ground"

rem make sure that the object's Y co-ordinate is equal to the "gravity"
y = gravity
position object 1, 0, y, 0

rem make sure the object doesn't go below 0
if gravity < 0 then gravity = 0

sync
loop