<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>What is this exactly? (BITMAP related)</title>
		<link>http://www.allegro.cc/forums/view/591385</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 20 May 2007 20:20:08 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I was searching around for posts that discuss movement and collision using Mappy and found this: <a href="http://www.allegro.cc/forums/thread/588658">http://www.allegro.cc/forums/thread/588658</a></p><p>Inside I found some code and this is what I&#39;m trying to understand:</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>grabframe<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>source, <span class="k1">int</span> width, <span class="k1">int</span> height, <span class="k1">int</span> startx, <span class="k1">int</span> starty, <span class="k1">int</span> columns, <span class="k1">int</span> frame<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>temp <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>width,height<span class="k2">)</span><span class="k2">;</span>

    <span class="k1">int</span> x <span class="k3">=</span> startx <span class="k3">+</span> <span class="k2">(</span>frame % columns<span class="k2">)</span> <span class="k3">*</span> width<span class="k2">;</span>
    <span class="k1">int</span> y <span class="k3">=</span> starty <span class="k3">+</span> <span class="k2">(</span>frame <span class="k3">/</span> columns<span class="k2">)</span> <span class="k3">*</span> height<span class="k2">;</span>
    
    <a href="http://www.allegro.cc/manual/masked_blit" target="_blank"><span class="a">masked_blit</span></a><span class="k2">(</span>source,temp,x,y,<span class="n">0</span>,<span class="n">0</span>,width,height<span class="k2">)</span><span class="k2">;</span>

    <span class="k1">return</span> temp<span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

I mean, I KNOW what it&#39;s suppose to do.. But, what the hell? Is it some kind of bitmap function?  I was trying to use this particular piece of code (in C++), but it&#39;s kinda sketchy and I&#39;m getting weird errors like undefined reference to vtable.</p><p>Suppose I should also mention I&#39;m trying to use it in a class.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Mon, 14 May 2007 08:29:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It returns a pointer to a freshly created bitmap using the following arguments:</p><p>&lt;b&gt;BITMAP <b>source</b><br />This is a single BITMAP which acts as a sheet of sprites you want to grab a sprite from.</p><p><b>int width, int height</b><br />The size of each sprite on the sprite sheet. Each sprite on the sheet should be the exact same size and arranged in a grid.</p><p><b>int startx, int starty</b><br />Almost pointless. The top left corner of the grid. Most of the time this will be 0,0.</p><p><b>int columns</b><br />The number of sprites there are in a single row of sprites on the sprite sheet. For instance, if the grid has 80 sprites, arranged in rows of 10, you would use the number 10 here.</p><p><b>int frame</b><br />The sprite number to grab, from left to right then top to bottom. So given a 10x8 grid of sprites, sprite number 23 would be the fourth sprite in the third row. In a 7x15 grid, 23 would be the third sprite in the fourth row.</p><p>Since this routine actually creates the BITMAP object, you must store the result into a BITMAP pointer that hasn&#39;t been initialized, or is NULL.</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Mon, 14 May 2007 10:17:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>An &quot;undefined reference to vtable&quot; error generally means you haven&#39;t defined a function for a baseclass or one of it&#39;s children. The error has to do with your code in the class and not the function you posted, so it&#39;s hard to pinpoint with what we were given. If you are unable to find the error in your code, post the declaration and definition of your baseclass (and childrens&#39;) member functions, as well as the class itself.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elverion)</author>
		<pubDate>Mon, 14 May 2007 10:44:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
undefined reference to vtable
</p></div></div><p>
I can&#39;t imagine how the code you posted could possibly generate that ...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (23yrold3yrold)</author>
		<pubDate>Mon, 14 May 2007 10:44:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">23yrold3yrold said:</div><div class="quote"><p>
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
undefined reference to vtable
</p></div></div><p>I can&#39;t imagine how the code you posted could possibly generate that ...
</p></div></div><p>
</p><div class="quote_container"><div class="title">julian_boolean said:</div><div class="quote"><p>
Suppose I should also mention I&#39;m trying to use it in a class.
</p></div></div><p>

