DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   C++ game? (http://www.daniweb.com/forums/thread5123.html)

viperman224 Apr 6th, 2004 10:11 pm
C++ game?
 
Is it possible to make a very simple game with C++? any good sites to read up on how to do it? I have a program called Dev-C++. any kind of tips or code that i should know? I'm am just a noob at C++. I wish to play with it before I attend a computer programing camp during this summer. thanks

Creator Apr 6th, 2004 11:18 pm
Re: C++ game?
 
Of course it is possible. I've been thinking about making a command-line (text) based RPG with C++. What you could do is say, create some bad guys, create a menu of what the user can do to them, randomize some attacks and etc... It will take a lot of function work but yes it could be done. I don't know of any good sites that provide basic game info. But there are lots of OpenGL sites and advanced sites. But you won't make a 3D game by this summer so I'd stick with command line stuff.

BountyX Apr 6th, 2004 11:47 pm
Re: C++ game?
 
C/C++ is a fully functional language, you make the computer do virtually ANYTHING you want. The limitations of the language can be overcome with experience and skills.

BTW: 73.2 % of all games on the market are created in C/C++ in cluding popular titles such as Warcraft 3, and Diablo 2.

Creator Apr 7th, 2004 3:42 am
Re: C++ game?
 
I just wrote a small game in C++. I also have the source code to a few RPG games. It actually isn't that hard to make a console RPG. And as BountyX said, funny you should ask if games could be made in C++ because almost all games are. So you've picked the right language! You wouldn't want Java or C# as much because they are slower languages.

Tempus Apr 7th, 2004 3:51 pm
Re: C++ game?
 
You can now get the original Quake source files (C++) and see what a full game looks like.

Check the website for it. Its released under the GNU rules.

Bleek Apr 8th, 2004 6:19 pm
Re: C++ game?
 
i have my first game code of a dice game you can look at if you would like. ill post it if you reply back, it displays the dice using characters... its simple but i like it.

viperman224 Apr 8th, 2004 8:05 pm
Re: C++ game?
 
I would be glad to take a look at it

BountyX Apr 9th, 2004 2:16 pm
Re: C++ game?
 
post is please :)

Tempus Apr 13th, 2004 11:06 am
Re: C++ game?
 
Honestly, you really should use C#. Its alot more fun.

Bleek Apr 13th, 2004 5:34 pm
Re: C++ game?
 
i wrote it a while ago but anyways...
Dice Game

/*
  Name: Dice Game
  Author: Bleek
  Description: Game
  Date: N/A
  Copyright: N/A
*/

#include <iostream>
#include <time.h>
#include <cstdlib>
#include <windows.h>
using namespace std;
void one();
void two();
void three();
void four();
void five();
void six();
//Declare Functions used
int main()
{
short unsigned int score = 0;
short unsigned int compScore = 0;
short unsigned int num = 0;
short unsigned int num2 = 0;
short unsigned int compNum = 0;
short unsigned int compNum2 = 0;
short unsigned int sum = 0;
short unsigned int compSum = 0;
char letter;
//Declare Variables
srand(time(NULL));
//Initialize random number generator
system("title Joe's Dice Game");
while (letter != 'q')
{
    cout << "Your Score: " << score << endl;
    cout << "computer's Score: " << compScore << endl << endl;
    cout << "Press r to roll or q to quit: ";
    cin >> letter;
    num = 1 + rand() % (6 - 1 + 1);
    num2 = 1 + rand() % (6 - 1 + 1);
    compNum = 1 + rand() % (6 - 1 + 1);
    compNum2 = 1 + rand() % (6 - 1 + 1);
   
    //Random numbers
   
    sum = num + num2;
    compSum = compNum + compNum2;
   
    //Calculate Sums
   
    if (letter == 'q')
        break;
    if (letter != 'r')
    {
        system("cls");
        continue;
    }
   
    switch (num)
    {
        case 1:
                one();
                break;
        case 2:
                two();
                break;
        case 3:
                three();
                break;
        case 4:
                four();
                break;
        case 5:
                five();
                break;
        case 6:
                six();
                break;
        default:
                cout << "Error...";
                break;
    } //end switch
   
    switch (num2)
    {
        case 1:
                one();
                break;
        case 2:
                two();
                break;
        case 3:
                three();
                break;
        case 4:
                four();
                break;
        case 5:
                five();
                break;
        case 6:
                six();
                break;
        default:
                cout << "Error...";
                break;
    } //end switch
       
    cout << endl << "Yours: " << num << ", " << num2 << endl;
    cout << "Computer's: " << compNum << ", " << compNum2 << "\n\n";
   
    //Display dice and numbers
   
    if (sum > compSum)
    {
        cout << "You won!!" << endl << endl;
        score++;
    }
    else
    {
        compScore++;
        cout << "you lost..." << endl << endl;
    }
   
    //Calculate score
   
    system("pause");
    system("cls");
   
    if (score == 12)
    {
        MessageBox(0, "You Won!!!", "Results:", MB_ICONEXCLAMATION);
        break;
    }
    if (compScore == 12)
    {
        MessageBox(0, "You lost...", "Results:", MB_ICONEXCLAMATION);
        break;   
    }
}
return 0;
}

void one()
{
cout << " -----" << endl;
cout << "|    |" << endl;
cout << "|  O  |" << endl;
cout << "|    |" << endl;
cout <<  " -----" << endl;
}
void two()
{
cout << " -----" << endl;
cout << "|    O|" << endl;
cout << "|    |" << endl;
cout << "|O    |" << endl;
cout <<  " -----" << endl;
}
void three()
{
cout << " -----" << endl;
cout << "|    O|" << endl;
cout << "|  O  |" << endl;
cout << "|O    |" << endl;
cout <<  " -----" << endl;
}
void four()
{
cout << " -----" << endl;
cout << "|O  O|" << endl;
cout << "|    |" << endl;
cout << "|O  O|" << endl;
cout <<  " -----" << endl;
}
void five()
{
cout << " -----" << endl;
cout << "|O  O|" << endl;
cout << "|  O  |" << endl;
cout << "|O  O|" << endl;
cout <<  " -----" << endl;
}
void six()
{
cout << " -----" << endl;
cout << "|O  O|" << endl;
cout << "|O  O|" << endl;
cout << "|O  O|" << endl;
cout <<  " -----" << endl;
}
<< moderator edit: added [code][/code] tags >>

BountyX Apr 13th, 2004 10:16 pm
Re: C++ game?
 
:D thnx for posting it pretty cool, but use the [ C O D E ] [ / C O D E ] tags next time plz I had to school for almost an hour on my laptops little 800x600 resolution lol

Bleek Apr 14th, 2004 11:12 am
Re: C++ game?
 
i shall do that...

Cercetasu Apr 19th, 2004 8:33 am
Re: C++ game?
 
hi, i'm a beginner in programming
i've tried to compile your game but it doesn't work. i used Borland C++ 4.52.
it says "declaration sintax error" for "using namespace std"; what does this line do??

Dark_Omen Apr 19th, 2004 2:22 pm
Re: C++ game?
 
You should read "Sams Teach Yourself Game Programming in 24 Hours." It is a very good book with a lot of examples. It uses C++.
The Program compiled for me. Pretty cool program.

Bleek Apr 22nd, 2004 9:53 pm
Re: C++ game?
 
the using directive is almost like the #include command. it is using the namespace std (or standard) held in the iostream header file. what it does is it lets you use the line:

 cout << "Hello"; 
 
instead of needing
 
std::cout << "Hello";

it's just more convenient...
i do recommend the SAMS book...;)

lotsofsloths Jan 1st, 2007 9:12 pm
Re: C++ game?
 
That dice game look awsome and i compiled and played it on my computer, using dev-c++.
though i had a question: How does the computer randomize the dice roll:?:

John A Jan 1st, 2007 10:25 pm
Re: C++ game?
 
Quote:

Originally Posted by lotsofsloths (Post 295702)
That dice game look awsome and i compiled and played it on my computer, using dev-c++.
though i had a question: How does the computer randomize the dice roll:?:

What's Google? And also look in your previous thread; it's answered there too. Bumping old threads is generally discouraged, if you have a new question, post it in its own thread.

virus.exe Mar 20th, 2007 9:17 pm
Re: C++ game?
 
I made a pretty sweet Number Hang Man Game. Im really noob but it wasnt hard.

 
// Number HangMan
// By: David Seviour
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <time.h>
#include <windows.h>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;
int main ()
{
   
   
    int c;
    int w=8;
    int s=0;
    int l=0;
   
   
   
    int d;
    int e;
    int f;
    int g;
    int h;
    int i;
    int j;
    int k;
   
startover:   
srand((unsigned)time(0));
int b;
for(int index=0; index<1; index++){
b = (rand()%100)+1; }
   
   
cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
cout << "                          Loading.";
Sleep(1000);
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
cout << "                          Loading..";
Sleep(1000);
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
cout << "                          Loading...";
Sleep(1000);
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
cout << "                          Loading....Ready!" << endl;
Sleep(1000);
cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
system("PAUSE");
system("cls");
   
system("title Numb4rs Hang Man");   
cout << "NUMB4RS HANG MAN" << endl;
cout << "By: David Seviour\n\n\n\n\n\n\n\n\n\n\n\n";
cout << "                      Press Alt+Enter for Full screen.";
cout << "\n\n\n\n\n\n\n\n\n\n" << endl;
system("PAUSE");
system("cls");
   
   
   
   
   
   
   
   
   
    system("color 08");
    system("title Numb4rs Hang Man");
    c = 0;
    cout << "Number Hang Man!\n" << endl;
    cout << "So far You have " << l << " deaths and " << s << " survivors";
    cout << "\n\n\n";
    cout << "-------|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "-----" << endl;
    cout << "                  Im a number Between 1-100" << endl;
    cout << "\n\n" << endl;
   
    cout << "Guess What number I Am..." << endl;
    cin >> d;
   
    if (d < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower;}
    else if (d > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower;}
    else if (d = b) {goto loopwin;}
   
    return 0;
   
   
// _____________________________________________________________________________________________
   
   
    loophigherlower:
    system("cls");
    system("color 02");
    system("title Numb4rs Hang Man");
    c = c + 1;
    cout << "Try number " << c << " of 6";
    if (c == w) goto LOSE;
    cout << "\n\n\n";
    cout << "-------|" << endl;
    cout << "|      O" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "-----" << endl;
    cout << "                  Im a number Between 1-100\n" << endl;
    cout << "      You have selected the following numbers so far: " << d;
    cout << "\n\n" << endl;
   
    cout << "Guess What number I Am..." << endl;
    cin >> e;
             
      if (e < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower2;}
    else if (e > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower2;}
    else if (e = b) {goto loopwin;}         
   
    return 0;
   
//________________________________________________________________________________________________
   
    loophigherlower2:
                   
    system("cls");
    system("color 09");
    system("title Numb4rs Hang Man");
    c = c + 1;
    cout << "Try number " << c << " of 6";
    if (c == w) goto LOSE;
    cout << "\n\n\n";
    cout << "-------|" << endl;
    cout << "|      O" << endl;
    cout << "|      |" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "-----" << endl;
    cout << "                  Im a number Between 1-100\n" << endl;
    cout << "      You have selected the following numbers so far: " << d << "," << e;
    cout << "\n\n" << endl;
    cout << "Guess What number I Am..." << endl;
    cin >> f;
             
      if (f < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower3;}
    else if (f > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower3;}
    else if (f = b) {goto loopwin;}         
   
//__________________________________________________________________________________________
loophigherlower3:
               
                system("cls");
                system("color 04");
    system("title Numb4rs Hang Man");
    c = c + 1;
    cout << "Try number " << c << " of 6";
    if (c == w) goto LOSE;
    cout << "\n\n\n";
    cout << "-------|" << endl;
    cout << "|      O" << endl;
    cout << "|    -|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "-----" << endl;
    cout << "                Im a number Between 1-100\n" << endl;
    cout << "      You have selected the following numbers so far: " << d << "," << e << "," << f;
    cout << "\n\n" << endl;
   
    cout << "Guess What number I Am..." << endl;
    cin >> g;
             
      if (g < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower4;}
    else if (g > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower4;}
    else if (g = b) {goto loopwin;}             
   
//_______________________________________________________________________________________________
   
    loophigherlower4:

system("cls");
system("color 05");
    system("title Numb4rs Hang Man");
    c = c + 1;
    cout << "Try number " << c << " of 6";
    if (c == w) goto LOSE;
    cout << "\n\n\n";
    cout << "-------|" << endl;
    cout << "|      O" << endl;
    cout << "|    -|-" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "-----" << endl;
    cout << "                  Im a number Between 1-100\n" << endl;
    cout << "      You have selected the following numbers so far: " << d << "," << e << "," << f << "," << g;
    cout << "\n\n" << endl;
   
    cout << "Guess What number I Am..." << endl;
    cin >> h;
             
      if (h < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower5;}
    else if (h > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower5;}
    else if (h = b) {goto loopwin;}         
   
//___________________________________________________________________________________________
loophigherlower5:
             
              system("cls");
              system("color 02");
    system("title Numb4rs Hang Man");
    c = c + 1;
    cout << "Try number " << c << " of 6";
    if (c == w) goto LOSE;
    cout << "\n\n\n";
    cout << "-------|" << endl;
    cout << "|      O" << endl;
    cout << "|    -|-" << endl;
    cout << "|      |" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "-----" << endl;
    cout << "                  Im a number Between 1-100\n" << endl;
    cout << "      You have selected the following numbers so far: " << d << "," << e << "," << f << "," << g << "," << h;
    cout << "\n\n" << endl;
   
    cout << "Guess What number I Am..." << endl;
    cin >> i;
             
      if (i < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower6;}
    else if (i > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower6;}
    else if (i = b) {goto loopwin;}         
 
   
//_______________________________________________________________________________________________
loophigherlower6:
               
                system("cls");
                system("color 09");
    system("title Numb4rs Hang Man");
    c = c + 1;
    cout << "Try number " << c << " of 6";
    if (c == w) goto LOSE;
    cout << "\n\n\n";
    cout << "-------|" << endl;
    cout << "|      O" << endl;
    cout << "|    -|-" << endl;
    cout << "|      |" << endl;
    cout << "|      o" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "-----" << endl;
    cout << "                  A number Between 1-100\n" << endl;
    cout << "      You have selected the following numbers so far: " << d << "," << e << "," << f << "," << g << "," << h << "," << i;
    cout << "\n\n" << endl;
   
    cout << "Guess What number I Am... Last Try!!!" << endl;
    cin >> j;
             
      if (j < b) { cout << "\nHaHaHa!\n\n"; cout << "The Number Was " << b << "\n\n";  system("PAUSE"); goto loophigherlower7;}
    else if (j > b) { cout << "\nHeHeHe!\n\n"; cout << "The Number Was " << b << "\n\n"; system("PAUSE"); goto loophigherlower7;}
    else if (j = b) {goto loopwin;}         
   
    return 0;
   
//__________________________________________________________________________________________________
loophigherlower7:
 
    system("cls");
    system("title Numb4rs Hang Man");
    cout << "\n\n\n";
    cout << "-------|" << endl;
    cout << "|      O" << endl;
    cout << "|    -|-" << endl;
    cout << "|      |" << endl;
    cout << "|    o o" << endl;
    cout << "|" << endl;
    cout << "|" << endl;
    cout << "-----" << endl;
   
    system("color fc");
    system("color cf");
    system("color fc");
    system("color fc");
    Sleep(100);
    system("color cf");
    Sleep(100);
    system("color fc");
    Sleep(100);
    system("color fc");
    Sleep(100);
    system("color cf");
    Sleep(500);
    system("color fc");
    Sleep(500);
    system("color fc");
    Sleep(1000);
    system("color cf");
    Sleep(1000);
    system("color fc");
    Sleep(200);
    system("cls");
   
    cout << "\n\n\n";
    cout << "-------|" << endl;
    cout << "|      [" << endl;
    cout << "|      O" << endl;
    cout << "|    -|-" << endl;
    cout << "|      |" << endl;
    cout << "|    o o" << endl;
    cout << "|" << endl;
    cout << "-----" << endl;
   
    Sleep(200);
    system("cls");
        cout << "\n\n\n";
    cout << "-------|" << endl;
    cout << "|      [" << endl;
    cout << "|      ]" << endl;
    cout << "|      O" << endl;
    cout << "|    -|-" << endl;
    cout << "|      |" << endl;
    cout << "|    o o" << endl;
    cout << "-----" << endl;
   
    Sleep(3000);
   
    if (c == w) goto LOSE;
//___________________________________________________________________________________________________
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
//____________________________________________________________________________________________________________

LOSE:
 
 system("cls");
 cout << "\n\n";   
 cout << "You were Hung!\n\n";
 system("PAUSE");
 system("cls\n\n");
 l = l + 1;
goto  startover;

return 0;
 
//_______________________________________________________________________________________________________________
    loopwin:
   
   
    system("title WINNER!!!");
   
   
   
    system("cls");
    cout << "\n\n\n\n\n\n\n\n\n\n";
    cout << "                    *      *      *    *    *    *  |  " << endl;
    cout << "                      *    * *    *    *    * *  *  |  " << endl;
    cout << "                      *  *  *  *      *    *  * *  |  " << endl;
    cout << "                        **    **      *    *    *  O  " << endl;
    system("color fc");   
    system("color 0f");
    system("color e6");
    system("color c3");
    system("color ae");
    system("color e3");
    system("color 4c");
    system("color a1");
    system("color d2");
    system("color fc");   
    system("color 0f");
    system("color e6");
    system("color c3");
    system("color ae");
    system("color e3");
    system("color 4c");
    system("color a1");
    system("color d2");
    system("color fc");   
    system("color 0f");
    system("color e6");
    system("color c3");
    system("color ae");
    system("color e3");
    system("color 4c");
    system("color a1");
    system("color d2");
    system("color fc");   
    system("color 0f");
    system("color e6");
    system("color c3");
    system("color ae");
    system("color e3");
    system("color 4c");
    system("color a1");
    system("color d2");
    system("color fc");   
    system("color 0f");
    system("color e6");
    system("color c3");
    system("color ae");
    system("color e3");
    system("color 4c");
    system("color a1");
    system("color d2");
   
   
    cout << "\n\n\n\n\n\n\n";
    system("PAUSE");
    system("cls\n\n");
    s = s + 1;
    goto startover;
   
    return 0;
   
}

