View Single Post
Old 09-4-2015, 10:16 PM   #17
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)

As much as it might not be relevant to my assignment, it was super helpful. The Terraria example you gave made sense and I think I've got an idea of how this array works. Now every time I play Terraria, I'm going to be running around being like, 'some ore here, that tile is a 1' and 'Ooooh there's nothing there, it must be EMPTY in the array cause that's what 0 is'.

Anyway, I've written an answer for that question and that ticks off the code analysis part. Now comes writing and modifying the code. Here is my next question:

Your first coding task is to create a function that performs the initialisation of the console window and to replace the existing code within main that serves this purpose with an invocation of this new function. Your function must adhere to the declaration
Code:
void InitConsole(const unsigned int, const unsigned int);
where the function arguments are the height and width of the window buffer. You will need to provide a definition for this function that implements the functionality currently provided within main.


So far, I think I've located the piece of code that I need to modify, I'm just not sure what to modify. I have declared InitConsole, that was no problem. Here's the section of code I think I need to modify:
Code:
/**************************************************************************
	  * Initialise the standard output console
	  */		
	HANDLE	hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
	if (hStdOut != INVALID_HANDLE_VALUE)
	{
		ClearConsole(hStdOut);

		// Set window title
		SetConsoleTitle(TEXT("Tile Map Demo"));

		// Set window size
		SMALL_RECT srWindowRect;
		srWindowRect.Left = 0;
		srWindowRect.Top = 0;
		srWindowRect.Bottom = srWindowRect.Top + MAP_HEIGHT;
		srWindowRect.Right = srWindowRect.Left + MAP_WIDTH;

		SetConsoleWindowInfo(hStdOut, true, &srWindowRect);

		// Set screen buffer size
		COORD cWindowSize = { MAP_WIDTH, MAP_HEIGHT };
		SetConsoleScreenBufferSize(hStdOut, cWindowSize);
	}
Can someone tell me if this is the right section I need to modify and what exactly I need to change? I've tried changing ClearConsole(hStdOut) to InitConsole but the hStdOut part becomes incorrect. Assuming this because I didn't declare it as a parameter for InitConsole but when I tried to do this, it says 'type name not allowed'. Halp please!
__________________
sickufully is offline   Reply With Quote