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

2's Complement of 2Byte Number

This program will work out the 2's Complement of a 2 Byte Number. As Microprocessor can perform 8 bits at a time in Accumulator, so we follow the foloowing Algo Fetch the 2 Byte Number in a Register Pair Bring Least Significant Byte of the Number from last Register into A (Accumulator) Make Complement of A and add 1 Store back the Updated LSByte into its source Register Bring MSByte of the Number from another Register into A Make Complement of A and add 1 if carry was genetrated at the time of LSByte opeartion Store back the Updated MSByte into its source Register Store the Result to a Memory location Suppose, Argument Number is stored in Location 1000H and 1001H Memory Location and store the value in 2000H and 2001H Memory Locations. Memory Location Hex Code Label Mnemonics Comment 3050 3051 3052 2A 00 10 START: LHLD 1000H ;Load the HL Register Pair with the content of Memory Location 1000H and 1001H 3053 7D MOV A, L ;Move the Content of L to A ( Accumulator ) 3054 2F

Flip-Flop Conversion

Flip-Flop is a memory element. You can say a basic element. It is a circuit that can hold a binary state (0 or 1 as low or high volts) until an input to change that state. We have many flip-flops as SR Flip-Flop (Set Reset) D Flip-Flop (Data) JK Flip-Flop T Flip-Flop (Toggle) Those Flip-Flops are available in market in IC Package Form. Now You have a circuit that uses 1 JK and 1 D Flip-Flop and 3 NOT Gates. So you have to buy three ICs- one for JK, one for D and other for NOT Gate. Ultimately you will see that a flip flop in IC of JK, a flip-flop in D IC and 3 NOT gates are not used. Now, if you convert a JK flip flop into D flip flop then you didn’t have to pay for the D flip flop IC. So, your circuit will be made by 2 ICs in place of 3 and in cheap cost. This article is for that reason. How the Flip-Flops are converted from one to other. Procedure: 1. Write Qt and Qt+1 Table with 4 combination of 0 and 1. 2. Write columns for inputs of destination Flop-Fl op. 3. Write the ce

How to set Set-Top Box to Resume automatically to last Channel after switch on?

How to set customised automatic Resume Channel to last viewed in Set-Top Box?  Introduction In the era of Digitally fast growing life WiFi enabled smart devices and also voice controlled smart devices are trying to be companion of every human being. But, all human do not change their habit at the same time. It may be cause of mental attachment or financial limits or unwillingness or though as unnecessary. What ever the reason may be, there exists the old technology, like IR(Infrared), RF(Radio Frequency), etc. So, this article for them who are using "Un-smart" TV like me in this time of Smart World. I was searching for a solution to set my Set-top Box of Videocon DTH (controlled by a RF Remote) to resume the last viewed channel when I power on my TV anytime. Suppose, I was watching NAT-Geo and switch off my (Un-smart) TV, even switch off the plug power at board. Now, after some time / on the next day, when I switch on my TV it will directly tune to the last viewed channel, i.