<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HobbyGameDev &#187; Vol. 09</title>
	<atom:link href="http://www.hobbygamedev.com/category/articles/vol9/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hobbygamedev.com</link>
	<description>Formerly GameDevLessons.com</description>
	<lastBuildDate>Sat, 04 Feb 2012 02:22:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Free E-Book: 10 Years of Indie Dev Takeaways</title>
		<link>http://www.hobbygamedev.com/articles/vol9/free-e-book-10-years-of-indie-dev-takeaways/</link>
		<comments>http://www.hobbygamedev.com/articles/vol9/free-e-book-10-years-of-indie-dev-takeaways/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 09:55:04 +0000</pubDate>
		<dc:creator>Chris DeLeon</dc:creator>
				<category><![CDATA[Special Topic]]></category>
		<category><![CDATA[Vol. 09]]></category>
		<category><![CDATA[Author's Games]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Popular Entry]]></category>
		<category><![CDATA[Student Games]]></category>

		<guid isPermaLink="false">http://gamedevlessons.ryanburrell.com/?p=1083</guid>
		<description><![CDATA[In 2007, on my way out of Carnegie Mellon&#8217;s Game Creation Society, I wrote The Young Videogame Developer&#8217;s Journal as a way to leave behind some of the lessons that I learned from my previous decade of making homebrew videogames. After finishing the first edition, I got feedback from peers, and things slowed down to&#8230;]]></description>
			<content:encoded><![CDATA[<p><img src="http://gamedevlessons.com/lessons/yvgdj.jpg" alt="Image of the free e-book" align="left"/><br />
In 2007, on my way out of Carnegie Mellon&#8217;s <a href="http://www.gamecreation.org/">Game Creation Society</a>, I wrote <a href="http://www.scribd.com/full/24501458?access_key=key-2oig7xig2yy2270ncpnv">The Young Videogame Developer&#8217;s Journal</a> as a way to leave behind some of the lessons that I learned from my previous decade of making homebrew videogames.</p>
<p>After finishing the first edition, I got feedback from peers, and things slowed down to a halt while I was preparing a second revamped and extended edition. A couple of years later &#8211; this past week &#8211; I realized that the old text in its unpublished state wasn&#8217;t helping anyone, and that along the way, I&#8217;ve picked up an ongoing audience of readers that are into hobby videogame development. I decided to go ahead and share the previously unpublished first edition:</p>
<p>It&#8217;s free! Read:<br />
<a href="http://www.scribd.com/full/24501458?access_key=key-2oig7xig2yy2270ncpnv">The Young Videogame Developer&#8217;s Journal</a></p>
<p>Browse, print, share, and link to this e-book however you&#8217;d like.</p>
<p>Interested in playing any of the games mentioned in that e-book, to put the text into context? Most of them are available at the <a href="http://interactionartist.com/archives/index.html">Archives page at InteractionArtist.com</a>.</p>
<p><em>(Originally posted as <a href="http://gamedevlessons.com/lessons/letter9.html#ebook">GameDevLessons.com Vol. 9 Sec. 4</a>)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hobbygamedev.com/articles/vol9/free-e-book-10-years-of-indie-dev-takeaways/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>On the Meaning of Alice in Bomberland</title>
		<link>http://www.hobbygamedev.com/articles/vol9/on-the-meaning-of-alice-in-bomberland/</link>
		<comments>http://www.hobbygamedev.com/articles/vol9/on-the-meaning-of-alice-in-bomberland/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 09:43:37 +0000</pubDate>
		<dc:creator>Chris DeLeon</dc:creator>
				<category><![CDATA[Advanced]]></category>
		<category><![CDATA[Vol. 09]]></category>
		<category><![CDATA[Author's Games]]></category>
		<category><![CDATA[Experimental Gameplay]]></category>
		<category><![CDATA[Game Dissection]]></category>
		<category><![CDATA[Popular Entry]]></category>
		<category><![CDATA[Value of Videogames]]></category>

		<guid isPermaLink="false">http://gamedevlessons.ryanburrell.com/?p=1079</guid>
		<description><![CDATA[Alice in Bomberland is a videogame for iPhone and iPod Touch that I developed along with a team of supporting artists, published by Sonic Boom. I wrote a lengthy essay on the meaning and design of Alice for my admissions essay to Georgia Tech&#8217;s Digital Media program. It&#8217;s available online both as a print-ready PDF&#8230;]]></description>
			<content:encoded><![CDATA[<div>
<img src="http://gamedevlessons.com/lessons/lesson9-aib/ch_alice.jpg">
</div>
<p><br/><br/><br/><br/><br/><br/><br/><br />
<em>Alice in Bomberland</em> is a videogame for iPhone and iPod Touch that I developed along with a team of supporting artists, published by Sonic Boom. I wrote a lengthy essay on the meaning and design of <em>Alice</em> for my admissions essay to Georgia Tech&#8217;s Digital Media program. It&#8217;s available online both as a <a href="http://www.scribd.com/full/24753017?access_key=key-un3d0xeyte9gd6ar4gb" target="_blank">print-ready PDF</a> and <a href="http://gamedevlessons.com/lessons/essay.html" target="_blank">in HTML with extra in-document links</a>.</p>
<div style="padding-left:30px;">
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/HmyqGiOwcAk&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/HmyqGiOwcAk&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
</div>
<p><em>(Originally posted as <a href="http://gamedevlessons.com/lessons/letter9.html#adv">GameDevLessons.com Vol. 9 Sec. 3</a>)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hobbygamedev.com/articles/vol9/on-the-meaning-of-alice-in-bomberland/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Particle Effects Code</title>
		<link>http://www.hobbygamedev.com/articles/vol9/particle-effects-code/</link>
		<comments>http://www.hobbygamedev.com/articles/vol9/particle-effects-code/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 09:29:11 +0000</pubDate>
		<dc:creator>Chris DeLeon</dc:creator>
				<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[Vol. 09]]></category>
		<category><![CDATA[Sample Code]]></category>

		<guid isPermaLink="false">http://gamedevlessons.ryanburrell.com/?p=1069</guid>
		<description><![CDATA[What are Particle Effects? Puffs of dirt kicked up from tires, smoke after explosions, empty shell casings ejecting from automatic rifles, and splashes of water are all particle effects. Shattered pieces of scored gems in a puzzle game, splatters of blood from gunfire, broken glass, chunks of wood, snowflakes, sparks, and shards of plants are&#8230;]]></description>
			<content:encoded><![CDATA[<h3>What are Particle Effects?</h3>
<p>Puffs of dirt kicked up from tires, smoke after explosions, empty shell casings ejecting from automatic rifles, and splashes of water are all particle effects. Shattered pieces of scored gems in a puzzle game, splatters of blood from gunfire, broken glass, chunks of wood, snowflakes, sparks, and shards of plants are all particle effects.</p>
<p>Particle effects are categorically different from most other objects in a videogame. Note the following differences:</p>
<ul>
<li><u>Particles don&#8217;t influence gameplay.</u> They don&#8217;t knock things over, respond to being stepped on by enemies, or inflict damage. A game that has particle effects, generally speaking, would play out exactly the same without the particle effects.<br/><br/></li>
<li><u>The game needs to move and draw many particles at once.</u> Dozens or even hundreds of particles may be constantly present &#8211; perhaps as rocket thrust, boat wake, or damage smoke &#8211; and during intense action the game may need to handle many thousands of particles. This means they must be small in memory and require minimal processing.<br/><br/></li>
<li><u>Particle effects are dynamic.</u> Particles spin, rotate, fade, bounce, drift, fall, and sometimes even produce sounds (when they start, fizzle out, or hit the ground).<br/><br/></li>
<li><u>The number of particles must be limited to protect the game&#8217;s framerate.</u> Drawing and moving thousands of particles every second can pose a serious risk to game performance.<br/><br/></li>
<li><u>Particles spawn with some randomness.</u> Because many particles can be spawned from a single event, introducing slight randomness into the initial location, velocity, and lifetime avoids particles overlapping one another, increasing the odds that each one using processing and rendering time gets seen.<br/><br/></li>
<li><u>Particles only last a few seconds.</u> What makes particles exciting is their movement. Once the particle&#8217;s action is complete it needs to be made available for a future effect.<br/></li>
</ul>
<h3>Benefits of a Fixed-Size Array</h3>
<p>There are dozens of container structures that are more complex, robust, and flexible than fixed-size (i.e. normal, basic, no frills) arrays &#8211; linked lists, vectors, and so on. Why do I recommend using fixed-size arrays for particle effects?</p>
<ul>
<li>Arrays are extremely fast to access.<br/><br/></li>
<li>Arrays avoid overhead from memory allocation or deallocation, and in so doing also avoid cumulative memory fragmentation.<br/><br/></li>
<li>The usual downside to using fixed-size arrays &#8211; that they have a maximum number of elements allowed at once &#8211; is desirable for particle effects! This ensures the number of particle effects are kept within a sane limit.</br></li>
</ul>
<h3>Code, Applied to Asteroids Source</h3>
<p>In main.cpp of the <a href="http://hobbygamedev.com/articles/vol9/programming-asteroids/" title="Programming Asteroids" >sample Asteroids starter source</a>&#8230;</p>
<p><u>After:</u></p>
<pre>#define ROCK_NUM 25</pre>
<p><u>Add:</u></p>
<pre>#define PFX_NUM 1000 // maximum number of particle effects</pre>
<p><u>After:</u></p>
<pre>obj_typ ast[ROCK_NUM];</pre>
<p><u>Add:</u></p>
<pre>struct pfx_typ {
  float xv, yv; // component velocity
  float x, y; // position
  int life; // frames until it vanishes
  int color; // color of this particle
};

int pfx_alive = 0;
pfx_typ pfx[PFX_NUM];</pre>
<p><u>Before:</u></p>
<pre>void drawThings() {</pre>
<p><u>Add:</u></p>
<pre>void pfxJet(int spawnNum, obj_typ *fromObj) {
  int toSpawn;

  if( pfx_alive + spawnNum >= PFX_NUM ) {
    toSpawn = PFX_NUM-1 - pfx_alive;
  } else {
    toSpawn = spawnNum;
  }

  float cosPower = -cos(fromObj->ang) * 0.5;
  float sinPower = -sin(fromObj->ang) * 0.5;

  int colorForThisSet;

  colorForThisSet = 224+(rand()&#038;0x1F); // shade from 224 to 255

  if(rand() &#038; 0x01 == 1) {
    // bold reds
    colorForThisSet = makecol(colorForThisSet, 0, 0);
  } else {
    // bold yellow
    colorForThisSet = makecol(colorForThisSet, colorForThisSet, 0);
  }

  for(int i=0;i<toSpawn;i++) {
    pfx_typ *effect = &#038;(pfx[pfx_alive]);
    effect->x = fromObj->x - 3 + (rand()&#038;0x07);
    effect->y = fromObj->y - 3 + (rand()&#038;0x07);
    effect->xv = fromObj->xv+float(-127+(rand()&#038;0xFF))*0.002+cosPower;
    effect->yv = fromObj->yv+float(-127+(rand()&#038;0xFF))*0.002+sinPower;
    effect->life = 60+(rand()&#038;0x7F);
    effect->color = colorForThisSet;
    pfx_alive++; // raise the particle count to include the newest one
  }
}</pre>
<p><u>Before:</u></p>
<pre>drawLine( &#038;ship , makecol(255, 255, 0) );</pre>
<p><u>Add:</u></p>
<pre>// move and draw particles in the same pass
// remember that we may have a TON of particles,
// so it's good to only iterate over the list
// as few times as possible

for(int i=0;i
<pfx_alive;i++) {
  pfx_typ *effect = &#038;(pfx[i]);

  if( --effect->life > 0) { // move and draw it
    effect->x += effect->xv;
    effect->y += effect->yv;

    circlefill(screenBuffer,
      int(effect->x), int(effect->y),
      int(effect->life>>6), // radius as life/64
      effect->color);
  } else { // remove it from the list
    pfx_alive--; // decrease number of live particles
    if(pfx_alive >= 0) { // providing we had 1+ particle left:
      pfx[i] = pfx[pfx_alive]; // copy last particle onto this one
      i--; // reconsider this particle
    }
  }
}</pre>
<p><u>After:</u></p>
<pre>ship.yv += sin(ship.ang) * thrustPower;</pre>
<p><u>Add:</u></p>
<pre>pfxJet(10,&#038;ship);</pre>
<p>That&#8217;s it! The code includes a number of strange optimizations &#8211; none of which I benchmarked (feel free to inform me if I&#8217;ve been silly to cache the array accesses into pointers, etc.). A few examples of minor optimizations shown here are <a href="http://www.arduino.cc/en/Reference/Bitshift">bit shifting for division</a>, <a href="http://en.wikipedia.org/wiki/Modulo_operation#Performance_issues">bitwise AND as alternative to modulo to limit rand</a>, and end-swapping in an array to avoid gaps without element shifting. Because particles can number in the thousands, particle programming is one of the areas where otherwise outdated or trivial optimizations (that otherwise should be avoided to keep code readable) can make a significant difference.</p>
<h3>Modified Source</h3>
<p>Here&#8217;s an updated example main.cpp file with the above changes made, in case the above insertion hints proved tricky to follow: <a href="http://cdgdl.com/lessons/asteroids_maincpp-with-pfx.zip">Asteroids main.cpp with particles</a>.<br />
(Note that this requires core.cpp and core.h from <a href="http://hobbygamedev.com/articles/vol9/programming-asteroids/" title="Programming Asteroids" >the main starter source</a>.)</p>
<p><em>(Originally posted as <a href="http://gamedevlessons.com/lessons/letter9.html#int">GameDevLessons.com Vol. 9 Sec. 2</a>)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hobbygamedev.com/articles/vol9/particle-effects-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Programming Asteroids</title>
		<link>http://www.hobbygamedev.com/articles/vol9/programming-asteroids/</link>
		<comments>http://www.hobbygamedev.com/articles/vol9/programming-asteroids/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 07:16:21 +0000</pubDate>
		<dc:creator>Chris DeLeon</dc:creator>
				<category><![CDATA[Beginner]]></category>
		<category><![CDATA[Vol. 09]]></category>
		<category><![CDATA[Sample Code]]></category>

		<guid isPermaLink="false">http://gamedevlessons.ryanburrell.com/?p=1059</guid>
		<description><![CDATA[Asteroids Starting Game Source To play, you&#8217;ll first need to compile the source into an executable. This can be done in only 5-10 minutes following the steps below, and is the first step to your exploring the elements of programming. Unzip/copy these files into a new folder before continuing (you can unzip them anywhere; creating&#8230;]]></description>
			<content:encoded><![CDATA[<p><a href="http://cdgdl.com/lessons/asteroids_ex.zip">Asteroids Starting Game Source</a></p>
<p>To play, you&#8217;ll first need to compile the source into an executable. This can be done in only 5-10 minutes following the steps below, and is the first step to your exploring the elements of programming. Unzip/copy these files into a new folder before continuing (you can unzip them anywhere; creating a &#8220;Projects&#8221; folder on your desktop works).</p>
<p>Use Left and Right keyboard arrows to turn the ship.<br />
The Up key applies forward thrust.<br />
Spacebar &#8220;fires&#8221; (drops) a green laser.<br />
Press the Escape key to quit.</p>
<p>Are you only seeing a small white line on an otherwise completely black screen? Perfect! That&#8217;s all there is to the program in its current form. The rest, as you&#8217;ll find outlined in the comments of the code (the core.cpp, main.cpp, and core.h files), is up to you.</p>
<p>Once you have the program compiling &#8211; on whichever operating system you prefer &#8211; for next steps, read through the comments in the project&#8217;s main.cpp file. See if you can figure out how to modify the text to perform some of the remaining tasks. For a conceptual explanation of programming, check out <a href="http://hobbygamedev.com/articles/vol1/what-videogames-are-made-of/" title="What Videogames Are Made Of" >Text Lessons Vol. 1</a>. For a detailed introduction to different programming structures as they relate to videogame programming, check out <a href="http://hobbygamedev.com/articles/vol5/game-programming-fundamentals/" title="Game Programming Fundamentals" >Text Lessons Vol. 5</a>.</p>
<h3>Compiling on PC/Windows</h3>
<p>Download and install <a href="http://prdownloads.sourceforge.net/dev-cpp/devcpp-4.9.9.2_setup.exe">Dev-C++ 5.0 beta 9.2 (4.9.9.2) (9.0 MB) with Mingw/GCC 3.4.2</a>.</p>
<p>After it&#8217;s installed, run Dev-C++, check the &#8220;Tools&#8221; menu for &#8220;Check for Updates/Packages&#8221;, then under &#8220;Select devpak server&#8221; choose &#8220;devpaks.org Community Devpaks&#8221;. Press the &#8220;Check for Updates&#8221; button, then check the boxes to install Allegro (the library for audio, input, and graphical functions) and Allegro Supplement (documentation and sample files) &#8211; if you&#8217;re having a hard time locating those options in the list, click the heading of that names column to alphabetize the listings.</p>
<p>Next, use the File menu to create a New -> Project, type Empty Project, with the &#8220;C++ Project&#8221; radio button filled. Name it &#8220;Asteroids&#8221; and save the &#8220;Asteroids.dev&#8221; project file in the same folder as the downloaded source files.</p>
<p>To add the project&#8217;s files to the project, use the Project menu to find the option for &#8220;Add to Project&#8221;, then select all 3 files that were copied from the downloaded asteroids_ex.zip file (core.cpp, core.h, and main.cpp). Click on any project file in the left hand project view to see the contents of that file &#8211; main.cpp is the most interesting, as it&#8217;s where the game-specific action takes place.</p>
<p>Before we can compile, we need to add the Allegro library to the project&#8217;s setup. Under the &#8220;Project&#8221; menu, open &#8220;Project Options&#8221;, then flip to the &#8220;Parameters&#8221; tab. Under the right-most dialog box, the one headed &#8220;Linker&#8221;, type in &#8220;-lalleg&#8221; (minus the quotes). Press Ok.</p>
<p>Lastly, use the menus to go to Execute, then &#8220;Compile &#038; Run&#8221;. The game (at this point only a white line on a black screen) should open, which you can interact with by using the arrow keys and spacebar. Press escape to quit.</p>
<p>Any time you make changes to the program source, you can update the game itself by repeating that last step to &#8220;Compile &#038; Run&#8221;. Each time the game is compiled, the &#8220;Asteroids.exe&#8221; file in the same folder as the source files will be updated. That file is the program which you can share with others.</p>
<h3>Compiling on a Mac or Linux</h3>
<p>If on a Mac, download <a href="http://developer.apple.com/technology/Xcode.html">Xcode for Mac-only Development</a> from Apple&#8217;s website to get all developer&#8217;s tools installed &#8211; if you&#8217;re on Linux, the OS shell probably already is set up for all of the commands that we&#8217;ll need. Also download the <a href="http://www.allegro.cc/files/4.2.2/allegro-4.2.2.tar.gz">Allegro source for Linux</a> (I found that <a href="http://www.allegro.cc/files/">here</a>). Double click that downloaded allegro tar.gz to turn it into a folder, then use the Terminal to &#8216;cd&#8217; command your way into that new allegro-4.2.2 folder (need to learn the <a href="http://gamedevlessons.com/lessons/commandline.html">Basic Terminal Commands?</a>), then type the following lines into the terminal to install Allegro:</p>
<pre>chmod +x fix.sh
./fix.sh macosx
make
sudo make install
sudo make install-man
sudo make install-applehelp
sudo make install-framework
make
sudo make install</pre>
<p>Followed by using the Terminal to navigate into the folder containing the Asteroids game sample source. Then type in this command:</p>
<pre>g++ main.cpp core.cpp -o asteroids-mac `allegro-config --libs`</pre>
<p>NOTE that the ` is a BACKTICK on the same key as tilde (~), NOT a single quote/apostrophe from the same key as the parenthesis (&#8220;).</p>
<p>To edit the code, open main.cpp using any plain text editor (TextEdit, TextWrangler, DashCode&#8230;). To recompile the program to reflect changes made to main.cpp, repeat the step above for typing &#8220;g++ main.cpp&#8230;[and the rest]&#8221; in the Terminal.</p>
<p><em>(Originally posted as <a href="http://gamedevlessons.com/lessons/letter9.html#exgame">GameDevLessons.com Vol. 9 Sec. 1</a>)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hobbygamedev.com/articles/vol9/programming-asteroids/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

