I'm creating this library of functions so they can be used in all of my games- or yours- from here on out. I decided to distribute it so you all can give me ideas on what to add.
I'll be adding as days go along. Suggestions are open.
Most of these functions are modified, easier to use versions of built in DBPro functions. Such as 'set camera to follow' and 'waitkey'.
Current Functions
3D Math Functions
...Object to Object Distance
...Camera to Object Distance
...AngleY Towards an Object
Camera Functions
...Set Camera To Follow
...Move Camera Left
...Move Camera Right
Miscellaneous Functions
...Wait For Key
Free Functions (Use these to find the next empty slot)
...FreeObject(), FreeSound(), etc. everything
Code
REM Project: XenMedia Library of Functions
REM Created: 1/6/2008 9:00:52 PM
REM
REM ***** Main Source File *****
REM
`-----------------------------------------------------------------------------------
`------3D MATH FUNCTIONS------------------------------------------------------------
Function Xen_Object_To_Object_Distance(Object1_Number as integer, Object2_Number as integer)
dist#=SQRT((Object Position X(Object1_Number)-Object Position X(Object2_Number))^2+(Object Position Y(Object1_Number)-Object Position Y(Object2_Number))^2+(Object Position Z(Object1_Number)-Object Position Z(Object2_Number))^2)
EndFunction dist#
Function Xen_Camera_To_Object_Distance(Camera_Number as integer, Object2_Number as integer)
dist#=SQRT((Camera Position X(Camera_Number)-Object Position X(Object2_Number))^2+(Camera Position Y(Camera_Number)-Object Position Y(Object2_Number))^2+(Camera Position Z(Camera_Number)-Object Position Z(Object2_Number))^2)
EndFunction dist#
Function Xen_AngleYTowardsObject(Object1_Number as integer, Object2_Number as integer)
angy#=AtanFull(Object Position X(Object2_Number)-Object Position X(Object1_Number), Object Position Z(Object2_Number)-Object Position Z(Object1_Number))
EndFunction angy#
`-----------------------------------------------------------------------------------
`-----------------------------------------------------------------------------------
`------CAMERA FUNCTIONS-------------------------------------------------------------
Function Xen_SetCameraToFollow(Camera_Number as integer, Object_Number as integer, Height_Above_Object as float, Distance_Behind_Object as float, Point_Camera_Above as float)
`Notes:
`Camera_Number- 0 for Default
`Point_Camera_Above- 0 for directly at object, any higher is pointing the camera more upwards
Position Camera Camera_Number, Object Position X(Object_Number), Object Position Y(Object_Number)+Height_Above_Object, Object Position Z(Object_Number)
YRotate Camera Camera_Number, Object Angle Y(Object_Number)
Move Camera Camera_Number, 0-Distance_Behind_Object
Point Camera Camera_Number, Object Position X(Object_Number), Object Position Y(Object_Number)+Point_Camera_Above, Object Position Z(Object_Number)
EndFunction
Function Xen_MoveCameraLeft(Camera_Number as integer, Distance as float)
Position Camera Camera_Number, Camera Position X(Camera_Number)+Distance*Sin(Camera Angle Y(Camera_Number)+270), Camera Position Y(Camera_Number), Camera Position Z(Camera_Number)+Distance*Cos(Camera Angle Y(Camera_Number)+270)
EndFunction
Function Xen_MoveCameraRight(Camera_Number as integer, Distance as float)
Position Camera Camera_Number, Camera Position X(Camera_Number)+Distance*Sin(Camera Angle Y(Camera_Number)+90), Camera Position Y(Camera_Number), Camera Position Z(Camera_Number)+Distance*Cos(Camera Angle Y(Camera_Number)+90)
EndFunction
`-----------------------------------------------------------------------------------
`-----------------------------------------------------------------------------------
`------MISCELLANEOUS (RANDOM)-------------------------------------------------------
Function Xen_WaitForKey()
`This, as compared to DB's 'WaitKey', waits for the press and release of any key
Repeat
Until ScanCode()>0
If ScanCode()>0
Repeat
Until ScanCode()=0
EndIf
EndFunction
`-----------------------------------------------------------------------------------
`-----------------------------------------------------------------------------------
`------THE FREE FUNCTIONS-----------------------------------------------------------
Function Xen_FreeObject()
Object = 0
Repeat
Inc Object,1
Until Object Exist(Object)=0
EndFunction Object
Function Xen_FreeMesh()
Mesh = 0
Repeat
Inc Mesh,1
Until Mesh Exist(Mesh)=0
EndFunction Mesh
Function Xen_FreeImage()
Image = 0
Repeat
Inc Image,1
Until Image Exist(Image)=0
EndFunction Image
Function Xen_FreeSprite()
Spriten = 0
Repeat
Inc Spriten,1
Until Sprite Exist(Spriten)=0
EndFunction Spriten
Function Xen_FreeSound()
Sound = 0
Repeat
Inc Sound,1
Until Sound Exist(Sound)=0
EndFunction Sound
Function Xen_FreeMusic()
Music = 0
Repeat
Inc Music,1
Until Music Exist(Music)=0
EndFunction Music
Function Xen_FreeEffect()
Effect = 0
Repeat
Inc Effect,1
Until Effect Exist(Effect)=0
EndFunction Effect
Function Xen_FreeMemblock()
Memblock = 0
Repeat
Inc Memblock,1
Until Memblock Exist(Memblock)=0
EndFunction Memblock
`-----------------------------------------------------------------------------------
Cheers,
Xenocythe
I am Xenocythe. XENOCYTHE!
Please, mods change my name back! I've learned my lesson about the evil name changing capabilities moderators have