Skip to content

Instantly share code, notes, and snippets.

@amalaugustinejose
Last active January 26, 2017 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalaugustinejose/58f403441c50d7ffffaf21e113b725ee to your computer and use it in GitHub Desktop.
Save amalaugustinejose/58f403441c50d7ffffaf21e113b725ee to your computer and use it in GitHub Desktop.
Draw a polygon using mouse clicks
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
void main() {
int gd = DETECT, gm, gate, fx, fy, ax, ay, bx, by;
union REGS i, o;
initgraph(&gd, &gm, "C:\\TurboC3\\BGI");
i.x.ax = 0;
int86(0x33, &i, &o);
i.x.ax = 1;
int86(0x33, &i, &o);
while (gate) {
gate = 1;
i.x.ax = 5;
i.x.bx = 0;
int86(0x33, &i, &o);
if (o.x.bx == 1) {
gate = 0;
fx = o.x.cx;
fy = o.x.dx;
}
}
ax = fx;
ay = fy;
do {
gate = 1;
while(gate) {
i.x.ax = 5;
i.x.bx = 0;
int86(0x33, &i, &o);
if (o.x.bx == 1) {
gate = 0;
bx = o.x.cx;
by = o.x.dx;
}
}
line(ax, ay, bx, by);
ax = bx;
ay = by;
}while (!kbhit());
line(fx, fy, ax, ay);
delay(5000);
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment