Hello gentelemen,

I'm sure many of you are experiencing what I am experiencing right now. I'm halfway into Christmas break, back at my parents', with the paperbacks I brought along depleted, the roguelike I downloaded unable to start after an OS upgrade and literally nothing else to do for the next 3-4 days I'm gonna be staying here.

So, what the heck, I might as well try playing around with some code. I'm bad at C++ anyway so I could use the extra familiarity with it.

Hence I started making a little console-operated Monopoly game, to show my litte sister the basics of C++. Thing is, I need your feedback on how to do the follwing stuff:

•Blinking text of one line. I admit it, I want to make a little "Press Start to begin..." welcome screen, along with some ascii art made by my little assistant. I googled around only to find a wacky set of solutions (and an entertaining little argument about system("cls"); in a thread hosted here, heh), the best one being "Clearing the whole console using clrscr(); and re-printing the whole thing...
I was wondering if you guys had experience with anything of the like?

•Selective console output erasing. I'm gonna need it as some points, and it might even help with the above topic (erase the "Prss B to Begin" then reprinting it, then again and again etc). Can I manage it without clearing the whole screen and reprinting everything without the stuff I need erased? Sure, what I am saying is a solution, but it seems so wasteful...

In any case, happy new year to everyone reading this thread, any replies will be appreciated.

Well... that is one option or you could alternate between printing and writing blank spaces over the written text ( like clrscr(), bt not using it ) with a delay command in the middle...

You can keep doing that in a while loop until u press enter! Example code below :

#include<iostream.h>
#include<conio.h>
#include<dos.h>

void main()
{ while(getche()!='\r')
     { gotoxy(24,10);
       cout<<"Press Enter Key To Begin";
       delay(300);
       gotoxy(24,12);
       cout<<"                          ";
      }
}

Well... that is one option or you could alternate between printing and writing blank spaces over the written text ( like clrscr(), bt not using it ) with a delay command in the middle...

You can keep doing that in a while loop until u press enter! Example code below :

#include<iostream.h>
#include<conio.h>
#include<dos.h>

void main()
{ while(getche()!='\r')
     { gotoxy(24,10);
       cout<<"Press Enter Key To Begin";
       delay(300);
       gotoxy(24,12);
       cout<<"                          ";
      }
}

That's another way to approach the problem, nice.
Thank you :3

So, what the heck, I might as well try playing around with some code. I'm bad at C++ anyway so I could use the extra familiarity with it.

So why would you want to familiarize yourself with something that cannot easily be done in C++, is very compiler specific (it won't work on most compilers), and is not part of the C++ Standard?

IMO, you'd be better off dealing with problems that utilize the language as it's designed rather than using hacked-together code.

I think a Monopoly Game is a good idea, just wait on all that fancy stuff until you know the language well enough to add a GUI package. Design all your output and input as functions that can be replaced with calls to the GUI later.

Just my 2-cents.

Your welcome :)

commented: Helpful links +0

So why would you want to familiarize yourself with something that cannot easily be done in C++, is very compiler specific (it won't work on most compilers), and is not part of the C++ Standard?

IMO, you'd be better off dealing with problems that utilize the language as it's designed rather than using hacked-together code.

I think a Monopoly Game is a good idea, just wait on all that fancy stuff until you know the language well enough to add a GUI package. Design all your output and input as functions that can be replaced with calls to the GUI later.

Just my 2-cents.

I understand... Maybe it would be prudent to leave the fancy stuff alone for a while. As you said, all I've been finding to realise some of it was hacked together code.

Quick heads-up about the Monopoly.

I made a LOT structure (little sis cannot understand classes, even if I don't place them in different header files, so I resorted to structures) and attempted to initialise the board using the following code:

LOT Board[40];        
buildBoard(Board);

with buildBoard being the following:

void buildBoard(LOT* &board)
{
     int boardLength=strlen(board);
     //code here that lets you build random logs based on how many places
     //you actually want to be in the board
     cout <<"BOARD BEING BUILT... Length: "<<board_size<<endl;
     for(int i=0;i<boardLength;i++)
     {
        //fillup code be here!
     }
}

Of course, the use of strlen() there returns a compilation error as it expects a const char* as a parameter, not a LOT* (no pun intended)
Is there any way to get the size of the LOT array so i can fill the board with as many plaaces as I tell buildBoard to, without having to resort to sending the board size I want in a different var, with something like this?

void buildBoard(LOT* &board,int board_size)
{
     //code here that lets you build random logs based on how many places
     //you actually want to be in the board
     cout <<"BOARD BEING BUILT... Length: "<<boardLength<<endl;
     for(int i=0;i<board_size;i++)
     {
        //fillup code be here!
     }
}

int main()
{
   #define BOARD_SIZE 40
   LOT Board[BOARD_SIZE];
   buildBoard[Board,BOARD_SIZE];
   return 0;
}

And before someone notes it: Yes, the compiler also protests at me using void buildBoard(LOT* &board,int board_size). Can I not send an array of references as a parameter?

EDIT: Don't mind me, I'm dumb, after messing around a bit I was able to work it out. void buildBoard(LOT *board,int board_size){} works fine because, well... a pointer is used for reference.

Most of the features you want are probably available via the operating system API, I'll assume you're using Windows so here's the API ref.

http://msdn.microsoft.com/en-us/library/ff818516(v=vs.85).aspx

of course you don't have to roll your own, there is plenty of code available for random stuff.
http://www.codeproject.com/KB/cpp/AddColorConsole.aspx

otherwise here's the console link:
http://msdn.microsoft.com/en-us/library/ms682087(v=VS.85).aspx

That codeproject lib looks like a good one because it implements changing text colors as some stream manipulators.

commented: Helpful links in my C++ help thread +0

For any gentleman still interested:

The project is finished. Sure, it's a huge .cpp with 2880 lines and the most simplistic structures, but it's a lightweight enough classic monopoly game, through console.

Thank you, all of you.

You can find the whole project in a rar, under boardgames, here: dsfounis.carbonmade.com

Oh, and thread solves, +thanks to all of you.

Hi All, I was wondering if there was some way to simplify. Blinking Text In 2008 C++, I've tried different methods but seem to be at a loss.
I know the one way is to use the code

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14); // gives you yellow

But how can I get that to blink with a specific color in C++ 2008. Well gentleman I appreciate any advice or suggestions.Also to add that #include<windows.h> helps in the above.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.