Tic Tac Toe game
Author |
Message |
Cancer Sol
|
Posted: Sat Mar 16, 2013 2:54 pm Post subject: Tic Tac Toe game |
|
|
Okay so... I'm going to make a tic tac toe game through a console application. It's going to be a 2-player game (no A.I.'s).
What I'd like to know is: How do I clear the whole console screen? Or draw black on the whole game, so it's basically cleared?
Every time the game has to draw a new game board, I'm going clear the screen.
I'm also wondering, how do I use a loop for the game board but also show the new values on the board?
The board will look like:
code: |
1|2|3
-+-+-
4|5|6
-+-+-
7|8|9
//Basically, it looks like Al's Tic Tac Toe game board :P
|
So far, if I do a loop, the board will always look the same. How do I make it so that if player 1 choose to mark an "x" at number 5, then then the screen clears, the board will appear again with 5 replaced as x? Hopefully, it'll stay there each time the screen clears though :/
So far, that's the only thing I think I need help with, and credits to Al for making his Tic Tac Toe game so I kinda know how to start it |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Sat Mar 16, 2013 3:46 pm Post subject: RE:Tic Tac Toe game |
|
|
Clearing the screen in any traditional way will break cross-platform compatibility. You could just write a whole bunch of empty lines so that the old board scrolls up out of view and then draw the new one.
Quote: How do I make it so that if player 1 choose to mark an "x" at number 5, then then the screen clears, the board will appear again with 5 replaced as x
This will be very, very easy to do once you have the game actually working. I say this because if you can't figure this out, then your game probably doesn't work anyway. It's a problem that solves itself, really. |
|
|
|
|
|
Cancer Sol
|
Posted: Sat Mar 16, 2013 3:52 pm Post subject: Re: RE:Tic Tac Toe game |
|
|
Insectoid @ 3/16/2013, 3:46 pm wrote: Clearing the screen in any traditional way will break cross-platform compatibility. You could just write a whole bunch of empty lines so that the old board scrolls up out of view and then draw the new one.
Quote: How do I make it so that if player 1 choose to mark an "x" at number 5, then then the screen clears, the board will appear again with 5 replaced as x
This will be very, very easy to do once you have the game actually working. I say this because if you can't figure this out, then your game probably doesn't work anyway. It's a problem that solves itself, really.
Well so far, I think I remember seeing someone saying that if I input another value at number 5, for example, then the old value would be removed, and the variable would have the new value that was inputed. I'll try that to see if it'll work
Edit: It worked! I know how to do that part then
So far, I was only trying to output this text based picture:
c++: |
#include <iostream>
using namespace std;
void clearscreen ()
{
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl
<< endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
}
int main ()
{
cout << " __ __ " << endl
<< " \ \ / / " << endl
<< " \ \_/ /_ _ _ __ __ _ " << endl
<< " \ / _` | '_ \ / _` |" << endl
<< " | | (_| | | | | (_| |" << endl
<< " |_|\__,_|_| |_|\__, |" << endl
<< " __/ |" << endl
<< " |___/ " << endl;
}
|
but it looks really messed up when I compile and run it. Does anybody know how I can fix this problem? |
|
|
|
|
|
evildaddy911
|
Posted: Mon Mar 18, 2013 4:05 pm Post subject: RE:Tic Tac Toe game |
|
|
aren't back slashes (\) "escape" characters? meaning that the next character is treated specially, like "\n" means "new line" in most languages. Maybe the "\_" and "\ " are being interpreted differently than you think.
I'm not an expert on the C languages, but my suggestion would be to double your slashes, making the third line
code: | << " \\ \\ / / " << endl
|
|
|
|
|
|
|
Insectoid
|
Posted: Mon Mar 18, 2013 4:17 pm Post subject: RE:Tic Tac Toe game |
|
|
This was already discusses in your other thread. Tony gave you the answer you need. His answer works. I know; I've tried it. |
|
|
|
|
|
Cancer Sol
|
Posted: Wed Mar 20, 2013 6:50 pm Post subject: Re: Tic Tac Toe game |
|
|
Oh whoops, sorry. I don't even remember posting this here, but I guess I did
I'll try to be more aware of what I post in the future.
Edit: Btw, it was TZak who gave me the solution |
|
|
|
|
|
|
|