<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Tile slicing again</title>
		<link>http://www.allegro.cc/forums/view/600334</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 02 Jun 2009 20:27:30 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, I gave credits to those helping me out in tile slicing.<br />Now I have a little problem yet: what do I do in order to blit the bitmaps I sliced?<br />I mean, how do I split a 4x2 tile bitmap in a 8 element array is a clear task. But how do I blit a tile in the array? Please note, I will have to paste the same image more than once.<br />In Darkbasic Professional I would do something like:</p><p>load image, 1<br />for x = 1 to 4<br />    for y = 1 to 2<br />        get image y*x<br />    next y<br />next x</p><p>for x = 1 to 7<br />    for y = 1 to 23<br />        paste image, myGameGrid[x, y]<br />    next y<br />next x</p><p>The code will probably not run in DarkBasic professional as I done it on the fly.<br />But I gave the idea no?<br />How do I do to do something like this?</p><p>Thanks everybody in advance.</p><p>Bye, Berserk.<br />.<br /><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Thu, 21 May 2009 20:22:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Not quite sure if you want to </p><p>create a bitmap the size you need for mygamegrid.</p><p>something like this perhaps :-</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><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>grid<span class="k2">;</span>
<span class="number">  2</span>
<span class="number">  3</span>
<span class="number">  4</span>
<span class="number">  5</span>grid <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>TILE_LENGTH <span class="k3">*</span> GRID_WIDTH_IN_TILES, TILE_HEIGHT <span class="k3">*</span> GRID_HEIGHT_IN_TILES<span class="k2">)</span><span class="k2">;</span>
<span class="number">  6</span>
<span class="number">  7</span>
<span class="number">  8</span><span class="c">/* then */</span>
<span class="number">  9</span>
<span class="number"> 10</span><span class="k1">for</span><span class="k2">(</span>x <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> x <span class="k3">&lt;</span> <span class="n">7</span><span class="k2">;</span> <span class="k3">+</span><span class="k3">+</span>x<span class="k2">)</span>
<span class="number"> 11</span><span class="k2">{</span>
<span class="number"> 12</span>   <span class="k1">for</span><span class="k2">(</span>y <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> y <span class="k3">&lt;</span> <span class="n">23</span><span class="k2">;</span> <span class="k3">+</span><span class="k3">+</span>y<span class="k2">)</span>
<span class="number"> 13</span>   <span class="k2">{</span>
<span class="number"> 14</span>      <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>image<span class="k2">[</span>y<span class="k2">]</span><span class="k2">[</span>x<span class="k2">]</span>, grid, <span class="n">0</span>, <span class="n">0</span>, x <span class="k3">*</span> TILE_LENGTH, y <span class="k3">*</span> TILE_HEIGHT, TILE_LENGTH, TILE_HEIGHT<span class="k2">)</span><span class="k2">;</span> 
<span class="number"> 15</span>
<span class="number"> 16</span>   <span class="k2">}</span>
<span class="number"> 17</span><span class="k2">}</span>
</div></div><p>

Sorry if that&#39;s a headache <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (William Labbett)</author>
		<pubDate>Thu, 21 May 2009 22:57:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, sorry. My problem is another.<br />I have a bitmap containing the tiles, so I would do</p><p>Rem Project: example<br />Rem Created: 23/05/2009 17.05.59</p><p>Rem ***** Main Source File *****</p><p>set display mode 800, 600, 32<br />set window on<br />hide mouse<br />sync on</p><p>dim grid(7, 23)</p><p>load image &quot;blocks.bmp&quot;, 1<br />paste image 1, 0, 0</p><p>for x = 1 to 4<br />    for y = 1 to 2<br />        get image (x + (y - 1) * 4), 32 * (x - 1), 32 * (y - 1), 32 * x, 32 * y<br />    next y<br />next x</p><p>for x = 1 to 7<br />    for y = 1 to 23<br />        grid(x, y) = rnd(7) + 1<br />    next y<br />next x</p><p>do<br />    cls<br />    for x = 1 to 7<br />        for y = 1 to 23<br />             paste image grid(x, y), x * 32, (y - 1) * 32<br />        next y<br />    next x<br />    sync<br />loop</p><p>Please note DarkBasic Professional uses 1 based arrays indexes, while C++ uses 0 based.<br />The grid contains values going 1 to 8 (0 to 7 in C++).</p><p>Thanks in advance for any help.</p><p>Bye, Berserk.<br />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Sat, 23 May 2009 01:30:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>sorry chap. I&#39;m not sure what that code is doing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (William Labbett)</author>
		<pubDate>Sat, 23 May 2009 22:33:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m assuming you have an array of BITMAPs for your tiles like this: <span class="source-code"><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>tiles<span class="k2">[</span><span class="n">8</span><span class="k2">]</span><span class="k2">;</span></span>?</p><p>If you wanted, for example,  to blit the 4th tile 60 times to a buffer, in a 10x6 grid, starting from the point 100, 100, you would do this:</p><div class="source-code snippet"><div class="inner"><pre>startx <span class="k3">=</span> <span class="n">100</span><span class="k2">;</span>
