TGC Codebase Backup



Scalable velocity with mouse by Sam Cameron

3rd Jan 2004 10:59
Summary

Code for control objects with scalable velocity using mouse



Description

Code for control objects with scalable velocity using mouse, the midle of the screen it's
zero velocity and the bordes increase the velocitie scalable, this code it's for X and Z, but you can change for any direction, include explanations.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem *** scalable velocity of objects controlled by mouse ***
Rem                  *** By Sam Cameron ***


Rem setting up the scene for camera and object
autocam off
make camera 1
MAKE OBJECT CUBE 1,5
MOVE CAMERA 1,-50


Rem MAIN LOOP

do

Rem if a screen size it's 640x480 we must write -320 for X and -240 for Y
Rem the half of screen size to control the positives and negatives values for the mouse
Rem in the midle point of the screen is the zero value for the movement
Rem the multiply operations it's for rest the point value of what you get from mouse()

Rem velocity x
velocityx#=mousex()-320
velocityx#=velocityx# * .001

Rem velocity z
velocityz#=mousey()-240
velocityz#=velocityz# * -1 * .001

Rem Updating object position with velocities for X and Z
position object 1,object position x(1)+velocityx#,0,object position z(1)+velocityz#

loop