map editor help

Forum for the creative side of the game development process: art, music, storyline, gameplay, concepts, etc. Any sort of relevant discussion is welcome here.

Moderator: PC Supremacists

User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: map editor help

Post by eatcomics »

Moosader wrote:
XianForce wrote:
acerookie1 wrote:thanx moosader! :bow: :worship: :bow: . you should really add this to your 2d map editor book.
For sure... You may want to also consider adding deallocation of a dynamic 3D array... haha
Oy vey. I did, at one time, have a dynamic 3D array working. But MusuGo uses a 1D array lol. :p (it might use three/four separate 1D arrays, even. Laziness...)
that's more efficient than using multidimensional arrays they can take up a lot of memory (although you'd probably be alright to use them)
Image
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: map editor help

Post by Falco Girgis »

eatcomics wrote:
Moosader wrote:
XianForce wrote:
acerookie1 wrote:thanx moosader! :bow: :worship: :bow: . you should really add this to your 2d map editor book.
For sure... You may want to also consider adding deallocation of a dynamic 3D array... haha
Oy vey. I did, at one time, have a dynamic 3D array working. But MusuGo uses a 1D array lol. :p (it might use three/four separate 1D arrays, even. Laziness...)
that's more efficient than using multidimensional arrays they can take up a lot of memory (although you'd probably be alright to use them)
Actually, it's not. It's stored sequentially in memory, so the only difference between using a giant 1D and 2D arrays is how you are accessing them.

When you do array[3][2], the compiler is moving the pointer "array" (which points to the first object) to the correct location by adding an offset.
array + 3*COL_SIZE*sizeof(object) + 2*sizeof(object)

(the sizeof() is implicit in C/++).

The only difference between that and a one-dimensional array is an extra offset being applied. And I'm guessing that if Rachel really is using a 1D array, she's just applying that offset manually, which means that the chances are the compiler would optimize a 2D array better than a programmer emulating 2D array access.
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: map editor help

Post by K-Bal »

There are also some low level tricks to avoid demand paging and optimize cache usage when using arrays and those seem more intuitive with 1D arrays. But multi-dimensional arrays are internally 1D arrays like Falco said, so if you are aware of the memory layouts of your data it doesn't make a difference. This is also only important for arrays > 4kb.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: map editor help

Post by eatcomics »

GyroVorbis wrote:
eatcomics wrote:
Moosader wrote:
XianForce wrote:
acerookie1 wrote:thanx moosader! :bow: :worship: :bow: . you should really add this to your 2d map editor book.
For sure... You may want to also consider adding deallocation of a dynamic 3D array... haha
Oy vey. I did, at one time, have a dynamic 3D array working. But MusuGo uses a 1D array lol. :p (it might use three/four separate 1D arrays, even. Laziness...)
that's more efficient than using multidimensional arrays they can take up a lot of memory (although you'd probably be alright to use them)
Actually, it's not. It's stored sequentially in memory, so the only difference between using a giant 1D and 2D arrays is how you are accessing them.

When you do array[3][2], the compiler is moving the pointer "array" (which points to the first object) to the correct location by adding an offset.
array + 3*COL_SIZE*sizeof(object) + 2*sizeof(object)

(the sizeof() is implicit in C/++).

The only difference between that and a one-dimensional array is an extra offset being applied. And I'm guessing that if Rachel really is using a 1D array, she's just applying that offset manually, which means that the chances are the compiler would optimize a 2D array better than a programmer emulating 2D array access.
Damn you, my book lied to me, its old I guess it should be expected
Image
Post Reply