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)Moosader wrote: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...)XianForce wrote:For sure... You may want to also consider adding deallocation of a dynamic 3D array... hahaacerookie1 wrote:thanx moosader! . you should really add this to your 2d map editor book.
map editor help
Moderator: PC Supremacists
Re: map editor help
- Falco Girgis
- 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
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.eatcomics wrote: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)Moosader wrote: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...)XianForce wrote:For sure... You may want to also consider adding deallocation of a dynamic 3D array... hahaacerookie1 wrote:thanx moosader! . you should really add this to your 2d map editor book.
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.
Re: map editor help
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.
Re: map editor help
Damn you, my book lied to me, its old I guess it should be expectedGyroVorbis wrote: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.eatcomics wrote: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)Moosader wrote: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...)XianForce wrote:For sure... You may want to also consider adding deallocation of a dynamic 3D array... hahaacerookie1 wrote:thanx moosader! . you should really add this to your 2d map editor book.
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.