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 >>


All times are GMT -4. The time now is 6:57 am.

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