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.

DarkBASIC Discussion / function help, and 3d area position help

Author
Message
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 24th Jun 2005 09:46
I need help with functions (I know what they are and how the fomat goes, I just don't know how to call them or how to use them) (Same thing I guess), and I don't know how to tell where an object will appear on a matrix. Like, where is 25 x or 35 z. Really the extra variable z confuses me. In both of these topics I get them, its just I don't understand them completely. Any help or advice is appreciated !! Thanks in advance!

------------------------
Visit my website of Games!
http://dabip.t35.com
gpex
19
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 24th Jun 2005 10:58 Edited at: 24th Jun 2005 10:59
well, i'll try to help you as best i can without confusing you...i'm assuming that you know functions can return a variable but have to be set equal to something if you plan to use it later, and you can take variables to the function...



as for the z axis thing, thats beyond me at this point... but i hope that helped, reply if you still need help.


-gpex-

Your signature has been erased by a mod because it is larger than 600x120...
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 24th Jun 2005 14:43
Yaa, the
is that supposed to be just plain old, function add(a,b)? And on the endfunction, is that supposed to be endfunction add ? I just want to make sure that is correct. So if I get this correctly, a function is basicly an advanced way to get a number? Oh and thank you for the example!

------------------------
Visit my website of Games!
http://dabip.t35.com
Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 24th Jun 2005 20:03
No, every command in darkbasic is actualy a function, but you can also create your own user defined function. For example when you need to create a box with a border around it and needd to create it a few times on the screen. I cleaner and faster to create a function wich does this twice in stead of haveing the codeing in the main loop.

From the help files:


please reply
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 25th Jun 2005 03:39
So Let me see If I've got this.


Would this code work? If so then I think I might be able to do a few cool things with this!!

------------------------
Visit my website of Games!
http://dabip.t35.com
gpex
19
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 25th Jun 2005 04:22 Edited at: 25th Jun 2005 04:28
well, your code wouldnt exactly work the way you want it to. First, you are trying to take the variable "won" to the function but there is nothing stored in that variable(technically 0 is stored there but you get what i'm saying.) and then at "endfunction win" you didnt store anything new into the variable "win" so it should probably be "endfunction won"

I re-wrote your code and it works, but win# will always equal 12, i'm just showing you so you can get a good idea of how functions work...



I hope that helped. Also, as link was saying, functions are not just used for getting a number. They can be used for anything that you want, from printing text on screen to loading graphics. I just gave you an example of a function that added two numbers because it was simple.
You can take whatever variables you want to the function and store them into any variables you want to.(i hope that makes sense)

If you have more questions, please reply.

-gpex-

Your signature has been erased by a mod because it is larger than 600x120...
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 25th Jun 2005 05:20
Okay. I get it. THANKS!!!

------------------------
Visit my website of Games!
http://dabip.t35.com
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 25th Jun 2005 09:37
Think YOur Could help me with this little bit of code?


Thanks if you could!

------------------------
Visit my website of Games!
http://dabip.t35.com
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 25th Jun 2005 11:12 Edited at: 25th Jun 2005 11:13
vgames master,

To add, a function is a method to keep you from having to retype code over and over. To clarify, if you are going to be using the same group of calculations over and over, within different areas of your source code, then you can call the function at each point within the program where the calculations are needed. So, instead of:



...you would write it like:



Although, technically, these calculations would be better off written like b# = ((b# * 35) / 2) + 35, the above are just an example.


+NanoBrain+
gpex
19
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 25th Jun 2005 11:39
well vgames, i would love to help you with that code. But is there more to the program, because if there is you need to post it. Because there are some variables that arent ever used before the function so i cant test the program to see if it is doing what you want it to do.


-gpex-

Your signature has been erased by a mod because it is larger than 600x120...
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 26th Jun 2005 03:26
OKay, Sorry. Here is the full code. It is a hefty chunk of code though. Although, thanks NanoBrain. I understand what you are trying to say to me. I hope. Please note, this is part of my official puzzle game entry. I was THINKING on making my tic tac toe game better. Mainly I was wanting to fix the way it knows who won by using functions. SO, I THINK you will need at LEAST 3 files if you want to test one part of my game. I will only include the 1v2 player instead of all the 1vComuter so that way you don't have to worry about so much code. Trust me, the player 1 versus computer hard is about half the code for the whole game.

------------------------
Visit my website of Games!
http://dabip.t35.com
gpex
19
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 26th Jun 2005 07:05
well, that is a very long piece of code but i did notice that in the winner function you returned the variable "winner" which would not equal what you want it to, you should return the variable "winner#"
heres the code...



-gpex-

Your signature has been erased by a mod because it is larger than 600x120...
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 27th Jun 2005 05:41
Oh. Okay. I'll test out the code to see if it works better. I hope it does. The last way I had it, my game wouldn't always check to see who won. OR would check late. So, thank you!

------------------------
Visit my website of Games!
http://dabip.t35.com
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 27th Jun 2005 08:04
Sorry, IT isn't working. I even tried copying ans pasting the code into mine but it just isn't working. What else might you suggest I do?

------------------------
Visit my website of Games!
http://dabip.t35.com
gpex
19
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 27th Jun 2005 11:40
well, i've read through the code but i think that you would have a better chance at getting it to work than me since you have been with it throught the whole development process and you have a much better idea of how it works. But i'll look at it some more later and see what i come up with, but for now...that is all.


-gpex-

Your signature has been erased by a mod because it is larger than 600x120...
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 28th Jun 2005 01:50
OKay, Wel I thank you very much for your help. I appreciate it very much. Thank You.

------------------------
Visit my website of Games!
http://dabip.t35.com
waffle
22
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 28th Jun 2005 04:43
your origial ?
Quote: "Like, where is 25 x or 35 z"
confuses me .

A Matrix (in DB Terms) is sorta a 3D plain (ignore the hills for now). The (X,Y,Z) represent a 3D position in free space. This position has no real meaning unless given a "context". Example:

Position Camera XC#,YC#,ZC#
this places the camera into a "known" position.
this has no real value because we do not know what is there ..
so, to provide a "context" place the matrix someplace ...

Position Matrix 1,XC#-MW/2,YC#-200,ZC#-MD/2
MW is the width of the matrix when created
MD is the matrix depth (Z value) when created
this function places Matrix 1 centered below the camera 200.
But, to complete the "context" we need to tell the camera
what to look at ...

Point Camera XC#,YC#,ZC# +200
this point the camera level with the matrix ...

Now, that we have a complete "context", meaning that we have
objects to see, and a camera to see them, I'll explain XYZ better.

In this context,
X is left/right of the camera.
All X values less than XC# will be to the left.

Y is up/down of camera
All Y values less than YC# will be below the camera

Z is farther/closer to the camera (depth)
All Z values greater then ZC# will be farther away.
All Z values less than ZC# will be behind the camera,
and will not be rendered. Also, with this in mind,
Examine the Set Camera Range command. All objects
closer than the minimum range will not be rendered.

OK, now lets mess this up a bit.
Rotate Camera 0,25,0

The camera is still in the same place, just looking in a different direction. Now, moving an object over the matrix in the Z direction
will look as though its moving kinda to the left of the camera.

This should help you understand 3D a wee bit more.
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 29th Jun 2005 02:46
I'm pretty sure I get it a "wee bit more". When you rotated the camera 25 on the y axis, you pointed it up, right? You also brought another question I have about 3d, how do you point? I don't get how you point an object. Think anyone could help? By hte way wallfe, thanks!

------------------------
Visit my website of Games!
http://dabip.t35.com

Login to post a reply

Server time is: 2025-05-22 21:31:17
Your offset time is: 2025-05-22 21:31:17