Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualServant of the Lord

Posted 01 January 2013 - 09:34 PM

They aren't a class, just a collection of functions. You can copy the code into a new empty header file and a new empty source file.
You need to make sure the files are "added" to your "project" in whatever way your IDE (Visual Studio?) requires that.
 
Then, any source file that wants to use any of the functions in Console.h must #include "Console.h".
 
Your project needs to then call "ConsoleStartup()" when you enter "main()", and "ConsoleShutdown()" before you exit main(). I think. smile.png
 
Something like this:
 
int main()
{ 
    if(ConsoleStartup() == -1)
        return -1;
    
    ResizeConsole(CONSOLE_WIDTH, CONSOLE_HEIGHT);
 
    //setup anything else here.
 
    while(playingGame)
    { 
        //Handle any events.
        //Do any time-based updates.
        //Do any drawing.

        Sleep(20);
    }
    
    ConsoleShutdown();
    
    return 0;
}

Silly enough, it appears that I hard-code the console's caption text in the ConsoleStartup() function, so you'll want to edit that as well.

#3Servant of the Lord

Posted 01 January 2013 - 09:32 PM

They aren't a class, just a collection of functions. You can copy the code into a new empty header file and a new empty source file.
You need to make sure the files are "added" to your "project" in whatever way your IDE (Visual Studio?) requires that.
 
Then, any source file that wants to use any of the functions in Console.h must #include "Console.h".
 
Your project needs to then call "ConsoleStartup()" when you enter "main()", and "ConsoleShutdown()" before you exit main(). I think. smile.png
 
Something like this:
 
int main()
{ 
    if(ConsoleStartup() == -1)
        return -1;
    
    ResizeConsole(CONSOLE_WIDTH, CONSOLE_HEIGHT);
 
    //setup anything else here.
 
    while(playingGame)
    { 
        //Handle any events.
        //Do any time-based updates.
        //Do any drawing.

        Sleep(20);
    }
    
    ConsoleShutdown();
    
    return 0;
}

#2Servant of the Lord

Posted 01 January 2013 - 09:32 PM

They aren't a class, just a collection of functions. You can copy the code into a new empty header file and a new empty source file.

You need to make sure the files are "added" to your "project" in whatever way your IDE (Visual Studio?) requires that.

 

Then, any source file that wants to use any of the functions in Console.h must #include "Console.h".

 

Your project needs to then call "ConsoleStartup()" when you enter "main()", and "ConsoleShutdown()" before you exit main(). I think. smile.png

 

Something like this:

int main()
</p><div>{ </div>
<div>if(ConsoleStartup() == -1)</div>
<div>return -1;</div>
<div> </div>
<div>ResizeConsole(CONSOLE_WIDTH, CONSOLE_HEIGHT);</div>
<div> </div>
<div>//setup anything else here.</div>
<div> </div>
<div>while(playingGame)</div>
<div>{</div>
<div> </div>
<div>//Handle any events.</div>
<div>//Do any time-based updates.</div>
<div>//Do any drawing.</div>
<div> </div>
<div>Sleep(20);</div>
<div>}</div>
<div> </div>
<div>ConsoleShutdown();</div>
<div> </div>
<div>return 0;</div>
<div>}

#1Servant of the Lord

Posted 01 January 2013 - 09:24 PM

They aren't a class, just a collection of functions. You can copy the code into a new empty header file and a new empty source file.


PARTNERS