Page 4 of 4

Re: Tile Engine question

Posted: Thu Mar 25, 2010 2:44 pm
by Falco Girgis
Okay, I've been looking back over this topic, and I am SOOO done with this shit. There is a fundamental misunderstanding about how we are representing map arrays. The guys that posted before avansc were representing their maps as 2D arrays of tiles like:

Code: Select all

Tile **tile;
I was arguing for representing them as an array of indices into an array of tiles:

Code: Select all

Tile tileset[256];
unsigned char tile[WIDTH][HEIGHT];
avansc defends the other method with:
avansc wrote:while i agree that doing something like tile[layers][width][height]; is "prettier" than doing Tile ***tiles;

i prefer doing ***tiles. here is why.
Here is where the misunderstanding happened. He said it was "prettier' than doing Tile ***tiles. What the fuck datatype is that? Tile. Not a character. Not an index into a list. That is a fucking TILE POINTER.

So I was thinking that he was talking about dynamically allocated a 2D array where each element is a POINTER to a Tile. In which case everything that I said was completely, 100% correct. The sizeof(Tile*) is 4/8bytes while character index is 1 byte.

Then MAGICALLY, avansc comes back with 3D array of CHARACTERS. Now the third pointer dimension no longer represents a pointer to a Tile, but DEPTH.

There is a misunderstanding between whether we had a 2D array of Tile pointers or a 3D array of characters. Avansc said one thing, then flopped and showed the code and memory sizes for another.

I'm so fucking done here. Whether you did it on purpose or accident avansc, your original argument no longer matches the case you are trying to present. I'm sick of scouring through code and posts searching for logic and truth through misunderstandings and your inconsistencies.

Everything that I said was completely relevant and true to avansc's original argument of a dynamic 2D array of tile pointers. Now that avansc has changed completely, it's a simple matter of heap versus stack allocation, which is something that I never, ever would have argued about. And no shit, it isn't magically going to take more space on the heap than the stack.

Peace.

Re: Tile Engine question

Posted: Thu Mar 25, 2010 3:48 pm
by avansc
ummm. you might want to re read my post, the first time i mentioned
"Tile ***tiles", was right after xianforce had this.

Code: Select all

class Layer
{
Tile** tiles
};

class Map
{
std::vector<Layer> layers;
};
the Tile ***tiles has always been a 3D array, i never refer or imply its 2D. the extra * was in place of using the vector.

"So I was thinking that he was talking about dynamically allocated a 2D array where each element is a POINTER to a Tile. In which case everything that I said was completely, 100% correct. The sizeof(Tile*) is 4/8bytes while character index is 1 byte."

not sure how you got it was 2D, since i complare char*** to char[][][] and even mention depth, height and width. not just height and width.

i dont care if your tile type is char or Tile or whatever, it wont make a difference on the size argument, (baring that both declarations on the heap and stack use the same type)

AND i still maintain that you dont need to WASTE memory, but its your prerogative.

"Everything that I said was completely relevant and true to avansc's original argument of a dynamic 2D array of tile pointers. Now that avansc has changed completely"

please show me where i indicated 2D, and where i changed.. look this was a simple misunderstanding, and im sorry if i was not clear or misunderstood you, BUT dont say i said and did something i clearly did not.

i only used characters since i got that was what you used, and just tried to maintain a common ground there...

ps: and when i said only using as much memory as you need is the smart thing to do, and if you use more merely because its convenient is not smark, or lazy as i put it, i was not implying that you are stupid or lazy, id never presume that, i know you are capable and a hard worker. I dont wanna fight or argue with you, not my intention, it was just a big misunderstanding i guess.

Re: Tile Engine question

Posted: Thu Mar 25, 2010 7:04 pm
by Falco Girgis
All that I was saying was that if your ***map was of Tile type, it would imply that you had a 2D array of pointers to tiles, because I know that you are smart enough to not ACTUALLY have an array of Tiles.

Think about it. That changes everything. A 2D array of Tile* would be much larger than a corresponding array of characters. Your original post said that you agreed with "Tile ***", which is the entire reason I even argued to begin with.
avansc wrote:i dont care if your tile type is char or Tile or whatever, it wont make a difference on the size argument, (baring that both declarations on the heap and stack use the same type)
That makes a HUGE difference. a Tile* is bigger than a character. I don't think you really understand what "tile" is in a 2D game. It's a structure containing attributes like:

Code: Select all

struct Tile {
    bool solid;
    etc.
}
that the map is indexing. You seem to think that "Tile" and "char" are completely interchangeable, which is where the entire debate came from. You were incorrect in saying that you prefer "Tile***" while you really were talking about a 3D character array.

