|
It won't compile when I use ftofix! |
peelemachine
Member #8,085
December 2006
|
Sorry for making another topic, but why am I getting this compile error? I read some other posts, and looked in the manual, but nothing explains what I'm doing wrong. I just want to find the sin of my float. I've tried this... float angle = 5; y = int(100 * sin(angle) - 20); error: conversion from `float' to non-scalar type `fix' requested and this... error: conversion from `fixed' to non-scalar type `fix' requested I'm using gcc and C++ You're damned if you do, and you're damned if you don't. |
kazzmir
Member #1,786
December 2001
|
#include <math.h> before you include allegro.h. |
peelemachine
Member #8,085
December 2006
|
Cool, thanks. I thought allegro had its own cos/sin functions because it only uses 256 degrees instead of 360. But it doesn't matter? I have a bitmap of a crosshair, and I'm using sin and cos to make it move around in a circle, but I want the crosshair to line up with the center point of the circle. Do you have any ideas for that? x <--- Center point / /\ < crosshair The crosshair should be angled towards the center point, but it's not. Right now, I'm using the slope of those two points and applying different math functions to it, with no luck. I've tried angle = slope * 32; and it works for about 64 degrees. I've also tried 256 * cos(slope); but it doesn't work. Is there an obvious way that I don't know about? You're damned if you do, and you're damned if you don't. |
gnolam
Member #2,030
March 2002
|
Quote: Cool, thanks. I thought allegro had its own cos/sin functions because it only uses 256 degrees instead of 360. It does, but the regular sin and cos use radians, not silly Babylonian degrees. // angle in radians rotate_sprite(buffer, crosshair_sprite, center_point.x+radius*cos(angle), center_point.y-sin(angle), ftofix(M_PI*angle/128.0f));
-- |
peelemachine
Member #8,085
December 2006
|
Ok I AM a genius... I figured out such a simple way to achieve the same effect. I went into GIMP and changed the width for the scope image, placing 100 columns of pink pixels to the left of the original image. Then i used pivot_sprite() and just pivot the scope image around from 0 for X, and half the scope image height for Y. Thanks anyways You're damned if you do, and you're damned if you don't. |
gnolam
Member #2,030
March 2002
|
There are words to describe "an ugly hack done instead of implementing something properly", but "genius" isn't one of them. -- |
|