View Single Post
Old 09-2-2015, 06:40 AM   #14
Xayphon
sausage
FFR Simfile AuthorD7 Elite KeysmasherFFR Veteran
 
Xayphon's Avatar
 
Join Date: Nov 2008
Location: Germany
Posts: 1,630
Default Re: [University - C++ Programming] Help With Assignment (Very Basic Stuff)

I wish I could help you more with this stuff, but I only know Java and Python, and I can't pinpoint how datatypes work in C++ yet myself without reading into it more. So this'll be an attempt to help you without knowing C++.

Concerning your last question, I think I can safely tell you that, even though "MAP_HEIGHT" and "MAP_WIDTH" are ints, they do not necessarily mean that two integers are used within the Array ENTITY[MAP_HEIGHT][MAP_WIDTH]. They only declare the size of the Array, which is MAP_HEIGHT x MAP_WIDTH, so 20x30. The Array can thus hold 20x30 elements of a certain Datatype.

Now the Array itself is literally empty, as in all 20x30 elements are Null, so now you have to look more into the code and find out where this array is filled with actual elements that replace the Nulls in the array. Those elements that are being put into the array are probably the datatype you are looking for.

This piece of code struck the most for me:

Code:
/*************************************************************************
	* Initialise the tile map with appropriate ENTITY values
	*/
	MAP_BUFFER		tileMap;
	
	for (unsigned int row = 0; row < MAP_HEIGHT; row++)
	{
		for (unsigned int col = 0; col < MAP_WIDTH; col++)
		{
			tileMap[row][col] = EMPTY;
		}
	}
	/*************************************************************************/
To me it seems like that what is saved in MAP_BUFFER (which is ENTITY[MAP_HEIGHT][MAP_WIDTH] ?) is now renamed to "tileMap", so the value "tileMap" becomes the ENTITY[][] Array. Thanks to the for-loop, "tileMap" aka ENTITY[][] is now being completely filled with a value called EMPTY, which is, according to this little comment before the for-loop, an "appropriate ENTITY value" (be aware that just because it is called EMPTY it does not mean the Array's elements are Null i.e. literally empty anymore, it actually contains something now). Doing 1+1, I'd then conclude that the Array holds elements of type ENTITY, which would indeed make the Array and as such MAP_BUFFER a datatype of ENTITY.

Take this advice with a grain of salt, though. I don't know if this is what's even asked for or if this is actually correct given that C++ might work completely different than Java. "tileMap" being ENTITY[][] all of sudden just because it says MAP_BUFFER was something I simply concluded without doing some read ups, but I thought this seems the most reasonable to go with. Someone might be able to provide a better or correct explanation, but I'd be glad if this helps.

Last edited by Xayphon; 09-2-2015 at 08:12 AM..
Xayphon is offline   Reply With Quote