</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Since this routine actually creates the BITMAP object, you must store the result into a BITMAP pointer that hasn&#39;t been initialized, or is NULL.
</p></div></div><p>

It&#39;s worth mentioning that you are also responsible for destroying the object Just making sure you don&#39;t forget to manage your memory properly. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Mon, 14 May 2007 15:28:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">julian_boolean said:</div><div class="quote"><p>
<span class="source-code">    <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>temp <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>width,height<span class="k2">)</span><span class="k2">;</span></span>
</p></div></div><p>
<i>temp</i> isn&#39;t a very good identifier for this variable. It&#39;s temporary in the sense that all local variables are temporary, but in the context of the function it actually stores the BITMAP of the frame you&#39;re grabbing.
</p><div class="quote_container"><div class="title">Kris Asick said:</div><div class="quote"><p>
It returns a pointer to a freshly created bitmap...
</p></div></div><p>
Out of curiosity, is there an advantage to storing your frames as a sheet of sprites as opposed to an array of BITMAPs or self-defined FRAME objects? It seems that memory usage should be slightly less then if each frame had a separate BITMAP object.</p><p>Is the processing time of ripping frames from a sheet of sprites small enough to make it worthwhile getting them from a sheet every time you access them or is it better to store them as separate BITMAPs?</p><p>Or was that function designed to initialize an ANIMATION object with FRAME objects? <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" /></p><p><img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Mon, 14 May 2007 22:49:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ever heard of <span class="source-code"><a href="http://www.allegro.cc/manual/create_sub_bitmap" target="_blank"><span class="a">create_sub_bitmap</span></a></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Tue, 15 May 2007 02:32:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Dustin Dettmer said:</div><div class="quote"><p>
Ever heard of</p><p><span class="source-code"><a href="http://www.allegro.cc/manual/create_sub_bitmap" target="_blank"><span class="a">create_sub_bitmap</span></a></span>
</p></div></div><p>

create_sub_bitmap() sounds somewhat more appropriate for this function (maybe), however, my question still remains. Is it common/good practice to leave your sprites on a sheet-bitmap and rip them over and over again to save memory or is it better to rip them once into memory (when loading the game or level and reuse them)?</p><p><img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" /><img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Tue, 15 May 2007 04:50:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It doesn&#39;t mater much how you load them, but a sprite sheet is generally easier to work with. You should load all sprites at the beginning of the game, and not unload them until game exit, unless you&#39;re making a really big game and targeting older systems.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elverion)</author>
		<pubDate>Tue, 15 May 2007 04:58:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks everyone, I think I&#39;m going to try out create_sub_bitmap.  I guess that&#39;s what this guy was trying to make.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Tue, 15 May 2007 06:34:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>separate images is better.</p><p>the big bitmap is stored as a sequence of bits like so:</p><p>1478f92379e97397a7893478bc8976d987f</p><p>for example.</p><p>&quot;image 1&quot; (a box inside the bigger image) might be stored in</p><p><b>1478</b>f92379e97<b>397a</b>7893478b<b>c897</b>6d987f...</p><p>whilest &quot;image 2&quot; (a different box inside the same bigger image) might be stored in</p><p>1478<b>f923</b>79e97397a<b>7893</b>478bc897<b>6d98</b>7f....</p><p>etc.</p><p>If they are separate then each image is stored completely sequentially.</p><p>This probably has a very mimor performance improvement as the memory prefetch system gets more of what you want (as it has finite capability and is wasting less time).</p><p>That&#39;s about all there is to it. QED etc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (m c)</author>
		<pubDate>Tue, 15 May 2007 14:24:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Of course, you&#39;re using more HD space by keeping them separate. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>But then there&#39;s the argument for taking them in as one big bitmap and splitting them up on initialization.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Tue, 15 May 2007 14:45:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Out of curiosity, is there an advantage to storing your frames as a sheet of sprites as opposed to an array of BITMAPs or self-defined FRAME objects? It seems that memory usage should be slightly less then if each frame had a separate BITMAP object.
</p></div></div><p>
This question has been done to death on the forum. Bottom line is, it doesn&#39;t really matter that much. Sprite sheets are generally a bit easier to work with, especially if you use a sub-standard sprite editor (say, MS Paint), and provide a natural way of bundling related sprites together, while single frames are a tiny bit more efficient speed-wise and will probably produce slightly cleaner code. The differences, especially performance-wise, are really negligible, so you should really just use what you feel more comfortable with and enjoy. No need to ponder.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Wed, 16 May 2007 01:21:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m not so sure if I can really use create_sub_bitmap.  It seems to be missing some parameters that this other function has, namely int columns and int frame.</p><p>My sprite sheet (bmp) looks sorta like this (each number represents the frame):</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// yeah.. please try to picture this as 40x80 sprites. hehe</span>

n  n  n  n  n <span class="c">// north</span>
<span class="n">0</span>  <span class="n">1</span>  <span class="n">2</span>  <span class="n">3</span>  <span class="n">4</span>

e  e  e  e  e <span class="c">// east</span>
<span class="n">5</span>  <span class="n">6</span>  <span class="n">7</span>  <span class="n">8</span>  <span class="n">9</span>

s  s  s  s  s <span class="c">// south</span>
<span class="n">10</span>  <span class="n">11</span>  <span class="n">12</span>  <span class="n">13</span>  <span class="n">14</span>

w  w  w  w  w <span class="c">// west</span>
<span class="n">15</span>  <span class="n">16</span>  <span class="n">17</span>  <span class="n">18</span>  <span class="n">19</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Wed, 16 May 2007 06:25:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You would use it instead of this part:</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>temp <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>width,height<span class="k2">)</span><span class="k2">;</span>

    <span class="k1">int</span> x <span class="k3">=</span> startx <span class="k3">+</span> <span class="k2">(</span>frame % columns<span class="k2">)</span> <span class="k3">*</span> width<span class="k2">;</span>
    <span class="k1">int</span> y <span class="k3">=</span> starty <span class="k3">+</span> <span class="k2">(</span>frame <span class="k3">/</span> columns<span class="k2">)</span> <span class="k3">*</span> height<span class="k2">;</span>
    
    <a href="http://www.allegro.cc/manual/masked_blit" target="_blank"><span class="a">masked_blit</span></a><span class="k2">(</span>source,temp,x,y,<span class="n">0</span>,<span class="n">0</span>,width,height<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Like this:</p><div class="source-code snippet"><div class="inner"><pre>    <span class="k1">int</span> x <span class="k3">=</span> startx <span class="k3">+</span> <span class="k2">(</span>frame % columns<span class="k2">)</span> <span class="k3">*</span> width<span class="k2">;</span>
    <span class="k1">int</span> y <span class="k3">=</span> starty <span class="k3">+</span> <span class="k2">(</span>frame <span class="k3">/</span> columns<span class="k2">)</span> <span class="k3">*</span> height<span class="k2">;</span>
    
    <span class="k1">return</span> <a href="http://www.allegro.cc/manual/create_sub_bitmap" target="_blank"><span class="a">create_sub_bitmap</span></a><span class="k2">(</span>source, x, y, width, height<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

This way you can spare some memory space on those temporary bitmaps.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jakub Wasilewski)</author>
		<pubDate>Wed, 16 May 2007 13:16:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hm.. But, how would that work if those two variables aren&#39;t even being used?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Thu, 17 May 2007 01:10:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Err, they are being used. Specifically, they are being used for calculating the x and y a specific frame starts at. Once you know those, you have all the information about the frame (because the width and height is fixed), so you can create a subbitmap (look them up if you like) that represents the single frame.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jakub Wasilewski)</author>
		<pubDate>Thu, 17 May 2007 01:29:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m trying to avoid using the whole BITMAP *grabframe function thing since I can&#39;t seem to get it to work properly. <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" /></p><p>Edit:</p><p>What does &quot;%&quot; and &quot;/&quot; mean and do anyhow?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Thu, 17 May 2007 02:17:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">julian_boolean said:</div><div class="quote"><p>

What does &quot;%&quot; and &quot;/&quot; mean and do anyhow?
</p></div></div><p>

You really should start at the beginning. Learn coding.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Thu, 17 May 2007 16:54:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Um.  Just because I don&#39;t know what those two mean, means I don&#39;t know how to code?  If you don&#39;t have a helpful reply, please don&#39;t reply at all.</p><p>Edit:</p><p>NM asked someone else about it.  Thanks for your help.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Thu, 17 May 2007 18:38:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Just because I don&#39;t know what those two mean, means I don&#39;t know how to code?
</p></div></div><p>Nor do you know math <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> They are absolutely fundamental operators in coding. If you don&#39;t know what they are, you&#39;ve missed a TON of stuff.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 17 May 2007 18:58:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I may have missed a thing or two along the way. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> I&#39;ve just never used these before, or seen them being used.. Well until now.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Thu, 17 May 2007 19:08:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
What does &quot;%&quot; and &quot;/&quot; mean and do anyhow?
</p></div></div><p>

Sigged! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rampage)</author>
		<pubDate>Thu, 17 May 2007 20:18:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Isn&#39;t there a bridge you should be guarding?  Like I said, there&#39;s the odd thing I didn&#39;t learn when I started c++ (like half a year ago.)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Thu, 17 May 2007 21:01:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Isn&#39;t there a bridge you should be guarding? Like I said, there&#39;s the odd thing I didn&#39;t learn when I started c++ (like half a year ago.)
