Help with C++ project

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2007
Posts: 3
Reputation: it_dude is an unknown quantity at this point 
Solved Threads: 0
it_dude it_dude is offline Offline
Newbie Poster

Help with C++ project

 
0
  #1
Apr 12th, 2007
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!
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: Help with C++ project

 
0
  #2
Apr 12th, 2007
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.

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

will give an illusion that 1 disappears after 1 second..
Last edited by thekashyap; Apr 12th, 2007 at 10:59 am.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,131
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 283
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: Help with C++ project

 
0
  #3
Apr 12th, 2007
Originally Posted by thekashyap View Post
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.

  1. System("clrscr");
  2. printf( "1 2 3" ) ;
  3. Sleep(1000) ;
  4. System("clrscr");
  5. 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.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 3
Reputation: it_dude is an unknown quantity at this point 
Solved Threads: 0
it_dude it_dude is offline Offline
Newbie Poster

Re: Help with C++ project

 
0
  #4
Apr 12th, 2007
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:
  1. //Final Project-Game BY Dennis Rodriguez, Created/Revised April 12, 2007
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <string>
  5.  
  6. using namespace std;
  7. //validation of column function prototype
  8. int validcol(int, int, string);
  9.  
  10. int main()
  11. {
  12. //declare variables
  13. string name1 = "";
  14. string name2 = "";
  15. int col = 0;
  16. int num = 0;
  17. //Get players names
  18. cout <<"Enter player 1's name: ";
  19. cin >> name1;
  20. cout <<"Enter player 2's name: ";
  21. cin >> name2;
  22.  
  23. //clear the screen
  24. system("cls");
  25.  
  26.  
  27. //display gameboard
  28. for (int die1 = 1; die1 <= 5; die1 = die1 + 1)
  29. {
  30. for (int die2 = 1; die2 <= 3; die2 = die2 + 1)
  31. {
  32. cout << die2 << " ";
  33.  
  34. }
  35. cout << endl;
  36. }
  37. //call validcol function
  38. validcol(col,num,name1);
  39.  
  40.  
  41.  
  42.  
  43. /*cout << "Enter number to take: ";
  44.   cin >> num;*/
  45.  
  46.  
  47. while (num > 5 || num < 1){
  48. cout << num << " isn't a valid number for column " << col << ". Enter a valid number to take: ";
  49. cin >> num;
  50. }
  51.  
  52. system("pause");
  53.  
  54. }
  55. //validation of column function definition
  56. int validcol(int column,int num, string name1)
  57. {
  58.  
  59. cout << name1 << ", enter column to take from: ";
  60. cin >> column;
  61.  
  62. if (column == 1 || column == 2 || column == 3)
  63. {
  64. cout << "Enter number to take: ";
  65. cin >> num;
  66. /*cout << column << " isn't a valid column. Enter a valid column to take from: ";
  67.   cin >> column;*/
  68. }
  69. else
  70. {
  71. cout << column << " isn't a valid column. Enter a valid column to take from: ";
  72. cin >> column;
  73. }
  74. return num;
  75. }
Last edited by WaltP; Apr 13th, 2007 at 12:49 am. Reason: Added CODE tags, since you ignored the request to use them
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,131
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 283
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: Help with C++ project

 
0
  #5
Apr 13th, 2007
Did the link confuse you? Or did you simply ignore my suggestion?
Originally Posted by WaltP View Post
Be sure to read up on Code Tags first.
:evil:
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 3
Reputation: it_dude is an unknown quantity at this point 
Solved Threads: 0
it_dude it_dude is offline Offline
Newbie Poster

Re: Help with C++ project

 
0
  #6
Apr 13th, 2007
i truly didn't understand how to do it. i figured most of it out.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: Help with C++ project

 
0
  #7
Apr 13th, 2007
Originally Posted by WaltP View Post
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..

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

this will give an illusion that 1 disappears after 1 second..
Last edited by thekashyap; Apr 13th, 2007 at 3:55 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1051 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC