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 / MULTI-DIMENSIONAL ARRAYS ??? Say what?

Author
Message
Slay The Wicked
19
Years of Service
User Offline
Joined: 4th Nov 2004
Location: at the right hand of Yeschua
Posted: 1st Mar 2005 16:52
Can someone explain or point me in a direction as to what multi dimensional arrays are in DB Pro ???


~Bow down to no one...Bow down to none.~
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 1st Mar 2005 18:23
Well, a 1-dimensional (1d) array would be like:

DIM array(32)

Making an array with 32 indices

A 2D array would be like:

DIM array(32,32)

An array with 32x32 indices. If you've got any experience with spreadsheets, it's an idea to visualise a 2D array as a spreadsheet - more dimensions in the array might signify 'worksheets', like a 3D array:

DIM array(256,256,10)
Which would be like a spreadsheet with 256x256 cells, and 10 pages.
In Excel terms, cell A1 on worksheet 1 might be array(0,0,0).


Van-B


It's c**p being the only coder in the village.
AtomR
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 1st Mar 2005 19:24
Excelentely put. Where have you been all my life. I get a headache trying to explain that to my brother.

Take care
AtomR
Slay The Wicked
19
Years of Service
User Offline
Joined: 4th Nov 2004
Location: at the right hand of Yeschua
Posted: 2nd Mar 2005 02:43
ok...well say you had those numbers. can you explain how that applies to entitites in a game? i don't understand taht analogy...thank you for the effort though. i DO appreciate that.

~Bow down to no one...Bow down to none.~
Zokomoko
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 2nd Mar 2005 03:33 Edited at: 2nd Mar 2005 03:34
Well, let's say your character has 4 weapons, and you want to know how much damage each weapon does.

We make a 2 dimentional array.

CharacterWeaponDamage(10,4)

In the above array, there are 10 characters, EACH has 4 weapon slots.
You can use that array for a variaty of things, like storing weapon DAMAGER, or weapon RELOAD TIME.

for example:

Here we talk about character number 1 (or entity number 1), as you can see the left number on the index represents the number of the entity, and the second number represents the weapon number.
CharacterWeaponTimer(1,1)=500 `weapon 1
CharacterWeaponTimer(1,2)=1000 `weapon 2
CharacterWeaponTimer(1,3)=1500 `weapon 3
CharacterWeaponTimer(1,4)=2000 `weapon 4
So have character 1 which has 4 weapons, each weapon holds a number.
That number represents the damage that specific weapon on that specific character does.
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 2nd Mar 2005 03:39
This belongs in the Newcomer's Corner

It is a perilous occupation for TGC to post anything by way of a promise, as the words get etched in indestructable marble for all time.
-Lee Bamber

Login to post a reply

Server time is: 2024-09-23 13:17:34
Your offset time is: 2024-09-23 13:17:34