C++ question

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: C++ question
Master
Member # 4614
Profile Homepage #0
Alright, I'm still a beginner, so keep that in mind.

Okay, so I made a Tic-Tac-Toe game, and it seems to work pretty good. The problem is, whenever someone selects a space for their move, the program redraws the board below, with the correct changes made. After a few moves, it starts to look kind of confusing with all the different boards.

Is there some way I can just draw the new board on top of the original one each time someone moves so the same board just changes instead of drawing a whole new one.

If you know what I mean... :rolleyes:

--------------------
-ben4808

For those who love to spam:
CSM Forums
RIFQ
Posts: 3360 | Registered: Friday, June 25 2004 07:00
Shock Trooper
Member # 5181
Profile Homepage #1
In DOS or Windows, you can system() a cls command.
Posts: 262 | Registered: Thursday, November 11 2004 08:00
By Committee
Member # 4233
Profile #2
I second that. If you're building it with ASCII characters (which I assume to be the case, given you're a beginner), your only option would be to clear the screen and then redraw the table.

[ Wednesday, December 29, 2004 12:51: Message edited by: Andrew Miller ]
Posts: 2242 | Registered: Saturday, April 10 2004 07:00
Master
Member # 4614
Profile Homepage #3
So just typing system(); will clear the screen for me?

And yes, I'm using ASCII characters. Board:
| |
-+-+-
| |
-+-+-
| |
:)

--------------------
-ben4808

For those who love to spam:
CSM Forums
RIFQ
Posts: 3360 | Registered: Friday, June 25 2004 07:00
Warrior
Member # 4238
Profile #4
quote:
Originally written by 4614 and 4808:

So just typing system(); will clear the screen for me?

And yes, I'm using ASCII characters. Board:
| |
-+-+-
| |
-+-+-
| |
:)

system("cls");

Or on Unix systems:
system("clear");

This is a crappy way to do it, but the easiest.
Posts: 70 | Registered: Monday, April 12 2004 07:00
Warrior
Member # 4238
Profile #5
You'll also need the stdlib header, BTW. So:
#include <cstdlib>

...

system("cls");

Posts: 70 | Registered: Monday, April 12 2004 07:00
Master
Member # 4614
Profile Homepage #6
Okay, thanks guys. On my compiler, I have to type
#include <stdlib.h>
...
system("pause");
to get it to pause anyway. Just doing return 0; doesn't do it. I'll try it out.

EDIT: Cool. It works just fine. Two more questions come to mind, though:

1. How can you clear just a portion of the screen?
2. Is there an easy way to have the program respond to a click by the user?

[ Thursday, December 30, 2004 11:59: Message edited by: 4614 and 4808 ]

--------------------
-ben4808

For those who love to spam:
CSM Forums
RIFQ
Posts: 3360 | Registered: Friday, June 25 2004 07:00
Shock Trooper
Member # 5181
Profile Homepage #7
Yes, but you need to make a screen buffer to do it, which still involves clearing the screen in some form or another.
Posts: 262 | Registered: Thursday, November 11 2004 08:00
Master
Member # 4614
Profile Homepage #8
Huh?

--------------------
-ben4808

For those who love to spam:
CSM Forums
RIFQ
Posts: 3360 | Registered: Friday, June 25 2004 07:00
Shock Trooper
Member # 5181
Profile Homepage #9
STFW. It's fairly common.
Posts: 262 | Registered: Thursday, November 11 2004 08:00