By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,516 Members | 1,369 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,516 IT Pros & Developers. It's quick & easy.

Small Game - Ascii image in Console Application

doma23
100+
P: 107
Ciao guys,
I've started to study C++ recently.
I've made a small game in which you must guess a number from 1 to 100. You can see the code below.
What I want to do is to put an image of ascii characters instead of bingo, for example of a lady, like on this website:
http://www.codeproject.com/KB/web-image/AsciiArt.aspx

Anybody know how can I do that?
Thanks!

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main() {
  7.     int raspon = 100;
  8.  
  9.     srand(time(0)); //incijalizira generator slucajnih brojeva
  10.     rand();
  11.     //generira slucajni broj izmedju 1 i raspon:
  12.     int trazeniBroj = double(rand()) / RAND_MAX * raspon;
  13.  
  14.     cout << "You need to guess a number between 1 and " << raspon << endl;
  15.     int mojBroj;
  16.     int brojPokusa = 0;
  17.  
  18.     do {
  19.         if (brojPokusa > 9) {
  20.            cout << endl << "The required number is " << -(mojBroj-trazeniBroj) << " positions further." << endl;
  21.            cout << "Aaaaahhhh, come on, you can do better than that." << endl;
  22.         }
  23.         cout << ++brojPokusa << ". guess: ";
  24.  
  25.         cin >> mojBroj;
  26.         if (mojBroj > trazeniBroj)
  27.            cout << "LESS!" << endl;
  28.         else if (mojBroj < trazeniBroj)
  29.              cout << "MORE!" << endl;
  30.     } while (mojBroj != trazeniBroj);
  31.  
  32.     cout << endl << "BINGO!!! Yippee ki-yay... << endl;
  33.  
  34.     system("pause");
  35.     return 0;
  36. }
Oct 29 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.