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.

Newcomers DBPro Corner / Toturial "How to make a simple control for 3d objects" For dbpro

Author
Message
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 21st Nov 2004 05:00 Edited at: 3rd Apr 2005 03:39
Hi all


After i tried the "My first pong game" tut it inspired me to make a little tut on just some off the things i learned from it but first of all i wanna thank Chris K [/u].
So thank you for all that stuff you taught me

Now lets start.

This little tut will cover the most basic on how to make a nice and simple control to an 3d object.


*Make the sync setup*

Some of the first things to do is to make the sync setup but first i will explain something about the sync command :

Sync is acually one of the very inportnent commands and you will need to use it in ETC the main loop. You will always need the sync command to keep you games running smooth. You need to insert this is you main loop but after all the other stuff it done.
So in every 3D game or 2D game you will need this so lets start the code like this:



The sync on command tells darkbasic to handle the screen refresh.
Now i have written sync rate 30 that is a good thing to write it will tell darkbasic to run the screen refreshing at 30 no matter what computer it is running on.


*Making the 3D object*

It is quite simple to make the 3D object lets make a box.
To make a box we use the MAKE OBJECT BOX command:

MAKE OBJECT BOX object number, x, y, z (I think).

so our code should look like this now:



Now the 3d box is just white so lets put some color on it.
For that we use the COLOR OBJECT object number, color
Remember that in programming language the colors are codes but in dbpro there is an easy way to pick you the color you want without writing the code.

So now the code should look like this:



To get the color picker you just need to right click on the mouse button (In the dbpro editor) then there should stand "RGB color picker" push that button and then just pick a color .

Now we need to make it so you can try to run the program and we do that on a simple way

We need to use the DO and LOOP command to make the main loop.

Now put this into the code Under all the other commands:




Now you when you run the code you should see a colored box. If you dont see that then maybe you have writet something wrong if you have that try to use this code:




Now before we go any further i have a little thing you need to solve:

try to color the box in another color.



Have you made it another color?
Good then lets move on
im sure you wanna know about the


code.
So i wanna tell you something about that code.
Everything that is between the DO and LOOP
darkBASIC will keep looping so we call it the "main loop" or "the game loop".
Something inportnent to remember is that the SYNC command should be in that loop also so remember to put the SYNC command in the end of the loop.
Now you see the Position object 1,0,0,5
That tells darkbasic to position the box in front of the screen.

Try to play around with the "Position object" command so you can learn a bit more about the position object command


*The variables*

Now this is one of the most inportnent things you need to have theese variables to make the movements of the box.


now in the code our code:



that line we need to change so it is going to look like this:



go change it to that.
This is were the variables come in.
every variables of this kind all ends with a # sign.
So we call the variable "player#".
This means that the our object is now a variable and ready to use

Now you should have a code like this one:




You see the:



line?

This means that IF upkey is pressed our variable(the bat) will move up.

Now when you run this code:




you should see nothing.
Then try to hit the upkey button and then the box should be visible and you should could see it move.

now under the:



line you should put this:



This means that when you hit the downkey button the box will move down.

As the last thing i have a problem for you to solve:

Try to change the speed on the box.
Here is a little hint:




i hope you found this tut helpfull
if you did then please comment it


If you code dosnt work then here is the final code( I have putted some comments in it so you can see what the things means):




If you need help to more things then you can add me on you msn i would be glad to help:

Here is my msn: kattenolle@hotmail.com




Waggames

*************
*panzergames*
http://www.panzergames.tekhawk.com
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 21st Nov 2004 05:20
*UPDATE*

If you want the camera to have a better position put this code in the loop:



so the final code will look like this:






Waggames

wanna join Waggames?
then visit our site at : http://www.freewebs.com/waggames
my old forum name was: The Nerd
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 21st Nov 2004 07:13
so nobody like my toturial?



Waggames

wanna join Waggames?
then visit our site at : http://www.freewebs.com/waggames
my old forum name was: The Nerd
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 21st Nov 2004 09:40
yes I do
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 21st Nov 2004 16:31
thanks

i hoped that someone would like it and you do


Waggames

wanna join Waggames?
then visit our site at : http://www.freewebs.com/waggames
my old forum name was: The Nerd
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 21st Nov 2004 22:36
please comment my tut





Waggames

wanna join Waggames?
then visit our site at : http://www.freewebs.com/waggames
my old forum name was: The Nerd
Opus
19
Years of Service
User Offline
Joined: 10th Jan 2005
Location:
Posted: 12th Jan 2005 01:49
Hello, The Nerd. I found your tutorial very useful. I am just returning to programming after at least a decade of not doing any coding at all.

A great deal of the old knowledge is coming back to me and that is because you and some other very helpful coders are willing to share your expertese. I thank you very much for that!
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 31st Mar 2005 05:34 Edited at: 31st Mar 2005 05:34
Thank you

whoa.... i wrote this a very long time ago...


PanzerGames website :
http://www.panzergames.tekhawk.com
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 3rd Apr 2005 03:17 Edited at: 3rd Apr 2005 03:18
Yeah, has been a while since this was made !
however please, please change...
Quote: "that stuff you learned me"

to
Quote: "that stuff you taught me"

please ?!
will add so much credability to the text.
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 3rd Apr 2005 03:40
ok....

*************
*panzergames*
http://www.panzergames.tekhawk.com
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 3rd Apr 2005 05:02
Yay thanks !
Jester Gorky
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 10th Apr 2005 22:54
Hey Nerd I've just started using DBPro & have been pottering about these forums for a night looking for something to help get me started on the movement & manipulation of game objects and I have to say that your tutorial was a big help, amoungst many many others, Thanks alot man! ~JG

Login to post a reply

Server time is: 2024-09-23 17:19:29
Your offset time is: 2024-09-23 17:19:29