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 / completly lost

Author
Message
Derek
17
Years of Service
User Offline
Joined: 6th Dec 2006
Location:
Posted: 7th Dec 2006 03:06
Hey iam new to the DarkBASIC system and do not know anything about this stuff. Iam completly lost and the farthest ive goten is like to the opening title stuff, and dont know how to do anything else past that. If someone could please show me some example codes or show me how to make a example mini game, or just please make this stuff clearer for me that would be great. Well i have the DarkBASIC system not DBPRO so yeah, can someone please help me.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 7th Dec 2006 03:54
coding is thinking about the instructions you want the computer to perform in a linear fashion. later on as you progress you will learn functions that allow you to group these commands into one word commands with parameters.

lets jump into the DARKBASIC hello world snippet like all other languages to get started.




lets break down these commands to understand them
sync rate 60 : sets the rate of refresh in laymans terms to 60 ticks or loops a second.

sync on : activates the sync to be used in your main loop

do : starts the do/loop which will repeat itself forever and ever until you press escape which is the standard key for all programs to stop them in dark basic unless you change that yourself.

print "Hello World" : prints the text Hello World as a string.
A string is a series of characters that the computer has no idea what they are, compared to a variable that might hold a number or a decimal place

sync : this tells the computer language to activate the screen refresh to update what was prior to it, hence in our loop we are printing Hello World again and again.

loop : this completes our loop and tells the computer to go back to the do statement and start all over again.

end : this safely terminates the program after you have completed your instructions.




now lets take this approach a little further into 3d



This program makes a spinning cube in 3d with the text hello world.

lets break it down again.

sync rate 60 : sets the rate of refresh in laymans terms to 60 ticks or loops a second.

sync on : activates the sync to be used in your main loop

make object cube : makes a 3d cube using a media space of 1, each 3d object needs its own media number for the program language to manage it, the extra 1 is for the size of the cube.

position object : this positions the object in 3d space x 0 y 0 z 0
basically the center point in most 3d worlds.

we do the same with the camera but -5 z so backwards in the forwards backwards dimension and up 5 in the y dimension thats up and down.

if you just load an object DB will use an automatic camera viewing feature that should be avoided for simplicity of setting things in your own space and distance.

do : starts the do/loop which will repeat itself forever and ever until you press escape which is the standard key for all programs to stop them in dark basic unless you change that yourself.

in our main loop we declare a variable integer, or a whole number variable called r, rotation for short.

we use another command built by TGC for DB called wrapvalue.
wrapvalue stops the number going past 360, hence 360 degrees of rotation. we add one each time the loop goes around and apply it to the x y and z dimensions of the cube for rotation.

now instead of print we use another similar command called text.
it will print text on the 2d screen on your monitor.
X in 2d is left right, Y is up down.
we set the text to be 1x and 1y and then print the hello world string there each loop cycle.

at the end of our program we safely delete the object we used and end the program.

this is the most basic primer i can imagine for you, covering very basic 2d and 3d.

if that appears to be too much at once, just re read each component and eventually it will all start to make sense.

get a pad and pencil and write down the ideas you want to create a game, then go back and read the commands you need to acheive that.

good luck its a lot of fun once you get the hang of it.

H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 7th Dec 2006 21:23
@Indi
Holy flip, did you just type that all right now?! Please tell me you just keep this text handy somewhere and copy+paste every time this question gets asked...

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 7th Dec 2006 22:28

Login to post a reply

Server time is: 2024-11-27 01:47:31
Your offset time is: 2024-11-27 01:47:31