<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>It won&#39;t compile when I use ftofix!</title>
		<link>http://www.allegro.cc/forums/view/590659</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 23 Mar 2007 19:45:32 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>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&#39;m doing wrong.</p><p>I just want to find the sin of my float.</p><p>I&#39;ve tried this...
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">float</span> angle <span class="k3">=</span> <span class="n">5</span><span class="k2">;</span>
y <span class="k3">=</span> <span class="k1">int</span><span class="k2">(</span><span class="n">100</span> <span class="k3">*</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_728.html" target="_blank">sin</a><span class="k2">(</span>angle<span class="k2">)</span> <span class="k3">-</span> <span class="n">20</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
<span class="source-code">error: conversion from `<span class="k1">float</span><span class="s">' to non-scalar type `fix'</span> requested</span></p><p>and this...
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">float</span> angle <span class="k3">=</span> <span class="n">5</span><span class="k2">;</span>
y <span class="k3">=</span> <span class="k1">int</span><span class="k2">(</span><span class="n">100</span> <span class="k3">*</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_728.html" target="_blank">sin</a><span class="k2">(</span><a href="http://www.allegro.cc/manual/ftofix" target="_blank"><span class="a">ftofix</span></a><span class="k2">(</span>angle<span class="k2">)</span><span class="k2">)</span> <span class="k3">-</span> <span class="n">20</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
<span class="source-code">error: conversion from `<a href="http://www.allegro.cc/manual/fixed" target="_blank"><span class="a">fixed</span></a><span class="s">' to non-scalar type `fix'</span> requested</span></p><p>I&#39;m using gcc and C++
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (peelemachine)</author>
		<pubDate>Thu, 22 Mar 2007 08:55:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>#include &lt;math.h&gt; before you include allegro.h.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Thu, 22 Mar 2007 08:59:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Cool, thanks. I thought allegro had its own cos/sin functions because it only uses 256 degrees instead of 360. But it doesn&#39;t matter?</p><p>I have a bitmap of a crosshair, and I&#39;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.</p><p>Do you have any ideas for that?</p><div class="source-code snippet"><div class="inner"><pre>


           x <span class="k3">&lt;</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span> Center point



 <span class="k3">/</span>
 <span class="k3">/</span>\ <span class="k3">&lt;</span> crosshair
</pre></div></div><p>

The crosshair should be angled towards the center point, but it&#39;s not.</p><p>Right now, I&#39;m using the slope of those two points and applying different math functions to it, with no luck.</p><p>I&#39;ve tried angle = slope * 32; and it works for about 64 degrees.</p><p>I&#39;ve also tried 256 * cos(slope); but it doesn&#39;t work.</p><p>Is there an obvious way that I don&#39;t know about?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (peelemachine)</author>
		<pubDate>Thu, 22 Mar 2007 09:26:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Cool, thanks. I thought allegro had its own cos/sin functions because it only uses 256 degrees instead of 360.
</p></div></div><p>
It does, but the regular sin and cos use radians, not silly Babylonian degrees.</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// angle in radians</span>
<a href="http://www.allegro.cc/manual/rotate_sprite" target="_blank"><span class="a">rotate_sprite</span></a><span class="k2">(</span>buffer, crosshair_sprite, center_point.x<span class="k3">+</span>radius<span class="k3">*</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_113.html" target="_blank">cos</a><span class="k2">(</span>angle<span class="k2">)</span>, center_point.y-sin<span class="k2">(</span>angle<span class="k2">)</span>, <a href="http://www.allegro.cc/manual/ftofix" target="_blank"><span class="a">ftofix</span></a><span class="k2">(</span>M_PI<span class="k3">*</span>angle<span class="k3">/</span><span class="n">128</span>.<span class="n">0f</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Thu, 22 Mar 2007 17:21:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok I AM a genius... I figured out such a simple way to achieve the same effect.</p><p>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.</p><p>Then i used pivot_sprite() and just pivot the scope image around from 0 for X, and half the scope image height for Y.</p><p>Thanks anyways
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (peelemachine)</author>
		<pubDate>Fri, 23 Mar 2007 07:31:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There are words to describe &quot;an ugly hack done instead of implementing something properly&quot;, but &quot;genius&quot; isn&#39;t one of them.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Fri, 23 Mar 2007 19:45:32 +0000</pubDate>
	</item>
</rss>
