Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / General Functions

Author
Message
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 3rd Nov 2006 22:36 Edited at: 3rd Nov 2006 22:38
These are my general functions that I've made to make my game making times easier, and no, this isn't one of those ones with 10 object distance functions (though I do have a lengthVector() function)...

Basically I decided to start by making my own free[Something]() library... I moved on and make things like 'Obj=makeSphere(Size)', from there I made my 'dLoad()' function, which I will explain later. I then thought to myself, "something that really bothers me is not being able to find a free vector, what a bummer" so, I remade all the vector commands in DBPro (obviously not as fast, but I prefer it none-the-less)... And to finish off I made some Sprite3D functions, which basically do what sprite commands do, but I find are better, and I can put text over them.

Here are all the functions + an example:



and now I'll try to explain a few functions:
stStart() - Standard Startup, better typing 1 line than all of those
freeObject() - find free object, the usual
freeImage () - etc etc etc
dLoad(file$) - will load a file, the type is not required (such as object, image), and will place it in an empty slot, and return the number
makeCube(size#) - creates a cube of certain size and returns free object number
makeSphere(size#) - etc etc etc

msControl(speed#) - my standard mouse control, best to function it.
cam3RDPerson(x#,y#,z#,ca#,oz#,oy#) - will make the camera follow a certain point, and the camera moved out slightly, very easy to code, but annoying none-the-less. note: curveangle() doesn't work in functions, so you'll have to provide your own angle..

freeVector() - no use to you..
makeVector() - finds a free vector and creates it.
setVector(x#,y#,z#) - blah blah blah
I added a few vector commands that aren't in DBPro, such as:
invVector() - inverts it
AngleX/Y/Zvector() - gets the x/y/z angle of a vector
rotateVector() - will rotate a vector by a certain x and y angle, z is not needed
equalVector() - will check if two vectors are equal
getNormal(ax#,ay#,vec) - put in an x and y angle, and define a vector, the normal of these angles will be placed into that vector. Just use the getVectorX/Y/Z() commands to retrieve the data.
Note: I hope you noticed, the vector commands are only 3 dimentional.


sprite3D(x,y,size x, size y, alpha, image) - will create a sprite for a plain, just define the screen coordinates, size, alpha and image number, and it will create it. It will also return the number of the sprite, so ofcourse it's created without you having to handle the numbers for it, just like freeObject() (thanks for the help Cu')
setSprite3D(num,x,y,sx,sy,alpha,i) - basically, this has to be used instead of the data on the first command if you want it's data to be changed.
updateSprite3D() - will update it's data.
setVisibilitySprite3D(num,flag) - just like hide/show sprite
checkObjSprite3D(obj) - will check if an object is being used as a sprite or not
checkSpriteObj3D(num) - will return the object used for that sprite.

There's also a usefull type at the end of the code you can use called tVec3, it's used for the vector commands, but you might aswell use it if you need it, saves you remaking it
I doubt the sprite3d type will come in usefull for ya.

Enjoy





Login to post a reply

Server time is: 2024-11-22 23:11:31
Your offset time is: 2024-11-22 23:11:31