<?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>Cheezeworld &#187; Uncategorized</title>
	<atom:link href="http://cheezeworld.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://cheezeworld.com</link>
	<description>The Cheeze to Your Macaroni - Games, Open Source Programming, and Other Odd Ramblings.</description>
	<lastBuildDate>Mon, 04 Jan 2010 18:23:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Game Entities and Representing Objects in a Game</title>
		<link>http://cheezeworld.com/game-entities/</link>
		<comments>http://cheezeworld.com/game-entities/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 23:32:02 +0000</pubDate>
		<dc:creator>Colby Cheeze</dc:creator>
				<category><![CDATA[Game Library]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[entities]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[game objects]]></category>
		<category><![CDATA[game structure]]></category>

		<guid isPermaLink="false">http://cheezeworld.com/?p=108</guid>
		<description><![CDATA[This is the 2nd article in the series Building a Game Structure. Be sure to read the introduction and article 1 which discusses building a foundation for your games.
I&#8217;m going to discuss how different objects should be represented in your games and do my best to explain the idea behind my reasoning. I&#8217;ll provide the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cheezeworld.com/wp-content/uploads/2008/11/mapediting_rahmosspawn.jpg"><img class="alignleft size-medium wp-image-113" title="Game Entities" src="http://cheezeworld.com/wp-content/uploads/2008/11/mapediting_rahmosspawn-300x233.jpg" alt="" width="300" height="233" /></a>This is the 2nd article in the series Building a Game Structure. Be sure to read the <a href="http://cheezeworld.com/game-structure/">introduction </a>and article 1 which discusses <a href="http://cheezeworld.com/game-foundation-and-screens/">building a foundation for your games</a>.</p>
<p>I&#8217;m going to discuss how different objects should be represented in your games and do my best to explain the idea behind my reasoning. I&#8217;ll provide the code I am using for my entities, and explain that a bit as well. So let&#8217;s get started. First of all, I feel that it is best to categorize your game objects into two categories: Entities and Game Objects. Let&#8217;s talk about Entities first.
<p></p>
<h2>What is an Entity?</h2>
<p>An entity can represent any physical object in your gameworld. Entities are generally things that can be interacted with in some way, or just anything that holds a position in the world. This could include: A barrel, door, powerup, player, enemy, trigger area, wall, etc.</p>
<p>All entities will use the update/dispose interface. Entities may contain other entities and game objects in a hierarchical structure as well. They contain the basic data to represent themselves in game space such as position, rotation, size, scale. Each has a unique ID associated with it for debug and storage purposes.</p>
<p>Ideally Entities will replace the need for multiple class types for each different enemy by providing somewhat of a &#8220;template.&#8221; In order to provide more functionality we do things such as extend the basic Entity class with &#8220;MovingEntity&#8221; which provides movement data, and in a later article I&#8217;ll discuss a &#8220;Vehicle&#8221; class which provides AI to the entity. Each individual game will extend those basic classes further with a general &#8220;Unit&#8221; class that can provide more specialized data such as health, damage, etc.</p>
<p>To make the Entity classes as reusable as possible we will provide basic hook functions that can be used or overrided by subclasses. We want to make it as easy as possible to centralize the creation of these entities within a factory class, and even create a way that these can be built using external data. Rather than having a long list of constructor parameters, we create an &#8220;EntityParameters&#8221; class that holds the basic startup variables to be passed through to each entity on creation. This will make it very easy to do the things we just discussed.</p>
<h2>Why Use Entities?</h2>
<p>One question some may ask is why we create a class to represent our objects rather than simply extending MovieClip. Well, the answer is that it is quite inflexible to extend MovieClip because you may wish to represent your object with several different types of graphical data. This approach I am preaching is more along the Model View Controller design pattern, which allows for the greatest of expandability. Also, there are some things that make using entities extremely faster than dealing with Display Objects directly.</p>
<h2>What is a game object?</h2>
<p>Now that we are clear on what an Entity is, and the idea behind it&#8230;isn&#8217;t that what a game object is? Well, yes and no. A game object can be any of the following: A Sprite which graphically represents an entity, an AI routine which must be calculated each frame, any sort of game GUI such as menus etc. A game object&#8217;s definition is really quite broad, but we will consider anything to be a game object which needs to be updated and disposed of properly and does not have an actual &#8220;Game World&#8221; representation. I suppose that leaves the question of&#8230;</p>
<h2>What is the &#8220;Game World&#8221;?</h2>
<p>The Game World is simply the area in which the entities reside. What would be displayed to the screen can be considered as what is visible in the &#8220;camera.&#8221; The Game World is in fact an entity itself. I don&#8217;t want to go into any more detail on this right now, because it will be discussed in detail with another article.</p>
<h2>Let&#8217;s build our Entity</h2>
<p><em>Note: This version of the Entity class has a small bit of it&#8217;s final functionality taken out. What you see below is the core of it, however we will build upon it slightly in future articles to allow for greater usefulness within our greater game structure.</em></p>
<p>I&#8217;m going to list out the interface of the Entities and Game Objects. I&#8217;ve commented the interface here. To see the full code you may download the files from the <a href="http://code.google.com/p/cheezeworld/">google project page</a>.<span id="more-108"></span></p>
<p><strong>This is used for anything that will be considered a Game Object</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IGameObject <span style="color: #0066CC;">extends</span> IEventDispatcher
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #66cc66;">&#40;</span> timePassed:<span style="color: #0066CC;">int</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;
	<span style="color: #000000; font-weight: bold;">function</span> dispose<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>These are for the construction of our entities.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EntityParams
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> parent:Entity;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> radius:<span style="color: #0066CC;">Number</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> id:<span style="color: #0066CC;">String</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> rotation:<span style="color: #0066CC;">Number</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> scale:<span style="color: #0066CC;">Number</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> EntityParams<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MovingEntityParams <span style="color: #0066CC;">extends</span> EntityParams
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> maxSpeed:<span style="color: #0066CC;">Number</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> doesRotMatchHeading:<span style="color: #0066CC;">Boolean</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> boundsBehavior:<span style="color: #0066CC;">String</span>;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> friction:<span style="color: #0066CC;">Number</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MovingEntityParams<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>The basic Entity class which can represent any stationary object.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Entity <span style="color: #0066CC;">extends</span> EventDispatcher
 <span style="color: #66cc66;">&#123;</span>
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> scale<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span>
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> scale<span style="color: #66cc66;">&#40;</span> a_value:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> id<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> parent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Entity
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> parent<span style="color: #66cc66;">&#40;</span> a_value:Entity <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>	
&nbsp;
 	<span style="color: #808080; font-style: italic;">/**
 	 * NOTES: The following variables are left open rather than using getter/setters because they are accessed
 	 * 	often and thus this VASTLY improves performance.
 	 *
 	 * 	newPos and actualPos ( have to use these since we don't do getter/setter )
 	 * 	newPos var should be what you change if you wish to change pos externally.
 	 */</span>
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> newPos:Vector2D;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> actualPos:Vector2D;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> rotation:<span style="color: #0066CC;">Number</span>;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> radius:<span style="color: #0066CC;">Number</span>;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> bounds:AABBox; 	
&nbsp;
 	<span style="color: #808080; font-style: italic;">/**
 	 * ID's are assigned automatically. If it is necessary to force an ID then set it
 	 * in the parameter file passed through the constructor.
 	 *
 	 */</span>
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Entity<span style="color: #66cc66;">&#40;</span> a_params:EntityParams <span style="color: #66cc66;">&#41;</span>	
&nbsp;
        <span style="color: #808080; font-style: italic;">// The basic interface</span>
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #66cc66;">&#40;</span> a_timePassed:<span style="color: #0066CC;">int</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> dispose<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// Each entity may inherit the basic hit detection functions or create it's own specialized version.</span>
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> isOverlapping<span style="color: #66cc66;">&#40;</span> a_entity:Entity <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
&nbsp;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> isOverlappingCircle<span style="color: #66cc66;">&#40;</span> a_pos:Vector2D, a_radius:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">Boolean</span> 	
&nbsp;
        <span style="color: #808080; font-style: italic;">// The following is the interface for handling child entities and game objects</span>
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addChild<span style="color: #66cc66;">&#40;</span> a_entity:Entity <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> removeChild<span style="color: #66cc66;">&#40;</span> a_id:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> clearChildren<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
&nbsp;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getChildByID<span style="color: #66cc66;">&#40;</span> a_id:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:Entity
&nbsp;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getChildren<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">Array</span>
&nbsp;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addGameObject<span style="color: #66cc66;">&#40;</span> a_gameObject:IGameObject <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
 	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> removeGameObject<span style="color: #66cc66;">&#40;</span> a_object:IGameObject <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
 	override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
&nbsp;
  	<span style="color: #808080; font-style: italic;">// -- PRIVATE --</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// These are hook functions to be used or overrided by subclasses. They are used within the update function.</span>
  	protected <span style="color: #000000; font-weight: bold;">function</span> updateChildren<span style="color: #66cc66;">&#40;</span> timePassed:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
  	protected <span style="color: #000000; font-weight: bold;">function</span> setInitialValues<span style="color: #66cc66;">&#40;</span> timePassed:<span style="color: #0066CC;">int</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
  	protected <span style="color: #000000; font-weight: bold;">var</span> _stepSize:<span style="color: #0066CC;">Number</span>;
        protected <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">_parent</span>:Entity;
&nbsp;
 <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>Now our Moving Entity which handles any movement data. Keep in mind that the movement logic used by this Class may be changed slightly depending on the game you are creating. Things such as rotation speed constraints etc may be applied, however this is a basic moving entity example.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MovingEntity <span style="color: #0066CC;">extends</span> Entity
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const BOUNDS_BOUNCE:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;bounce&quot;</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const BOUNDS_WRAP:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;wrap&quot;</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const BOUNDS_REMOVE:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;remove&quot;</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const BOUNDS_NONE:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;none&quot;</span>;
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> friction<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> _friction; <span style="color: #66cc66;">&#125;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> friction<span style="color: #66cc66;">&#40;</span> a_value:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> _friction = a_value; <span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/** CAUTION!
	 * The heading variable is left open for speed purposes, however it should only be set externally
	 * using the setHeading function! The side variable should never be set externally.
	 */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> heading:Vector2D;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> side:Vector2D;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setHeading<span style="color: #66cc66;">&#40;</span> a_value:Vector2D <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>		
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> speed:<span style="color: #0066CC;">Number</span>;
  	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> maxSpeed:<span style="color: #0066CC;">Number</span>;
  	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> boundsBehavior:<span style="color: #0066CC;">String</span>;
  	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> doesRotMatchHeading:<span style="color: #0066CC;">Boolean</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MovingEntity<span style="color: #66cc66;">&#40;</span> a_params:MovingEntityParams <span style="color: #66cc66;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// a simple way to get the entity to face a target position.</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> rotateToPosition<span style="color: #66cc66;">&#40;</span> a_target:Vector2D <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// apply a one time force to the entity. It will be removed after it is calculated.</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> applyForce<span style="color: #66cc66;">&#40;</span> a_force:Vector2D <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// add a constant force such as gravity to the entity.</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addConstantForce<span style="color: #66cc66;">&#40;</span> a_force:Vector2D, a_id:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> removeForce<span style="color: #66cc66;">&#40;</span> a_id:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
&nbsp;
 	<span style="color: #0066CC;">public</span> override <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #66cc66;">&#40;</span> a_timePassed:<span style="color: #0066CC;">int</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
&nbsp;
 	override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> dispose<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
&nbsp;
 	<span style="color: #808080; font-style: italic;">// -- PRIVATE --</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// Some new hooks are added</span>
 	override protected <span style="color: #000000; font-weight: bold;">function</span> setInitialValues<span style="color: #66cc66;">&#40;</span> a_timePassed:<span style="color: #0066CC;">int</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 	
&nbsp;
 	protected <span style="color: #000000; font-weight: bold;">function</span> calculateForces<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
        protected <span style="color: #000000; font-weight: bold;">function</span> calculateFinalVelocity<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
        protected <span style="color: #000000; font-weight: bold;">function</span> updatePosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
 	protected <span style="color: #000000; font-weight: bold;">function</span> updateHeading<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 	
&nbsp;
 	protected <span style="color: #000000; font-weight: bold;">function</span> wrapOnBounds<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
 	protected <span style="color: #000000; font-weight: bold;">function</span> bounceOnBounds<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
 	protected <span style="color: #000000; font-weight: bold;">function</span> removeOnBounds<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
&nbsp;
 	protected <span style="color: #000000; font-weight: bold;">var</span> _forces:<span style="color: #0066CC;">Array</span>;
 	protected <span style="color: #000000; font-weight: bold;">var</span> _constantForces:Dictionary;
 	protected <span style="color: #000000; font-weight: bold;">var</span> _newVel:Vector2D;
 	protected <span style="color: #000000; font-weight: bold;">var</span> _velocity:Vector2D;
        protected <span style="color: #000000; font-weight: bold;">var</span> _friction:<span style="color: #0066CC;">Number</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h2>Wrapping Up</h2>
<p>We now have a way to easily represent entities and thier associated objects in our games. The next steps would be to to create a class to manage all of our objects and entities effectively, as well as a generalized graphical representation class for our entities. Then we will want to centralize creation of entities and objects to a factory class, and ideally support external data driven creation.</p>
<p>In the next article, we will discuss game object management and we will create some renderers for our entities. For now, be sure to check out the example code on the <a href="http://code.google.com/p/cheezeworld/">google project page</a>.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_GameEntities_90115291"
			class="flashmovie"
			width="550"
			height="550">
	<param name="movie" value="http://www.cheezeworld.com/files/GameEntities.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.cheezeworld.com/files/GameEntities.swf"
			name="fm_GameEntities_90115291"
			width="550"
			height="550">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://cheezeworld.com/game-entities/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Programming on Paper</title>
		<link>http://cheezeworld.com/programming-on-paper/</link>
		<comments>http://cheezeworld.com/programming-on-paper/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 15:34:33 +0000</pubDate>
		<dc:creator>Colby Cheeze</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[organization]]></category>
		<category><![CDATA[paper]]></category>
		<category><![CDATA[planning]]></category>
		<category><![CDATA[pseudo code]]></category>

		<guid isPermaLink="false">http://cheezeworld.com/?p=62</guid>
		<description><![CDATA[
I want to discuss a technique that I have been using which works very well to get past the initial strain of programming a new part into your game. Yesterday I was trying to figure out how I would program the abilities system for units ( it is a Diablo style game, so there is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cheezeworld.com/wp-content/uploads/2008/10/pen-paper.jpg"><img class="alignleft size-full wp-image-63" title="pen-paper" src="http://cheezeworld.com/wp-content/uploads/2008/10/pen-paper.jpg" alt="" width="400" height="300" /></a></p>
<p>I want to discuss a technique that I have been using which works very well to get past the initial strain of programming a new part into your game. Yesterday I was trying to figure out how I would program the abilities system for units ( it is a Diablo style game, so there is a possibility for a lot of abilities ).</p>
<p>After staring at the screen for a while, I pulled out the ol&#8217; handy dandy notebook and just began writing things down on paper. Shortly thereafter I had the entire system programmed, and it worked great!</p>
<p>So, the process of programming on paper works like this:</p>
<ol>
<li>Decide your problem. Write it down.</li>
<li>List out the steps that need to take place from the player&#8217;s view in order for the problem to work. IE:
<ul>
<li>Player chooses class ( Wizard for example )</li>
<li>Unit is given abilities.</li>
<li>Player presses ability 1 key, ability 1 activates.</li>
</ul>
</li>
<li>Now that you see what is required to complete your problem it is much easier to program it. Decide on which classes will be needed, and then write out how it will all work using pseudo code&#8230;so for me it was something like this:
<ul>
<li>Ability Class, abilities will extend this&#8230;for example: HealAbility, ProjectileAbility, etc.</li>
<li>onKeyPress( &#8220;A&#8221; ) : Unit.useAbility( 1 );</li>
<li>Unit.useAbility(): ability1.execute();</li>
<li>ability1.execute(): unit.addHealth( 20 ); //or spawnProjectile( &#8220;Fireball&#8221; ); //or unit.addBuff( &#8230; )</li>
</ul>
</li>
<li>Once you have all of it written down in pseudo code like that it really makes it super simple to code everything because you are just basically putting it in Actionscript.</li>
</ol>
<p>Originally I had thought it would be difficult and take quite some time to design and program all of the things I did yesterday (it was a lot) however since I used this technique I believe it relieved the pressure of creating code that doesn&#8217;t work and just let me focus on the concept of HOW it should work. Hopefully you can find a style or programming on paper that works best for you as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://cheezeworld.com/programming-on-paper/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
