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 / Some of my functions

Author
Message
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 8th Jul 2006 14:23 Edited at: 21st Aug 2006 21:12
I've posted a bunch of functions here. Even if you find them useless, they're here. They have been tested in DBPro, not DBC. But some may work in DBC.

EDIT: Okay I've added a DBA file which includes all of the functions listed in this post. That way you don't have to clutter your workspace with all of these function declarations; you can just include the DBA file. Here is how (DBPro)
1.Go into Project View Mode for your project.
2.Select the little red tab in the bottom-right corner of your screen marked "Files"
3.Click it and then click "Browse..."
4.Go to where you saved the DBA file and click OPEN.
5.There you go. Your project may look like it was replaced with the function code, but it's not. At the top of this "Files" menu it says "Main Source File". Click on that once, maybe twice and your code should pop up again.


Or you could just use the #Include command

All of the globals and types are already declared in the DBA file, so you don't have to declare them yourself!
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
MY FUNCTIONS
See My Function List for details in the comments.

Control Object Using Arrowkeys
SYNTAX: Move_Object_Using_Arrowkeys(Obj,MS,TS)
-----Will move an object at a specified speed and with a specified turn rate. Similar to DBPro's Control Camera Using Arrowkeys command.

Third Person Camera
SYNTAX: Third_Person_Camera(Obj,Cam,Dist#,Height#,Smooth,FLAG)
-----Will make the specified camera follow an object.

Box Clear
SYNTAX: Box_Clear(Left,Top,Right,Bottom,Thick)
-----Just like the 2d box command, but the box made is clear with the line thickness that you specify.

Circle Fill
SYNTAX: Circle_Fill(x,y,Radius)
Not the fastest command. lower logic has a faster one (posted later)
-----Just like the 2d circle command, but the circle is pretty much filled in (pretty much...)

Triangle
SYNTAX: Triangle(X1,Y1,X2,Y2,X3,Y3)
-----Creates a 2d triangle using 3 points that you specify.

LBL Text (Letter-by-letter Text)
SYNTAX: LBL_Text(X,Y,Text$,Delay#,Sound)
-----Will print text to the screen letter by letter using a REPEAT and UNTIL loop.

FPS Camera (First Person Shooter Camera)
SYNTAX: FPS_Camera(Cam,Speed,FLAG)
-----Will make the specified camera act like a First Person Shooter Camera.

Merge Object
SYNTAX: Merge_Object(SObj,EObj,TOBj,X#,Y#,Z#)
-----Will merge all of the objects within an object range (SObj to EOBj) into one object. Each of the merged objects will now be a limb on the one object (TObj) and the new object will appear white. The limbs keep their original position and rotation. All of the positions and angles use world coordinates (where they are in te ACTUAL 3d space) Use the LIMB commands to modify individual parts of the new object. The center of the object (what the position is based on, I'm not sure what the word is) is at the point that you specify.

Pos To Tile (Position to Tile)
Semi-Advanced- Uses types and globals. This function is not the best one here, as it may bring up questions.
SYNTAX: Pos_To_Tile(Matrix,Size,Tiles,x#,z#)
-----Will convert a 3d coordinate into a tile coordinate on a matrix. The tile coordinate must be on the matrix. This function uses one type and a global. The type is where the tile coordinates are put. To access this type, use FTile.X or FTile.Z. There is a little code that you need to put at the start of your program. Everything you need is included in a REM in the function. If you have a question about this one, just ask me.

Detect Movement
SYNTAX: Detect_Movement()
-----Will return a 1 if the user does anything (move the mouse, press a key, etc.), otherwise a 0 is returned.

Tile To Pos (Tile to Position)
Semi-Advanced- Uses types and globals. This function is not the best one here, as it may bring up questions.
SYNTAX: Tile_To_Pos(Matrix,Size,Tiles,x,z)
-----Does the exact opposite of Pos To Tile (Position To Tile). This will convert a tile coordinate to a world coordinate in 3D space. The coordinate is the one at the exact CENTER of the tile positions specified. This function, like Pos_To_Tile, uses types and globals. The type is the same as the one for Pos_To_Tile. The global however is FPos instead of FTile. You can access the results generated from this function by typing in "FPos.x" or "FPos.z". As you may have guessed, "FPos.x" returns the X coordinate generated, and "FPos.z" returns the Z Coordinate. Everything you need is stored inside a REM within the function. Read the REM inside the function for details.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

<<<<<MY FUNCTION LIST>>>>>







Other Function Links

Xenocythe's Functions

Function Collection Thread(Started by Benji)

Attachments

Login to view attachments
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 8th Jul 2006 16:55
I'd like to hear what you guys think!

My Functions: Mine
Post yours: Post
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 8th Jul 2006 20:24
Cool! This might be helpful

Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 8th Jul 2006 20:50
Yay you checked it

My Functions: Mine
Post yours: Post
Digital Dragon
19
Years of Service
User Offline
Joined: 17th Dec 2004
Location: ...
Posted: 8th Jul 2006 22:20
very cool

Slayer
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: CA
Posted: 9th Jul 2006 05:58
well at least you know how to use functions...
there very usefull at the right times...

I dont know how to spell
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 9th Jul 2006 16:20
if they were not, then why bother to make them?

My Functions: Mine
Post yours: Post
Three Score
19
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 10th Jul 2006 03:21
look at goto's there not that useful but still people make them

JouleOS and friends
great thanks to http://galekus.com for FREE HOSTING!
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 10th Jul 2006 04:42
Hey I find those useful! But, let's try to stay on topic.

My Functions: Mine
Post yours: Post
lower logic
17
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 10th Jul 2006 10:23 Edited at: 10th Jul 2006 10:24
Really nice functions. I've made a faster fill circle function using boxes instead of dots, here you can try it with this code snippet. Just hold the space bar to switch between the two to see the difference:

Feel free to add my circle and ellipse functions to your list of functions .
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 10th Jul 2006 13:14 Edited at: 10th Jul 2006 13:22
Thanks! (I'm not the best 2D guy out there) This is good. I'd like to keep the first post for my functions (so people don't give credit to the wrong person). I will mention you though. That was the one command that I thought needed optimization. And maybe Pos_To_Tile as well... I could actually make 2 functions out of it, which would eliminate the globals. I'll think about that.

My Functions: Mine
Post yours: Post
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 13th Jul 2006 03:13
I'll leave it as is, I guess. IF you want a change, just say so.

Anyway...

If you try my functions out or use them could you at least tell me what you thought of them? Feedback can lead to improvement.

My Functions: Mine
Post yours: Post
Twu Kai
18
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 13th Jul 2006 23:22
These look good! I quite like the 3rd person camera function, as well as the control object using arrowkeys one.

Maybe you could make one that translates a matrix tile in to a 3d coordinate. It would be quite useful for a turn-based game!

Felthenra-Cat. Hiss your way to freedom.
Benji
18
Years of Service
User Offline
Joined: 17th Dec 2005
Location: Mount Doom
Posted: 13th Jul 2006 23:36
Very nice functions Sixty Squares.

Visit my Airplane Engine thread in the WIP board.
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 14th Jul 2006 04:06
@Felthenra: Thanks! About the Matrix tile to position one, that shouldn't be too hard. I'll think about it

@Benji: Gracias (That's thank you in spanish.)

My Functions: Mine
Post yours: Post
GALACTUS
19
Years of Service
User Offline
Joined: 24th Apr 2004
Location:
Posted: 16th Jul 2006 09:07
I wasn't sure if there was such a function out there. A function that generates your .x landscapes in your line of sight and drops off the ones behind you out of your line of sight. This would save tonnns of memory usage and would load much quicker.

?..?..?..?
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 16th Jul 2006 14:23 Edited at: 16th Jul 2006 16:12
I think for that one you may need to split your landscape up into many pieces. There's probably a complex way to do it. But, I have no idea how.

My Functions: Mine
Post yours: Post
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 16th Jul 2006 16:24
Oh and Felthenra I took your sugguestion. You're right, that could be used for a lot of things! (Calculating tile height, etc.)

My Functions: Mine
Post yours: Post
Twu Kai
18
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 30th Jul 2006 13:58
Ooh, now I can try to do something new with a matrix!

I would of posted sooner, but the power to my computer was off.

Thanks for making these functions. I hope to se more soon.

Felthenra-Cat. Hiss your way to freedom.
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 30th Jul 2006 14:05
Wow that was unexpected! Thanks! Do you think I should make one that can handle a non-square matrix?

Twu Kai
18
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 31st Jul 2006 14:10
I didn't know there was such a thing...!

But if you can do it, then I'm sure it would help people who are making maps like that.

Felthenra-Cat. Hiss your way to freedom.
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 3rd Aug 2006 19:00
Here's a weird program I made using a few of my functions:

Control Object Using Arrowkeys
Third Person Camera
Position To Tile
Box Clear
Merge Object





Without functions:



Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 20th Aug 2006 21:01
This is very nice . Ive wondered how to heigher or lower the positions on an matrix, and now I know where to look .
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 21st Aug 2006 05:20
Well, it's not very accurate, but it is an okay outline I guess. Thanks

Xenocythe
18
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 21st Aug 2006 20:56 Edited at: 21st Aug 2006 20:57
Sixty, I stopped with my function thing anyways, and half of them were crap



Nice functions, I always thought of making those, but forgot to post them on my function list.

If you want, you can add my functions (but the text button is kind of bugged)


The 'wait key' I have is pretty useful at times. Feel free to use it.

Applyby has Flies in his Eyes.
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 21st Aug 2006 21:08
Thanks, Xenocythe! Maybe I'll add a link.

Lover of games
19
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 1st Sep 2006 07:39 Edited at: 1st Sep 2006 07:56
I got a "Could not load FunctionPost.dba" error. I put it in the same folder. why couldn't it load?

EDIT: Never mind.........

EDIT AGAIN: When i tried to use a function (such as third_person_camera), it gave me a Command out of place in "FunctionsPost.dba" what the heck do i do to make them work? the file is in the same folder as the main program.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 1st Sep 2006 15:49
Not sure. It works for me in DBPro... Are you using DBC? That could be it...

Lover of games
19
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 1st Sep 2006 16:33
No, i'm using DBPro 6.2

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 1st Sep 2006 17:07
Well, I'm not sure then. You can just copy the functions that you want into your project from the list at the bottom of my first post.

Login to post a reply

Server time is: 2024-04-24 01:37:24
Your offset time is: 2024-04-24 01:37:24