starty <span class="k3">=</span> <span class="n">100</span><span class="k2">;</span>
width <span class="k3">=</span> tiles<span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k3">-</span><span class="k3">&gt;</span>w<span class="k2">;</span>
height <span class="k3">=</span> tiles<span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k3">-</span><span class="k3">&gt;</span>h<span class="k2">;</span>

<span class="k1">for</span> <span class="k2">(</span>y <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> y <span class="k3">&lt;</span> <span class="n">6</span><span class="k2">;</span> y<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>x <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> x <span class="k3">&lt;</span> <span class="n">10</span><span class="k2">;</span> x<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span> <span class="k2">{</span>

    <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>tiles<span class="k2">[</span><span class="n">3</span><span class="k2">]</span>, buffer, <span class="n">0</span>, <span class="n">0</span>, startx <span class="k3">+</span> x <span class="k3">*</span> width, starty <span class="k3">+</span> y <span class="k3">*</span> height, width, height<span class="k2">)</span><span class="k2">;</span>

  <span class="k2">}</span>

<span class="k2">}</span>
</pre></div></div><p>

You should be able to modify that to do whatever it is you want (I&#39;m not sure what that is, to be honest).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Sun, 24 May 2009 12:23:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The code above takes a bitmap and loads it onto the screen.<br />Then it splits the contents of the screen in tiles wich are loaded in an array.<br />Then it loads random values in my game grid, and finally shows the content of the game grid. The do ... loop statement clears the screen, pastes the images from the grid and flips the screen buffer.<br />How would I do the same with C++ and Allegro?</p><p>Bye, Berserk.<br />.<br />P.S.: Try the posted code with a trial of darkbasic professional and the attached blocks.bmp.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Mon, 25 May 2009 13: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/600334/813387#target">Thc-03_Berserk</a> said:</div><div class="quote"><p>How would I do the same with C++ and Allegro?</p></div></div><p>

The code you were given in your last thread (which takes a bitmap, and splits it into tiles) and the code I just gave you (which takes one of those tiles and blits it onto a grid) does almost all of what you want.  If you can&#39;t figure out how to modify them to suit your needs, then you have absolutely no future as a programmer and should just give up now.</p><p>If you&#39;re just too lazy, and expect everyone to do it fro you, then you&#39;re also out of luck.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>P.S.: Try the posted code with a trial of darkbasic professional and the attached blocks.bmp.</p></div></div><p>

I really doubt that anyone here is going to do that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Mon, 25 May 2009 14:01:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I just don&#39;t know allegro, I also tryed with SDL with a little more luck.<br />I would like someone converting the code as I don&#39;t have a clue of what the posted code does.<br />Plus I have another problem, I have 	while (!key[KEY_ESC] &amp;&amp; !done) { as the main loop but the program wont quit hitting the esc key. why?</p><p>Bye, Berserk.<br />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Mon, 25 May 2009 14:28:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>well, if you press the esc key, is done == true?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BlackShark)</author>
		<pubDate>Tue, 26 May 2009 01:29:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, done is not == true.<br />But if false and true should return false, so the loop should quit.<br />Please help me with the tile slicing code as this is my first allegro project.<br />Thanks.</p><p>Bye, Berserk.<br />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Tue, 26 May 2009 14:02:55 +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/600334/813393#target">Thc-03_Berserk</a> said:</div><div class="quote"><p>
I would like someone converting the code as I don&#39;t have a clue of what the posted code does.
</p></div></div><p>
This is the &lt;strong&gt;allegro&lt;/strong&gt;.cc forum. Allegro is a programming library for &lt;strong&gt;C&lt;/strong&gt;, and although it can be used with a lot of other programming languages, either directly as with C++, or through a wrapper or other glue, as with C# or Pascal, your chances of getting useful help here are practically zero unless you communicate in C or C++.<br />So either learn a bit of C (it&#39;s hard, but not THAT hard), or try a Darkbasic forum.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 26 May 2009 15:38:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Please don&#39;t misunderstand me. I wrote an entyre gameplay in C++ and I know the C++ language.<br />The only thing I don&#39;t know is the Allegro programming library, so I&#39;m in front of a wall trying to develop my first real game (by real I mean a C++ game).<br />I programmed other games before, either in darkbasic professional or in C++ console mode.<br />The game is ready, it just misses the graphics, sound and input management in order to be playable.<br />I explained what the code I wish to do, just post a code wich does it please.</p><p>Thanks in advance.</p><p>Bye, Berserk.<br />.</p><p>P.S.: However, here is a C++ + pseudocode snippet to work on.<br />[code]<br />// Project: example<br />// Created: 23/05/2009 17.05.59</p><p>// ***** Main Source File *****</p><p>set display mode 800, 600, 32 // this is clear, sets the display mode to 800x600 32 bits<br />set window on // this sets windowed mode<br />hide mouse // this hides the mouse cursor<br />sync on // this is dbpro only: sets manual syncing of the screen</p><p>dim grid(7, 23) // this would be equivalent to int grid[7][23];</p><p>load image &quot;blocks.bmp&quot;, 1 // loads an image<br />paste image 1, 0, 0 // paste such image onto the screen. please note the next operations are done on the screen and not on the image</p><p>for (int x = 1; x &lt;= 4; x++) {<br />    for (int y = 1; y &lt;= 2; y++) {<br />        get image (x + (y - 1) * 4), 32 * (x - 1), 32 * (y - 1), 32 * x, 32 * y<br />        // this will get an image from the screen, the parameters are:<br />        // get image (image number), (x left), (y top), (x right), (y bottom)<br />    }<br />}</p><p>for (int x = 1; x &lt;= 7; x++) {<br />    for (int y = 1; y &lt;= 23; y++) {<br />        grid[x][y] = rand() % 7 + 1<br />    }<br />}</p><p>while(!(escape_key)) {<br />    cls // clear the screen<br />    for (int x = 1; x &lt;= 7; x++) {<br />        for (int y = 1; y &lt;= 23; y++) {<br />             paste image grid(x, y), x * 32, (y - 1) * 32<br />             // this will paste the tile on the screen. parameters are<br />             // paste image (image number), (x coordinate), (y coordinate)<br />        }<br />    }<br />    sync // update the screen<br />}<br />[/code]<br />Thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Wed, 27 May 2009 07:17:43 +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/600334/813682#target">Thc-03_Berserk</a> said:</div><div class="quote"><p>The only thing I don&#39;t know is the Allegro programming library, so I&#39;m in front of a wall trying to develop my first real game (by real I mean a C++ game).</p></div></div><p>

There&#39;s an expression that gets used quite a bit that&#39;s quite applicable in this situation, it goes like this: <i>read the <span class="cuss"><span>fuck</span></span>ing manual</i>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Wed, 27 May 2009 11:28:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In addition to reading the friendly manual, you might try altering the example programs in small ways to see what happens.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 27 May 2009 11:31:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There is also the wiki link in the main page of a.cc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Wed, 27 May 2009 20:32:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There should be a reason if I have not read the <span class="cuss"><span>fuck</span></span>ing manual as you sayd.<br />In fact I&#39;m limited to 1 hour PC using a day, that&#39;s why I&#39;m asking here instead of completing he &quot;step by step guide on programming a game with allegro&quot; book, wich I downloaded in my main language (italian) and I still have no time to read.<br />Thanks for your <span class="cuss"><span>fuck</span></span>ing help, <span class="cuss"><span>fuck</span></span>ing community.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Thu, 28 May 2009 05:09:28 +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/600334/813831#target">Thc-03_Berserk</a> said:</div><div class="quote"><p>Thanks for your <span class="cuss"><span>fuck</span></span>ing help, <span class="cuss"><span>fuck</span></span>ing community.</p></div></div><p>

You were given help, but we&#39;re not going to do everything for you.  I&#39;m guessing you&#39;re leaving then?  Good riddance.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Thu, 28 May 2009 14:32:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
  Seems to me that it&#39;s a question of being realistic. If you want to write a game using allegro but you&#39;ve got severely limited time with a PC then you&#39;ve got a problem because you won&#39;t get anywhere if you can&#39;t learn (which means practice) some C programming.</p><p> People don&#39;t want to write your game for you because they know it won&#39;t help you in the long run.</p><p> My advice is spend the time you&#39;ve got learning C and look at the examples and it&#39;ll become clear what you need to do.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (William Labbett)</author>
		<pubDate>Thu, 28 May 2009 18:38:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Why not take a look at some of the Allegro example programs?<br />I&#39;ve attached exsprite, which is an example of all the sprite-drawing functions. It should help you figure out how to load images from datafiles as well.</p><p>Messing around with the examples is often the best way to learn things.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Schyfis)</author>
		<pubDate>Thu, 28 May 2009 18:57:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, I solved on another forum. Thanks for the exsprite but I already have it and I already gave it a look. Unfortunately I wasn&#39;t able to recognize ho to do a sub texture. Now, all I asked was simply create_sub_bitmap( function explanation, but I wasn&#39;t knowing that function. Nevermind, I solved on another forum. And no, I&#39;m not gonna leave.</p><p>Bye, Berserk.<br />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Fri, 29 May 2009 14:05:41 +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/600334/814010#target">Thc-03_Berserk</a> said:</div><div class="quote"><p>
And no, I&#39;m not gonna leave.
</p></div></div><p>
Persistence is a virtue for programmers. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Fri, 29 May 2009 14:08:03 +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/600334/814011#target">Arthur Kalliokoski</a> said:</div><div class="quote"><p>Persistence is a virtue for programmers.</p></div></div><p>

So is the ability to think for yourself.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Fri, 29 May 2009 14:25:32 +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/600334/814010#target">Thc-03_Berserk</a> said:</div><div class="quote"><p>
Now, all I asked was simply create_sub_bitmap( function explanation, but I wasn&#39;t knowing that function
</p></div></div><p>
No, that was not all. You pretty much asked for an entire game to be written for you:
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600334/813682#target">Thc-03_Berserk</a> said:</div><div class="quote"><p>
The game is ready, it just misses the graphics, sound and input management in order to be playable.<br />I explained what the code I wish to do, just post a code wich does it please.
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 29 May 2009 17:10:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>[code]<br />BITMAP *buf, *tiles[7], *blocks; // this is at the beginning of my main function<br />newGrid.redraw(tiles, buf); // this is in my main loop</p><p>void grid::redraw(BITMAP ** tiles, BITMAP * screen) {<br />	for (int x = 0; x &lt; 7; x++) {<br />		for (int y = 0; y &lt; 19; y++) {<br />			blit(tiles[playground[x][y]], screen, 0, 0, (this-&gt;x + x) * 32, (this-&gt;y + y) * 32, tiles[playground[x][y]]-&gt;w, tiles[playground[x][y]]-&gt;h);<br />		}<br />	}<br />}</p><p>this code is where I split my image in tiles<br />	for (int x = 0; x &lt; 4; x++) {<br />		for (int y = 0; y &lt; 2; y++) {<br />			tiles[x + y * 4] = create_sub_bitmap(blocks, x * 32, y * 32, 32, 32);<br />		}<br />	}<br />[/code]<br />I also added a vsync but all I get is a black screen. Why?</p><p>Bye, Berserk.<br />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Sat, 30 May 2009 06:55:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Not enough code</p><p>Where and when do you load what into this variables?
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600334/814081#target">Thc-03_Berserk</a> said:</div><div class="quote"><p>
BITMAP *buf, *tiles[7], *blocks; // this is at the beginning of my main function
</p></div></div><p>

What is buf? A buffer? If so why do you blit directly to the screen and not to the buffer?</p><p>And please note that it is:
</p><pre>
&lt;code&gt;
your code
&lt;/code&gt;
</pre><p>

NOT<br />[code]<br />[/code]
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (count)</author>
		<pubDate>Sat, 30 May 2009 07:07:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><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> 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> <span class="k2">{</span>
<span class="number">  2</span>  <a href="http://www.delorie.com/djgpp/doc/libc/libc_739.html" target="_blank">srand</a><span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a><span class="k2">(</span><span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  3</span>  <span class="k1">int</span> level <span class="k3">=</span> <span class="n">1</span><span class="k2">;</span>
<span class="number">  4</span>  grid newGrid<span class="k2">(</span><span class="n">2</span>, <span class="n">1</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  5</span>  tetraminos <span class="k3">*</span>current, <span class="k3">*</span>next, piece<span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_637.html" target="_blank">rand</a><span class="k2">(</span><span class="k2">)</span> % <span class="n">7</span><span class="k2">)</span>, piece2<span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_637.html" target="_blank">rand</a><span class="k2">(</span><span class="k2">)</span> % <span class="n">7</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  6</span>  current <span class="k3">=</span> <span class="k3">&amp;</span>piece<span class="k2">;</span>
<span class="number">  7</span>  next <span class="k3">=</span> <span class="k3">&amp;</span>piece2<span class="k2">;</span>
<span class="number">  8</span>  <span class="k1">int</span> counter <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number">  9</span>  <span class="k1">bool</span> done <span class="k3">=</span> <span class="k1">false</span><span class="k2">;</span>
<span class="number"> 10</span>  <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>buf, <span class="k3">*</span>tiles<span class="k2">[</span><span class="n">7</span><span class="k2">]</span>, <span class="k3">*</span>blocks<span class="k2">;</span>
<span class="number"> 11</span>  <a href="http://www.allegro.cc/manual/allegro_init" target="_blank"><span class="a">allegro_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>  <a href="http://www.allegro.cc/manual/install_keyboard" target="_blank"><span class="a">install_keyboard</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span>  <a href="http://www.allegro.cc/manual/set_gfx_mode" target="_blank"><span class="a">set_gfx_mode</span></a><span class="k2">(</span>GFX_AUTODETECT, <span class="n">800</span>, <span class="n">600</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 14</span>  buf <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><span class="n">800</span>, <span class="n">600</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 15</span>  blocks <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">"blocks.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 16</span>  <span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> x <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> x <span class="k3">&lt;</span> <span class="n">4</span><span class="k2">;</span> x<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 17</span>    <span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> y <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> y <span class="k3">&lt;</span> <span class="n">2</span><span class="k2">;</span> y<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 18</span>      tiles<span class="k2">[</span>x <span class="k3">+</span> y <span class="k3">*</span> <span class="n">4</span><span class="k2">]</span> <span class="k3">=</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>blocks, x <span class="k3">*</span> <span class="n">32</span>, y <span class="k3">*</span> <span class="n">32</span>, <span class="n">32</span>, <span class="n">32</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 19</span>    <span class="k2">}</span>
<span class="number"> 20</span>  <span class="k2">}</span>
<span class="number"> 21</span>  <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="k3">&amp;</span><span class="k3">&amp;</span> <span class="k3">!</span>done<span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 22</span>    newGrid.redraw<span class="k2">(</span>tiles, <a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</span>    <a href="http://www.allegro.cc/manual/vsync" target="_blank"><span class="a">vsync</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 24</span>    counter <span class="k3">+</span><span class="k3">=</span> level <span class="k3">*</span> <span class="n">4</span><span class="k2">;</span>
<span class="number"> 25</span>    <span class="k1">if</span> <span class="k2">(</span>counter <span class="k3">&gt;</span><span class="k3">=</span> <span class="n">100</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 26</span>      current-&gt;y <span class="k3">+</span><span class="k3">=</span> <span class="n">1</span><span class="k2">;</span>
<span class="number"> 27</span>      <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>newGrid.canMove<span class="k2">(</span><span class="k3">*</span>current<span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 28</span>        current-&gt;y <span class="k3">-</span><span class="k3">=</span> <span class="n">1</span><span class="k2">;</span>
<span class="number"> 29</span>        newGrid.placePiece<span class="k2">(</span><span class="k3">*</span>current, <span class="k3">&amp;</span>done<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 30</span>        current <span class="k3">=</span> next<span class="k2">;</span>
<span class="number"> 31</span>        next-&gt;reset<span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_637.html" target="_blank">rand</a><span class="k2">(</span><span class="k2">)</span> % <span class="n">7</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 32</span>      <span class="k2">}</span>
<span class="number"> 33</span>    <span class="k2">}</span>
<span class="number"> 34</span>  <span class="k2">}</span>
<span class="number"> 35</span>  <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>buf<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 36</span>  <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>blocks<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 37</span>  <span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> x <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> x <span class="k3">&lt;</span> <span class="n">8</span><span class="k2">;</span> x<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 38</span>    <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>tiles<span class="k2">[</span>x<span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 39</span>  <span class="k2">}</span>
<span class="number"> 40</span>  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 41</span><span class="k2">}</span>
<span class="number"> 42</span>  <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><span class="k2">;</span>
</div></div><p>
Even writing on screen (wich someone told me is a global variable) I still get a black screen.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Sat, 30 May 2009 20:19:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Check the return values of your function calls, especially those of <span class="source-code"><a href="http://www.allegro.cc/manual/set_gfx_mode" target="_blank"><span class="a">set_gfx_mode</span></a></span> and <span class="source-code"><a href="http://www.allegro.cc/manual/load_bitmap" target="_blank"><span class="a">load_bitmap</span></a></span>. Also note that the documentation 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> clearly states &quot;Remember to free the sub bitmap before freeing the parent bitmap to avoid memory leaks and potential crashes accessing memory which has been freed.&quot;</p><p>You do it exactly the other way &#39;round.</p><p><i>Edit:</i> Oh, and we need more source code. What&#39;s <span class="source-code">grid::redraw</span> doing, for example?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Indeterminatus)</author>
		<pubDate>Sat, 30 May 2009 20:28:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> grid::redraw<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span><span class="k3">*</span> tiles, <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span> screen2<span class="k2">)</span> <span class="k2">{</span>
  <span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> x <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> x <span class="k3">&lt;</span> <span class="n">7</span><span class="k2">;</span> 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><span class="k1">int</span> y <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> y <span class="k3">&lt;</span> <span class="n">19</span><span class="k2">;</span> y<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span> <span class="k2">{</span>
      <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>tiles<span class="k2">[</span>playground<span class="k2">[</span>x<span class="k2">]</span><span class="k2">[</span>y<span class="k2">]</span><span class="k2">]</span>, screen2, <span class="n">0</span>, <span class="n">0</span>, this-&gt;x <span class="k3">+</span> x <span class="k3">*</span> <span class="n">32</span>, this-&gt;y <span class="k3">+</span> y <span class="k3">*</span> <span class="n">32</span>, tiles<span class="k2">[</span>playground<span class="k2">[</span>x<span class="k2">]</span><span class="k2">[</span>y<span class="k2">]</span><span class="k2">]</span><span class="k3">-</span><span class="k3">&gt;</span>w, tiles<span class="k2">[</span>playground<span class="k2">[</span>x<span class="k2">]</span><span class="k2">[</span>y<span class="k2">]</span><span class="k2">]</span><span class="k3">-</span><span class="k3">&gt;</span>h<span class="k2">)</span><span class="k2">;</span>
    <span class="k2">}</span>
  <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>
If you need more, just ask. Thanks in advance for any help.</p><p>Bye, Berserk.<br />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Mon, 01 Jun 2009 13:58:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I certainly won&#39;t solve this issue for you, I can&#39;t find anything obviously wrong with the snippet (apart from a few unclear things, like what values <span class="source-code">this-&gt;x</span> and <span class="source-code">this-&gt;y</span> can take in <span class="source-code">grid::redraw</span>). Here are some pointers to find the error yourself (in no way do I claim that this list is complete or guarantees success):</p><ol><li><p>Verify the graphics mode is set correctly
</p></li><li><p>Verify that &quot;blocks.bmp&quot; is loaded correctly and contains the scenery you want
</p></li><li><p>Verify (for each of the blocks) that it contains the graphics it should
</p></li><li><p>Verify <span class="source-code">grid::redraw</span> uses correct positions (e.g., by placing a <span class="source-code"><a href="http://www.allegro.cc/manual/putpixel" target="_blank"><span class="a">putpixel</span></a></span> or similar at strategic points)
</p></li><li><p>Verify that <span class="source-code">playground</span> contains the correct values (and thus, point to valid block tiles)</p></li></ol><p>You should be able to do most of these tasks simply by outputting something to the screen, and probably wait for user input, thus allowing you to &quot;step through&quot; the program flow.</p><p>What also can help is removing things until it works again (like, modifying the grid in any way). If it then magically appears to be working, you probably could reduce the domain of the error (it may not always be that simple, though).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Indeterminatus)</author>
		<pubDate>Mon, 01 Jun 2009 23:46:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks very much.</p><p>Bye, Berserk.<br />.</p><p>EDIT: Now it works flawlessly. Why? Because I was executing the game from visual studio using the play icn on the toolbar. Executing the game by double-clicking it shows me the game grid. Shame on me.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thc-03_Berserk)</author>
		<pubDate>Tue, 02 Jun 2009 20:27:30 +0000</pubDate>
	</item>
</rss>
