TGC Codebase Backup



Cubeherd by Alexander Altman

24th May 2009 16:07
Summary

Simple 3D game using random movement; no media! Chase the cube to get it to collide with the sphere.



Description

The cube jiggles as you approach it. Chase the cube to try to get it to collide with the sphere, which ends the game. It times you and dislays your time with "end prompt"; my high score is 4 seconds. Uses the eXtends Expansion Pack and DBPro U7.3. Move with "control camera using arrowkeys". No media! Code and Project files are attached in the downloadable "cubeherd.zip". Must must MUST have eXtends to run from code.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    void = ext initialized()
randomize timer()
cls
sync on
sync rate 0
cube = b3d make object cube( 7 )
sphere = b3d make object sphere( 8 )
position camera 0, 0, -10
move object cube, (rnd(2)-1)*50*rnd(10)
sync
stime = timer()
repeat
 control camera using arrowkeys 0, 0.01, 0.05
 ns# = b3d get distance from camera( cube )
 move object cube, (rnd(100)-50)/ns#
 sync
until object collision(cube,sphere) and (timer()-stime)>3000
exit prompt "Congratulations, you won in "+str$((timer()-stime)/1000)+" seconds!","SCORE"