Mail Archives: djgpp/2002/01/11/19:15:20
Hello A. Sinan!
Thank you for responding to my post! I'm really greatful for the help it
gave me a new persepctive on the problem. Heres a revised edition for the
propeller spinning line if you want one point stationary then comment out
xang2 and yang2.
-Zen
#include <math.h>
#include <conio.h>
#include <iostream.h>
#include <allegro.h>
void linerotate();
int main()
{
allegro_init();
set_gfx_mode(GFX_VESA1,800,600,0,0);
linerotate();
return 0;
};
/******************************************************************/
void linerotate()
{ double rad,rad2,xang,yang,xpos=100,ypos=100,xpos2=100,ypos2=100,xang2,yang2;
for(int ang=0;ang<=360;ang++)
{
rad=ang*(3.14/180);
rad2=(ang+180)*(3.14/180);
xang=25*cos(rad)-25*sin(rad);
yang=25*sin(rad)+25*cos(rad);
xang2=25*cos(rad2)-25*sin(rad2);
yang2=25*sin(rad2)+25*cos(rad2);
xpos+=xang2;
ypos+=yang2;
xpos2+=xang;
ypos2+=yang;
line(screen,int(xpos),int(ypos),int(xpos2),int(ypos2),3);
if(getch()=='q')
ang=359;
xpos=100; ypos=100; xpos2=100; ypos2=100;
}
clear(screen);
};
- Raw text -