</p></div></div><p>

No, and yes, everybody misses the basic arithmetic operators when learning C++.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rampage)</author>
		<pubDate>Thu, 17 May 2007 22:04:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The basic what?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Thu, 17 May 2007 22:14:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">I said:</div><div class="quote"><p>
arithmetic operators
</p></div></div><p>

Like +, -, *, / and %.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rampage)</author>
		<pubDate>Thu, 17 May 2007 22:18:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>+ is addition. It adds two numbers together. If I have 3 posts and I add 2 posts to it, how many posts do I have?<br />- is subtraction. It takes stuff away. If I have 2,000 posts and I get too trollish, so ML deletes 3, how many posts do I have?
</p><ul><li><p>is multiplication. If ML deletes 3 posts from 5 users, how many posts has he deleted?
</p></li></ul><p>/ is division. If 430 posts are posted by 10 users, what was the average per user?<br />% is modulus. If I have 2356 posts and I want to have my number of posts be a multiple of 3, what is the closest multiple of 3?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 17 May 2007 22:25:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>God, BAF, you are too good. </p><p>Julian_Boolean: Are you sure you ever learn C or C++ ? Last time I was cool, but I should not have been that sweet. I told you something helpful. I told you to learn, and learning is always helpful. Now excuse me, but not knowing how to do a division while it is really basic programming... I could not have been more cool with you than telling you should go back to learn.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Thu, 17 May 2007 23:14:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>BAF: Thank you very much <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> I already know/heard of the first three.  I know division, I just thought / might mean something else.  % on the other hand, I had no clue what that meant.</p><p>GullRaDriel: orly?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Thu, 17 May 2007 23:42:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Oh, really, yes ?</p><p>I could have told you to RTFM, to stop programming, ... Else I told you to go back learn. So, oh, really, yes.</p><p>Just launch calc in Windows, and see, the division button, it is a &#39;/&#39; . Astonishing , isn&#39;t it ?</p><p>EDITED
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Thu, 17 May 2007 23:48:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi Julian,</p><p>This bit of code is to help you grab individual sprite frames from a sprite sheet. It&#39;s actually in a book called &#39;Game Programming All In One 2nd Edition by Jonathan S. Harbour&#39; which concentrates on developing games using &#39;C&#39; and Allegro.</p><p>An example is of a sprite sheet containing 32 images of a rotating ball, 8 columns wide by 4 rows deep. Each sprite image is 64x64 pixels.</p><p>What you need to do to make it work is to include this code (say in main()) for ease of showing it is as follows:</p><p>BITAMP *temp;</p><p>//load 32-frame tiled sprite image<br />temp=load_bitmap(&quot;sphere.bmp&quot;,NULL);  // this is the sprite sheet<br />for(n=0;n&lt;32;n++)<br /> {<br />  ballimg[n]=grabframe(temp,64,64,0,0,8,n);<br /> }<br />destroy_bitmap(temp);</p><p>Before main() you need to include:</p><p>BITMAP *ballimg[32];<br />int n;</p><p>a quick re-cap of the grabframe function arguments:</p><p>temp = spritesheet (in this case sphere.bmp)<br />64 = pixel width of frame on sprite sheet<br />64 = pixel height of frame on sprite sheet<br />0 = x start position of 1st frame on sprite sheet<br />0 = y start position of 1st frame on sprite sheet<br />8 = columns of frames (in this case 8 cols x 4 rows)<br />n = frame number (get this from for loop statement)</p><p>You can have more then 1 set of sprites in a sheet and thats why you can alter the sizes of the width/height of the frames and where in the sprite sheet x,y to start grabbing them from.</p><p>Hope this helps, but if you need a demo i&#39;ll supply a complete code listing and graphics for you to play with <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul Rowan)</author>
		<pubDate>Thu, 17 May 2007 23:54:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes! Thank you very much!</p><p>What I wanted to know was how could I do that in C++? (Please don&#39;t laugh at me <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />)</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// eh?</span>

<a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> myclass::grabframe<span class="k2">(</span>...<span class="k2">)</span>
<span class="k2">{</span>
  ...
<span class="k2">}</span>
</pre></div></div><p>

Edit:</p><p>Would it make it easier to take rows into consideration and use it as a parameter?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Fri, 18 May 2007 05:51:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry, I am only just learning myself how to use Allegro to create games, and I&#39;m using the book mentioned in my previous post which uses C only, and I&#39;m having to learn that too <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />. I have no experience yet of using C++, so I can&#39;t help you with your problem <img src="http://www.allegro.cc/forums/smileys/cry.gif" alt=":&#39;(" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul Rowan)</author>
		<pubDate>Fri, 18 May 2007 12:11:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Uhm... what&#39;s not C++ about the original? I don&#39;t see many changes you can make to it, unless you put it in a class and make a whole animation system.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Fri, 18 May 2007 19:43:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>NM! I guess I was just doing something wrong, it compiles now.. But crashes.. BUT I get no errors! So I&#39;m on the right track. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Fri, 18 May 2007 20:39:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If it&#39;s compiling OK then ur code is fine. One reason it may be crashing, cos this has happened to me before, is to make sure that the graphics file is being loaded properly into temp - put an error checker on it to see if this loads in correctly first.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul Rowan)</author>
		<pubDate>Fri, 18 May 2007 23:05:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My brother actually has that book, well the third edition.  I found a different function inside of it that seems to work better (it doesn&#39;t crash and even displays the first frame in the sheet!) But I can&#39;t move it around with my arrow keys.</p><p>Here&#39;s the function:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> drawframe<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> source, <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> dest, <span class="k1">int</span> x, <span class="k1">int</span> y, <span class="k1">int</span> width, <span class="k1">int</span> height, <span class="k1">int</span> startx, <span class="k1">int</span> starty, <span class="k1">int</span> columns, <span class="k1">int</span> frame<span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">int</span> framex <span class="k3">=</span> startx <span class="k3">+</span> <span class="k2">(</span>frame % columns<span class="k2">)</span> <span class="k3">*</span> width<span class="k2">;</span>
  <span class="k1">int</span> framey <span class="k3">=</span> starty <span class="k3">+</span> <span class="k2">(</span>frame <span class="k3">/</span> columns<span class="k2">)</span> <span class="k3">*</span> height<span class="k2">;</span>

  <a href="http://www.allegro.cc/manual/masked_blit" target="_blank"><span class="a">masked_blit</span></a><span class="k2">(</span>source, dest, framex, framey, width, height<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

I fooled around with it and it seems like it <b>should</b> work.</p><div class="source-code snippet"><div class="inner"><pre>  drawframe<span class="k2">(</span>image, buffer, x_being, y_being, <span class="n">80</span>, <span class="n">80</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">8</span>, curframe<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

If I replace curframe with just a number, the correct frame will pop up when I compile it, but I still can&#39;t move it..  I think I might know what&#39;s wrong but I&#39;m VERY happy this function works.</p><p>Edit:</p><p>Okay something is really screwed up:</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="k1">void</span> cplayer::logic<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td>  curframe <span class="k3">=</span> <span class="n">10</span><span class="k2">;</span></td></tr><tr><td class="number">4</td><td><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">void</span> cplayer::draw<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> buffer<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>  drawframe<span class="k2">(</span>image, buffer, x_player, y_player, <span class="n">80</span>, <span class="n">80</span>, <span class="n">8</span>, curframe<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">9</td><td><span class="k2">}</span></td></tr><tr><td class="number">10</td><td>&#160;</td></tr><tr><td class="number">11</td><td>...</td></tr><tr><td class="number">12</td><td>&#160;</td></tr><tr><td class="number">13</td><td><span class="c">// elsewhere</span></td></tr><tr><td class="number">14</td><td>&#160;</td></tr><tr><td class="number">15</td><td>  cplayer<span class="k3">*</span> player<span class="k2">;</span></td></tr><tr><td class="number">16</td><td>&#160;</td></tr><tr><td class="number">17</td><td>  player-&gt;logic<span class="k2">;</span> <span class="c">// inside the game loop</span></td></tr></tbody></table></div></div><p>

It&#39;s still showing frame 0 on my sprite sheet for some reason. <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Sat, 19 May 2007 04:54:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hum...</p><p>There is NOTHING magic in programming. If you need it to step one frame, you must tell it to do so.</p><p>The line drawframe(image, buffer, x_being, y_being, 80, 80, 0, 0, 8, curframe); will always draw the same frame until you make some change.</p><p>I see a curframe = 10, I do not see a curframe ++ or something else.</p><p>I think that you should really spend some times understanding how this (simple) function works.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Sun, 20 May 2007 19:52:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I do not see a curframe ++ or something else.
</p></div></div><p>

Your point?  I already found the problem and it a simple mistake (had nothing to do with the function.)  After fixing it setting curframe to 10 works, obviously.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Sun, 20 May 2007 19:59:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
After fixing it setting curframe to 10 works, obviously.
</p></div></div><p>

If you&#39;ve fixed the problem yourself, you should make an addendum to your post, so that others don&#39;t keep trying to solve the problem for you.</p><p>Also, why does your function take x and y parameters if they&#39;re not being used?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Sun, 20 May 2007 20:10:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">julian_boolean said:</div><div class="quote"><p>

It&#39;s still showing frame 0 on my sprite sheet for some reason. <br />...<br />Your point? I already found the problem and it a simple mistake (had nothing to do with the function.) After fixing it setting curframe to 10 works, obviously.
</p></div></div><p>

First: You never wrote that your problem was solved.<br />Second: If you are initializing curframe to 10 without knowing why, you do not understand the function correctly<br />Third: If something need to change for you seeing the sprite moving, that is curframe.</p><p>Ending:<br />I never said there was a problem with the draw_frame function, I say there is one with the way you use it.</p><p>EDIT: beaten a few by LennyLen <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Sun, 20 May 2007 20:10:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>They are being used, just not in the code I showed.</p><p>I set curframe to 10 so I could test to see if the proper frame would show up on the screen, using the x and y coordinates given somewhere else in the program.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Sun, 20 May 2007 20:20:08 +0000</pubDate>
	</item>
</rss>
