<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Change sprite color</title>
		<link>http://www.allegro.cc/forums/view/591254</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 03 May 2007 22:59:08 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi guys! I&#39;m not sure what it is exactly I need. I only know that I want to change the color of my already loaded sprite. If you&#39;re wondering why, here&#39;s the reason...</p><p>I have a bullet sprite. Let&#39;s say, when the player shoots that bullet it&#39;s colored blue(the default color from the bitmap including some shading). But when the enemy shoots that bullet I want it colored red(and the shading to follow). I want this to happen in the draw() method of my sprite. How can I achieve this? Thanks!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (armond)</author>
		<pubDate>Thu, 03 May 2007 19:21:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> change_color<span class="k2">(</span> <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>spr , <span class="k1">int</span> orig_col , <span class="k1">int</span> final_col <span class="k2">)</span>
<span class="k2">{</span>
    <span class="k1">for</span><span class="k2">(</span> it_x <span class="k3">=</span> <span class="n">0</span> <span class="k2">;</span> it_x <span class="k3">&lt;</span> spr <span class="k3">-</span><span class="k3">&gt;</span> w <span class="k2">;</span> it_x <span class="k3">+</span><span class="k3">+</span> <span class="k2">)</span>
    <span class="k2">{</span>
        <span class="k1">for</span><span class="k2">(</span> it_y <span class="k3">=</span> <span class="n">0</span> <span class="k2">;</span> it_y <span class="k3">&lt;</span> spr <span class="k3">-</span><span class="k3">&gt;</span> h <span class="k2">;</span> it_y <span class="k3">+</span><span class="k3">+</span> <span class="k2">)</span>
        <span class="k2">{</span>
            <span class="k1">if</span><span class="k2">(</span> <a href="http://www.allegro.cc/manual/getpixel" target="_blank"><span class="a">getpixel</span></a><span class="k2">(</span> spr , it_x , it_y <span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> orig_col <span class="k2">)</span>
                <a href="http://www.allegro.cc/manual/putpixel" target="_blank"><span class="a">putpixel</span></a><span class="k2">(</span> spr , it_x , it_y , final_col <span class="k2">)</span><span class="k2">;</span>
        <span class="k2">}</span>
    <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>

Just add some sort of percentage thing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Thu, 03 May 2007 19:40:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I should point out that you would be wise to make a copy of the bullet-bitmap and change the color of that (so you don&#39;t use that function once per enemy bullet per frame).</p><p>Another way to do it is to read in each pixel&#39;s color value, convert it to HSV, rotate the H part a certain amount (or simply set it to a specific value), convert it back to RGB and write it to the target bitmap.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Thu, 03 May 2007 20:06:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just prerender it with a decent graphic editor.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Thu, 03 May 2007 22:37:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="source-code"><a href="http://www.allegro.cc/manual/draw_lit_sprite" target="_blank"><span class="a">draw_lit_sprite</span></a><span class="k2">(</span><span class="k2">)</span></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Thu, 03 May 2007 22:53:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
draw_lit_sprite()
</p></div></div><p>
Seconded, this should be all you need for what you want to do.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Thu, 03 May 2007 22:59:08 +0000</pubDate>
	</item>
</rss>
