Allegro and maths...
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
Nothing and all, by some meaning, no difference
Just cast it to an integer.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
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
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
Nothing and all, by some meaning, no difference
January 28, 2003 12:17 PM
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);
}
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);
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement