Code:

#include <iostream>
#include <graphics.h>
#include <iostream>
#include <math.h>
using namespace std;
struct Vertex {
double x, y, z;
// need default values for constructor to work in Face struct...
Vertex(double _x=0, double _y=0,double _z=0) {
x = _x;
y = _y;
z = _z;
}
};
struct Face {
// start top-left and go anti-clockwise;
Vertex vertices[4];
Vertex v0, v1, v2, v3;
Face(Vertex _pts[]) {
for (int i = 0; i< 4; i++)
vertices[i] = _pts[i];
v0 = vertices[0];
v1 = vertices[1];
v2 = vertices[2];
v3 = vertices[3];
}
void drawBody() {
moveto(v0.x,v0.y);
lineto(v1.x, v1.y);
lineto(v2.x, v2.y);
lineto(v3.x, v3.y);
lineto(v0.x, v0.y);
}
};
int main() {
initwindow(640, 480, "Rectangle");
Vertex pts[] = {Vertex(100,100,0), Vertex(100, 200, 0), Vertex(200, 200, 0), Vertex(200, 100, 0)};
Face f = Face(pts);
f.drawBody();
int centreX, centreY;
centreX = 100;
float angle = -M_PI_2;
float dTheta = M_PI/10;
int myColour = 1;
centreY = 300 + 50*sin(angle);
circle(centreX, centreY, 1);
setlinestyle(0, 1, 1);
setfillstyle(1, 15);
int stangle = 0; // stangle == start angle
for (int i = 0; i < 4; i++){
pieslice(centreX, centreY,stangle + i*90, stangle+30+(i*90), 40);
}
while (!kbhit( )) {
delay(200);
cleardevice();
angle += dTheta;
stangle -= 5;
if (myColour == 15)
myColour = 4;
else myColour = 15;
setfillstyle(1, myColour);
for (int i = 0; i < 4; i++){
pieslice(centreX, centreY,stangle + i*90, stangle+30+(i*90), 40);
pieslice(centreX+105, centreY,stangle + i*90, stangle+30+(i*90), 40);
}
closegraph();
return 0;
}
}