Archived

This topic is now archived and is closed to further replies.

Optimus

Allegro and maths...

Recommended Posts

Hi, and welcome to my post set_gfx_mode(GFX_AUTODETECT,320,200,0,0); This thing here above creates a sort of bitmap with represents the screen. When written to it it directly outputs on screen. We all know what 320,200 meens, 320 X 200.. So I have like 320X200 positions where I can put points, fill points. But my question.. If I use stuff like sin();, cos(); or other stuff included in math.h, I get double values back, but I can only put an int value in a function like putpixel(screen,180,100,44); bitmap, x , y ,color I allegro not capable of to have ''complex'' math ? Can anyone help ? Thx Nothing and all, by some meaning, no difference

Share this post


Link to post
Share on other sites
This cannot be done, or I dont know how.
Thats why I am asking this question.

This is my source :

#include <allegro.h>
#include <math.h>
int q;

int x1;
int x2;

int main(){
allegro_init();
install_timer();

set_gfx_mode(GFX_AUTODETECT,320,200,0,0);
for(q=1;q<361;q++){
x1=sin(q)+100;
x2=cos(q)+100;
circle(screen,x1,x2,22);
rest(100);
}
}

Does not work, cannot store a double value in an integer.

Nothing and all, by some meaning, no difference

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
how about

double q=0;
while (!keys[''Q''])
{
clear(screen);
int x1 = (int)(sin(q) * 50 + 100); //sin/cos returns -1 to 1
int y1 = (int)(cos(q) * 50 + 100); //and takes the angle in radians
circle(screen,x1,y1,22);
rest(100);
}

Share this post


Link to post
Share on other sites