{"id":839,"date":"2010-12-11T14:51:48","date_gmt":"2010-12-11T18:51:48","guid":{"rendered":"http:\/\/www.braindeadprojects.com\/blog\/?p=839"},"modified":"2010-12-12T15:19:35","modified_gmt":"2010-12-12T19:19:35","slug":"video-game-creation-using-blender-gimp-and-allegro","status":"publish","type":"post","link":"http:\/\/www.braindeadprojects.com\/blog\/what\/video-game-creation-using-blender-gimp-and-allegro\/","title":{"rendered":"Video Game Creation using Blender, Gimp, and Allegro"},"content":{"rendered":"<p>I had an enjoyable assignment in a college course on the C language the other day &#8211; using the <a href=\"http:\/\/alleg.sourceforge.net\/\" target=\"_blank\">Allegro libraries<\/a>, write a game of your choosing.<\/p>\n<p style=\"text-align: left;\">The assignment coincided with my recent discovery of <a href=\"http:\/\/www.blender.org\/\" target=\"_blank\">Blender<\/a>, the 3D mesh animation and design tool. Out of boredom on a recent weekend afternoon, I found Blender in a series of random Google searches&#8230; and dedicated the better part of 3 weeks teaching myself the ins and outs. (Surprisingly <em>EVERYONE<\/em> I know already knew about it, I&#8217;m not sure how Blender eluded my radar).<\/p>\n<figure id=\"attachment_868\" aria-describedby=\"caption-attachment-868\" style=\"width: 212px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/424px-Big_buck_bunny_poster_big.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-868\" title=\"424px-Big_buck_bunny_poster_big\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/424px-Big_buck_bunny_poster_big-212x300.jpg\" alt=\"\" width=\"212\" height=\"300\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/424px-Big_buck_bunny_poster_big-212x300.jpg 212w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/424px-Big_buck_bunny_poster_big.jpg 424w\" sizes=\"(max-width: 212px) 100vw, 212px\" \/><\/a><figcaption id=\"caption-attachment-868\" class=\"wp-caption-text\">The entire movie Big Buck Bunny was created in Blender<\/figcaption><\/figure>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">So many people are familar with Blender \u00a0in fact, that there are hundreds of\u00a0<a href=\"http:\/\/www.youtube.com\/watch?v=K-0g8JaqO_w\">YouTube videos<\/a> (and even \u00a0<a href=\"http:\/\/nystic.com\/products.php\" target=\"_blank\">DVDs<\/a>) covering practically anything you&#8217;re looking to do.<\/p>\n<p style=\"text-align: left;\">My first job was to model an alien &#8211; one similar to one of the enemies in a great game from my childhood &#8211; <a href=\"http:\/\/www.commander-keen.com\/marooned-on-mars.php\" target=\"_blank\">Commander Keen<\/a>. <em>(Side note: I first got the game\u00a0from one of the many mail-order shareware companies that were\u00a0popular before the Internet was in practically every home.)<\/em><\/p>\n<p style=\"text-align: left;\">Simple enough, the Alien is basically 3 spheres and 2 cylinders. After 30 or so iterations, I finally had one I liked.<\/p>\n<figure id=\"attachment_846\" aria-describedby=\"caption-attachment-846\" style=\"width: 226px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/alien.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-846\" title=\"alien\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/alien.jpg\" alt=\"\" width=\"226\" height=\"218\" \/><\/a><figcaption id=\"caption-attachment-846\" class=\"wp-caption-text\">My inspiration (from Commander Keen)<\/figcaption><\/figure>\n<figure id=\"attachment_844\" aria-describedby=\"caption-attachment-844\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/blender.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-844\" title=\"Behold the power of Blender\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/blender-300x210.png\" alt=\"\" width=\"300\" height=\"210\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/blender-300x210.png 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/blender.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-844\" class=\"wp-caption-text\">My Tribute to Commander Keen<\/figcaption><\/figure>\n<p style=\"text-align: left;\">Learning to paint took about 2 days of watching video after video trying to figure things out. Part of that time was devoted to me hunting down the cause of\u00a0 a &#8220;bug&#8221;, which I later learned was a default setting in vertex paint.<\/p>\n<figure id=\"attachment_849\" aria-describedby=\"caption-attachment-849\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/vertex-white.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-849\" title=\"vertex-white\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/vertex-white-300x210.png\" alt=\"\" width=\"300\" height=\"210\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/vertex-white-300x210.png 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/vertex-white.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-849\" class=\"wp-caption-text\">This is not a boog.<\/figcaption><\/figure>\n<figure id=\"attachment_850\" aria-describedby=\"caption-attachment-850\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/vertex-not.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-850\" title=\"vertex-not\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/vertex-not-300x210.png\" alt=\"\" width=\"300\" height=\"210\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/vertex-not-300x210.png 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/vertex-not.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-850\" class=\"wp-caption-text\">With the Painting Mask enabled (the &#39;F&#39; key)<\/figcaption><\/figure>\n<p>The freenode #blender channel had plenty of knowledgeable users that convinced me that I wasn&#8217;t dealing with a bug in my install<\/p>\n<p>Probably the best thing about Blender is that even I (having no real graphical talents), was able to create a decent looking object with a small amount of effort. And\u00a0 I could then animate it, using armatures and a <a href=\"http:\/\/www.youtube.com\/watch?v=l9JqKOOG1IY\" target=\"_blank\">tutorial<\/a> by Ira Krakow.<\/p>\n<figure id=\"attachment_887\" aria-describedby=\"caption-attachment-887\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/flower.jpeg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-887\" title=\"flower\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/flower-300x210.jpg\" alt=\"\" width=\"300\" height=\"210\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/flower-300x210.jpg 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/flower-1024x717.jpg 1024w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/flower.jpeg 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-887\" class=\"wp-caption-text\">Citronella is Evil: The Action Editor and Timeline<\/figcaption><\/figure>\n<p>After creating a few other random objects (some of which looked just plain pathetic), I ended up with a small stable of characters &#8211; and thankfully an assignment where they could live.<\/p>\n<p>The Allegro programming library is a well documented, easy to use programming library that handles the tough parts of graphics programming &#8211; getting objects onto the screen. As with everything &#8211; where does one start?<\/p>\n<p>Having two weeks to start and finish a game, I decided another childhood staple would be the perfect game to write &#8211; <a href=\"http:\/\/www.dosgamesonline.com\/index\/game\/248\/Jetpack.html\" target=\"_blank\">Jetpack<\/a>.<\/p>\n<figure id=\"attachment_855\" aria-describedby=\"caption-attachment-855\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/jetpack.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-855\" title=\"jetpack\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/jetpack-300x180.png\" alt=\"\" width=\"300\" height=\"180\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/jetpack-300x180.png 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/jetpack.png 800w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-855\" class=\"wp-caption-text\">Just a fun game.<\/figcaption><\/figure>\n<p>Jetpack had a lot of great things going for it &#8211; fun game, re-playable (especially since it had a built in level editor) , and one of my favorite things &#8211; a jetpack. Jetpack could easily be thought of as <a href=\"http:\/\/en.wikipedia.org\/wiki\/Lode_Runner\" target=\"_blank\">Lode Runner<\/a> with the ability to fly.<\/p>\n<figure id=\"attachment_875\" aria-describedby=\"caption-attachment-875\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/xscavenger.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-875\" title=\"xscavenger\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/xscavenger-300x225.png\" alt=\"\" width=\"300\" height=\"225\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/xscavenger-300x225.png 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/xscavenger.png 640w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-875\" class=\"wp-caption-text\">XScavenger is a fun Linux port of Lode Runner<\/figcaption><\/figure>\n<p>While digging through <a href=\"http:\/\/alleg.sourceforge.net\/latestdocs\/en\/allegro.html\" target=\"_blank\">Allegro&#8217;s online manual<\/a> and chatting with other users on freenode (trying to\u00a0 figure out how I could write this thing), my storyline inspiration played on my <a href=\"http:\/\/last.fm\" target=\"_blank\">Last.FM <\/a>stream &#8211; &#8220;<a href=\"http:\/\/www.youtube.com\/watch?v=DSnj15pY2tA\" target=\"_blank\">Let&#8217;s save Tony Orlando&#8217;s House<\/a>&#8220;, a great song by <a href=\"http:\/\/www.last.fm\/music\/Yo+La+Tengo\" target=\"_blank\">Yo La Tengo<\/a> about<a href=\"http:\/\/en.wikipedia.org\/wiki\/Frankie_Valli\" target=\"_blank\"> Frankie Valli<\/a> setting fire to\u00a0 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Tony_Orlando\" target=\"_blank\">Tony Orlando&#8217;s<\/a> house after a dispute over backup singers. The song is so subtle (it could easily be played in an elevator) that I had probably heard it a dozen times before actually realizing this soft song was all about a pretty amusing instance of arson.<\/p>\n<p>So, I had a storyline, I had a borrowed game idea- and I had little time.\u00a0 My first tasks basically drilled down to these items:<\/p>\n<p><strong><em>How do I make the background of a bitmap image transparent?<\/em><\/strong><\/p>\n<p>Set the transparent portion of the bitmap to #FF00FF (pink), and use masked_blit() or draw_sprite()<\/p>\n<p><strong><em>Hmm, Allegro didn&#8217;t remove all the pink background?<\/em><\/strong><\/p>\n<p>Make sure to disable anti-aliasing, you&#8217;re blending #FF00FF with nearby colors<\/p>\n<p><strong><em>How do I easily generate animations?<\/em><\/strong><\/p>\n<p>Design the models in Blender, use armatures and timelines to create the motion, save them as individual bitmaps (with OSA disabled and with the camera&#8217;s background color set to #FF00FF)<\/p>\n<p><strong><em>What&#8217;s the shortcut to add bitmaps to a datfile? Grabber would take forever!<\/em><\/strong><\/p>\n<p>Use the command line interface to datfiles &#8211; &#8220;dat&#8221;. Trust me on this one, I could archive 300 images in a few seconds, doing it by hand would be masochistic, taking hours.<\/p>\n<p><strong><em>How do I prevent choppiness in animations and movement?<\/em><\/strong><\/p>\n<p>There&#8217;s system bitmaps, video bitmaps, and memory bitmaps. Look into them, and the example code that comes with Allegro (especially <a href=\"http:\/\/alleg.sourceforge.net\/latestdocs\/en\/alleg045.html#exupdate\" target=\"_blank\">exupdate<\/a>) for ideas and examples.<\/p>\n<p><em><strong>How can I fade in\/out?<\/strong><\/em><\/p>\n<p>One method is to place a semi-transparent black rectangle over the screen. Look at set_trans_blender(), drawing_mode(), and rectfill().<\/p>\n<p>With the answers to those questions in tow, I had a decent demo ready in under two weeks; one that supported smooth screen scrolling, had some limited game-physics, and an even more limited level editor.<\/p>\n<p>In the end, I pieced together level backgrounds using <a href=\"http:\/\/www.gimp.org\/\" target=\"_blank\">GIMP<\/a> and a few photos from <a href=\"http:\/\/istockphoto.com\" target=\"_blank\">IStockPhoto.com<\/a>. The game physics could be better, I&#8217;ll attribute their current state to my inexperience and the pending deadline. In the end &#8211; I think the project turned out fairly well.<\/p>\n<figure id=\"attachment_879\" aria-describedby=\"caption-attachment-879\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/gimp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-879\" title=\"gimp\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/gimp-300x225.png\" alt=\"\" width=\"300\" height=\"225\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/gimp-300x225.png 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/gimp-1024x768.png 1024w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/gimp.png 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-879\" class=\"wp-caption-text\">GIMP and the first level background<\/figcaption><\/figure>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/TitleScreen2.bmp\"><\/a><\/p>\n<figure id=\"attachment_883\" aria-describedby=\"caption-attachment-883\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/TitleScreen2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-883\" title=\"TitleScreen2\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/TitleScreen2-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/TitleScreen2-300x225.jpg 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/TitleScreen2.jpg 800w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-883\" class=\"wp-caption-text\">Part of the Title Sequence to the game. Tony Orlando image used without his consent.<\/figcaption><\/figure>\n<p>I took the following screen capture of the game using <a href=\"http:\/\/taksi.sourceforge.net\/\" target=\"_blank\">Taksi<\/a>, an open-source, and free capture program in the same vein as <a href=\"http:\/\/www.fraps.com\/\" target=\"_blank\">Fraps<\/a> (although Fraps is limited to 30 seconds of capture in the trial version). The screen-capture doesn&#8217;t have sound (the game does) and the actual game runs much smoother than the screen-capture..<\/p>\n<p><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"480\" height=\"385\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"allowFullScreen\" value=\"true\" \/><param name=\"allowscriptaccess\" value=\"always\" \/><param name=\"src\" value=\"http:\/\/www.youtube.com\/v\/OtaOqHiwBTY?fs=1&amp;hl=en_US\" \/><param name=\"allowfullscreen\" value=\"true\" \/><embed type=\"application\/x-shockwave-flash\" width=\"480\" height=\"385\" src=\"http:\/\/www.youtube.com\/v\/OtaOqHiwBTY?fs=1&amp;hl=en_US\" allowscriptaccess=\"always\" allowfullscreen=\"true\"><\/embed><\/object><\/p>\n<p>So basically, you&#8217;re a mosquito with no wings (thank you Mr. Orlando) fighting to survive, collecting blood IV&#8217;s and gascans to fuel your jetpack. Now, I&#8217;ve got another project to dedicate free time to &#8211; all made possible with Blender, Allegro, GIMP,\u00a0 and a little programming.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had an enjoyable assignment in a college course on the C language the other day &#8211; using the Allegro libraries, write a game of your choosing. The assignment coincided with my recent discovery of Blender, the 3D mesh animation and design tool. Out of boredom on a recent weekend afternoon, I found Blender in &hellip; <a href=\"http:\/\/www.braindeadprojects.com\/blog\/what\/video-game-creation-using-blender-gimp-and-allegro\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Video Game Creation using Blender, Gimp, and Allegro<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,23,25,24,1],"tags":[],"class_list":["post-839","post","type-post","status-publish","format-standard","hentry","category-allegro","category-blender","category-c","category-gimp","category-what"],"_links":{"self":[{"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/posts\/839"}],"collection":[{"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/comments?post=839"}],"version-history":[{"count":48,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/posts\/839\/revisions"}],"predecessor-version":[{"id":899,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/posts\/839\/revisions\/899"}],"wp:attachment":[{"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/media?parent=839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/categories?post=839"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/tags?post=839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}