lol it's kinda fun, anywayz add me on msn for any help with noob stuff.

<snip email>

peace

Clinton Portis Mar 20th, 2007 11:47 pm
Re: C++ game?
 
//Preprocessor Directives
#include<iostream>
#include<string>
#include<cstdlib>
#include<cctype>
#include<ctime>

using namespace std;

//Function Prototypes
void SeedRandom();
void PrintHeader();
void PlayOneMatch(int&, int&, int&, int&, int&);
int  GetPlayerChoice();
int  DrawNum(int);
void PrintMove(int, int, int&, int&);
void WonAGame(char, int&, int&, int&);
void PrintFinalResults(int, int, int, int);
void Reset(int&, int&, int&, int&, int&, int&, int&);

//Main Driver
int main()
{
  char WinnerNumber = '0';
  int  GamesWon    =  0,
        WinnerMoney  =  0,
        LoserMoney  =  0,
        Player1Money =  100,
        Player2Money =  100,       
        Games1Won    =  0,
        Games2Won    =  0,
        TieCount    =  0,       
        MatchCounter =  0,       
        TotalGames  =  0;
       
  SeedRandom(); 
       
  do{
        Reset(GamesWon, WinnerMoney, LoserMoney, Games1Won, Games2Won, TieCount, MatchCounter);
        PrintHeader();
        PlayOneMatch(Games1Won, Games2Won, TieCount, Player1Money, Player2Money);       
        PrintFinalResults(Games1Won, Games2Won, TieCount, TotalGames+=3);     
       
  }while(TotalGames < 20 || !Player1Money || !Player2Money);
 
return 0;
}


//Function Definitions
void SeedRandom()
{
    srand(time(NULL));
}

void PrintHeader()
{
    cout << "\n\t----------=====******=====----------"
          << "\n\tRock, Paper, and Scissors:"
          << "\n\t----------=====******=====----------"
          << "\n\n\tThis program plays the EXCITING game of Rock, Paper,"
          << "\n\tand Scissors.  Two players choose either Rock, Paper or Scissors,"
          << "\n\tand the results of their picks are compared.  Each match is"
          << "\n\tdetermined as follows:"
          << "\n\n\tPlayer 1  Player 2  Result"
          << "\n\t--------  --------  ------"
          << "\n\t---        ---        Any matching combo. A tie!"
          << "\n\n\tNow you are about to play against world-class computer"
          << "\n\tchampion Dr. Windows.  You are Player 1, and the computer"
          << "\n\tis Player 2.  Player 2's moves are randomly chosen by the computer."
          << "\n\tBoth players start with $100 and the game is finished when either one player"
          << "\n\treaches $0 or there have been 3 matches played.  The bet per metch is $5.";
}

void PlayOneMatch(int& Games1Won, int& Games2Won, int& TieCount,
                  int& Player1Money, int& Player2Money)
{
  int playerchoice  = 0,
      computerchoice = 0,
      MatchCounter  = 0; 
                 
  do{
                 
      cout << "\n\n\tPlayer 1, Enter your choice of"
          << "\n\t    1 Rock"
          << "\n\t    2 Paper"
          << "\n\t    3 Scissors -> ";
     
      playerchoice  = GetPlayerChoice();
      computerchoice = DrawNum(3);
     
      if(playerchoice == computerchoice)
       
        TieCount++;                 
     
      else if(playerchoice > computerchoice ||
              playerchoice == 1 && computerchoice == 3)
      {
        ++Games1Won;             
        WonAGame('1', Games1Won, Player1Money, Player2Money);
      }
             
      else
      {
        ++Games2Won;   
        WonAGame('2', Games2Won, Player2Money, Player1Money);
      }
             
      PrintMove(playerchoice, computerchoice, Player2Money, Player1Money);
      MatchCounter++;
     
      }while(MatchCounter < 3 || !Player1Money || !Player2Money);         
}
 
