Skip to main content

VIDEO CASINO (Slot Machine)

Many People spend their time and money to play CASINO Game in Hi-fi Hotel... They do in real. But if you want to
spoil your money virtualy and time realy then u can use following game...
So, not spoiling our time let's talk about the game design...

This Game simply constructed in C Language but in console(DOS) mode also.

Procedure used::
  1. Set Player's Initial cash
  2. Take a Number between 0 to 100 from Player as input
  3. Check for valid input
  4. if input is valid goto step 5 else goto step 2
  5. Generate a random number between 0 and 100
  6. Compare with Player's input and computer generated Random Number
  7. if both match then goto step 8 else goto step 9
  8. Update Win Counter and add the Player input with Player cash. goto step 10
  9. Update Lose Counter and deduce the Player input from Player cash.
  10. Check Player's cash goes under 0 or not.
  11. if cash is less than or equal to 0 goto step 12 else goto step 2 for play again.
  12. End


Program::
// Header File Inclusion....

#include<stdio.h>
 #include<conio.h>
  #include<stdlib.h>
   #include<dos.h>



//User defined Function Prototype declaration

void loading(int,int);



// main() function declaration

void main()
{

 // Variable Declaration and initialization....

 int s,p,i,j,c=500;
 int l=0,w=0;
 char ch='Y';


 // Game Evironment initialization.....

 textmode(C80);
 clrscr();
 window(20,8,60,18);
 _setcursortype(_NOCURSOR);


 // Animated Loading Function call.....

 loading(3,1);
 delay(5000);


 do
 {
 
  // Display setup....
   textbackground(BLACK);
    clrscr();
     _setcursortype(_SOLIDCURSOR);

 gotoxy(1,1);
  textcolor(YELLOW);
   textbackground(BROWN);
    cprintf("Cash:: Rs.");
 gotoxy(11,1);
  textcolor(RED);
   cprintf("%0.5d",c);
 gotoxy(25,1);
  textcolor(CYAN);
   textbackground(BLUE);
    cprintf("LOSE::");
  textcolor(RED);
   cprintf("%#.2d",l);
  textcolor(CYAN);
   cprintf(" GAIN::");
  textcolor(RED);
   cprintf("%#.2d",w);

 textbackground(0);
  textcolor(LIGHTRED+BLINK);
   gotoxy(3,3);
    cprintf("Guess any number between 0 to 100.....");

 textcolor(GREEN);
  gotoxy(22,4);
   scanf("%d",&s);     // Take input from Player....

 if(s<0||s>99)   // Check for valid Input....
  continue;

 _setcursortype(_NOCURSOR);

 randomize();
 p=rand()%100;        // Generate random number between 0 and 100


 textcolor(WHITE);

 j=0;
 for(i=0; i<=p; i++)
 {
   j++;
    gotoxy(22,5);
     j=(j<15)?j:0;
     textbackground(j);
    cprintf("%0.2d",i);
   delay(100);
 }



 textcolor(LIGHTMAGENTA+BLINK);
  textbackground(0);
   gotoxy(15,6);
 
 if(p==s)
  {
   cprintf("You Win :: Rs. %d",p);
    c+=p;
   w++;
  }
 else
  {
   if(c>p)
     cprintf("You Lose:: Rs. %d",p);
   else
     cprintf("You Lost All Cash");
   c-=p;
    l++;
  }
 
 if(c>0)
  {
   gotoxy(19,7);
    textcolor(LIGHTGREEN);
     cprintf("Continue..");
  }
 else
  {
   gotoxy(8,7);
    textcolor(LIGHTRED);
     cprintf("! ! ! You Are A Big Looser ! ! !");
      gotoxy(14,8);
     cprintf("Enter any Key to Exit");
    getch();
   break;
  }
 
 i=0;
  do{
    gotoxy(15,9);
     ch=toupper(getch());
      if(ch=='N'||ch=='Y')
       i=1;
      else
       cprintf("Bad Choice");

    }while(i==0);

  } while(ch=='Y');
}




void loading(int x, int y)
 //This User defined Function makes a simple animation loading environment....
{
 // Dimension of Total Loading Display
 // Height = 9 Rows
 // Width  = 34 Cols
 // X is the initial for Left
 // Y is the initial for Right

 int i,j;
 char msg[]="KHUD KO BARBAD KARNE KA SAHI RASTA";
 int a[][2]={{5,2},{4,1},{3,1},{2,2},{1,3},{1,4},{1,5},{2,6},{3,7},{4,7},{5,6},
      
             {7,7},{7,6},{7,5},{7,4},{7,3},{7,2},{8,1},{9,1},{10,2},{10,3},{10,4},
      {10,5},{10,6},{10,7},{8,4},{9,4},
      
             {16,2},{15,1},{14,1},{13,1},{12,2},{12,3},{13,4},{14,4},{15,4},{16,5},
             {16,6},{15,7},{14,7},{13,7},{12,6},

      {18,1},{19,1},{20,1},{19,2},{19,3},{19,4},{19,5},{19,6},{18,7},{19,7},
             {20,7},
      
             {22,7},{22,6},{22,5},{22,4},{22,3},{22,2},{22,1},{23,2},{24,3},{24,4},
             {25,5},{26,7},{26,6},{26,5},{26,4},{26,3},{26,2},{26,1},

      {30,1},{29,2},{28,3},{28,4},{28,5},{29,6},{30,7},{31,7},{32,6},{33,5},
             {33,4},{33,3},{32,2},{31,1}};

 // Print a Blinking Loading Message.

 gotoxy(14+x,y);
 textcolor(BROWN+BLINK);
 cprintf("Loading...");

 // Write CASINO with 3D Effect....

 for(i=0;i<85;i++)
  {
   gotoxy(a[i][0]+x,a[i][1]+y);
   textcolor(CYAN);
   cprintf("Û");
   textcolor(BLUE);
   cprintf("°");
   delay(100);
  }


  // Display a Custom Counting Message...

  for(i=0;i<=33;i++)
  {
   for(j=65;j<=msg[i];j++)
   {
    gotoxy(i+1+x,8+y);
    cprintf("%c",j);
    delay(50);
   }

  }

}

NB:: Compile it using Turbo C++ in DOS Mode...

Comments

Popular posts from this blog

IntArray Class Definition:: It can hold an array of Integer with Diffrent Size

A Class named ' intarray ' which can store an integer array of different size. This Class contains:: O Constructor with deafault argument value At the time of Object creation if array size is missing then An array of size 0 will be created. O Copy Constructor This Constructor is used to create a new Object from an existing Object. O Overloaded Operator = This operator is overloaded to assign an intarray object into another object, simply as two integer variables can be made. O Overloading Operator [ ] As array element can be reffered by its position declaring in Subscript operator ( [ ] ), here every element of an object array can be reffered by [ ] operator. O Overloading Operator >> This is an input operator . Here we can take input to a object simply by this line cin >> a; . Here a is an intarray object. O Overloading Operator This is an output operator . Here we can get the output of an intarray object by this line cout . Here a is an intarray ob...

0s and 1s Count in 1 Byte Memory Word

This program will count all the 1s and 0s individualy presents in a 1 byte word. And store the result in individual places in Memory. Suppose, argument byte is stored in memory location 2050H and store the result of 1's count at 2060H memory location and 0's at 2061H Memory Location Hex Code Label Mnemonics Comment 3050 3051 3052 3A 50 20 START: LDA 2050H ;Load Accumulator with the number stored at location 2050H 3053 3054 06 00 MVI B, 00H ;Initiate 0's Counter 3055 3056 0E 00 MVI C, 00H ;Initiate 1's Counter 3057 3058 16 08 MVI D, 08H ;Initiate Bit Counter 3059 07 LOOP: RLC ;Rotate Accumulator Left with Carry 305A 305B 305C DA 61 30 JC ONE ;If 1 is found count 1 305D 04 INR B ;If 1 is not found it must be 0. So increase 0's Counter 305E 305F 3060 D2 62 30 JNC NEXT ;Go to next Bit 3061 0C ONE: INR C ;Increase 1's Counter 3062 15 NEXT: DCR D ;Decrease the Bit Counter 3063 3064 3065 C2 ...