<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Im a beginner needing help! xD</title>
		<link>http://www.allegro.cc/forums/view/597784</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 26 Sep 2008 09:14:29 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>well... i&#39;m starting with allegro now and i&#39;m having a lot of troubles...<br />I&#39;m trying to do an RPG game... and it have to be done til october, 2th (as my teacher said xD)...<br />My question is....<br />when i put two bitmaps in the screen, like one for the game itself, and another for the atributes and stuff, the screen keeps blinking and then it says <br />&quot;your program executed an ilegal operation and... u guys know...</p><p>So... i&#39;m needing help... =X<br />i&#39;ll send an annex with a &quot;simplified&quot; code, in wich the same problem happens:</p><p>	while (!key[KEY_ESC]) {<br />          <br />          BITMAP *a = load_bitmap(&quot;E:\\Documents and Settings\\Servidor\\Meus documentos\\1.bmp&quot;, NULL);<br />          BITMAP *b = load_bitmap(&quot;E:\\Documents and Settings\\Servidor\\Meus documentos\\2.bmp&quot;, NULL);<br />          draw_sprite (screen, a, 0, 0);<br />          draw_sprite (screen, b, 0, 0);</p><p>	}</p><p>Sorry for mistakes in the writing, im from brazil and still have a lot to learn in english<br />xD
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thiago Lazier)</author>
		<pubDate>Wed, 24 Sep 2008 17:00:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Check the returns. Once you&#39;ve called load_bitmap, test to see if it worked like so...</p><div class="source-code snippet"><div class="inner"><pre>   <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>a <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">"E:\\Documents and Settings\\Servidor\\Meus documentos\\1.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span>
   <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>b <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">"E:\\Documents and Settings\\Servidor\\Meus documentos\\2.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span>

   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>a<span class="k2">)</span>
   <span class="k2">{</span>
      <a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><span class="s">"Could not load bitmap a!"</span><span class="k2">;</span>
      <a href="http://www.allegro.cc/manual/allegro_exit" target="_blank"><span class="a">allegro_exit</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
   <span class="k2">}</span>

   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>b<span class="k2">)</span>
   <span class="k2">{</span>
      <a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><span class="s">"Could not load bitmap b!"</span><span class="k2">;</span>
      <a href="http://www.allegro.cc/manual/allegro_exit" target="_blank"><span class="a">allegro_exit</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
   <span class="k2">}</span>
</pre></div></div><p>

If you get either of those message popping up then you&#39;ve probably set the wrong path for the bitmap or allegro doesn&#39;t like them for some reason.<br />If not then... i don&#39;t know <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />.<br />Hope it helps <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sol Blast)</author>
		<pubDate>Wed, 24 Sep 2008 17:09:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>@Thiago Lazier: Just a note: on the forums you can surround code with BBCode tags (i.e. [code]text[/code]) and it will maintain white-space, attempt to highlight the source, and even provides links to the Allegro manual and AFAIK a C standard library reference. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> You can see the rest of the BBCode syntax if you click the &quot;<a href="http://www.allegro.cc/mockup.html">Help</a>&quot; option in the toolbar above the post textarea (IMO it&#39;s hard to spot until you know it&#39;s there though)...
</p><div class="quote_container"><div class="title">Thiago Lazier said:</div><div class="quote"><p>
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">while</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">[</span>KEY_ESC<span class="k2">]</span><span class="k2">)</span> <span class="k2">{</span>

<a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>a <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">"E:\\Documents and Settings\\Servidor\\Meus documentos\\1.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>b <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">"E:\\Documents and Settings\\Servidor\\Meus documentos\\2.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/draw_sprite" target="_blank"><span class="a">draw_sprite</span></a> <span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, a, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/draw_sprite" target="_blank"><span class="a">draw_sprite</span></a> <span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, b, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>

<span class="k2">}</span>
</pre></div></div><p>
</p></div></div><p>
Assuming the above code is working, it repeatedly loads <tt>1.bmp</tt> and <tt>2.bmp</tt> before drawing them (technically leaking the memory consumed by the past iterations&#39; loaded <tt>BITMAP</tt>s). So first of all, you&#39;re going to want to move the <tt>load_bitmap</tt> calls outside of the <tt>while</tt> loop.</p><p>Secondly, I&#39;ve heard of two solutions for eliminating the &quot;flickering&quot; screen problem. Double buffering and using Allegro&#39;s <a href="http://www.allegro.cc/manual/api/graphics-modes/vsync">vsync</a> routine. Double buffering is a technique where you create an empty <tt>BITMAP</tt> structure (i.e. your buffer) with the same dimensions as the screen and draw everything to it. Then, when your game loop / frame ends you draw the buffer to the screen. System memory is much faster than video memory, IIRC, so this results in the whole operation being much faster, eliminating the visible flickering.
</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><span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span> <span class="k1">const</span> BMP_1 <span class="k3">=</span> <span class="s">"E:\\Documents and Settings\\Servidor\\Meus documentos\\1.bmp"</span><span class="k2">;</span></td></tr><tr><td class="number">4</td><td><span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span> <span class="k1">const</span> BMP_2 <span class="k3">=</span> <span class="s">"E:\\Documents and Settings\\Servidor\\Meus documentos\\2.bmp"</span><span class="k2">;</span></td></tr><tr><td class="number">5</td><td>&#160;</td></tr><tr><td class="number">6</td><td><span class="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argc, <span class="k1">char</span> <span class="k3">*</span>argv<span class="k2">[</span><span class="k2">]</span><span class="k2">)</span></td></tr><tr><td class="number">7</td><td><span class="k2">{</span></td></tr><tr><td class="number">8</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="k3">=</span> NULL, <span class="k3">*</span>a <span class="k3">=</span> NULL, <span class="k3">*</span>b <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">9</td><td>&#160;</td></tr><tr><td class="number">10</td><td>    <span class="c">/* ... Initialization Of Allegro Goes Here ...*/</span></td></tr><tr><td class="number">11</td><td>&#160;</td></tr><tr><td class="number">12</td><td>    <span class="c">// Once Allegro is successfully initialized we create our screen buffer.</span></td></tr><tr><td class="number">13</td><td>    <span class="k1">if</span><span class="k2">(</span><span class="k2">(</span>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>screen-&gt;w, screen-&gt;h<span class="k2">)</span><span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> NULL<span class="k2">)</span></td></tr><tr><td class="number">14</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">15</td><td>        <a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><span class="s">"Failed to create screen buffer."</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">16</td><td>        <a href="http://www.delorie.com/djgpp/doc/libc/libc_298.html" target="_blank">exit</a><span class="k2">(</span><span class="k3">-</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">18</td><td>&#160;</td></tr><tr><td class="number">19</td><td>    <span class="c">// Now we load bitmaps from disk.</span></td></tr><tr><td class="number">20</td><td>    <span class="k1">if</span><span class="k2">(</span><span class="k2">(</span>a <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>BMP_1, NULL<span class="k2">)</span><span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> NULL</td></tr><tr><td class="number">21</td><td>            <span class="k3">|</span><span class="k3">|</span> <span class="k2">(</span>b <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>BMP_2, NULL<span class="k2">)</span><span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> NULL<span class="k2">)</span></td></tr><tr><td class="number">22</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">23</td><td>        <a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><span class="s">"Failed to load one or more bitmaps."</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">24</td><td>        <a href="http://www.delorie.com/djgpp/doc/libc/libc_298.html" target="_blank">exit</a><span class="k2">(</span><span class="k3">-</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">25</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">26</td><td>&#160;</td></tr><tr><td class="number">27</td><td>    <span class="c">// Begin the main loop.</span></td></tr><tr><td class="number">28</td><td>    <span class="k1">while</span><span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">[</span>KEY_ESC<span class="k2">]</span><span class="k2">)</span></td></tr><tr><td class="number">29</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">30</td><td>        <span class="c">// Draw everything to the buffer instead of the screen.</span></td></tr><tr><td class="number">31</td><td>        <a href="http://www.allegro.cc/manual/draw_sprite" target="_blank"><span class="a">draw_sprite</span></a><span class="k2">(</span>buffer, a, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">32</td><td>        <a href="http://www.allegro.cc/manual/draw_sprite" target="_blank"><span class="a">draw_sprite</span></a><span class="k2">(</span>buffer, b, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">33</td><td>&#160;</td></tr><tr><td class="number">34</td><td>        <span class="c">/*</span></td></tr><tr><td class="number">35</td><td><span class="c">         * Then when you're finished drawing everything, draw the buffer onto the</span></td></tr><tr><td class="number">36</td><td><span class="c">         * screen.</span></td></tr><tr><td class="number">37</td><td><span class="c">         */</span></td></tr><tr><td class="number">38</td><td>        <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>buffer, <a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, screen-&gt;w, screen-&gt;h<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">39</td><td>&#160;</td></tr><tr><td class="number">40</td><td>        <span class="c">// And, depending on the technique used, clear the buffer.</span></td></tr><tr><td class="number">41</td><td>        <a href="http://www.allegro.cc/manual/clear_bitmap" target="_blank"><span class="a">clear_bitmap</span></a><span class="k2">(</span>buffer<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">42</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">43</td><td>&#160;</td></tr><tr><td class="number">44</td><td>    <span class="c">// Clean-up.</span></td></tr><tr><td class="number">45</td><td>    <span class="k1">if</span><span class="k2">(</span>buffer<span class="k2">)</span></td></tr><tr><td class="number">46</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">47</td><td>        <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>buffer<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">48</td><td>        buffer <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">49</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">50</td><td>&#160;</td></tr><tr><td class="number">51</td><td>    <span class="k1">if</span><span class="k2">(</span>a<span class="k2">)</span></td></tr><tr><td class="number">52</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">53</td><td>        <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>a<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">54</td><td>        a <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">55</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">56</td><td>&#160;</td></tr><tr><td class="number">57</td><td>    <span class="k1">if</span><span class="k2">(</span>b<span class="k2">)</span></td></tr><tr><td class="number">58</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">59</td><td>        <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>b<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">60</td><td>        b <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">61</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">62</td><td>&#160;</td></tr><tr><td class="number">63</td><td>    <span class="k1">return</span><span class="k2">(</span><span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">64</td><td><span class="k2">}</span></td></tr><tr><td class="number">65</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></td></tr></tbody></table></div></div><p>
I&#39;ve never used <tt>vsync</tt> before so I can&#39;t be sure on the syntax, but if you&#39;re still having problems after double buffering then you can give it a try too.</p><p>If you&#39;re able to show us more code then we can probably help you correct some other common mistakes before you get very far. A lot of people neglect return values, which leads to unexpected errors. If a routine returns a value indicating success or failure make sure to check that it was successful and react accordingly. Timing is another common problem.</p><p>IMHO, attempting to write an RPG before Oct 2 when you&#39;re this new is unlikely to succeed. You might want to negotiate with your teacher/professor either on the project or the deadline.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Wed, 24 Sep 2008 18:39:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello Thiago Lazier, you probably won&#39;t appreciate what I&#39;m about to say. </p><p>Even if you had &quot;the skills&quot; you probably won&#39;t finish a full fledged RPG in a week, unless it&#39;s very small. So in case you&#39;re aiming that high you should reconsider.</p><p>You could however make the engine in a week, and maybe even throw in an editor. I&#39;m not sure how new you are to game programming but you should aim at a simple engine to begin with.</p><p>I&#39;m sure your programming teacher will be impressed with that.</p><p>Just a tip, you do whatever you think is best.</p><p>Oh, and good luck with leveling your ragnarok characters. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Wed, 24 Sep 2008 19:08:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>RPG in a week? Your teacher must play speedhack <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />. Don´t even try an RPG in a week. Making a battle system, datbase, and... well, you got the idea.</p><p>anyways, My best solution for you would be that you just copy some of the examples on the allegro folder to get a page-flipping system or a simple double buffer.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dario ff)</author>
		<pubDate>Wed, 24 Sep 2008 21:22:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>These MP3&#39;s should help: <a href="http://www.allegro.cc/files/attachment/596486">Verse 1</a>, <a href="http://www.allegro.cc/files/attachment/596493">Verse 2</a>.</p><p>Sorry for the rough quality. We started them on Monday, and aren&#39;t done yet, despite it being Wednesday. Hopefully we have the final mix ready by the second though. <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 24 Sep 2008 22:01:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Matthew that was awesome!:D;D8-)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Wed, 24 Sep 2008 22:26:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nice Matthew! <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Wed, 24 Sep 2008 23:52:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That made my day.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Schyfis)</author>
		<pubDate>Thu, 25 Sep 2008 01:56:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The song itself is one of the most successful monday projects ever.:D
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Thu, 25 Sep 2008 20:43:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Or Tuesday, for that matter!:P
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Thu, 25 Sep 2008 23:20:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Don Freeman said:</div><div class="quote"><p>
Or Tuesday, for that matter!:P
</p></div></div><p>
No, no.  Tuesday is the <i>other</i> group&#39;s Group Project.  As I recall, there were three groups: Monday, Tuesday and Duke Nukem Forever.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (OnlineCop)</author>
		<pubDate>Fri, 26 Sep 2008 03:27:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
As I recall, there were three groups: Monday, Tuesday and Duke Nukem Forever.
</p></div></div><p>

Sigged.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Fri, 26 Sep 2008 09:14:29 +0000</pubDate>
	</item>
</rss>