int GetPlayerChoice()     
{
    char choice = '0';
   
    cin.get(choice);
    cin.ignore(1000,'\n');
   
    while(!isdigit(choice) || choice < '1' || choice > '3')
    {
      cout << "\n\t\aThat was not a valid entry.  Please try again -> ";
      cin.get(choice);
      cin.ignore(1000,'\n');
    }
       
    return atoi(&choice);
}
 
int DrawNum(int max)
{     
  double x = RAND_MAX + 1.0;
  int    y = 0;
 
  y = static_cast<int> (1 + rand() * (max / x));
 
  return (y);
}

void PrintMove(int Move1, int Move2, int& Player1Money, int& Player2Money)
{
  string action[] = {"rock", "paper", "scissors"};
   
  cout << "\n\n\tRESULTS OF THIS MOVE"
        << "\n\t=-=-=-=-=-=-=-=-=-=-"
        << "\n\t  Player 1            Player 2                Player 1's  Player 2's"
        << "\n\tNumber  Action  Number    Action  Winner      Money      Money"
        << "\n\t------  ------  ------    ------  ------      -----      -----"
        << "\n\t  " << Move1 << "    "    << action[Move1-1]
        << "      "  << Move2 << "        " << action[Move2-1] << "  ";
       
        if(Move1 == Move2)
       
          cout << "A tie!";
         
        else if(Move1 > Move2 || Move1 == 1 && Move2 == 3)
       
          cout << "Player 1!";
         
        else
       
          cout << "Player 2!";
         
        cout << "    $" << Player1Money << "        $" << Player2Money;
}

