<?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>Brainfold &#187; entity system</title>
	<atom:link href="http://www.brainfold.org/blog/tag/entity-system/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brainfold.org/blog</link>
	<description>On Python, game development and everything</description>
	<lastBuildDate>Sat, 15 May 2010 21:58:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Triggering (explosive) payloads</title>
		<link>http://www.brainfold.org/blog/2009/02/09/triggering-explosive-payloads/</link>
		<comments>http://www.brainfold.org/blog/2009/02/09/triggering-explosive-payloads/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 07:26:45 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Artillery Brawl]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[lepton]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[triggers]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=145</guid>
		<description><![CDATA[As part of my effort to integrate Lepton for particle effects, I have been implementing a system of triggers and payloads to make projectiles more interesting in general. The system is heavily inspired by the similar payload system for my old artillery game, Arty, which I wrote about earlier, but of course redesigned and modernized [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my effort to integrate <a href="http://code.google.com/p/py-lepton/">Lepton</a> for particle effects, I have been implementing a system of triggers and payloads to make projectiles more interesting in general. The system is heavily inspired by the similar payload system for my old artillery game, Arty, which I <a href="http://www.brainfold.org/blog/2007/11/28/memoirs-of-a-game-developer/">wrote about earlier</a>, but of course redesigned and modernized to make it more generic and cleaner. I haven't settled on an interface yet, and looks like I'll have to make yet more changes to the entity system, but every change is a step closer to perfection, right? Anyway, about triggers and payloads...</p>
<p>Any number of triggers and payloads can be attached to entities. For now, they will only be used for projectiles (artillery shells), but later they could be used for many other gameplay applications. Triggers can react to collisions, height from ground, proximity to units, or they could activate after a delay. Almost anything is possible, really, but I'm starting with just collision triggers. Payloads are triggered, well, by triggers; they are the "meat" of the projectile system. Again, I'm starting simple with just kinetic (contact damage based on mass, velocity and an armor piercing multiplier) and explosive (yay, particle effects and shrapnel projectiles) payload, but almost anything would be possible. For example, it would be easy to make a cluster bomb that explodes above ground (height trigger attached to directed explosive payload) into many small bomblets (individual projectiles with contact triggers attached to explosive payloads).</p>
<p>More on the triggers and payloads when I get the system implemented.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2009/02/09/triggering-explosive-payloads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Last of 2008</title>
		<link>http://www.brainfold.org/blog/2008/12/30/last-of-2008/</link>
		<comments>http://www.brainfold.org/blog/2008/12/30/last-of-2008/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 21:55:52 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Artillery Brawl]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[lepton]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=118</guid>
		<description><![CDATA[I just wrote my last lines of Python for this year. I haven't got to particle explosions (I'm going to try lepton for those) or other interesting bits yet, and the code doesn't actually even run at the moment... as usual, one thing led to another while working on small fixes, and I'm just about [...]]]></description>
			<content:encoded><![CDATA[<p>I just wrote my last lines of Python for this year. I haven't got to particle explosions (I'm going to try <a href="http://code.google.com/p/py-lepton/">lepton</a> for those) or other interesting bits yet, and the code doesn't actually even run at the moment... as usual, one thing led to another while working on small fixes, and I'm just about to finish a huge reorganization and cleanup of the entity system. The good thing is, even if I decide to ditch Artillery Brawl, this code will be useful for other projects, as it's starting to come together really nicely.</p>
<p>One of the biggest changes has been the move of messaging from individual components to the entity itself. I might write about the details later when I've finished my changes and actually used the system for a while, but I can already tell it has reduced dependencies between parts of the code; always a good thing. The biggest test for my entity system will come when I start to implement some more complex gameplay, but so far, so good.</p>
<p>See you next year, happy 2009 everyone!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2008/12/30/last-of-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Holiday coding</title>
		<link>http://www.brainfold.org/blog/2008/12/27/holiday-coding/</link>
		<comments>http://www.brainfold.org/blog/2008/12/27/holiday-coding/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 21:55:28 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Artillery Brawl]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=108</guid>
		<description><![CDATA[As promised (to myself and readers), I have continued game development during the holidays. Not much, mind you, I've mostly been enjoying the chance of being lazy for a change, but it's something, and I hope I don't get any more months-long breaks in the near future. I have been working on Artillery Brawl, with [...]]]></description>
			<content:encoded><![CDATA[<p>As promised (to myself and readers), I have continued game development during the holidays. Not much, mind you, I've mostly been enjoying the chance of being lazy for a change, but it's something, and I hope I don't get any more months-long breaks in the near future. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I have been working on Artillery Brawl, with stuff that was left incomplete when I stopped working on it in July. I haven't started on <a href="http://www.brainfold.org/blog/2008/07/05/artillery-brawl-prototyping/">prototyping shooting</a> yet, because I have some related stuff to do first. I have completely changed the units are represented in the code. Instead of a single entity for a unit, there are now several entities for the different parts of a unit; body, turret, later tracks and wheels. To keep all these together, I made a component (an entity is composed of components) that groups several entities together, so I can still essentially handle the unit as a single entity. At least to me, it's a very clean solution, as all these features are in self-contained components, with the entity only containing components which it doesn't know about. At some point, I'm going to have to write about my final entity system in detail, but first I need to actually finish it...</p>
<p>After this change is complete, I will probably work on fixing <a href="http://www.brainfold.org/blog/2008/06/30/bullet-through-the-wall/">shell collisions </a>and then move on to particle systems, camera improvements and other stuff related to trying to make shooting fun.</p>
<p>Happy belated holidays, everyone!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2008/12/27/holiday-coding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bullet through the wall</title>
		<link>http://www.brainfold.org/blog/2008/06/30/bullet-through-the-wall/</link>
		<comments>http://www.brainfold.org/blog/2008/06/30/bullet-through-the-wall/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 22:18:52 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Artillery Brawl]]></category>
		<category><![CDATA[Box2d]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[physics]]></category>
		<category><![CDATA[pymunk]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=82</guid>
		<description><![CDATA[My work with the entity system is pretty much finished for now. Everything seems to be finally working and the code is reasonably clean. I don't want to get stuck polishing the code while it's still missing most of the planned features. I didn't get to gameplay / user interface stuff yet, but I hope [...]]]></description>
			<content:encoded><![CDATA[<p>My work with the entity system is pretty much finished for now. Everything seems to be finally working and the code is reasonably clean. I don't want to get stuck polishing the code while it's still missing most of the planned features. I didn't get to gameplay / user interface stuff yet, but I hope to do so next week. Time to get something concrete done for a change.</p>
<p>I did run into some problems with collision detection though. Shells that are fired travel relatively fast compared to their size, which leads to the infamous bullet-through-wall effect when they collide with ground. In other words: they go straight through it. I tried fixing this both by making the terrain collision shape consist of polygons instead of line segments, and decreasing the step size so that shells wouldn't jump over the line segments. Both of these were too much for pymunk though, and the game ground to a halt. Note this isn't a problem with Python either, since all the physics number crunching is done in C code.</p>
<p>I now have a couple of options. First, I'll try <a href="http://code.google.com/p/pybox2d/">pyBox2d</a>, based on the <a href="http://www.box2d.org/">Box2D</a> physics library (which <a href="http://wiki.slembcke.net/main/published/Chipmunk">chipmunk</a> is based on, which <a href="http://code.google.com/p/pymunk/">pymunk</a> is based on...) Box2D has continuous collision detection, meaning that objects can't jump through each other between steps, but the pyBox2d bindings are based on <a href="http://www.swig.org/">SWIG</a>, which is much slower than ctypes, so it might have performance problems of its own... Additionally, I just (literally a minute ago) stumbled on <a href="http://elements.linuxuser.at/">Elements</a>, which is another Python 2D physics library based on Box2D, so I'll take a look at that as well. A backup plan is faking continuous collision detection by making the collision shapes of shells longer than they actually are. Because the action in Artillery Brawl isn't very dynamic, this shouldn't cause any noticable errors in collision detection, but I'll have to see about that if I'm not satisfied with pyBox2d.</p>
<p>EDIT: At least <a href="http://wiki.laptop.org/go/Physic_Engines/Speed_Tests">these results</a> look promising for Box2d.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2008/06/30/bullet-through-the-wall/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Final stretch</title>
		<link>http://www.brainfold.org/blog/2008/06/29/final-stretch/</link>
		<comments>http://www.brainfold.org/blog/2008/06/29/final-stretch/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 00:30:25 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Artillery Brawl]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[issue tracker]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=81</guid>
		<description><![CDATA[Yet more entities The entity system overhaul is almost finished. Everything looks all right now, but doesn't really behave... there must still be some bugs left in the physics system. I'll concentrate on bug hunting and cleanup tomorrow, and hope to get to gameplay as well, next week if not tomorrow. It's really nice to [...]]]></description>
			<content:encoded><![CDATA[<h4>Yet more entities</h4>
<p>The entity system overhaul is almost finished. Everything looks all right now, but doesn't really behave... there must still be some bugs left in the physics system. I'll concentrate on bug hunting and cleanup tomorrow, and hope to get to gameplay as well, next week if not tomorrow. It's really nice to have some real progress for a change.</p>
<h4>Architecture</h4>
<p>As every programmer knows, or at least should know, program architecture is a hard subject. Really hard. A lot of my development time during the last couple of days has been spent thinking about the perfect architecture for parts of my entity system. I want to get this at least mostly right this time to avoid having to make huge, sweeping changes again in the future (like I'm doing now, but with a relatively small codebase). I feel I have succeeded quite well, with a couple of minor warts I'm going to remedy at some point in the future.</p>
<h4>More issue tracking</h4>
<p>Today, I wasted an hour or two trying to install <a href="http://roundup.sourceforge.net/">Roundup</a>. To my surprise, it got stuck trying to initialize the database, the same problem I had with <a href="http://trac.edgewall.org/">Trac</a> yesterday. Digging into the problem a bit deeper, it seems sqlite (or its Python bindings) is to blame! Specifically, it dies, claiming that the database is already locked. That means I might give Trac another chance if I get the sqlite problem sorted out, or maybe I should just try to use Roundup with another database backend. I gave up on issue tracking for now though, so more on that later.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2008/06/29/final-stretch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entities ahoy!</title>
		<link>http://www.brainfold.org/blog/2008/06/28/entities-ahoy/</link>
		<comments>http://www.brainfold.org/blog/2008/06/28/entities-ahoy/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 01:27:14 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Artillery Brawl]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[issue tracker]]></category>
		<category><![CDATA[setuptools]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=79</guid>
		<description><![CDATA[Entity system Today I've continued work under the hood, on the entity system. Both components and entity types are now loaded using the plugin / entry point system of setuptools, which means custom components and units will be really easy to create and distribute. And much easier for me to load. I have a habit [...]]]></description>
			<content:encoded><![CDATA[<h4>Entity system</h4>
<p>Today I've continued work under the hood, on the entity system. Both components and entity types are now loaded using the plugin / entry point system of <a href="http://peak.telecommunity.com/DevCenter/setuptools">setuptools</a>, which means custom components and units will be really easy to create and distribute. And much easier for me to load. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I have a habit of making too many sweeping changes to code at once, and this is no exception. On the other hand, this does result in massive improvements to the entity system and especially creation of entity type files, so it's all for the greater good.</p>
<p>No screenshots to show for my efforts, but see the end of the post for examples of what entity type files currently look like. This might change before these changes are completed.</p>
<h4>Entity editor</h4>
<p>I'll probably have to start working on an entity editor at some point, since I recon unit and other entity creation will get quite complicated when multiple linked entities, collision shapes, etc. etc. get involved. I'm no big fan of GUI programming, especially since Python's <a href="http://wiki.python.org/moin/GuiProgramming">GUI libraries</a> all seem kind of shoddy (though that seems to apply to other languages too, at least C# and Java). Anyway, I'll probably use <a href="http://wxpython.org/">wxPython</a> for it. Making it in-game would be cool, but too much effort at the moment.</p>
<h4>Trac</h4>
<p>I tried installing <a href="http://trac.edgewall.org/">Trac</a> (again) today since they just released version 0.11, and couldn't get it working (again). After getting over a few hurdles, I was finally stumped when trac-admin hanged while trying to create the environment. Every time. I really want to like Trac, since it's excellent when it works, but I've had nothing but problems trying to get it working myself. It seems I'll have to let it go and find some other issue tracker when I really start needing one. I'd like it to integrate with <a href="http://www.eclipse.org/mylyn/">Mylyn</a>, but the (free) options there are a bit limited. We'll see...</p>
<p><span id="more-79"></span></p>
<h4>Entity types files</h4>
<p>Here's what a unit type file currently looks like. The interface for this is not fully implemented yet, but I hope I'll get that finished during this weekend.</p>
<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">from</span> artillerybrawl <span style="color: #ff7700;font-weight:bold;">import</span> component, entity<br />
<span style="color: #ff7700;font-weight:bold;">from</span> artillerybrawl.<span style="color: black;">entity</span> <span style="color: #ff7700;font-weight:bold;">import</span> Entity<br />
<br />
Unit = entity.<span style="color: black;">get_class</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;unit&quot;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">class</span> Howitzer<span style="color: black;">&#40;</span>Unit<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; name = <span style="color: #483d8b;">&quot;howitzer&quot;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Unit.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">mass</span> = <span style="color: #008000;">None</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">material</span> = <span style="color: #008000;">None</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">hitpoints</span> = <span style="color: #008000;">None</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">resistances</span> = <span style="color: #008000;">None</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Body</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">body_width</span> = <span style="color: #008000;">None</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">body_height</span> = <span style="color: #008000;">None</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">body_texture</span> = <span style="color: #008000;">None</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">collision_meshes</span> = <span style="color: #008000;">None</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Turret</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_offset</span> = <span style="color: #008000;">None</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_width</span> = <span style="color: #008000;">None</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_height</span> = <span style="color: #008000;">None</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_texture</span> = <span style="color: #008000;">None</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_min_angle</span> = <span style="color: #008000;">None</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_max_angle</span> = <span style="color: #008000;">None</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_max_power</span> = <span style="color: #008000;">None</span><br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> create<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; entity = Unit.<span style="color: black;">create</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Body</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; body_sprite = component.<span style="color: black;">create</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;sprite&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">body_width</span>, <span style="color: #008000;">self</span>.<span style="color: black;">body_height</span>, <span style="color: #008000;">self</span>.<span style="color: black;">body_texture</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; body_physics = component.<span style="color: black;">create</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;physics&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">mass</span>, <span style="color: #008000;">self</span>.<span style="color: black;">collision_meshes</span>, <span style="color: #008000;">self</span>.<span style="color: black;">material</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; body_damage = component.<span style="color: black;">create</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;damage&quot;</span>, <span style="color: #008000;">self</span>.<span style="color: black;">hitpoints</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; body = Entity<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">name</span>, <span style="color: black;">&#40;</span>body_sprite, body_physics, body_damage<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Turret</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; turret_transform = component.<span style="color: black;">create</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;transform&quot;</span>, parent=body<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; turret_sprite = component.<span style="color: black;">create</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;sprite&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_width</span>, <span style="color: #008000;">self</span>.<span style="color: black;">turret_height</span>, <span style="color: #008000;">self</span>.<span style="color: black;">turret_texture</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; turret_component = component.<span style="color: black;">create</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;turret&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_min_angle</span>, <span style="color: #008000;">self</span>.<span style="color: black;">turret_max_angle</span>, <span style="color: #008000;">self</span>.<span style="color: black;">turret_max_power</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; turret = Entity<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s_turret&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #008000;">self</span>.<span style="color: black;">name</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span>turret_transform, turret_sprite, turret_component<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> body</div></div>
<p>And an actual unit base on the unit type above.</p>
<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">from</span> artillerybrawl <span style="color: #ff7700;font-weight:bold;">import</span> entity<br />
<br />
Howitzer = entity.<span style="color: black;">get_class</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;howitzer&quot;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">class</span> A1<span style="color: black;">&#40;</span>Howitzer<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; name = <span style="color: #483d8b;">&quot;A1&quot;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Howitzer.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">mass</span> = <span style="color: #ff4500;">1000.0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">material</span> = <span style="color: #483d8b;">&quot;metal&quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">hitpoints</span> = <span style="color: #ff4500;">100</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">resistances</span> = <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;kinetic&quot;</span>: <span style="color: #ff4500;">50.0</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Body</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">body_width</span> = <span style="color: #ff4500;">5.0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">body_height</span> = <span style="color: #ff4500;">2.5</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">body_texture</span> = <span style="color: #483d8b;">&quot;a1&quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">collision_meshes</span> = <span style="color: black;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.0</span>, <span style="color: #ff4500;">0.0</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span><span style="color: #ff4500;">1.0</span>, <span style="color: #ff4500;">1.0</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span><span style="color: #ff4500;">0.0</span>, <span style="color: #ff4500;">1.0</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span><span style="color: #ff4500;">1.0</span>, <span style="color: #ff4500;">0.0</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.0</span>, <span style="color: #ff4500;">0.0</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span><span style="color: #ff4500;">1.0</span>, <span style="color: #ff4500;">1.0</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span><span style="color: #ff4500;">0.0</span>, <span style="color: #ff4500;">1.0</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span><span style="color: #ff4500;">1.0</span>, <span style="color: #ff4500;">0.0</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#93;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Turret</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_offset</span> = <span style="color: black;">&#40;</span><span style="color: #ff4500;">2.5</span>, <span style="color: #ff4500;">2.5</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_width</span> = <span style="color: #ff4500;">5.0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_height</span> = <span style="color: #ff4500;">1.0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_texture</span> = <span style="color: #483d8b;">&quot;a1_turret&quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_min_angle</span> = -<span style="color: #ff4500;">5.0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_max_angle</span> = <span style="color: #ff4500;">85.0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">turret_max_power</span> = <span style="color: #ff4500;">100.0</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2008/06/28/entities-ahoy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Artillery Brawl</title>
		<link>http://www.brainfold.org/blog/2008/06/22/artillery-brawl/</link>
		<comments>http://www.brainfold.org/blog/2008/06/22/artillery-brawl/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 20:27:39 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Artillery Brawl]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[setuptools]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=74</guid>
		<description><![CDATA[Today, I got back from Sweden, Arty got a new name, and I continued a tiny bit on my entity system. Rather than keeping the name of my old game, I'm making a tribute to Artillery Duel and naming it Artillery Brawl. Also, I already have some cool ideas for a possible sequel. Of course, [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I got back from Sweden, Arty got a new name, and I continued a tiny bit on my entity system. Rather than keeping the name of my old game, I'm making a tribute to <a href="http://en.wikipedia.org/wiki/Artillery_Duel">Artillery Duel</a> and naming it <strong>Artillery Brawl</strong>. Also, I already have some cool ideas for a possible sequel. Of course, that will be far in the future if it ever becomes reality, but at least I can store ideas in its brainstorming wiki instead of throwing them away if they don't fit in Artillery Brawl. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I'm in the progress of generalizing my entity system a bit. My current step is creating a "component library" so that unit files and other entity type definitions can load and create components by name instead of importing them, which would get really messy, really quick. I'm going to load components using entry points in <a href="http://peak.telecommunity.com/DevCenter/setuptools">setuptools</a>, which allows me to trivially support both builtin and modder-provided components. This means it's going to be easy to make <span style="text-decoration: underline;">and</span> distribute units with new functionality without the need to modify the source code of the game.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2008/06/22/artillery-brawl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groundwork</title>
		<link>http://www.brainfold.org/blog/2008/06/18/groundwork/</link>
		<comments>http://www.brainfold.org/blog/2008/06/18/groundwork/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 08:13:49 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Artillery Brawl]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=72</guid>
		<description><![CDATA[This week, I've done more groundwork with entities, and just started on unit placement. Unfortunately, I don't expect to finish it this week, since today I've got other things to do, and tomorrow I'm leaving for Sweden for a couple of days. The entity system is starting to look really nice though, and I've got [...]]]></description>
			<content:encoded><![CDATA[<p>This week, I've done more groundwork with entities, and just started on unit placement. Unfortunately, I don't expect to finish it this week, since today I've got other things to do, and tomorrow I'm leaving for Sweden for a couple of days. The entity system is starting to look really nice though, and I've got lots of ideas to make it even better. After unit placement, I think I'll concentrate on those ideas and some cleanup to pave the way for gameplay stuff and particles I was talking about earlier. At some point, I'm also going to write a whole post about the entity system, its design and development, and my experiences with it. But that will have to wait until the entity system is more complete. So, until next week!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2008/06/18/groundwork/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alternating states</title>
		<link>http://www.brainfold.org/blog/2008/06/13/alternating-states/</link>
		<comments>http://www.brainfold.org/blog/2008/06/13/alternating-states/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 10:40:52 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Artillery Brawl]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=70</guid>
		<description><![CDATA[Every programmer knows that sometimes you have to spend time to work on code that no one will ever see. Background work for new features, cleaning up, restructuring or refactoring old code etc. etc. This week I have been doing exactly that. In preparation for implementing unit placement, which requires a bit more interaction with [...]]]></description>
			<content:encoded><![CDATA[<p>Every programmer knows that sometimes you have to spend time to work on code that no one will ever see. Background work for new features, cleaning up, restructuring or refactoring old code etc. etc. This week I have been doing exactly that. In preparation for implementing unit placement, which requires a bit more interaction with terrain than I have currently (ie. any at all), I have been working on the entity/component system and the terrain entity to make them ready for that. I have also cleaned up some code here and there, but nothing that will show in screenshots. Expect that next week, when I'm going to finally implement unit placement for real. I'm also thinking of capturing my first ever game recording video of the results.</p>
<p>After unit placement, I think I'll spend some time on the interface. The current unit is not highlighted in anyway, and artillery shells are impossible to see if you don't zoom in ridiculously close. I'm not too keen about making them bigger since I'm aiming for a semi-realistic look. Besides, that solution won't scale if you want to zoom out even further. That means I'll have to invent some other type of highlighting for shells. After <span style="text-decoration: underline;">that</span>, I have a couple of option. I could work on hit effects, which means particles, which sound like fun (especially making them fast enough in Python). Or I could work on the actual game, ie. player management, menu structure etc. I haven't decided yet, so we'll see what I'm going to do.</p>
<p>Btw. if anyone can recommend a good program for capturing video from a game, I would be happy. I've found recommendations on <a href="http://www.fraps.com/">FRAPS</a> and <a href="http://www.growlersoftware.com/">Growler Guncam</a> thus far, but both look a bit... amateurish.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2008/06/13/alternating-states/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Component-based fun</title>
		<link>http://www.brainfold.org/blog/2008/02/25/component-based-fun/</link>
		<comments>http://www.brainfold.org/blog/2008/02/25/component-based-fun/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 23:25:20 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Artillery Brawl]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/2008/02/25/component-based-fun/</guid>
		<description><![CDATA[As I suspected, most of yesterday was spent snowboarding and playing board games, but today I have been working quite a lot on the game again. Specifically, I've been working on component-based entities. It was quite a big a change and it essentially had to be done all at once, so the game didn't even [...]]]></description>
			<content:encoded><![CDATA[<p>As I suspected, most of yesterday was spent snowboarding and playing board games, but today I have been working quite a lot on the game again. Specifically, I've been working on component-based entities. It was quite a big a change and it essentially had to be done all at once, so the game didn't even start for the whole day. And now all I got is a black screen with the HUD (GUI) drawn on it, so something's obviously wrong, but the hard part should be behind.</p>
<p>Though the code is still a bit of a mess and the transformation to components isn't fully done yet, I can really say they clean up the code structure and responsibilities a lot. Communications also work better than I expected, at least at this point. We'll see what problems I run into when things get a lot more complex. I really like the entity type / entity distinction too. You can already add new units and artillery shell types to the game by placing an appropriate Python script file in the "units" or "shells" directory, respectively. In any case I'm happy to finally get back to "real" progress after this transformation. And you can start expecting screenshots again next week. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Btw, if you want to know more about how some part of my design works, feel free to ask and I'll talk about it in a future post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2008/02/25/component-based-fun/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
