944,027 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1137
  • C++ RSS
Apr 12th, 2007
0

Help with C++ project

Expand Post »
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!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
it_dude is offline Offline
3 posts
since Apr 2007
Apr 12th, 2007
0

Re: Help with C++ project

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.
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
Apr 12th, 2007
0

Re: Help with C++ project

Click to Expand / Collapse  Quote originally posted by thekashyap ...
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.
Moderator
Reputation Points: 3278
Solved Threads: 894
Posting Sage
WaltP is offline Offline
7,747 posts
since May 2006
Apr 12th, 2007
0

Re: Help with C++ project

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
it_dude is offline Offline
3 posts
since Apr 2007
Apr 13th, 2007
0

Re: Help with C++ project

Did the link confuse you? Or did you simply ignore my suggestion?
Click to Expand / Collapse  Quote originally posted by WaltP ...
Be sure to read up on Code Tags first.
:evil:
Moderator
Reputation Points: 3278
Solved Threads: 894
Posting Sage
WaltP is offline Offline
7,747 posts
since May 2006
Apr 13th, 2007
0

Re: Help with C++ project

i truly didn't understand how to do it. i figured most of it out.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
it_dude is offline Offline
3 posts
since Apr 2007
Apr 13th, 2007
0

Re: Help with C++ project

Click to Expand / Collapse  Quote originally posted by WaltP ...
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.
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Finding matchin characers in strings
Next Thread in C++ Forum Timeline: operator - (minus) overloading problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC