<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>pivot sprite help</title>
		<link>http://www.allegro.cc/forums/view/579317</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 18 Apr 2006 12:30:43 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok, in my game i have a tank, and your looking at it from the side. and im trying to pivot the turret sprite so the turret rotates just like in the game pocket tanks, or the game worms, where you can aim everywhere... if im making any sense here, you should understand what i mean.</p><p>im having troubles with my pivot angle stuff...</p><p>i have :</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/pivot_sprite" target="_blank"><span class="a">pivot_sprite</span></a><span class="k2">(</span>buffer,turret_bmp,tanks<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.x<span class="k3">+</span><span class="n">15</span>,tanks<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.y<span class="k3">+</span><span class="n">2</span>,<span class="n">2</span>,<span class="n">14</span>,<a href="http://www.allegro.cc/manual/ftofix" target="_blank"><span class="a">ftofix</span></a><span class="k2">(</span>tanks<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.angle<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/textprintf_ex" target="_blank"><span class="a">textprintf_ex</span></a><span class="k2">(</span>buffer,<a href="http://www.allegro.cc/manual/font" target="_blank"><span class="a">font</span></a>,<span class="n">20</span>,<span class="n">320</span>,<a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">255</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span>,<span class="k3">-</span><span class="n">1</span>,<span class="s">"Angle: %d"</span>,<a href="http://www.allegro.cc/manual/ftofix" target="_blank"><span class="a">ftofix</span></a><span class="k2">(</span>tanks<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.angle<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

The turret rotates... but when i want to show the angle it is at on the screen.<br />it doesnt show the correct number for the direction. it just shows a lot of numbers that dont make sense... and when i take the ftofix out of the textprint function... it just shows a 0.</p><p>my tanks[0].angle is just a float number. and i add 1 to it when i press right, and subtract 1 from it when i press left...</p><p>is there a special way to do this stuff, or am i just doing everything wrong?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (MSGleader)</author>
		<pubDate>Sat, 15 Apr 2006 07:22:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>%d is for integers. You want to use %f. Try this: &quot;Angle: %.2f&quot;.</p><p>Go <a href="http://www.cplusplus.com/ref/cstdio/printf.html">here</a> for more info.</p><p>[edit]<br />Oh, nevermind. That&#39;s only part of your problem. Get rid of the ftofix in textprintf_ex.</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/textprintf_ex" target="_blank"><span class="a">textprintf_ex</span></a><span class="k2">(</span>buffer,<a href="http://www.allegro.cc/manual/font" target="_blank"><span class="a">font</span></a>,<span class="n">20</span>,<span class="n">320</span>,<a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">255</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span>,<span class="k3">-</span><span class="n">1</span>,<span class="s">"Angle: %.2f"</span>,tanks<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.angle<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Assuming tanks[0].angle is indeed a float (or double), that should work. ftofix converts a float to a fixed point number. You only want to do that when, well, you need a fixed point number. In this case you don&#39;t.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonny Cook)</author>
		<pubDate>Sat, 15 Apr 2006 09:56:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>thanx, i tried that, and it works now! <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /><br />just one of those small things you overlook eh?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (MSGleader)</author>
		<pubDate>Sat, 15 Apr 2006 10:11:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>To make it even more human-readable, you&#39;ll want to convert from allegro&#39;s 256-deg format to the usual 360 degrees: 
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/textprintf_ex" target="_blank"><span class="a">textprintf_ex</span></a><span class="k2">(</span>buffer,<a href="http://www.allegro.cc/manual/font" target="_blank"><span class="a">font</span></a>,<span class="n">20</span>,<span class="n">320</span>,<a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">255</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span>,<span class="k3">-</span><span class="n">1</span>,<span class="s">"Angle: %.2f"</span>,tanks<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.angle <span class="k3">*</span> <span class="n">360</span>.<span class="n">0f</span> <span class="k3">/</span> <span class="n">256</span>.<span class="n">0f</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 18 Apr 2006 12:30:43 +0000</pubDate>
	</item>
</rss>
