<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Rotating the screen 90°... possible?</title>
		<link>http://www.allegro.cc/forums/view/587827</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 03 Oct 2006 02:53:23 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;d like to be able in my game at some point rotate the screen 90°... Is this possible without having to use rotated fonts/objects so they display correctly rotated???</p><p>Thanks!!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Marton)</author>
		<pubDate>Mon, 02 Oct 2006 03:49:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>instead of drawing directly to the screen when displaying your code, write it to an offscreen bitmap. You can then transfer that to the screen with rotate_sprite() or related function. You&#39;ll take a performance hit, but it might not really be noticeable on modern hardware.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (brigham toskin)</author>
		<pubDate>Mon, 02 Oct 2006 03:56:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Do you mean simplyp drawing your &quot;completely rendered&quot; BITMAP to your screen, flipped 90-degrees?  If so, you can probably very simply employ the <span class="source-code">rotate<span class="k2">(</span><span class="k2">)</span></span> function (see forum thread <a href="http://www.allegro.cc/forums/thread/323382">http://www.allegro.cc/forums/thread/323382</a> for others trying to do something similar...).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (TeamTerradactyl)</author>
		<pubDate>Mon, 02 Oct 2006 03:59:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Will check the thread, thanks!<br />What I need to do is have a textprintf() call that would write text rotated 90°... Can I do the printf to a bitmap buffer and then rotate it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Marton)</author>
		<pubDate>Mon, 02 Oct 2006 05:05:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>yes
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (brigham toskin)</author>
		<pubDate>Mon, 02 Oct 2006 05:30:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How am I supposed to do it? It doesn&#39;t rotate and the bitmap appears one pixel to the left and one down... I know this may be bad code but hey I&#39;m learning <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>    DATAFILE *datafile;<br />    BITMAP *bitmap, *temp;<br /> <br />    bitmap = create_bitmap(320,200);<br />    temp = create_bitmap(320,200);<br />    text_mode(-1);<br />    set_color_depth(16);<br />    set_color_conversion(COLORCONV_TOTAL);</p><p>    datafile = load_datafile(&quot;test.dat&quot;);<br />    blit(datafile[1].dat, bitmap, 0, 0, 0, 0, 320, 200);<br />    textprintf_centre(bitmap, datafile[0].dat, 160, 165, makecol(255, 0, 0), &quot;Please wait...  &quot;);<br />    rect(bitmap, 50, 195, 267, 175, makecol(255, 255, 255));<br />    rect(bitmap, 0, 199, 319, 0, makecol(255, 255, 255));<br />    rotate_sprite(temp, bitmap, 0, 0, 90);<br />    blit(temp, screen, 0, 0, 0, 0, 320, 200);<br />    destroy_bitmap(bitmap);<br />    destroy_bitmap(temp);<br />    unload_datafile(datafile);
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Marton)</author>
		<pubDate>Mon, 02 Oct 2006 06:37:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>A) you have to used &#39;fix&#39; numbers<br />B) the angle is really 0-255, not 0-360.</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/rotate_sprite" target="_blank"><span class="a">rotate_sprite</span></a><span class="k2">(</span> temp, bitmap, <span class="n">0</span>, <span class="n">0</span>, <a href="http://www.allegro.cc/manual/itofix" target="_blank"><span class="a">itofix</span></a><span class="k2">(</span> <span class="n">64</span> <span class="k2">)</span> <span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

In general to convert 0-360 into 0-255 use this
</p><div class="source-code snippet"><div class="inner"><pre>angle <span class="k3">*</span> <span class="n">256</span> <span class="k3">/</span> <span class="n">360</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Mon, 02 Oct 2006 07:02:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks!!! That was the trick!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Marton)</author>
		<pubDate>Mon, 02 Oct 2006 07:13:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you want performance, there&#39;s more efficient ways to rotate a bitmap 90 decrees (as it&#39;s a special case of rotation). However, you&#39;ll need to write your own drawing function for that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fladimir da Gorf)</author>
		<pubDate>Mon, 02 Oct 2006 15:24:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think roatate_sprite already does multiples of 90 degrees with specialized more efficient code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Mon, 02 Oct 2006 15:32:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes it does. At least the C version of the code contains a comment somewhere about the trivial cases (i.e. multiples of 90 degrees).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Mon, 02 Oct 2006 16:31:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Does this game use matrices to set screen positions?  If so, you could alter a few members of the matrix and it&#39;ll get rotated automagically.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 02 Oct 2006 22:53:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nope, no matrices. Anyway with rotate_sprite it works like a charm <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>Thanks!!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Marton)</author>
		<pubDate>Tue, 03 Oct 2006 02:53:23 +0000</pubDate>
	</item>
</rss>
