SWAT GAME

SWAT GAME

/*******************************************************
*     MYCPLUS Sample Code - https://www.mycplus.com     *
*                                                     *
*   This code is made available as a service to our   *
*      visitors and is provided strictly for the      *
*               purpose of illustration.              *
*                                                     *
* Please direct all inquiries to saqib at mycplus.com *
*******************************************************/
#include 
#include 
#include 
#include 

class swat{
 public:
 void draw_swat( int x ){
  setcolor( LIGHTCYAN );
  setlinestyle( SOLID_LINE,0,3 );
  line( x,470,x,275);
  setfillstyle( XHATCH_FILL, LIGHTCYAN );
  rectangle( x-80,50,x+80,275);
  floodfill( x,200, LIGHTCYAN );
 }
} swats;

int final_x, final_y;

class fly{
 private:
 int move_x, move_y, current_x, current_y;

 public:
 void draw_fly( int& );

 void show_fly(){
  setcolor( WHITE );
  setfillstyle( SOLID_FILL, getcolor() );
  circle( final_x, final_y, 4 );
  floodfill( final_x, final_y, getcolor() );
 }
} fly;


void fly :: draw_fly( int &time )
{

 randomize();

 current_x = random(600);
 current_y = random(275);

 for( int i=0; i 600 )
   current_x -= 1.25 * move_x;
  else current_x += move_x;
  if ( current_x  275 )
   current_y -= move_y;

  else if( current_y + move_y ");
 highvideo();

 do{
  user = LOSE;
  pos = 120;

  cleardevice();
  fly.draw_fly( time );
  time-= 50;
  for( int i=0; i 0 ))
   user = WIN;
   break;

   case '2' : if( ( final_x  220 ) )
   user = WIN;
   break;

   case '3' : if( ( final_x  420 ) )
   user = WIN;
   break;
  }

  cleardevice();
  if( time 
M. Saqib: Saqib is Master-level Senior Software Engineer with over 14 years of experience in designing and developing large-scale software and web applications. He has more than eight years experience of leading software development teams. Saqib provides consultancy to develop software systems and web services for Fortune 500 companies. He has hands-on experience in C/C++ Java, JavaScript, PHP and .NET Technologies. Saqib owns and write contents on mycplus.com since 2004.
Related Post