#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 :-
#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 :-
I can control on going motion of circle through mouse
ReplyDeleteThis code is not going to work for codeblock, because codeblock doesnt allow mouse interrupt directly.
ReplyDeleteIf , anything not working don't fear to keep posting on blog
ReplyDelete