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 / Variable explanation

Author
Message
Random color object
16
Years of Service
User Offline
Joined: 14th Aug 2008
Location: Montreal Canada
Posted: 2nd Sep 2008 05:26
I am trying to understand some line of commands

Codes from Nuclear Glory Collision file sphere2sphere

i don't understand. First I tought global was a given name for a variable that will contain the camera value 0.
then global is used again sphere1=100, sphere2=101
Then at color backdrop camera, rgb(0,0,255) he use the (what I think he should use global as a variable) but it use camera. Really need explanation.




My actual color is Color object 1, RGB(128,2,3) but I would like it to be random.
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 2nd Sep 2008 06:23
No. Making a variable global, relates to it's visibility within the program. It's let DBPRO see variables that might have been defined outside of a function. In programmer jargon this is variable scope. TDK wrote a bunch of tutorials on this stuff. I'd recommend keep brushing over them. Over time the puzzle will become clear.

In the case of this snippet of code, the programmer has decided to define the Camera & Sphere1 variables as globals so they can be accessed from any place within the program. Namely from within functions.


Here's a little (untested) snippet. Try commenting out the "Global Score" line as see how it effects the programs behavior. When the Score is global, DBPRO can see it from inside the DisplayScore(), when it's not global, DBpro thinks score is a completely different variable, which is only visible inside the walls the function.




Good luck..

pirate
18
Years of Service
User Offline
Joined: 18th Apr 2006
Location: u.s.a
Posted: 2nd Sep 2008 07:05
this is a great tutorial for variables by: xenocythe...this is one of my favorites because it is short and to the point...i made a pdf of the tutorial on my site at jandscreations.com...here is the link to the tutorial...
http://www.jandscreations.com/files/VARIABLES.pdf

hope this helps...

thanks, pirate
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Sep 2008 20:24
@Random color object,
There's no quick route to understanding this stuff - although I'm sure you're getting sick of hearing this, I suggest you read TDK's tutorials and learn from them. They really do help the beginner to learn this stuff.

Login to post a reply

Server time is: 2024-11-25 18:40:42
Your offset time is: 2024-11-25 18:40:42