We're good, though. It was a misunderstanding. You were defending a 3D array of characters. I was offending a 2D array of tile pointers.

Re: Tile Engine question

Posted: Thu Mar 25, 2010 7:53 pm
by Falco Girgis
Avansc and I have made amends. It was a gigantic, unfortunate misunderstanding. We were arguing two different things at each other.

We're cool. :)

Re: Tile Engine question

Posted: Thu Mar 25, 2010 9:26 pm
by mattheweston
Ok, I've narrowed after further research I've narrowed my design down to two options and would like pros/cons of each.

Keep in mind target platform is the xBox and PC using XNA.

design #1: A structure with a 2D array for each layer.

Code: Select all

pseudocode

struct map {

int BaseLayer[width,height]
int TransitionLayer[width, height]
int CollisionLayer[width, height]
int ObjectLayer[width, height]
}

design #2 A 3D array


Also if you have any suggestions for additional layers let me know.

Any feedback is welcome and encouraged after all how can I learn without feedback. =)

Re: Tile Engine question

Posted: Thu Mar 25, 2010 9:54 pm
by avansc
using a 3D array certainly makes it alot easier to add extra layers without changing other code.

Re: Tile Engine question

Posted: Thu Mar 25, 2010 9:57 pm
by XianForce
Just a quick nitpick on that ^^:

Because you are representing them as integers, I'm assuming that it 'references' an actual tile in your tilesheet. If this is the case, using an integer will probably provide many more values than you need. A byte in C# on the other hand, has 256 different values, which is probably much more reasonable...

EDIT: On the OPs post, not avansc >.>

Re: Tile Engine question

Posted: Thu Mar 25, 2010 10:00 pm
by mattheweston
Well the issue I ran into was ease of loading/saving maps.

I would tend to think it would be easier to have the separate 2D arrays; however, I could be wrong and just haven't had enough experience with 3D arrays to know better. =)

Re: Tile Engine question

Posted: Thu Mar 25, 2010 10:45 pm
by avansc
mattheweston wrote:Well the issue I ran into was ease of loading/saving maps.

I would tend to think it would be easier to have the separate 2D arrays; however, I could be wrong and just haven't had enough experience with 3D arrays to know better. =)
ah yeas i see what you are saying. okay, as for making code scalable here is why a 3D array would be easier.

consider your draw function

for height
for width
draw layer1[height][depth]
draw layer2[height][depth]
end
end

so each time you add a new layer, or take one away, you have to change the draw call. on the other hand if you have a 3D array

for depth
for height
for width
draw layer[depth][height][width]
end
end
end

now for saving the map easily.. okay..

http://www.switchonthecode.com/tutorial ... -to-a-file
http://www.codeproject.com/KB/cs/objserial.aspx

look at that. you can save the entire map in one command, and load it back up.

Re: Tile Engine question

Posted: Thu Mar 25, 2010 11:19 pm
by mattheweston
Ok, so I serialize my load/save of maps?

Sounds like a great idea actually. But, I would like some other opinions before making a final decision. More so out of curiousity.

Re: Tile Engine question

Posted: Fri Mar 26, 2010 12:31 pm
by K-Bal
GyroVorbis wrote:Avansc and I have made amends. It was a gigantic, unfortunate misunderstanding. We were arguing two different things at each other.

We're cool. :)
Oh my gawd. So what discussion is up next? Health care? :)

Re: Tile Engine question

Posted: Fri Mar 26, 2010 12:39 pm
by avansc
K-Bal wrote:
GyroVorbis wrote:Avansc and I have made amends. It was a gigantic, unfortunate misunderstanding. We were arguing two different things at each other.

We're cool. :)
Oh my gawd. So what discussion is up next? Health care? :)
only if your mom will be my nurse.

Re: Tile Engine question

Posted: Fri Mar 26, 2010 12:41 pm
by Falco Girgis
K-Bal wrote:
GyroVorbis wrote:Avansc and I have made amends. It was a gigantic, unfortunate misunderstanding. We were arguing two different things at each other.

We're cool. :)
Oh my gawd. So what discussion is up next? Health care? :)
It was a completely legitimate argument. The only problem was that we both thought that we were arguing separate things.

Re: Tile Engine question

Posted: Fri Mar 26, 2010 12:51 pm
by K-Bal
Yeah I understood that ;) It's just interesting to see how much emotion people can put even in minor important discussions when everyone is so profoundly convinced of his opinion.