hi i was wondering if anyone could show me how to put graphics to the following card game as i want to learn how to add graphics and what type i should use like for example: DRAC or is there something even better, cheers:
#include<cstdlib>
#include <process.h>
#include<ctime>
#include <iostream>
using namespace std;
enum Suit { clubs, diamonds, hearts, spades };
const int jack = 11;
const int queen = 12;
const int king = 13;
const int ace = 14;
class card
{
protected: int number;
Suit suit;
public: card () { }
void set (int n, Suit s)
{suit = s; number =n;}
int getValue() { return number;}
friend class game;
void display();
bool isEqual(card);
};
void card::display()
{
if( number >= 2 && number <= 10 )
cout << number;
else
switch(number)
{
case jack:
cout << "J";
break;
case queen:
cout << "Q";
break;
case king:
cout << "K";
break;
case ace:
cout << "A";
break;
}
switch(suit)
{
case clubs:
cout << static_cast<char>(5);
break;
case diamonds:
cout << static_cast<char>(4);
break;
case hearts:
cout << static_cast<char>(3);
break;
case spades:
cout << static_cast<char>(6);
break;
}
}
void card::isEqual(card c2)
{
return (number == c2.number && suit==c2.suit )? true: false;
}
Class game
{
protected:
int player;
int npc;
card player;
card npc;
int k;
int j;
int p;
int n;
public:
card deck[52];
game () { }
void players (int p, int n)
{
player = p; npc = n;
}
int play();
void shuffle();
void discard(int);
void draw(int);
friend void card::display();
};
int game::play()
{
char winlose = 'w';
do
{
cout<< "game.play()"<<endl;
int t = 1;
int p = rand()%52;
int n = rand()%52;
player = deck[p];
npc = deck[n];
cout<<"Drawing random card"<<endl;
do
{
cout<< "same card-- re-drawing new cards"<<endl;
p = rand()%52;
n = rand()%52;
player = deck[p];
npc = deck[n];
player.getValue();
npc.getValue();
}
while(p == n);
if(player.number > npc.number)
{
cout<<"win/lose"<<endl;
player.getValue();
npc.getValue();
cout << "\n\nPlayer's card: ";
player.display();
cout <<endl;
cout<< " \nis higher than the \nComputer's Card: ";
npc.display();
cout <<"\n\nAwesome!\n You Win!"<<endl;
system("pause");
}
if(player.number < npc.number)
{
cout<<"lose/win"<<endl;
player.getValue();
npc.getValue();
cout << "\n\nPlayer's card: ";
player.display();
cout <<endl;
cout<< " \nis lower than the \nComputer's Card: ";
npc.display();
cout <<"\n\nYou Lose!"<<endl;
winlose = 'l';
}
}
while(winlose == 'w');
return 0;
}
void game::shuffle()
{
cout<<"shuffle()"<<endl;
for (j=0; j<52; j++)
{
int num = (j%13)+2;
Suit su = Suit (j /13);
deck[j].set(num, su);
}
srand(time(NULL)+_getpid());
for(j=0; j<52; j++)
{
int k = rand()%52;
card temp = deck[j];
deck[j] = deck[k];
deck[k] = temp;
}
return deck[j];
}
random = arr[rand() % (sizeof(arr) / sizeof(arr[0]))];
npc.display();
player.display();
int main()
{
char cAns = 'y' ;
void rules();
rules();
do
{
cout <<"Main()"<<endl;
game MyGame;
MyGame.shuffle();
MyGame.play();
cout<< "\nPlay Again? (y/n): ";
cin>> cAns;
cout << endl;
}
while(cAns == 'y' || cAns == 'Y');
if (cAns == 'n' || 'N')
return0;
void rules()
{
cout << static_cast<char>(5);
cout << static_cast<char>(4);
cout<<" Welcome to Highest Card Wins. " ;
cout << static_cast<char>(3);
cout << static_cast<char>(6)<< endl;
cout<< "\n\n\nRULES"<<endl;
cout<<"You will pick a card in the deck"<<endl;
cout<<"and I will pick a card out of the deck. " << endl;
cout<<"The player with the highest card face value will win!" << endl;
cout<<"The game ends when Player loses.\n\n"<< endl;
cout<<"To Pick a Card.... ";
system("pause");
}