void WonAGame(char WinnerNumber, int& GamesWon, int& WinnerMoney, int& LoserMoney)
{
    switch(WinnerNumber)
    {       
        case '1': WinnerMoney-=5; 
                  LoserMoney+=5;
                  break;
       
        case '2': LoserMoney+=5; 
                  WinnerMoney-=5;
                  break;
    }
}

void PrintFinalResults(int Games1Won, int Games2Won, int TieCount, int TotalGames)
{
  cout << "\n\n\n\tAnd there you have it folks, the final match between our two"
        << "\n\tcontestants.  The final results for tonight's game are as follows:"
        << "\n\n\t                    Player 1    Player 2"
        << "\n\t                    ========    ========"
        << "\n\tGames Won:              " << Games1Won << "          " << Games2Won
        << "\n\tPercent Won:            " << static_cast<int>(((double)Games1Won/3)*100) 
        << "%        " << static_cast<int>(((double)Games2Won/3)*100) << '%'
        << "\n\n\t\tTotal games tied: " << TieCount                         
        << "\n\t\tTotal games played: " << TotalGames
        << "\n\t\tThe overall winner is ";
       
        if(Games1Won == Games2Won)
       
          cout << "Both!";
       
        else if(Games1Won > Games2Won)
       
          cout << "Player 1!";
         
        else
       
          cout << "Player 2!";   
       
        cout << "\n\n\tStop in again soon to play another exciting match!!!\n\n\n\n\n\n";       
}

void Reset(int& GamesWon,  int& WinnerMoney, int& LoserMoney, int& Games1Won,
          int& Games2Won,  int& TieCount,    int& MatchCounter)
{
  GamesWon    = 0;
  WinnerMoney  = 0;
  LoserMoney  = 0;         
  Games1Won    = 0;
  Games2Won    = 0;
  TieCount    = 0;     
  MatchCounter = 0;
}

kannan420bar Nov 26th, 2007 1:07 pm
Re: C++ game?
 
oh cool

J.P. Nov 27th, 2007 9:07 pm
Re: C++ game?
 
Quote:

Originally Posted by Creator (Post 23459)
I also have the source code to a few RPG games. It actually isn't that hard to make a console RPG.

are those console or 2D codes?? mind sending em my way??

as for the original poster here is a good site
http://theharbourfamily.com/jonathan/?page_id=89

it's about GBA programming, but he starts you out with games like Pong & Tetris on C with vector graphics...really cool for starting out

Salem Nov 28th, 2007 3:28 am
Re: C++ game?
 
> are those console or 2D codes?? mind sending em my way??
Did you read the dates of those posts?
Reading their profile, it says "Last Activity: 10th Apr 2004".

I've got a new game, it's called "thread bumper 2007" :icon_rolleyes:


All times are GMT -4. The time now is 5:15 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC