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");     
}

hi i need more than just background text like cross link to graphics like DRAC

Please clarify what you mean by DRAC.

I've googled for it, but the only seemingly relevant term is the Dell Remote Access Card...

hi sorry my question wasnt clear to you , what i want to do with above code is to make it such a way that i can have a view on the screen of actual cards like we see in solitaire but still performs the game functions. thanks

DRAC is a free card game library

Ok, you will need to look into using graphics libraries.

OpenGL/DirectX/SDL/Glut/{Win32 Forms/MFC}

You will need to create images for all your cards. If you're using Windows Forms then you can get away with loading the pictures up and painting them manually onto the form.

Personally I would avoid that method. Which leaves you with using one of the graphics libraries.

This is not an easy undertaking, but there are many tutorials. Google for NeHe and GameDev.Net for some good beginner tutorials for OpenGL.

Glut is a wrapper for OpenGL which handles some of the more menial things like window creation.

DirectX is the Microsoft graphics library. Whilst good, may be complicated for you to get to grips with to start off.

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.