I've tried hard to solve this but I still couldn't make it right.
Here's what I've made.
#include <graphics.h>
#include <ctype.h>
#include <math.h>
#include <conio.h>
#include <stdio.h>
#include <process.h>
int check(int,char);
void Initialize(void);void drawEllipse1(int color);
void drawEllipse1(int color);
void drawEllipse2(int color);
void main() {
int color, color1;
char ch;
Initialize();
ch = 'R';color1=1;color=1;
do {
if (ch == 'R' || ch == 'L') {
if (ch == 'L') {
if (color1 == 4) color = 1;
else color = ++color1;
}
drawEllipse1(color);
color1 = color;
color = check(color, ch);
drawEllipse2(color);
}
ch = toupper(getche());
} while (ch!='X');
closegraph();
}
void Initialize(void) {
int driver = DETECT,mode, errorcode;
initgraph(&driver,&mode, "c:\\tc\\bgi");
errorcode = graphresult();
if (errorcode != grOk) {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("<Copy egavga.bgi to c:\\tc\\bgi>");
getch();
exit(1);
}
}
void drawEllipse1(int color) {
setfillstyle(SOLID_FILL,color);
setcolor(color);
fillellipse((getmaxx()/2),(getmaxy()/2), 25, 50);
}
void drawEllipse2(int color) {
setfillstyle(SOLID_FILL,color);
setcolor(color);
fillellipse(((getmaxx()/2)),(getmaxy() / 2),50,25);
}
int check(int color,char ch) {
if (ch == 'R') {
if (color < 4)
++color;
else if (color == 4)
color = 1;
}
if (ch == 'L') {
if (color == 4)
color = 1;
else color++;
}
return color;
}
I just couldn't make it rotate in 10 degrees. Please help me !