Public Group

#### Archived

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

# Allegro and maths...

This topic is 5649 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
Just cast it to an integer.

##### 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 on other sites

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 on other sites
Thank you, Anonymous Poster

Nothing and all, by some meaning, no difference

1. 1
Rutin
21
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 13
• 38
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631715
• Total Posts
3001868
×