<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Comparing Colors works sometimes</title>
		<link>http://www.allegro.cc/forums/view/608462</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 27 Sep 2011 20:30:22 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello everyone, here is the scenario. Making a 2D platformer, I have my standard background image, and a completely black and white version also loaded into memory. The black and white image is almost completely white, with the platforms themselves being completely black (no gradiant). Every cycle, I am comparing the color on my BW background against the color black to determine if I am standing on the ground. This works, until randomnly my avatar falls through the ground. It seems to be random at any given place and I cannot figure out why. Can you tell me what I am doing wrong? Furthermore, is there a better way to handle platforming?</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="k1">int</span> color_equiv<span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> c1, <a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> c2<span class="k2">)</span> <span class="k2">{</span>
<span class="number">  2</span>
<span class="number">  3</span>    <span class="k1">unsigned</span> <span class="k1">char</span> r1, g1, b1, r2, g2, b2<span class="k2">;</span>
<span class="number">  4</span>
<span class="number">  5</span>    <a href="http://www.allegro.cc/manual/al_unmap_rgb"><span class="a">al_unmap_rgb</span></a><span class="k2">(</span>c1, <span class="k3">&amp;</span>r1, <span class="k3">&amp;</span>g1, <span class="k3">&amp;</span>b1<span class="k2">)</span><span class="k2">;</span>
<span class="number">  6</span>    <a href="http://www.allegro.cc/manual/al_unmap_rgb"><span class="a">al_unmap_rgb</span></a><span class="k2">(</span>c2, <span class="k3">&amp;</span>r2, <span class="k3">&amp;</span>g2, <span class="k3">&amp;</span>b2<span class="k2">)</span><span class="k2">;</span>
<span class="number">  7</span>
<span class="number">  8</span>    <span class="k1">if</span> <span class="k2">(</span>r1 <span class="k3">!</span><span class="k3">=</span> r2 <span class="k3">|</span><span class="k3">|</span> g1 <span class="k3">!</span><span class="k3">=</span> g2 <span class="k3">|</span><span class="k3">|</span> b1 <span class="k3">!</span><span class="k3">=</span> b2<span class="k2">)</span>
<span class="number">  9</span>        <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 10</span>    <span class="k1">else</span>
<span class="number"> 11</span>        <span class="k1">return</span> <span class="n">1</span><span class="k2">;</span>
<span class="number"> 12</span>
<span class="number"> 13</span><span class="k2">}</span>
<span class="number"> 14</span>
<span class="number"> 15</span><span class="c">//in my update</span>
<span class="number"> 16</span><span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>color_equiv<span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_pixel"><span class="a">al_get_pixel</span></a><span class="k2">(</span>image, x, tempY <span class="k3">+</span> <span class="n">6</span><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>
<span class="number"> 17</span><span class="k2">{</span>
<span class="number"> 18</span>y <span class="k3">=</span> tempY<span class="k2">;</span>
<span class="number"> 19</span><span class="k2">}</span>
</div></div><p>

The color_equiv function was by another user on these forums. Thanks for your help</p><p><b> EDIT: Nevermind, figured it out. The question still stands though whether or not there is a better way to handle this</b>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (InfiniteLoop)</author>
		<pubDate>Tue, 27 Sep 2011 17:48:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Why not use tilemaps. Or a list of bounding boxes or maybe a list of polygons?</p><p>The only game where I can imagine a bitmap to be truly useful for collision detection is a game like worms.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (l j)</author>
		<pubDate>Tue, 27 Sep 2011 18:26:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I figured tilemaps would not be accurate enough. Also, I figured that collision detection against many, large, bounding boxes would be less efficient that comparing a single point. Finally, I figured using bitmaps would allow for rapid map development.</p><p>Am I wrong?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (InfiniteLoop)</author>
		<pubDate>Tue, 27 Sep 2011 18:31:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well you could always put bounding boxes in a grid. So you only have to check for boxes close to the entities.</p><p>Or, although more difficult, you could use a quadtree to put your boxes in.</p><p>Also comparing to a single point is not going to be very accurate, at all.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (l j)</author>
		<pubDate>Tue, 27 Sep 2011 18:52:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/608462/932423#target">InfiniteLoop</a> said:</div><div class="quote"><p>I figured using bitmaps would allow for rapid map development</p></div></div><p>
If you have found the right tools to keep the &quot;map&quot; and the &quot;collision map&quot; synchronized, then it&#39;s a good development method.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Tue, 27 Sep 2011 20:30:22 +0000</pubDate>
	</item>
</rss>
