Help with C++ project
59 Minutes Ago | Add to it_dude's Reputation vbrep_register("343564") | Flag Bad Post | #1
I am a beginning programmer and urgently need help with a project that requires me making a game consisting of a "gameboard". It looks something like this:
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3

The goal is to find a way to cause the numbers to disappear.
For example if I choose column 1, and an amount of 3, the board look like this:

2 3
2 3
2 3
1 2 3
1 2 3

There are 2 players in the game and the game finishes when the last player is left with a number.
I want to know how to make the numbers disappear.
PLEASE HELP!

Usually if the board is not too big reprinting the whole thing (with spaces where you want a number the disappear) does the trick fast enough..
clear the screen before you print of course..
E.g.

System("clrscr");
printf( "1  2  3" ) ;
Sleep(1000) ;
System("clrscr");
printf( "   2  3" ) ;

will give an illusion that 1 disappears after 1 second..

Usually if the board is not too big reprinting the whole thing (with spaces where you want a number the disappear) does the trick fast enough..
clear the screen before you print of course..
E.g.

System("clrscr");
printf( "1  2  3" ) ;
Sleep(1000) ;
System("clrscr");
printf( "   2  3" ) ;

will give an illusion that 1 disappears after 1 second..

Except for the fact that System() is undefined and Sleep() may not be defined (depends on your compiler).

it_dude, you need to describe what you want better than that. From your description there are hundreds of ways to do what you want, but few will be useful to you (as you can see from thekashyap's response ;))

Try posting code so we know what you are dealing with. Be sure to read up on Code Tags first.

My questin is how do i make numbers disappear from the gameboard using for statements and preferably no arrays. i was able to make it build a gameboard but don't know what next step in making it disappear
Here is my code:

//Final Project-Game BY Dennis Rodriguez, Created/Revised April 12, 2007
#include <iostream>
#include <iomanip>
#include <string>
 
using namespace std;
//validation of column function prototype
int validcol(int, int, string);

int main()
{
 //declare variables
 string name1 = "";
 string name2 = "";
 int col = 0;
 int num = 0;
    //Get players names
 cout <<"Enter player 1's name: ";
 cin >> name1;
 cout <<"Enter player 2's name: ";
 cin >> name2;
 
 //clear the screen
 system("cls");
   
    
   //display gameboard
    for (int die1 = 1; die1 <= 5; die1 = die1 + 1)
    {
        for (int die2 = 1; die2 <= 3; die2 = die2 + 1)
        {
   cout << die2 << "     ";
   
  }
  cout << endl;
 }
 //call validcol function
 validcol(col,num,name1);    
         
 
 
 
 /*cout << "Enter number to take: ";
    cin >> num;*/
 
 
 while (num > 5 || num < 1){
  cout << num << " isn't a valid number for column " << col << ".  Enter a valid number to take: ";
  cin >> num; 
 }
 
    system("pause");
    
}
//validation of column function definition
int validcol(int column,int num, string name1)
{
      
    cout << name1 << ", enter column to take from: ";
 cin >> column;
 
 if (column == 1 || column == 2 || column == 3)
    {
  cout << "Enter number to take: ";
        cin >> num;
        /*cout << column << " isn't a valid column.  Enter a valid column to take from: ";
  cin >> column;*/   
    }
    else
    {
        cout << column << " isn't a valid column.  Enter a valid column to take from: ";
  cin >> column; 
    }
    return  num;   
}

i truly didn't understand how to do it. i figured most of it out.

Except for the fact that System() is undefined and Sleep() may not be defined (depends on your compiler).

You're right.. But I was hoping it_dude will figure that much out himself.. anyway here is teh updated suggestion.. :)

//something that will clear the screen e.g. system("cls");
printf( "1  2  3" ) ;
//something that will make this thread sleep for a minute e.g. Sleep(1000) ;
//something that will clear the screen e.g. system("cls");
printf( "   2  3" ) ;

this will give an illusion that 1 disappears after 1 second..

This article has been dead for over six months. Start a new discussion instead.