Mail Archives: djgpp/2002/01/10/18:15:13
X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f
|
From: | "Zenko B. Klapko Jr." <zen1 AT comcast DOT net>
|
Subject: | allegro and math libraries
|
Newsgroups: | comp.os.msdos.djgpp
|
User-Agent: | Pan/0.9.1 (Unix)
|
X-No-Productlinks: | Yes
|
Lines: | 83
|
Message-ID: | <5cp%7.332292$ez.47656452@news1.rdc1.nj.home.com>
|
Date: | Thu, 10 Jan 2002 23:10:57 GMT
|
NNTP-Posting-Host: | 68.38.96.90
|
X-Complaints-To: | abuse AT home DOT net
|
X-Trace: | news1.rdc1.nj.home.com 1010704257 68.38.96.90 (Thu, 10 Jan 2002 15:10:57 PST)
|
NNTP-Posting-Date: | Thu, 10 Jan 2002 15:10:57 PST
|
Organization: | Excite AT Home - The Leader in Broadband http://home.com/faster
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hello Everybody!
For a week or two I've been trying to get a line to rotate like a
propeller. I'm using the allegro and math libraries and I"m wondering
what i'm doing wrong. I felt this would be a proper place for it since
the programmers here are well educated and show concern for the people
who post. And I've asked 3 math teachers (2 of which program) for help but to no
avail. I've even tinkered with the equaitons and created really amazing
cylinders and other circular based patterns, but I really would like a
rotating line. Heres the Code and thanks for any time spent! -Zen
PS. if you have a simpler example that will do.
#include <dos.h>
#include <conio.h>
#include <iostream.h>
#include <math.h>
#include <allegro.h> //contains code for allegro library
void info();
void numtest();
int main()
{
allegro_init(); //sets up allegro environment
set_gfx_mode(GFX_VESA1,640,480,0,0); //sets gfx info
numtest();
return 0;
};
void numtest() //MUST CREATE 4 QUADRANTS ON SCREEN?
{ double xpos=100,ypos=100,xpos2=200,ypos2=200,rad,xang,yang,xang2,yang2;
clear(screen);
// line(screen,int(xpos),int(ypos),int(xpos2),int(ypos2),10);
for (int ang=1;ang <=360;ang++)
{
rad=ang*(3.1415/180);
xang=50*cos(rad)-50*sin(rad);
yang=50*sin(rad)+50*cos(rad);
xang2=50*sin(rad)-50*cos(rad);
yang2=50*cos(rad)+50*sin(rad);
/* if (ang <= 90)
{*/
xpos-=xang;
ypos-=yang;
xpos2+=xang;
ypos2+=yang;
/* }
if ((ang > 90) && (ang <= 180))
{
xpos+=xang;
ypos+=xang;
xpos2-=xang;
ypos2-=yang;
}*/
/*
if ((ang > 180) && (ang <= 270))
{
xpos+=xang;
ypos+=xang;
xpos2-=xang;
ypos2-=yang;
}
if ((ang > 270) && (ang <= 360))
{
xpos-=xang;
ypos+=yang;
xpos2+=xang;
ypos2-=yang;
} */
line(screen,int(xpos),int(ypos),int(xpos2),int(ypos2),10);
xpos=100; ypos=100; xpos2=200; ypos2=200;
if (getch() == 'q')
ang=359;
}
getch();
return;
};
- Raw text -