You are on page 1of 7

/* This is just a simple dice game i made on visual studios 2008 express

edition when i was first learning C Programming*/

#include <stdio.h>
#include <stdlib.h>//needed for random function
#include <time.h>//needed for using time
#include <conio.h>//needed to make getchar work

int main()
{
int begin, die1, die2, game=1, win=0, lose=0, loopcount=0;//set values
in the variable spot itself

while(loopcount<10){//toggle number of games but remember to change


game summary at the end too

printf("%24c::::::THE GAME OF DICE::::::\n", ' ');//thats how you add


spaces
printf("%28cBy: NSM Technologies\n", ' ');
printf("%26cGame #%d/10 Wins:%d Loses:%d\n\n", ' ', game, win, lose);
printf("Conditions For A Victory: (A)If Dice Total 7 or
11\n");//beginning instructions
printf("%26c(B)If Dice Equal Eachother\n", ' ');
printf("%26c(C)If Either Die Lands On 6\n\n", ' ');
printf("Have Fun and ENJOY! :)\n\n");

printf("Enter Your Lucky Number To Start! ");//needed for easter egg


and to control loop
scanf("%d", &begin);//other option would be getchar
if(begin == 666){ //easter egg
win = 9999999;
lose = -12;
printf("\nYOU FOUND THE EASTER EGG! ROCK ON!\n");
printf("\n<<<YOU WIN>>>\n");
printf("\nWins:%d Loses:%d\n", win, lose);
printf("....(....\\............../....) \n");
printf(".... \\....\\........... /..../ \n");
printf("......\\....\\._..__..../..../ \n");
printf(".......\\..../´ .I. `\./__../ \n");
printf("......./... I....I..//__`/ \n");
printf("......I.....I._..I_.....\.\\ \n");
printf("......I.....I´..I´_.I..\../ \n");
printf("......\\.....` -...-´....' \n");
printf(".......\\____________.•´\n");
printf(".......|-_-_-_-_-_-_-_-\n");
printf(".----. _..............._. Thats The Rock Hand
Sign If You Can't Tell..\n");
break;//ends game
}
if(begin >= 0){//main if function
printf("\nRolling...\n\n\n");
srand (time(NULL));//seed random
die1 = 1+rand()%6;//starts at 1, creates random number to a max
of 6
die2 = 1+rand()%6;
if (die1==6 && die2==1){//36 possibilities
printf(" ------- ------- \n");
printf("| 0 0 | | |\n");
printf("| 0 0 | | 0 |\n");
printf("| 0 0 | | |\n");
printf(" ------- ------- \n");
}
if (die1==6 && die2==2){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 |\n");
printf("| 0 0 | | |\n");
printf("| 0 0 | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==6 && die2==3){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 |\n");
printf("| 0 0 | | 0 |\n");
printf("| 0 0 | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==6 && die2==4){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 0 |\n");
printf("| 0 0 | | |\n");
printf("| 0 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==6 && die2==5){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 0 |\n");
printf("| 0 0 | | 0 |\n");
printf("| 0 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==6 && die2==6){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 0 |\n");
printf("| 0 0 | | 0 0 |\n");
printf("| 0 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==5 && die2==1){
printf(" ------- ------- \n");
printf("| 0 0 | | |\n");
printf("| 0 | | 0 |\n");
printf("| 0 0 | | |\n");
printf(" ------- ------- \n");
}
if (die1==5 && die2==2){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 |\n");
printf("| 0 | | |\n");
printf("| 0 0 | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==5 && die2==3){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 |\n");
printf("| 0 | | 0 |\n");
printf("| 0 0 | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==5 && die2==4){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 0 |\n");
printf("| 0 | | |\n");
printf("| 0 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==5 && die2==5){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 0 |\n");
printf("| 0 | | 0 |\n");
printf("| 0 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==5 && die2==6){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 0 |\n");
printf("| 0 | | 0 0 |\n");
printf("| 0 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==4 && die2==1){
printf(" ------- ------- \n");
printf("| 0 0 | | |\n");
printf("| | | 0 |\n");
printf("| 0 0 | | |\n");
printf(" ------- ------- \n");
}
if (die1==4 && die2==2){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 |\n");
printf("| | | |\n");
printf("| 0 0 | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==4 && die2==3){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 |\n");
printf("| | | 0 |\n");
printf("| 0 0 | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==4 && die2==4){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 0 |\n");
printf("| | | |\n");
printf("| 0 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==4 && die2==5){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 0 |\n");
printf("| | | 0 |\n");
printf("| 0 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==4 && die2==6){
printf(" ------- ------- \n");
printf("| 0 0 | | 0 0 |\n");
printf("| | | 0 0 |\n");
printf("| 0 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==3 && die2==1){
printf(" ------- ------- \n");
printf("| 0 | | |\n");
printf("| 0 | | 0 |\n");
printf("| 0 | | |\n");
printf(" ------- ------- \n");
}
if (die1==3 && die2==2){
printf(" ------- ------- \n");
printf("| 0 | | 0 |\n");
printf("| 0 | | |\n");
printf("| 0 | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==3 && die2==3){
printf(" ------- ------- \n");
printf("| 0 | | 0 |\n");
printf("| 0 | | 0 |\n");
printf("| 0 | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==3 && die2==4){
printf(" ------- ------- \n");
printf("| 0 | | 0 0 |\n");
printf("| 0 | | |\n");
printf("| 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==3 && die2==5){
printf(" ------- ------- \n");
printf("| 0 | | 0 0 |\n");
printf("| 0 | | 0 |\n");
printf("| 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==3 && die2==6){
printf(" ------- ------- \n");
printf("| 0 | | 0 0 |\n");
printf("| 0 | | 0 0 |\n");
printf("| 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==2 && die2==1){
printf(" ------- ------- \n");
printf("| 0 | | |\n");
printf("| | | 0 |\n");
printf("| 0 | | |\n");
printf(" ------- ------- \n");
}
if (die1==2 && die2==2){
printf(" ------- ------- \n");
printf("| 0 | | 0 |\n");
printf("| | | |\n");
printf("| 0 | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==2 && die2==3){
printf(" ------- ------- \n");
printf("| 0 | | 0 |\n");
printf("| | | 0 |\n");
printf("| 0 | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==2 && die2==4){
printf(" ------- ------- \n");
printf("| 0 | | 0 0 |\n");
printf("| | | |\n");
printf("| 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==2 && die2==5){
printf(" ------- ------- \n");
printf("| 0 | | 0 0 |\n");
printf("| | | 0 |\n");
printf("| 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==2 && die2==6){
printf(" ------- ------- \n");
printf("| 0 | | 0 0 |\n");
printf("| | | 0 0 |\n");
printf("| 0 | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==1 && die2==1){
printf(" ------- ------- \n");
printf("| | | |\n");
printf("| 0 | | 0 |\n");
printf("| | | |\n");
printf(" ------- ------- \n");
}
if (die1==1 && die2==2){
printf(" ------- ------- \n");
printf("| | | 0 |\n");
printf("| 0 | | |\n");
printf("| | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==1 && die2==3){
printf(" ------- ------- \n");
printf("| | | 0 |\n");
printf("| 0 | | 0 |\n");
printf("| | | 0 |\n");
printf(" ------- ------- \n");
}
if (die1==1 && die2==4){
printf(" ------- ------- \n");
printf("| | | 0 0 |\n");
printf("| 0 | | |\n");
printf("| | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==1 && die2==5){
printf(" ------- ------- \n");
printf("| | | 0 0 |\n");
printf("| 0 | | 0 |\n");
printf("| | | 0 0 |\n");
printf(" ------- ------- \n");
}
if (die1==1 && die2==6){
printf(" ------- ------- \n");
printf("| | | 0 0 |\n");
printf("| 0 | | 0 0 |\n");
printf("| | | 0 0 |\n");
printf(" ------- ------- \n");
}

printf("\n\n*Die One Landed On %d!*\n", die1);


printf("*Die Two Landed On %d!*\n\n", die2);
if(die1 + die2 == 11){
printf("YOU WIN! The Dice Equal 11!\n");//if functions in
order of authority from top instructions
printf("Thank You For Playing!\n\n");
win++;
}
else if(die1 + die2 == 7){
printf("YOU WIN! The Dice Equal 7!\n\n");
printf("Thank You For Playing!\n\n");
win++;
}
else if(die1 == die2){
printf("YOU WIN! The Dice Equal Eachother!\n\n");
printf("Thank You For Playing!\n\n");
win++;
}
else if(die1 == 6){
printf("YOU WIN! Die One Landed On 6!\n\n");
printf("Thank You For Playing!\n\n");
win++;
}
else if(die2 == 6){
printf("YOU WIN! Die Landed On 6!\n\n");
printf("Thank You For Playing!\n\n");
win++;
}
else {
printf("YOU LOSE! Sorry, Maybe Next Time.\n\n");
lose++;
}
game++;
loopcount++;
}//end main if function block

else {//for if user doesnt enter the number one


printf("\nInvalid Entry. Please Use Absolute Values.\n\n");
}

printf("---------------------------------------------------------------------
-----------\n");
if(game >10){
printf("Summary: %d Games %d Wins %d Loses\n\n", (game-1), win,
lose);
}
}//end loop function block

getch();
}