Paradox and edwardr
if I had 4 columns of a "Gun" array: gunID, damage, speed, firerate
Global constant number GUN_ID = 0
Global constant number DAMAGE = 1
Global constant number SPEED = 2
Global constant number FIRE_RATE = 3
so it reads:
GunArray Set value at (0,GUN_ID) to 1
GunArray Set value at (0,DAMAGE) to 10
GunArray Set value at (0,SPEED) to 400
GunArray Set value at (0,FIRE_RATE) to 1
GunArray Set value at (1,GUN_ID) to 2
GunArray Set value at (1,DAMAGE) to 5
GunArray Set value at (1,SPEED) to 400
GunArray Set value at (1,FIRE_RATE) to 1
GunArray Set value at (2,GUN_ID) to 3
GunArray Set value at (2,DAMAGE) to 40
GunArray Set value at (2,SPEED) to 300
GunArray Set value at (2,FIRE_RATE) to 3
GunArray Set value at (3,GUN_ID) to 4
GunArray Set value at (3,DAMAGE) to 100
GunArray Set value at (3,SPEED) to 200
GunArray Set value at (3,FIRE_RATE) to 10
ahhhhh I feel better..
I consider this best practice, it can be called 'self-documenting code' BTW it's the rows not the columns, and of course you can also do it for the columns (i.e. PISTOL=0, SHOTGUN=1, RIFLE=2 etc). So,
GunArray Set value at (PISTOL, GUN_ID) to 1
GunArray Set value at (PISTOL, DAMAGE) to 10
GunArray Set value at (PISTOL, SPEED) to 400
GunArray Set value at (PISTOL, FIRE_RATE) to 1
and you can use these everywhere, not just when initialising the array. Also not meaning to be pedantic but, #defines for constants in C++? ... hmm don't do it
[quote:3qjjiam2] and I make them all caps as well.
edit: just remembered, C2 forces constant variables uppercase