I'm trying to make the tic tac toe console game from the beginners exorcises article, but i don't know any way to control the console.
is there a way that i can make a very simple text based GUI that will let me highlight the different squares of the game board? and clear/redraw the screen, when i need to to? from what Ive read i shouldn't use any calls to system..
I'm using Code::Blocks as my IDE, and I'm on windows.
any one know what i should do?
i know i could prolly just get around it and ask the user for the coordinates, but i don't like that :<
also id like to have a way of controlling the color of the text as well...
and maybe formating the text that comes out...
@NGen
i already knew that, and I'm trying to find out about ways of controlling the console, like clearing the screen, and changing the color of things, and the spacing between things.
I'm new to c++ and i have no idea how to use PDcurses, it isn't a built in thing like #include <iostream> i don't think.
Nope, it's not built in. Anyway, to change the spaces, you can use stream manipulators like setprecision() or fixed. For colors/stuff, that can vary by console/OS, so you are basically stuck using a 3rd party library like PDcurses.
N/PDCurses is good though. You'll need to download it; it will come with instructions on where to place it. If it doesn't; I'll tell you anyway:
1. Open CodeBlocks
2. Navigate to Settings -> Compiler and Debugger...
3. Find the "Search Directories" tab; and add the path where you placed the header (".h") files of PDCurses; e.g.
C:\Program Files\CodeBlocks\PDCurses
C:\Program Files\CodeBlocks\PDCurses\win32
4. Find the "Linker Settings" tab. Click "add" In Link Libraries and type the parths to the libraries, e.g.
C:\Program Files\CodeBlocks\PDCurses\win32\panel.a
C:\Program Files\CodeBlocks\PDCurses\win32\pdcurses.a
5. Then try the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <curses.h>
int main() {
initscr(); /* Initialize the screen */
printw("Use this function like printf... but with a w.");
refresh(); /* Because curses stores your window data in a structure; you need to refresh() when you want
* to see what you've done */
endwin(); /* Destroy the curses window */
return 0;
}
So you have pdcurses.dll?
You'll need to #include <curses.h> and then load the DLL; http://www.codeproject.com/KB/DLL/loadingdll.aspx
That's the best I can do, I'm afraid, unless you download and install cygwin and use that...
Edit: This simplifies things; you just have to statically link pdcurses.lib
Otherwise you'd have to dynamically link pdcurses.dll; meaning if you were to distribute anything the DLL would HAVE to go along with it, in the same folder or, AFAIK, the system32 folder.
@bazzy
it confuses me because I'm new to c++, i don't understand the workings of includes and what any of those linking things mean :(
@chrisname
i don't really understand this linking stuff...
and that talks about VC++ I'll try to figure it out in code blocks tho..
thank you for putting up with my questions..
i don't understand the workings of includes and what any of those linking things mean
#include<header> puts the entire contents of the header file in your source file, the header contains the declarations of some symbols present in the library. Linking your program to a library ( as the word 'link' suggest ) makes your program know where the definitions of those library stuff are.
If you link statically, all the contents of the library will be present in your binary file ( which will be heavier but more portable )
If you link statically, you must have the DLL in the computer to run the program. ( The binary file size would be smaller but you have to make sure that the library is installed in the computer )
chrisname already told you what you need to do, replace the names of the files he gave you to those you have the file downloaded:
2. Navigate to Settings -> Compiler and Debugger...
3. Find the "Search Directories" tab; and add the path where you placed the header (".h") files of PDCurses; e.g.
C:\Program Files\CodeBlocks\PDCurses ( directory in which curses.h is installed )
C:\Program Files\CodeBlocks\PDCurses\win32
4. Find the "Linker Settings" tab. Click "add" In Link Libraries and type the parths to the libraries, e.g.
C:\Program Files\CodeBlocks\PDCurses\win32\panel.a ( library files )
C:\Program Files\CodeBlocks\PDCurses\win32\pdcurses.a
The easiest way of installing curses to work with CodeBlocks on Windows is this: http://pdcurses.slashon.com/ - download the library from there -