<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>trying to move font....</title>
		<link>http://www.allegro.cc/forums/view/616026</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 04 Feb 2016 06:42:34 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hy everybody, instead of doing the typical bitmap moving experiment, I am trying to move a font phrase. I am simply doing this for training, but I am stuck and although it would be easier for me to just move a bitmap, I figure It would be more educational if I learn how to do more unique things with fonts, like move it. I even tried putting my font_x and font_y variables in the parenthasies of my al_draw_text statement. Any help would be very good and thank you in advance.</p><p>#define ALLEGRO_STATICLINK<br />#include &lt;iostream&gt;<br />#include &lt;allegro5\allegro.h&gt;<br />#include &lt;allegro5\allegro_font.h&gt;<br />#include &lt;allegro5\allegro_ttf.h&gt;<br />#include &lt;allegro5\allegro_native_dialog.h&gt;<br />#include &lt;allegro5\allegro_primitives.h&gt;<br />#include &lt;allegro5\allegro_image.h&gt;<br />using namespace std;</p><p>enum KEYS{UP, DOWN, LEFT, RIGHT};</p><p>int main(void){<br />bool done = false;<br />int font_x = 0;<br />int font_y = 0;<br />bool keys[5] = {false, false, false, false};</p><p>ALLEGRO_DISPLAY *display = NULL;<br />ALLEGRO_DISPLAY_MODE    disp_data;<br />ALLEGRO_EVENT_QUEUE *event_queue = NULL;</p><p>al_init();<br />al_init_image_addon();<br />al_init_primitives_addon();<br />al_init_font_addon();<br />al_init_ttf_addon();<br />al_install_keyboard();</p><p>ALLEGRO_FONT *font10 = al_load_font(&quot;ARDESTINE.ttf&quot;, 24, 0);</p><p>al_get_display_mode(al_get_num_display_modes() - 1, &amp;disp_data);<br />al_set_new_display_flags(ALLEGRO_FULLSCREEN);<br />display = al_create_display(disp_data.width, disp_data.height);<br />event_queue = al_create_event_queue();<br />al_register_event_source(event_queue, al_get_keyboard_event_source());<br />al_register_event_source(event_queue, al_get_display_event_source(display));<br />while(!done){<br />    ALLEGRO_EVENT ev;<br />al_wait_for_event(event_queue, &amp;ev);</p><p>if (ev.type == ALLEGRO_EVENT_KEY_DOWN){<br />    switch (ev.keyboard.keycode){</p><p>    case ALLEGRO_KEY_UP:<br />    keys[UP] = true;<br />    break;</p><p>    case ALLEGRO_KEY_DOWN:<br />    keys[DOWN] = true;<br />    break;</p><p>    case ALLEGRO_KEY_LEFT:<br />    keys[LEFT] = true;<br />    break;</p><p>    case ALLEGRO_KEY_RIGHT:<br />    keys[RIGHT] = true;<br />    break;</p><p>    case ALLEGRO_KEY_ESCAPE:<br />    done = true;<br />    }<br />}<br />else if (ev.type == ALLEGRO_EVENT_KEY_UP){<br />switch (ev.keyboard.keycode){</p><p>    case ALLEGRO_KEY_UP:<br />    keys[UP] = false;<br />    break;</p><p>    case ALLEGRO_KEY_DOWN:<br />    keys[DOWN] = false;<br />    break;</p><p>    case ALLEGRO_KEY_LEFT:<br />    keys[LEFT] = true;<br />    break;</p><p>    case ALLEGRO_KEY_RIGHT:<br />    keys[RIGHT] = false;<br />    break;</p><p>    case ALLEGRO_KEY_ESCAPE:<br />    done = false;<br />}</p><p>}<br />else if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE){<br />    done = true;<br />}</p><p>if (keys[UP]){<br />  font_y -= 4.0;<br />}<br />if (keys[DOWN]){<br />font_y += 4.0;<br />}</p><p>if (keys[LEFT]){<br />    font_x -= 4.0;<br />}</p><p>if (keys[RIGHT]){<br />    font_x += 4.0;<br />}</p><p>al_draw_text(font10, al_map_rgb(233,100,90),50,50,0,&quot;Hy! Move me around please!&quot;);</p><p>al_clear_to_color(al_map_rgb(0,0,0));<br />al_flip_display();<br />}</p><p>al_rest(15);<br />al_flip_display();<br />al_destroy_display(display);<br />al_destroy_font(font10);<br />return 0;<br />}
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (PCwizard200)</author>
		<pubDate>Wed, 03 Feb 2016 06:45:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Awe man, you&#39;re so close! <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" /></p><p>Right now you have:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_draw_text"><span class="a">al_draw_text</span></a><span class="k2">(</span>font10, <a href="http://www.allegro.cc/manual/al_map_rgb"><span class="a">al_map_rgb</span></a><span class="k2">(</span><span class="n">233</span>,<span class="n">100</span>,<span class="n">90</span><span class="k2">)</span>,<span class="n">50</span>,<span class="n">50</span>,<span class="n">0</span>,<span class="s">"Hy! Move me around please!"</span><span class="k2">)</span><span class="k2">;</span>

<a href="http://www.allegro.cc/manual/al_clear_to_color"><span class="a">al_clear_to_color</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_map_rgb"><span class="a">al_map_rgb</span></a><span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_flip_display"><span class="a">al_flip_display</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
So you are 1) drawing the text, <i>then 2) completely clearing the screen</i>, then 3) flipping the cleared screen to the display.</p><p>Fix that and I think you&#39;ll be able to solve the rest no problem. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Wed, 03 Feb 2016 09:40:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks! Sorry for the late reply I was very busy, any way I shall now fix my code in a jiff.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (PCwizard200)</author>
		<pubDate>Thu, 04 Feb 2016 06:42:34 +0000</pubDate>
	</item>
</rss>
