Monday 12 October 2015

Mouse Programming wid Graphics in C - Example progam

#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<dos.h>
#include<stdlib.h>
#include<iostream.h>
#include<graphics.h>
union REGS i,o;
void init();
void hide();
void show();
void show_ptr(int*,int*,int*);
void main()
{
int gd=0,gm=0,x,y,b,x1,y1;
initgraph(&gd,&gm,"c:\\"); \* Here set path of bgi(disk\turboc3\bgi) directory as per your System*/
circle(122,324,43);
init();
while(!kbhit())
{
show_ptr(&x,&y,&b);
circle(x,y,30);
setcolor(random(15));
cout <<  endl;
while(b==1)
{
show_ptr(&x1,&y1,&b);
circle(x,y,abs(x-x1));
delay(150);

}

}

getch();
}
void init()
{
i.x.ax = 0;
int86(0x33,&i,&o);
}
void show()
{
i.x.ax = 1;
int86(0x33,&i,&o);
}
void hide()
{
i.x.ax = 2;
int86(0x33,&i,&o);
}
void show_ptr(int *x,int *y,int *b)
{
i.x.ax = 3;
int86(0x33,&i,&o);
*x = o.x.cx;
*y = o.x.dx;
*b = o.x.bx;
delay(20);


}



OUTPUT :-

3 comments:

  1. I can control on going motion of circle through mouse

    ReplyDelete
  2. This code is not going to work for codeblock, because codeblock doesnt allow mouse interrupt directly.

    ReplyDelete
  3. If , anything not working don't fear to keep posting on blog

    ReplyDelete

How to install google-chrome in redhat without redhat subscription

Install google-chrome in redhat  Download the .rpm file of chrome https://www.google.com/chrome/thank-you.html?installdataindex=empty&st...