TGC Codebase Backup



a cube follows the mouse pointer by The Big Babou

18th Mar 2004 7:11
Summary

a cube follows the mouse pointer



Description



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

cubex as float
cubey as float
stepx as float
stepy as float

rem setup object
make object cube 1,10
set object cull 1,0
lock object on 1

rem starting values
cubex=mousex()
cubey=mousey()
stepx=0
stepy=0
speed=30

position mouse screen width()/2,screen height()/2

do

rem rotates and positions the cube
rotate object 1,wrapvalue(object angle x(1)+1),wrapvalue(object angle y(1)+1),wrapvalue(object angle z(1)+1)
position object 1,cubex,cubey,400

rem calculates the cubes position
stepx=(mousex()-screen width()/2-object position x(1))/speed
cubex=(cubex+stepx)
stepy=(-1*mousey()+screen height()/2-object position y(1))/speed
cubey=(cubey+stepy)

ein$=inkey$()

if ein$="w" then set object wireframe 1,1
if ein$="s" then set object wireframe 1,0
if ein$="q" then inc speed
if ein$="a" then dec speed

set cursor 0,0
print "press 'q' to increase speed, 'a' to decrease speed"
print "speed: ",speed

sync
loop