<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>rotate_angle problem</title>
		<link>http://www.allegro.cc/forums/view/590926</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 10 Apr 2007 02:09:17 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I can&#39;t get rotate_angle to work! It compiles fine but when I run it the game crashes. Here&#39;s the code.</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="p">#include &lt;allegro.h&gt;</span></td></tr><tr><td class="number">2</td><td>&#160;</td></tr><tr><td class="number">3</td><td><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> buffer<span class="k2">;</span></td></tr><tr><td class="number">4</td><td><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> Ship<span class="k2">;</span></td></tr><tr><td class="number">5</td><td><span class="k1">int</span> Rot_Angle<span class="k2">;</span></td></tr><tr><td class="number">6</td><td>&#160;</td></tr><tr><td class="number">7</td><td>&#160;</td></tr><tr><td class="number">8</td><td>&#160;</td></tr><tr><td class="number">9</td><td><span class="k1">void</span> Init_Stuff<span class="k2">(</span><span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">10</td><td>     <span class="c">// Set up the game</span></td></tr><tr><td class="number">11</td><td>     <a href="http://www.allegro.cc/manual/allegro_init" target="_blank"><span class="a">allegro_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>     <a href="http://www.allegro.cc/manual/install_keyboard" target="_blank"><span class="a">install_keyboard</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>     <a href="http://www.allegro.cc/manual/set_color_depth" target="_blank"><span class="a">set_color_depth</span></a><span class="k2">(</span><span class="n">16</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>     <a href="http://www.allegro.cc/manual/set_gfx_mode" target="_blank"><span class="a">set_gfx_mode</span></a><span class="k2">(</span> GFX_AUTODETECT, <span class="n">640</span>, <span class="n">480</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>     </td></tr><tr><td class="number">16</td><td>     buffer <span class="k3">=</span> <a href="http://www.allegro.cc/manual/create_bitmap" target="_blank"><span class="a">create_bitmap</span></a><span class="k2">(</span><span class="n">640</span>, <span class="n">480</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>     </td></tr><tr><td class="number">18</td><td>     Ship <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_bitmap" target="_blank"><span class="a">load_bitmap</span></a><span class="k2">(</span> <span class="s">"Ship.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">19</td><td>     Rot_Angle <span class="k3">=</span> <span class="n">64</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td><span class="k2">}</span></td></tr><tr><td class="number">21</td><td>&#160;</td></tr><tr><td class="number">22</td><td><span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">23</td><td>    </td></tr><tr><td class="number">24</td><td>    <a href="http://www.allegro.cc/manual/clear_keybuf" target="_blank"><span class="a">clear_keybuf</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">25</td><td>    </td></tr><tr><td class="number">26</td><td>    <a href="http://www.allegro.cc/manual/rotate_sprite" target="_blank"><span class="a">rotate_sprite</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, Ship, <span class="n">10</span>, <span class="n">10</span>, <span class="n">64</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">27</td><td>    <a href="http://www.allegro.cc/manual/rotate_sprite" target="_blank"><span class="a">rotate_sprite</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, Ship, <span class="n">50</span>, <span class="n">10</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">28</td><td>    <a href="http://www.allegro.cc/manual/rotate_sprite" target="_blank"><span class="a">rotate_sprite</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, Ship, <span class="n">90</span>, <span class="n">10</span>, <span class="n">174</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">29</td><td>    </td></tr><tr><td class="number">30</td><td>    <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">31</td><td><span class="k2">}</span></td></tr><tr><td class="number">32</td><td><a href="http://www.allegro.cc/manual/END_OF_MAIN" target="_blank"><span class="a">END_OF_MAIN</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr></tbody></table></div></div><p>

That&#39;s as far as I got, because rotate_sprite wouldn&#39;t work. When I take out the rotate_sprite statements, it doesn&#39;t crash. I just noticed I put a semi-colon on END_OF_MAIN(), but I don&#39;t think that&#39;s the problem.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Mon, 09 Apr 2007 17:52:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;re not checking if Ship was loaded successfully. Check it. I&#39;m betting it&#39;s 1) failing 2) because Ship.bmp is in the wrong directory.</p><p>Also, you need to itofix() those (Allegro) angles. But you shouldn&#39;t really store things in Allegro degrees anyway - use radians in floats/doubles and convert when passing the angle argument to rotate_sprite().
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Mon, 09 Apr 2007 17:56:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How do I convert, and how do I use itofix()?</p><p>The bitmap is fine, it works with draw_sprite()
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Mon, 09 Apr 2007 18:01:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, in that case it&#39;s crashing because you&#39;re never actually calling Init_Stuff(). <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /><br />Add error checking. <b>Now.</b><br />You also aren&#39;t destroying your loaded and created bitmaps like you should...</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
How do I convert
</p></div></div><p>The conversion factor to convert an angle in angle system 1 into angle system 2 is equal to the period for angle system 2 divided by the period for angle system 1. For radians -&gt; allegro degrees, this is <img class="math" src="http://www.allegro.cc/images/tex/0/d/0d3346e72db5361a61910ee6f4701948-96.png" alt="&lt;math&gt;\frac{256}{2\pi}&lt;/math&gt;" /><br />In other words, <span class="source-code">allegro_angle <span class="k3">=</span> <a href="http://www.allegro.cc/manual/ftofix" target="_blank"><span class="a">ftofix</span></a><span class="k2">(</span>radian_angle<span class="k3">*</span><span class="n">256</span>.<span class="n">0f</span><span class="k3">/</span><span class="k2">(</span><span class="n">2</span>.<span class="n">0f</span><span class="k3">*</span>M_PI<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></span></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
and how do I use itofix()?
</p></div></div><p>
It&#39;s in the manual.</p><p>[EDIT]<br />Various edits to fix mistakes caused by sleep deprivation.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Mon, 09 Apr 2007 18:10:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How do I do error checking, and how do I destroy loaded and created bitmaps? Links to tutorials would be good.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Tue, 10 Apr 2007 01:28:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Possumdude0 said:</div><div class="quote"><p>
How do I do error checking, and how do I destroy loaded and created bitmaps? Links to tutorials would be good.
</p></div></div><p>
There are examples. There&#39;s a manual. There are even examples <i>in</i> the manual. Please read them.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Tue, 10 Apr 2007 01:37:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t know what to look for in the manual. I mean, now I know I could look up destroying bitmaps, but before I didn&#39;t even know I needed to do that. Then I figured you could easily point me to some information, since you seem to have some experience and know what you&#39;re talking about.</p><p>But I guess I&#39;ll just sift through that huge manual for the tiny bit of information I need.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Tue, 10 Apr 2007 01:43:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">I said:</div><div class="quote"><p>
There are examples.
</p></div></div><p>

</p><div class="quote_container"><div class="title">Possumdude0 said:</div><div class="quote"><p>
Then I figured you could easily point me to some information, since you seem to have some experience and know what you&#39;re talking about.
</p></div></div><p>
I just did. At some point, you will <i>have</i> to start looking for information on your own. We can&#39;t spoon-feed you everything.<br />&quot;Give a man a fish and you have fed him for today. Teach a man to fish and you have fed him for a lifetime.&quot;
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Tue, 10 Apr 2007 01:47:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Unless over-fishing kills off all his food, or he loses his fishing pole, or runs out of bait. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>Seriously, I just don&#39;t know enough to know what information to look for. I checked out destroy bitmap in the manual. Do I call it for every bitmap at the end of my program?</p><p>Also, when you said look in the manual, I thought you meant that big long text document that came with allegro, I didn&#39;t know the manual here was sorted out with links and stuff for easy searching. I learn something new every day! <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>Thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Tue, 10 Apr 2007 01:53:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Also, when you said look in the manual, I thought you meant that big long text document that came with allegro
</p></div></div><p>
You should also have a HTML version.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Tue, 10 Apr 2007 01:58:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I haven&#39;t seen one, but it may be in there somewhere, I&#39;ll look next time I can (sometime in the next 3 days, stupid work cutting into my slacking off time!)</p><p>EDIT:<br />Yep, I&#39;ve got the HTML version.</p><p>Oh yeah, it&#39;s working now, too <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Tue, 10 Apr 2007 02:09:17 +0000</pubDate>
	</item>
</rss>
