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 / What do I need the data command for?

Author
Message
Sonic 91 Software
20
Years of Service
User Offline
Joined: 19th Mar 2005
Location: In a Cryptic Crossworld!
Posted: 8th Dec 2005 12:17
And how can I use it in a 3d adventure or strategy game?

I am a Christian and I know that God loves me. That is what makes my life so great!
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 8th Dec 2005 13:40
You can use it for any kind of program and use it in any way... but it's best to use files instead. If you use data statements any changes to the data cannot be saved back into the program. If you use files you can change the data, save, and reload the changes easily.


TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Dec 2005 20:46 Edited at: 9th Dec 2005 03:28
One use for data statements is for items that can be pre-calculated - to save time if your program has to do the calculation many times - say in the main loop.

For example, lets say your program has to do a complicated calculation based on your character object's Y angle and each time the angle is say 45 degrees, the result is always the same.

There are 360 possible angles the character could be facing so you could pre-calculate those 360 values and store them as items in data statements.

You would read the data items into an array - like CalcArray() for example - and in your program, use the contents of the array instead of having to do the time-consuming calculation each time:

CalcResult = CalcArray(Object Angle Y(ObjNum))

is much faster than...

CalcResult = complicated formula

TDK_Man

re faze
20
Years of Service
User Offline
Joined: 24th Sep 2004
Location: The shores of hell.
Posted: 8th Dec 2005 23:43
also for a patch, im guessing that you could alter the data blocks without corrupting the program.

Login to post a reply

Server time is: 2025-05-22 20:40:30
Your offset time is: 2025-05-22 20:40:30