Tuesday, January 13, 2009

Solitaire game Coding in C Language

#include
#include
#include
#include

this thing only do is generate the number:

int random(int x)
{
srand((int) time(NULL));
return 1 + rand() % x;
}

and this, the colors:
void cardcolr(int naipe,int cardwcolr)
{
if (naipe == 1) // Hearts
{
switch(cardwcolr)
{
case 1:
textcolor(LIGHTRED);
printf(" A\3");
break;
case 11:
textcolor(LIGHTRED);
printf(" J\3");
break;
case 12:
textcolor(LIGHTRED);
printf(" Q\3");
break;
case 13:
textcolor(LIGHTRED);
printf(" K\3");
break;
default:
textcolor(LIGHTRED);
printf(" %d\3",cardwcolr);
}
}
if (naipe == 2) // Spades
{
switch(cardwcolr)
{
case 1:
textcolor(BLACK);
printf(" A\6");
break;
case 11:
textcolor(BLACK);
printf(" J\6");
break;
case 12:
textcolor(BLACK);
printf(" Q\6");
break;
case 13:
textcolor(BLACK);
printf(" K\6");
break;
default:
textcolor(BLACK);
printf(" %d\6",cardwcolr);
}
}
if (naipe == 3) // Diamonds
{
switch(cardwcolr)
{
case 1:
textcolor(LIGHTRED);
printf(" A\4");
break;
case 11:
textcolor(LIGHTRED);
printf(" J\4");
break;
case 12:
textcolor(LIGHTRED);
printf(" Q\4");
break;
case 13:
textcolor(LIGHTRED);
printf(" K\4");
break;
default:
textcolor(LIGHTRED);
printf(" %d\4",cardwcolr);
}
}
if (naipe == 4) // Clubs
{
switch(cardwcolr)
{
case 1:
textcolor(BLACK);
printf(" A\5");
break;
case 11:
textcolor(BLACK);
printf(" J\5");
break;
case 12:
textcolor(BLACK);
printf(" Q\5");
break;
case 13:
textcolor(BLACK);
printf(" K\5");
break;
default:
textcolor(BLACK);
printf(" %d\5",cardwcolr);
}
}
}

No comments:

Blog List