View Single Post
Old 09-3-2015, 03:54 AM   #15
sickufully
Sir Krisk
FFR Veteran
 
sickufully's Avatar
 
Join Date: Dec 2007
Location: Vic, Australia
Posts: 930
Default Re: [University - C++ Programming] Help With Assignment (Very Basic Stuff)

Wow thanks man, that was a huge help. The whole array part of this is slowly starting to click into place in my head now and I think I have a better understanding of how this array works (providing that your non-existent c++ knowledge is correct but since you sound like you know what you're taking about, I'm assuming it is correct :P). Also, sorry for the late reply, been at work for the past 10 hours.

So basically what you're saying is that the Array called ENTITY[MAP_HEIGHT][MAP_WIDTH] is empty, even though map height & width are ints, it doesn't mean that the 20x30 'boxes' in the array are filled with ints, until the value called EMPTY fills each 'box' in the array?

When I say boxes (of an array), this is what I mean. Also, each of these boxes are empty until the value EMPTY is used.
______________________________________
|____|____|____|____|____|____|____|____|
|____|____|____|____|____|____|____|____|
|____|____|____|____|____|____|____|____|
|____|____|____|____|____|____|____|____|
|____|____|____|____|____|____|____|____|
|____|____|____|____|____|____|____|____|

From what I gather, EMPTY is a value that equals 0.
Code:
enum entity_labels	{
	EMPTY = 0,
	WALL
};
So, when initialising the tilemap array with data elements, each time it moves to the next box, consecutive numbers are entered. This is what I mean:
______________________________________________
|__0__|__1__|__2__|__3__|__4__|__5__|__6__|__7__|
|__8__|__9__|__etc__|__etc__|____|____|____|____|
|____|____|____|____|____|____|____|____|
|____|____|____|____|____|____|____|____|
|____|____|____|____|____|____|____|____|
|____|____|____|____|____|____|____|____|

The only way I came to this conclusion is by these lines and the increment signs (row++ & col++). This also leads me to believe that the data type in the array is int because if EMPTY = 0, then increments can only be 1, 2, 3, 4, 5, etc.. Actually, just re-reading over that last sentence, that doesn't even make sense to me. It's surely wrong.
Code:
for (unsigned int row = 0; row < MAP_HEIGHT; row++)

		for (unsigned int col = 0; col < MAP_WIDTH; col++)
I'm not sure how close I am to figuring this out but this seemed like a logical answer.
__________________

Last edited by sickufully; 09-3-2015 at 06:38 AM..
sickufully is offline   Reply With Quote