<?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> &#187; Bold Pixel Engine</title>
	<atom:link href="http://blog.vortixgames.com/tag/bold-pixel-engine/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.vortixgames.com</link>
	<description></description>
	<lastBuildDate>Sun, 05 Feb 2012 00:55:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Performance vs Error Checking</title>
		<link>http://blog.vortixgames.com/performance-vs-error-checking</link>
		<comments>http://blog.vortixgames.com/performance-vs-error-checking#comments</comments>
		<pubDate>Sun, 05 Feb 2012 00:55:11 +0000</pubDate>
		<dc:creator>Vlad</dc:creator>
				<category><![CDATA[Dev Journal: Danger Zone]]></category>
		<category><![CDATA[The code of VGS]]></category>
		<category><![CDATA[Bold Pixel Engine]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Danger Zone]]></category>
		<category><![CDATA[FlashGameBlogs]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://blog.vortixgames.com/?p=1104</guid>
		<description><![CDATA[Hi everyone, Vlad here! Seems like on a thing versus some other thing rampage with Application Design vs Game Design shortly followed by this post. I guess that&#8217;s a good thing, it means there are challenges and doubts and that we need to research. This post is also inspired by some books I&#8217;ve been reading lately and [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone, Vlad here!</p>
<p>Seems like on a thing versus some other thing rampage with <a href="http://blog.vortixgames.com/application-design-vs-game-design-round-1">Application Design vs Game Design</a> shortly followed by this post. I guess that&#8217;s a good thing, it means there are challenges and doubts and that we need to research.</p>
<p>This post is also inspired by some books I&#8217;ve been reading lately and that I highly recommend: <a href="http://shop.oreilly.com/product/9780596519544.do">The Productive Programmer</a> that was influenced by <a href="http://pragprog.com/the-pragmatic-programmer">The Pragmatic Programmer</a>.</p>
<h2>Problem #1</h2>
<p>We are writing code and there&#8217;s not such thing as writing code without bugs. Sometimes our oldest, most used code, that code that we trust each of our games with gets into a specific spot where a hidden bug appears and we spend hours and hours figuring out what&#8217;s happening.</p>
<h2>Solution #1 is Problem #2</h2>
<p>There are several solutions to this. Writing code that includes testing is in my opinion the best. The problem with this, game development wise and specifically in scripted languages such as AS3, is that this makes the code much slower. The solution was checking for inconsistencies and not performing operations instead of throwing errors and exceptions.</p>
<p>I ended up creating conditions for use. For instance our blit package uses three different types: the core, the object and the texture. The core keeps the state of the whole system, the object keeps the state of what and where to render and the texture keeps the state of BitmapData. If the object did not have a texture it would simply not render. Sounds pretty cool, right?</p>
<p>To be honest&#8230; wrong&#8230;</p>
<h3>Problem #2.1</h3>
<p>First problem was the times where the position had NaN value instead of a Number. This rarely happened but every time it did it was a huge headache to identify why and then track the source of the bug down. While this seems unrelated, the fact was the it looked like the texture did not exist. So I had to check if the texture was created, if it was passed, if it was there at all and the worst part was that if the texture was there as it should, where the hell was the problem?</p>
<h3>Problem #2.2</h3>
<p>Performance wise checking if there is a texture is absolutely dumb! 99% of the times there is a texture present. More, the object class has a visible variable. If the object does not have a texture why is it visible in the first place?</p>
<p>So while apparently I solved a problem by checking if the texture was present and not performing any blit operation if it wasn&#8217;t, the truth is that both performance wise (not that serious by the way, it&#8217;s just a if statement) and the unwanted problems it induced in the code backfired from time to time.</p>
<p>I spread this type of behavior through the code. While one if statement does not have a large impact in performance, a lot of checking piles up and I had a lot!</p>
<h2>Solution #2</h2>
<p>A short story and a riddle both taken from those books that explain my thoughts on the &#8216;final&#8217; (we&#8217;ll see about that!) solution for these problems.</p>
<p>The first one was when one of the authors was hired as a consultant for a development project where the coders sent broken code to the version control system. What he did was to create a routine where the version control server would compile the code that was pushed. Every time the compilation didn&#8217;t work the server would send an email with the error. With the amount of mail with errors constantly piling up on mailboxes, one of the coders asked if there was a way of not getting that much email. The consultant replied: &#8220;Sure, don&#8217;t push code with errors!&#8221;</p>
<p>The riddle is&#8230; what code takes not time to be executed? The one that is not compiled.</p>
<p>So the solution is to write code that allows zero error tolerance while not compiling it. The way to achieve this is with <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html">conditional compilation</a> which can be used in several way but these are the ones I believe the most useful is to use code blocks, like this:</p><pre class="crayon-plain-tag"><code>private function someFunction():void {
	CONFIG::debug {
		// Development code
	}

	CONFIG::release {
		// Final code
	}

	// Both dev and final code
}</code></pre><p>
Inside the same function, different code is compiled depending on the current configuration. We can have several checks with exceptions and errors being thrown and then have a &#8216;don&#8217;t check at all&#8217; version in the release configuration.</p>
<p>This is a two stage solution really. On one hand every time I do something stupid, I get errors so my code has to be perfectly implemented at least when it comes to our framework. On the other hand the same code that make me code as best as I can is also the code that does not run in the final version.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vortixgames.com/performance-vs-error-checking/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Enhancing by refactoring</title>
		<link>http://blog.vortixgames.com/enhancing-by-refactoring</link>
		<comments>http://blog.vortixgames.com/enhancing-by-refactoring#comments</comments>
		<pubDate>Sat, 28 Jan 2012 02:00:03 +0000</pubDate>
		<dc:creator>Vlad</dc:creator>
				<category><![CDATA[Dev Journal: Danger Zone]]></category>
		<category><![CDATA[The code of VGS]]></category>
		<category><![CDATA[Bold Pixel Engine]]></category>
		<category><![CDATA[Danger Zone]]></category>
		<category><![CDATA[Encapsulation]]></category>
		<category><![CDATA[Inheritance]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://blog.vortixgames.com/?p=1091</guid>
		<description><![CDATA[Two years ago I read a lot about OOP. Every time I picked a new concept in some forum or chat I&#8217;d do my best to understand and apply it. I was eager to improve my coding knowledge and skills but everything we code as a purpose and an audience and if we forget the [...]]]></description>
			<content:encoded><![CDATA[<p>Two years ago I read a lot about OOP. Every time I picked a new concept in some forum or chat I&#8217;d do my best to understand and apply it. I was eager to improve my coding knowledge and skills but everything we code as a purpose and an audience and if we forget the purpose or the audience we are introducing more problems with the knowledge we have than solving problems.</p>
<p>That happened with Bold Pixel. At some point in time Bold Pixel became a monster to please developers instead of a tool to be more productive in my purpose to my audience: create games for players! People play games, not code!</p>
<p>I stopped over-engineering sometime ago and started reading about how to become a better programmer not by writing better code, but by writing the exact code to solve the exact problem. This brought a new problem: what to do with Bold Pixel and how to maintain and evolve it? First thing was to start a new package and only bring in classes that I needed but wire the classes up to be as slim and straight to the point as possible. I do that all the time to build up my code base right now, but that&#8217;s not all. Here&#8217;s the whole process I&#8217;m using right now.</p>
<h2>Start simple</h2>
<p>&nbsp;</p><pre class="crayon-plain-tag"><code>class BlitObject {

	// Position
	public var x:Number = 0;
	public var y:Number = 0;

	// Rendering
	public var visible:Boolean = true;

	public function BlitObject():void {
		// Constructor
	}

	internal function render():void {
		// Render stuff here
	}
}</code></pre><p>The class above can be a stub for a simple blit object. From a OOP perspective it breaks encapsulation completely since x, y and visible variables should be private but seriously, do I really need those to be private or protected and have getters and setters? No I don&#8217;t so no need to over-engineer it. The only thing I want to have contained is the render method that should only be called by the blit engine that lives in the same package.</p>
<p>The blit object only responsibility is to copyPixels or draw on a given world position translating camera position on the fly.</p>
<p>Writing a simple class like this is fast, performs fast, case closed.</p>
<h2>Evaluate new needs</h2>
<p>Now I need a tile map class. This class is also a blit object so following the <a href="http://en.wikipedia.org/wiki/Is-a">&#8220;is a&#8221;</a> versus <a href="http://en.wikipedia.org/wiki/Has-a">&#8220;has a&#8221;</a> rule tile map should inherit blit object. Considering the blit engine has a camera, the tile map won&#8217;t move. This brings two new problem.</p>
<p>1. If the tile map doesn&#8217;t move, why do I have x and y publicly accessible?<br />
2. I want my camera to follow blit objects so blit objects must have x and y variables (or properties). How can I make tile map be recognized as a blit object, have x and y and have none of those altered?</p>
<p>Sounds messy&#8230;</p>
<p>I could write a Blittable interface that would define a render function and getter and setter methods for x and y. The problem is that if there&#8217;s something I want to keep in the package scope is the render function and interfaces define public interfaces.</p>
<p>The solution is to convert blit object in an abstract class and have its original functionality moved to a new graphic class.</p><pre class="crayon-plain-tag"><code>class BlitObject {

	// Rendering
	public var visible:Boolean = true;

	internal function render():void {
		throw new Error(&quot;Abstract function called. Override render()!&quot;);
	}

	public function get x():Number {
		return NaN;
	}

	public function set x(v:Number):void {
		throw new Error(&quot;Abstract function called or property x not available.&quot;);
	}

	public function get y():Number {
		return NaN;
	}

	public function set y(v:Number):void {
		throw new Error(&quot;Abstract function called or property y not available.&quot;);
	}	
}

class Graphic extends BlitObject {

	// Position
	private var _x:Number = 0;
	private var _y:Number = 0;

	override internal function render():void {
		// Render stuff here
	}

	// Position
	override public function get x():Number { return _x }
	override public function set x(v:Number):void { _x = v }
	override public function get y():Number { return _y }
	override public function set y(v:Number):void { _y = v }
}

class TileMap extends BlitObject {

	override internal function render():void {
		// Render the tile map
	}
}</code></pre><p><p>
Problem solved. The class responsibilities are much better defined.</p>
<p>1. A blit object renders and has x and y coordinates. Since it is an abstract class everything we try to do with it directly will result in an error.<br />
2. A graphic is a world movable blit object that renders by copyPixel or draw.<br />
3. A tile map is a world static blit object that renders very large objects by copyPixel or draw  based on a predefined xml specification.</p>
<h2>Conclusion</h2>
<p>What&#8217;s the conclusion here? Well for starters by this time I&#8217;d have a couple of interfaces and probably a helpers. I&#8217;m not saying it is wrong to have interfaces and helpers, actually it is preferable, but it would be coding for the sake of coding instead of coding for the sake of making a game. It took me 10 minutes to do this and while I was at it the BlitObject class also extends a ListObject class that really speed up the iteration, addition and removal of objects from the blit engine.</p>
<p>Still&#8230; I did repeat my self and the code has suffered another refactoring since then. I&#8217;ll leave that for another post but I wonder if you know what&#8217;s repeated&#8230; <img src='http://blog.vortixgames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vortixgames.com/enhancing-by-refactoring/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BADJ Day 19: So much stuff&#8230;</title>
		<link>http://blog.vortixgames.com/badj-day-19-so-much-stuff</link>
		<comments>http://blog.vortixgames.com/badj-day-19-so-much-stuff#comments</comments>
		<pubDate>Mon, 18 Oct 2010 23:29:33 +0000</pubDate>
		<dc:creator>Vlad</dc:creator>
				<category><![CDATA[Dev Journal: Bruce Ali]]></category>
		<category><![CDATA[Bold Pixel Engine]]></category>
		<category><![CDATA[Bruce Ali]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[FlashGameBlogs]]></category>

		<guid isPermaLink="false">http://blog.vortixgames.com/?p=1007</guid>
		<description><![CDATA[Nineteen days have gone&#8230; WOW! After getting full speed ahead for a number of days, I had a stop for a day&#8230; domestic stuff kicked in. A lot of work was finished in those quick days though. With all physics and blit done, I went straight ahead into coding the level. First task was to [...]]]></description>
			<content:encoded><![CDATA[<p>Nineteen days have gone&#8230; WOW! After getting full speed ahead for a number of days, I had a stop for a day&#8230; domestic stuff kicked in. A lot of work was finished in those quick days though.</p>
<p>With all physics and blit done, I went straight ahead into coding the level. First task was to look at what I had done previously and finding out&#8230; it would be easier to just start over, which I did! One very cool thing is that a Finite State Machine class I wrote earlier really proved its worth and is the base for all stuff in the level. I really have to go through how the level code is structured as soon as the dust settles down since right now a lot can change and it will probably make no sense.</p>
<p>One thing I had to change was the Manager class. Remember I mentioned a dependency to a specific class that put all in motion. That is easier to manage now.</p>
<p>But the really cool thing I did today was to quickly test a console class! I used <a href="http://junkbyte.com/wp/?p=43#more-43" target="_blank">Junkbyte&#8217;s Console 2.4</a> and I just love it! With it we will be able to change a lot of aspects in the game without recompiling.</p>
<p>What is happening right now? Visually? Not much, there&#8217;s a circle representing Bruce on screen. Code wise there&#8217;s a lot of stuff going on. For starters all the level classes (controller, factory, scene, blit, physics, etc) are created and doing their thing, so it&#8217;s just a matter of adding features to it. The state management system is just beautiful and it will save tons of work!</p>
<p>What is missing? Graphics and stuff getting kicked!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vortixgames.com/badj-day-19-so-much-stuff/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BADJ Day 12: Quick Update</title>
		<link>http://blog.vortixgames.com/badj-day-12-quick-update</link>
		<comments>http://blog.vortixgames.com/badj-day-12-quick-update#comments</comments>
		<pubDate>Thu, 07 Oct 2010 22:09:41 +0000</pubDate>
		<dc:creator>Vlad</dc:creator>
				<category><![CDATA[Dev Journal: Bruce Ali]]></category>
		<category><![CDATA[Bold Pixel Engine]]></category>
		<category><![CDATA[Bruce Ali]]></category>
		<category><![CDATA[FlashGameBlogs]]></category>

		<guid isPermaLink="false">http://blog.vortixgames.com/?p=969</guid>
		<description><![CDATA[Today was FANTASTIC! A super productive rainy Thursday brought the rewrite of the blit core. Marco complained he can&#8217;t see anything&#8230; well&#8230; debug and tracing is all I can offer right now since textures and blit entities are not working yet, but at this pace a lot of goodies will appear soon. To celebrate the [...]]]></description>
			<content:encoded><![CDATA[<p>Today was FANTASTIC! A super productive rainy Thursday brought the rewrite of the blit core. Marco complained he can&#8217;t see anything&#8230; well&#8230; debug and tracing is all I can offer right now since textures and blit entities are not working yet, but at this pace a lot of goodies will appear soon.</p>
<p>To celebrate the sensation of being (finally) at full speed, I&#8217;ll prepare a sweet thing tomorrow that I hope will be good for new developers and bring a lot of discussion for more experienced ones. Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vortixgames.com/badj-day-12-quick-update/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BADJ Day 11: A successful frustration</title>
		<link>http://blog.vortixgames.com/badj-day-11-a-successful-frustration</link>
		<comments>http://blog.vortixgames.com/badj-day-11-a-successful-frustration#comments</comments>
		<pubDate>Wed, 06 Oct 2010 23:56:01 +0000</pubDate>
		<dc:creator>Vlad</dc:creator>
				<category><![CDATA[Dev Journal: Bruce Ali]]></category>
		<category><![CDATA[Bold Pixel Engine]]></category>
		<category><![CDATA[Bruce Ali]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[FlashGameBlogs]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://blog.vortixgames.com/?p=967</guid>
		<description><![CDATA[So I coded and recoded, tested and retested a Object Pool class with a high degree of success and frustration. I wrote and tested three different pool managers, here&#8217;s the story&#8230; Objective: Centralized management of pools This one was easy. There is a PoolManager that has a static method to get a pool for a [...]]]></description>
			<content:encoded><![CDATA[<p>So I coded and recoded, tested and retested a Object Pool class with a high degree of success and frustration. I wrote and tested three different pool managers, here&#8217;s the story&#8230;</p>
<h3>Objective: Centralized management of pools</h3>
<p>This one was easy. There is a PoolManager that has a static method to get a pool for a certain class. If the pool for that class does not exist, it is created, if it does, it is returned. Objective achieved.</p>
<h3>Objective: Lightweight pools</h3>
<p>I don&#8217;t need pools to be amazingly complex, I just need the pools to get the job done, which is: be faster at getting new objects at the expense of memory. That didn&#8217;t go very well. The pools were lightweight alright, but I was not able to make it any faster than creating a objective directly.</p>
<p>This lead to the three versions of the pool manager and still the best performance gain is below 5% for any Bold Pixel entity. I was so frustrated, but then I saw the light!</p>
<h3>Not my fault really</h3>
<p>After testing and more testing I had a epiphany! What if Bold Pixel&#8217;s entities are simply too light to make pooling worth. It would not be something I&#8217;d consider. It really never crossed my mind that a instancing a object could be faster than getting it from a linked list kind of pool, but it is and the classes I was dealing with are somewhat heavy considering the inheritance and and composition of several.</p>
<p>The highest gain I got was 8ms in 1000 object. Creating 1000 objects took 54ms and getting 1000 objects from the object pool took 46ms.</p>
<h3>The unexpected success</h3>
<p>So either my classes are very light or flash behaves rather poorly in managing this. So I tested against some movie clip I had around. Creating 1000 movie clips took 102ms, almost doubling the worst case scenario.</p>
<p>Not only I was happy to note that my classes are lightweight, both pool manager and entity type classes, but I also proved that getting movie clips would make a difference.</p>
<h3>Conclusion</h3>
<p>I&#8217;m not happy with the pool manager for now, but I&#8217;ll work on it some other day. It gets the job done, but the objects I really wanted to make a better use of pooling are the ones that problably will have less impact.</p>
<p>If I regret anything in this bits of code is that I over engineered it at first. Tomorrow blit engine!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vortixgames.com/badj-day-11-a-successful-frustration/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>BADJ Day 3 (and 4!): Physics continued</title>
		<link>http://blog.vortixgames.com/badj-day-3-and-4-physics-continued</link>
		<comments>http://blog.vortixgames.com/badj-day-3-and-4-physics-continued#comments</comments>
		<pubDate>Fri, 24 Sep 2010 00:08:42 +0000</pubDate>
		<dc:creator>Vlad</dc:creator>
				<category><![CDATA[Dev Journal: Bruce Ali]]></category>
		<category><![CDATA[Bold Pixel Engine]]></category>
		<category><![CDATA[Bruce Ali]]></category>
		<category><![CDATA[FlashGameBlogs]]></category>
		<category><![CDATA[Hajime]]></category>
		<category><![CDATA[Nape]]></category>
		<category><![CDATA[Physics]]></category>

		<guid isPermaLink="false">http://blog.vortixgames.com/?p=942</guid>
		<description><![CDATA[Howdie! Nape wrapper is almost wrapped&#8230; pun intended, but first, apologies for the missed day 3. While Marco was working on the Hajime trailer I was surfing the waves of wrapping a physics engine. Before moving forward, a big thank you to deltaluca for helping out! Although not necessarily final, the current wrapper consists of: [...]]]></description>
			<content:encoded><![CDATA[<p>Howdie!</p>
<p>Nape wrapper is almost wrapped&#8230; pun intended, but first, apologies for the missed day 3. While Marco was working on the Hajime trailer I was surfing the waves of wrapping a physics engine. Before moving forward, a big thank you to deltaluca for helping out!</p>
<p>Although not necessarily final, the current wrapper consists of:</p>
<h3>Core</h3>
<p>This class basically controls the behavior of Nape&#8217;s space. Due to its nature, Nape wants simple things to be done quite often, for instance, if you want to change gravity, you need to wake all objects. Core does these small things for you.</p>
<h3>Entities</h3>
<p>Physics entities basically wrap Nape&#8217;s bodies. The abstract entity (if you don&#8217;t recall how we are using abstract classes in Bold Pixel, <a href="http://blog.vortixgames.com/bold-pixels-namespaces-and-interfaces" target="_blank">check this out</a>) will offer most if not all of the functionality. Although this means that the class is not really abstract, it also means that classes that inherit from this can and should be used as presets. Currently we have a simple box, simple circle, core walls and a explosion.</p>
<p>As time goes by more and more presets will be built, that&#8217;s the whole beauty of it!</p>
<h3>Debug View</h3>
<p>This class allows for fine lines to appear on screen so we can degub objects positions and so on. Quite useful for blit, not that useful for display objects since it uses Nape&#8217;s assignGraphic method. The debug view observes if there is a display object assigned before drawing the debug sprites. This means that if a object is already skinned, it won&#8217;t have a debug sprite.</p>
<h3>A simple test</h3>
<p>The SWF below uses the wrapper exclusively. The walls are a non-skinned PhysicsCoreWalls object. The light wood boxes are also non-skinned so we can see the debug sprite, but the bitmap is handled manualy. The objective of this is to show how blit objects will look if debug sprite is present. The dark wood boxes and the rock circles are a normal body with a assigned graphic, so, no debug sprite is created.</p>
<p>Plans for tomorrow: have a bang with Nape&#8230; almost literally! Until then, click the SWF underneath to watch a simple simulation.</p>
<p style="text-align: center;">
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="480" height="480" align="center">
      <param name="movie" value="http://blog.vortixgames.com/wp-content/uploads/2010/09/TestPhysics1.swf" />
      <param name="align" value="center" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://blog.vortixgames.com/wp-content/uploads/2010/09/TestPhysics1.swf" width="480" height="480" align="center">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
</p>
<h2>Click the SWF above to see the test&#8230;</h2>
]]></content:encoded>
			<wfw:commentRss>http://blog.vortixgames.com/badj-day-3-and-4-physics-continued/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BADJ Day 2: The Nape Wrapper</title>
		<link>http://blog.vortixgames.com/badj-day-2-the-nape-wrapper</link>
		<comments>http://blog.vortixgames.com/badj-day-2-the-nape-wrapper#comments</comments>
		<pubDate>Tue, 21 Sep 2010 22:12:43 +0000</pubDate>
		<dc:creator>Vlad</dc:creator>
				<category><![CDATA[Dev Journal: Bruce Ali]]></category>
		<category><![CDATA[Bold Pixel Engine]]></category>
		<category><![CDATA[Bruce Ali]]></category>
		<category><![CDATA[Developers]]></category>
		<category><![CDATA[Physics]]></category>

		<guid isPermaLink="false">http://blog.vortixgames.com/?p=929</guid>
		<description><![CDATA[Hello again. Like the previous days, I can&#8217;t really say we are already on full speed with Bruce Ali, mostly because there has been some loose stuff on other projects we had to deal with. After lunch I was able to pick on something that was on my task list for sometime: the physics! We [...]]]></description>
			<content:encoded><![CDATA[<p>Hello again.<br />
Like the previous days, I can&#8217;t really say we are already on full speed with Bruce Ali, mostly because there has been some loose stuff on other projects we had to deal with. After lunch I was able to pick on something that was on my task list for sometime: the physics!</p>
<p style="text-align: center;"><a href="http://deltaluca.me.uk/doc/"><img class="aligncenter" src="http://deltaluca.me.uk/doc/logo.jpg" alt="" width="326" height="230" /></a></p>
<p>We will be using Nape for physics. Nape is a physics engine developed by Luca Deltodesco (aka deltaluca on FGL and <a href="http://deltaluca.me.uk/forum/index.php" target="_blank">Nape&#8217;s forums</a>) that focuses on performance. For more about Nape, visit also the <a href="http://code.google.com/p/nape/" target="_blank">Project Page on Google Code</a> and the <a href="http://deltaluca.me.uk/doc/index.html" target="_blank">Documentation</a>.</p>
<p>We&#8217;ve been authorized by Luca to make Nape a part of Bold Pixel. In order to do this work, Bold Pixel releases (starting at v2) will include the AS3 SWC and our own wrapper. The wrapper is being designed to provide presets, easy management and a debug view that can be integrated with both other pieces of Bold Pixel (namely and most evident good use is the blit engine) or a typical Flash/AS3 project. Obviously it will have a lot of conventions and to make full use of Nape you&#8217;ll need to know how to use it, but the worst case scenario is that any coder will much less code to write and maintain.</p>
<p>We wish the best of luck to Luca and wish we can pull a lot from Nape and Bold Pixel. As soon as we have a tech demo of what we are doing with it, I&#8217;ll post it.</p>
<p>See you all tomorrow!</p>
<p>Vlad out!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vortixgames.com/badj-day-2-the-nape-wrapper/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bold Pixel&#8217;s Namespaces and Interfaces</title>
		<link>http://blog.vortixgames.com/bold-pixels-namespaces-and-interfaces</link>
		<comments>http://blog.vortixgames.com/bold-pixels-namespaces-and-interfaces#comments</comments>
		<pubDate>Wed, 01 Sep 2010 00:46:23 +0000</pubDate>
		<dc:creator>Vlad</dc:creator>
				<category><![CDATA[The code of VGS]]></category>
		<category><![CDATA[Bold Pixel Engine]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[FlashGameBlogs]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://blog.vortixgames.com/?p=911</guid>
		<description><![CDATA[After much thought and discussion by myself or at the FGL chat I made some decisions about how to make Bold Pixel more modular in order to simplify my own work. Since we are still on top of contracts, I couldn&#8217;t give enough attention to this but my brain was dealing with it in the [...]]]></description>
			<content:encoded><![CDATA[<p>After much thought and discussion by myself or at the FGL chat I made some decisions about how to make Bold Pixel more modular in order to simplify my own work. Since we are still on top of contracts, I couldn&#8217;t give enough attention to this but my brain was dealing with it in the background.</p>
<h3>Inheritance Spaghetti</h3>
<p>The problem presented was somewhat simple. My early coding of the blit engine got tangled in the dreadful inheritance headaches. My solution to it was to create one class per major responsibility. It worked fine until the time I decided to expand one of the classes to do something it wasn&#8217;t designed to do. So on one hand I solved the inheritance problems but on the other I lost modularity. At this time I had a OOP doubt that I expressed in the FGL forums and the discussion that started there really helped me to move in a different direction, one that I had never considered.</p>
<p>More over I said that I would not support requests that didn&#8217;t deal with deal with real problems we had in our own development. And while I stick to that, I couldn&#8217;t help but to think: what if Bold Pixel could help someone but it missed one little tiny feature? While this was puzzling me, there was real problem, one with impact in our development that was taunting me&#8230;</p>
<h3>The case of Blit vs Physics</h3>
<p>So Bold Pixel has a blit engine and it will wrap a physics engine (more about the physics engine this later this month) so the question that was on top of the table was: considering there is a blit entity and a physics entity, which one should access the other? Whatever the answer was, modularity was lost in the sense I imagine it. I don&#8217;t want blit to know physics and I don&#8217;t want physics to know blit!</p>
<p>After a nice chat with Antriel at FGL (thanks mate!) I got to know the <a href="http://en.wikipedia.org/wiki/Strategy_pattern" target="_blank">Strategy Pattern</a> and all my problems were solved. In simple terms, I will be defining interfaces for all interchangeable objects but the implementations of the interfaces can exist anywhere. In the case presented, a blit entity will have its spatial properties (rotation, x, y and scale) defined by a spatial interface. By default it will be a simple class and it&#8217;s needed since the properties of the spatial interface are needed to render bitmapdata. A physics entity will be a implementation of  the spatial interface, so if I want to use physics on a blit entity, I simply write: myBlitEntity.position = myPhysicsEntity;</p>
<h3>Visibility and Access Issues</h3>
<p>This brought another problem. Bold Pixel has always kept its inner &#8220;stuff&#8221; hidden. The objective was this was to keep the auto-completion short and the use easy preventing mistakes. In order to implement interfaces I would have to make a lot of code public.</p>
<p>The answer to this would be <a href="http://en.wikipedia.org/wiki/Abstract_class" target="_blank">abstract classes</a>, but ActionScript3 does not support it. That will be addressed with simple naming and convention over configuration. Any class in any namespace in Bold Pixel that starts with Abstract will only have the simplest shortest implementation needed for something to work. For instance, if I want a blit entity that draws pixels I will have to extend a AbstractBlitEntity class (I guess that will be the name) but that brings another problem&#8230;</p>
<p>So ActionScript does not support abstract classes&#8230; convention will say that Abstract defines an abstract class.</p>
<h3>Namespaces (to wrap this up!)</h3>
<p>To have a better code organization I will need more packages and to have more packages I will need to provide access to classes in different packages. This will be done with namespaces. The only thing that annoys me is that Flash Develop in the current version (3.2.2) does not support code-completion with custom namespaces, but what matters is that using custom namespaces solves two problems. First I can have a bunch of private functionality like I like, but second, any coder can with a simple namespace use extend Bold Pixel to his own needs in a full modular way.</p>
<p>While I reckon that this is all just in my head and that a lot of work will have to be done and even considering that probably this will make Bold Pixel a little bit more complicated to the average coder, I feel it sorts a lot of questions, so: Namespaces and Interfaces FTW!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vortixgames.com/bold-pixels-namespaces-and-interfaces/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bold Pixel Engine v1 Post Mortem</title>
		<link>http://blog.vortixgames.com/bold-pixel-engine-v1-post-mortem</link>
		<comments>http://blog.vortixgames.com/bold-pixel-engine-v1-post-mortem#comments</comments>
		<pubDate>Thu, 12 Aug 2010 10:53:24 +0000</pubDate>
		<dc:creator>Vlad</dc:creator>
				<category><![CDATA[Postmortems]]></category>
		<category><![CDATA[Bold Pixel Engine]]></category>
		<category><![CDATA[Developers]]></category>
		<category><![CDATA[Feedback]]></category>
		<category><![CDATA[FlashGameBlogs]]></category>

		<guid isPermaLink="false">http://blog.vortixgames.com/?p=900</guid>
		<description><![CDATA[I guess it&#8217;s pretty strange to have a post mortem of something that is not a game, but Bold Pixel Engine, in its first version was a fantastic learning experience, but it had a overwhelming amount of failures also. To sort my thoughts I checked the tag of the engine in our blog and read [...]]]></description>
			<content:encoded><![CDATA[<p>I guess it&#8217;s pretty strange to have a post mortem of something that is not a game, but Bold Pixel Engine, in its first version was a fantastic learning experience, but it had a overwhelming amount of failures also. To sort my thoughts I checked <a href="http://blog.vortixgames.com/tag/bold-pixel-engine" target="_blank">the tag of the engine in our blog</a> and read some of the stuff that happened as time passed. This led me to write this post mortem, on one hand to know exactly what is right about it, on the other hand to learn from our own mistakes.</p>
<p>A bit of historical perspective</p>
<p>Bold Pixel Engine started with our first flash game because of a simple music management class. Back then, both me and Diogo were coding and I remember (and I admit I deeply miss) our discussions about code standards and organization. I&#8217;m a bit of a dictator when it comes to have stuff organized, credits to Marco that has used the word &#8220;dictator&#8221; more than once and with a large amount of reason and giggles.</p>
<p>Soon our bunch of classes were our own internal library and I even <a href="http://blog.vortixgames.com/from-refactor-to-library" target="_blank">posted some of my own experience</a> while organizing that library. Some of the most important definitions of Bold Pixel where then starting to emerge.<a href="http://blog.vortixgames.com/bold-pixel-update-its-alive" target="_blank"> July 27th 2009 we announced Bold Pixel Engine was alive</a>.</p>
<p>I was quite excited about it!</p>
<p>The turning page from internal library to public engine was the blit engine. We had so much help from many amazing developers that we would not keep it for ourselves. We wanted to share, we wanted to hear what others had to say and that&#8217;s what we did. After two games under his belt and a lot of opinions, the engine was publicly available and his version 1 life was pretty much that until the version 2 turning point a couple of months ago&#8230; but I&#8217;ll get to that eventually.</p>
<h3>What went right! <img src='http://blog.vortixgames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </h3>
<p>The learning process was amazing code wise. After Diogo left I really had to raise my standards and get to work and the engine allowed that. Coding such a piece of technology made me contradict myself several times and pushed me forward. I&#8217;m absolutely convinced that I am a much better ActionScript programmer now than I was before and I feel I learnt little from the games but a lot from the engine because I forced myself to respect the principles I wanted to see applied to it.</p>
<p>And speaking of principles, these stay true from the first line of code until today and are something that really went right. And these are:</p>
<p><strong>Convention over configuration:</strong> Bold Pixel Engine is written assuming some conventions. For example, if the programmer tells the Scene Manager to create a new scene, the previous one and all dialogs will be removed, which makes a lot of sense but maybe it makes less sense to say that all scenes have their pivot point at 0,0. This means that scenes and dialogs are simply added to the display list and that&#8217;s it, nothing to configure since there is a convention.</p>
<p><strong>Ease of Use:</strong> This goes hand in hand with convention over configuration. If there&#8217;s something that really makes my head hurt is to look at the code needed to make something happen in libraries like <a href="http://flixel.org/" target="_blank">Flixel</a> and <a href="http://www.box2d.org/" target="_blank">Box2D</a>. I appreciate the effort put in these libraries and the flexibility and power provided but I believe that if we have to configure every single tiny detail the code becomes cryptic and extremely difficult to debug. I don&#8217;t mind loosing flexibility because I will create more mechanisms that will help me achieve my goals as time goes by.</p>
<p><strong>Modularity:</strong> There is only one dependency in Bold Pixel Engine, which is the Manager class. If you want a single loop or to manage scenes and dialogs, you need to start it up. Apart from that Bold Pixel Engine started modular and will stay modular. The reasoning behind this were two questions I made once:</p>
<p>1. What if I don&#8217;t want to use the blit engine?<br />
2. What if I want to add something that will wreck dependencies?</p>
<p>The answer to that was that I wanted it to be flexible, meaning, I can use whatever I want with only one dependency and that&#8217;s it. I don&#8217;t want the engine to behave like an engine. I want it to be a toolkit at my disposal. I even <a href="http://blog.vortixgames.com/downgrading-from-engine-to-toolkit" target="_blank">had a laugh</a> about this.</p>
<h3>What went wrong&#8230; <img src='http://blog.vortixgames.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </h3>
<p>First and worst aspect of thing that went wrong was that I did too much stuff that we didn&#8217;t need that was requested and I didn&#8217;t do it with the same dedication I did the rest. That will never happen again. I&#8217;m convinced I got carried away by the kindness of a lot of devs, but we can&#8217;t have the engine restricted to the needs of others, which was something I said it wouldn&#8217;t happen from start. But what it really makes me feel bad about it was that other devs got involved in the project and this collided with either our work or their work making it a bad solution for everyone.</p>
<p>The second thing that went wrong was that I overcomplicated somethings because I felt it made sense. For instance there is a Scene Manager and a Input Manager and a Manager. All of these managers depend of a Display Object and/or its stage. While it sounds easier to manage code and it looks more tidy and clean, having a gazilion classes doesn&#8217;t make it easier to code with. I found myself looking through the classes to find what I wanted&#8230; that doesn&#8217;t sound like a good thing, right? I mean, I coded it!</p>
<p>And last but not least, I think I really rushed things. The idea behind the public releases of the engine were that we would make two games between each release, which we actually did with v1, but as soon as I had the mechanics ready and all the engine&#8217;s juicy code was on a actual project, I went head over heels with it. It lacked documentation, it lacked cross-testing (so, just because I did two games, I should have tried against the two games again) and most important it lacked a critical look and a some honest and critical analysis.</p>
<h3>Conclusions</h3>
<p>Great experience and I really appreciate all the kind words that I got from developers. I think the really cool thing that most developers got from it was the ease of use, probably the <a href="http://www.youtube.com/VortixGamesStudio" target="_blank">YouTube channel</a> with some nice overview on it. I could&#8217;ve written a post trying to sell the idea that we are overwhelmed with joy and l33tness, but I would be failing to be honest. I truly believe that BPE v1 is a great piece of software, but I was naive in the approach and maybe over-friendly in the &#8220;pleasing my fellow devs&#8221; department.</p>
<p>We have a game going with v2 and I think I sorted my doubts about what is going to happen with the engine. Many things that were wrong with v1 are already gone and there is a lot of stuff that isn&#8217;t even started, like moving the Music class which started all this into the current version.</p>
<p>There&#8217;s a lot to be said about v2, but this is a hell of a long post mortem and I&#8217;ll write about that soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vortixgames.com/bold-pixel-engine-v1-post-mortem/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random thoughts on life and code</title>
		<link>http://blog.vortixgames.com/random-thoughts-on-life-and-code</link>
		<comments>http://blog.vortixgames.com/random-thoughts-on-life-and-code#comments</comments>
		<pubDate>Thu, 29 Jul 2010 13:31:10 +0000</pubDate>
		<dc:creator>Vlad</dc:creator>
				<category><![CDATA[The life of VGS]]></category>
		<category><![CDATA[Bold Pixel Engine]]></category>
		<category><![CDATA[Contracts]]></category>
		<category><![CDATA[Hajime]]></category>
		<category><![CDATA[M:A:D]]></category>

		<guid isPermaLink="false">http://blog.vortixgames.com/?p=871</guid>
		<description><![CDATA[Been a while since I write here. This post will be a bit like therapy. So life is treating us so-so. A couple of contracts are approaching the end and after speaking with Marco we concluded that we won&#8217;t be doing contract work for a good while. We have too many good stuff right now [...]]]></description>
			<content:encoded><![CDATA[<p>Been a while since I write here. This post will be a bit like therapy. <img src='http://blog.vortixgames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So life is treating us so-so. A couple of contracts are approaching the end and after speaking with Marco we concluded that we won&#8217;t be doing contract work for a good while. We have too many good stuff right now to work on that has caught way too much dust.</p>
<p>Looking back over the past few months, a lot of what we did was neglected because of contracts. They were alright in a way, some for the money, some for the knowledge, some for something else. But unlike our own games, there&#8217;s always a part that is missing, regardless of how good the project is. We feel that has to stop and that what moves us forward is our ability to pursue what we want: pride and happyness.</p>
<p>I also feel that both can go hand in hand with stability and stability is what we found in the past months. We need to step up and do our thing. We need to improve what we did for us.</p>
<p>Project wise, that means that we have to put Hajime on FGL, we have to decided what we want for M:A:D and we have to have time for our most promising game. Code wise this means that I have to reflect if we want to keep Bold Pixel public considering that the current version suits our needs more than it suits the initial user friendliness. I strive to keep things simple, to impose convention over configuration as a standard. Right now I&#8217;m not that sure that this will fit developers needs to the point that BPE is helpful.</p>
<p>We&#8217;ll see about that in the next couple of weeks. Thanks for reading and the therapy session. <img src='http://blog.vortixgames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Vlad out!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vortixgames.com/random-thoughts-on-life-and-code/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

