<?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>Emanuele Feronato &#187; Game design</title>
	<atom:link href="http://www.emanueleferonato.com/category/game-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emanueleferonato.com</link>
	<description>italian geek and PROgrammer</description>
	<lastBuildDate>Tue, 16 Mar 2010 15:55:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Citrus Engine released for free for learning</title>
		<link>http://www.emanueleferonato.com/2010/03/16/citrus-engine-released-for-free-for-learning/</link>
		<comments>http://www.emanueleferonato.com/2010/03/16/citrus-engine-released-for-free-for-learning/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 15:55:36 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Box2D]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2534</guid>
		<description><![CDATA[Do you know Citrus Engine?

It&#8217;s a Box2D library designed to allow game developers making 2D side-scrolling platform games, including a graphical level builder that allows you to drag, drop, and customize all of the game objects and art in your game.
These are the main features, as they appear on the official site:

Blazing 50 FPS in [...]]]></description>
			<content:encoded><![CDATA[<p>Do you know <strong><a href="http://citrusengine.com/" target = "_blank">Citrus Engine</a></strong>?</p>
<p><a href="http://citrusengine.com/" target = "_blank"><img src="/wp-content/uploads/2010/03/citrus.png" /></a></p>
<p>It&#8217;s a Box2D library designed to allow game developers making 2D side-scrolling platform games, including a graphical level builder that allows you to drag, drop, and customize all of the game objects and art in your game.</p>
<p>These are the main features, as they appear on the <a href="http://citrusengine.com/about/features" target = "_blank">official site</a>:<span id="more-2534"></span></p>
<ul>
<li>Blazing 50 FPS in the browser on current machines, and 250+ FPS on the desktop (or Adobe AIR).</li>
<li>Physics-based engine allows for tumbling crates, pulleys, vehicles, and just about anything else you can imagine, without the limitations of a grid.</li>
<li>The Level Architect visual level editor makes it easier to create level blueprints, then tweak your level to your heart’s desire.</li>
<li>Robust documentation includes and ASDoc API, tutorial videos, and a developer-friendly manual.</li>
<li>Standards-based code API means developers and designers spend more time tweaking the fun stuff, and less time debugging.</li>
<li>Level-based progressive downloading allows gamers to start playing the game quicker by only downloading what the next level needs.</li>
<li>Pre-made commonly used objects, like a hero, coins, enemy, moving platforms, and more!</li>
<li>Object spawning management</li>
<li>Graphics rendering system that gives your animators and artists flexibility</li>
<li>Sound management</li>
<li>Keyboard and input management</li>
<li>Intuitive events framework</li>
</ul>
<p>That&#8217;s really a lot of features&#8230;</p>
<p><strong>You can have it for free</strong></p>
<p>Citrus Engine is now free for educational users. This means students, educators, and hobbiest wont&#8217;a pay for it.</p>
<p><strong>You can STILL have it for free&#8230;</strong></p>
<p>If you are looking to use the engine in commercial projects, you can still have it for free&#8230; just <a href="http://citrusengine.com/blog/view/tweet-about-citrusengine" target = "_blank">tweet about it</a> before April 15th 2010 and you can win one commercial license or a $0.25 discount per follower.</p>
<p>I am testing the engine right now, so expect some tutorial very soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/03/16/citrus-engine-released-for-free-for-learning/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Get up to $100,000 for your next Flash game with Mochi GAME Developer Fund</title>
		<link>http://www.emanueleferonato.com/2010/03/11/get-up-to-to-100000-for-your-next-flash-game-with-mochi-game-developer-fund/</link>
		<comments>http://www.emanueleferonato.com/2010/03/11/get-up-to-to-100000-for-your-next-flash-game-with-mochi-game-developer-fund/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 23:30:32 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Monetize]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2519</guid>
		<description><![CDATA[Imagine a Flash game sponsor encouraging you to use MochiAds, helping you to market and promote your game, reviewing and testing it putting his experience at your service and helping you to integrate the latest APIs in the most proficuous way.
For some developers this dream could become true because MochiMedia created the Mochi GAME Developer [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine a Flash game sponsor encouraging you to use <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiAds</a>, helping you to market and promote your game, reviewing and testing it putting his experience at your service and helping you to integrate the latest APIs in the most proficuous way.</p>
<p>For some developers this dream could become true because <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiMedia</a> created the <strong>Mochi GAME Developer Fund</strong>: a $10 million fund that will help promising Flash and social game developers support their games through sponsorship, licensing and publishing deals.</p>
<p>The fund will assist small Flash game development studios and independent game developers worldwide in building world-class games and businesses.</p>
<p><a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank"><img src="/wp-content/uploads/2010/03/mochi-dev-fund-logo-300x198.png" /></a></p>
<p>You will find the details in the <a href="http://www.mochimedia.com/developers/fund.html" target = "_blank">official page</a>, with some FAQs. Here&#8217;s the four more interesting:</p>
<p><strong>Q: What is the Mochi GAME Developer Fund?</strong><br />
A: The Mochi GAME Developer Fund $10 million USD fund for investing in promising Flash and social game developers through sponsorship, licensing, and publishing. The goal of the Fund is to assist developers in launching and building rockstar premium games on the Mochi platform, and to cultivate long term relationships with Flash and social game developers looking to build world-class games and businesses. </p>
<p><strong>Q: What is the target deal size for the Mochi GAME Developer Fund?</strong><br />
A: The Mochi GAME Developer Fund intends to partner with Flash and social game developers on a sponsorship, licensing or publishing basis anywhere from $1,000 to $100,000. Additional consideration may be given to other types of relationships on a case-by-case basis. Generally, the funds will be given upon the achievement of certain milestones of the game development process. The specific milestones can be discussed with the Mochi GAME Developer Fund team. </p>
<p><strong>Q: What types of games is the Mochi GAME Developer Fund seeking?</strong><br />
A: We are open to Flash and social games of all genres and gameplay types targeting all kinds of audiences. Particular attention will be given to games that have high potential to monetize via MochiCoins microtransactions, include social elements that may be enhanced via MochiSocial or are particularly great games. </p>
<p><strong>Q: I don’t live in the United States. Can I still work with the Mochi GAME Developer Fund?</strong><br />
A: Absolutely! Flash and social game developers are located all across the world. We care less about where you live and care more about helping you build great games using the Mochi platform. </p>
<p>According to these FAQs, it looks like an exclusive sponsorship, but I hope to give you more information as I&#8217;m running to <a href="http://mochimedia.us1.list-manage.com/subscribe?u=1c2da7d6e8&#038;id=7ce02a64fb" target = "_blank">submit the form</a> and ask for some millions for my next game.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/03/11/get-up-to-to-100000-for-your-next-flash-game-with-mochi-game-developer-fund/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sell sitelocked version of your Flash games and even .fla sources to Free Online Games</title>
		<link>http://www.emanueleferonato.com/2010/03/09/sell-sitelocked-version-of-your-flash-games-and-even-fla-sources-to-free-online-games/</link>
		<comments>http://www.emanueleferonato.com/2010/03/09/sell-sitelocked-version-of-your-flash-games-and-even-fla-sources-to-free-online-games/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 09:28:23 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Monetize]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2500</guid>
		<description><![CDATA[Are you looking for a quick way to sell a site locked version of your game? Do you want to earn some more selling the .fla source code? Then Neil from Free Online Games (aka FOG) is your man.

FOG is looking for any game, no matter how old it is or how wide spread it [...]]]></description>
			<content:encoded><![CDATA[<p>Are you looking for a quick way to sell a site locked version of your game? Do you want to earn some more selling the <code>.fla</code> source code? Then <strong>Neil</strong> from <a href="http://www.freeonlinegames.com/" target = "_blank">Free Online Games</a> (aka FOG) is your man.</p>
<p><a href="http://www.freeonlinegames.com/" target = "_blank"><img src="/wp-content/uploads/2010/03/fog.jpg" /></a></p>
<p>FOG is looking for any game, no matter how old it is or how wide spread it is already, as long as it&#8217;s a decent game. In this case FOG will buy you a site locked version of your game, or even the <code>.fla</code> source code.</p>
<p><strong>What happens when <a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a> buys a site locked version of your game</strong></p>
<p>* The game is sitelocked to <a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a><br />
* You have to interface your game with their API<br />
* You have to remove all external branding and ads</p>
<p><strong>What happens when <a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a> buys the source code of your game</strong></p>
<p>* <a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a> retains the rights to re-release, resell, re-use, delete, make more version and all in all everything with your code<br />
* All branding, ads and credits will be removed</p>
<p>Note: if your game is already sponsored, you may no longer have the right to sell your source code. Check with your sponsor as <a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a> is not responsible for your previous deals<span id="more-2500"></span></p>
<p><strong>My experience</strong></p>
<p>I am currently managing the latest small details about <a href="http://www.emanueleferonato.com/2009/12/09/play-barbalance-my-latest-game/">BarBalance</a>. I&#8217;m selling the source code. Working with Neil is a pleasure as he&#8217;s very kind, professional and will support you through the entire process. Just consider FOG&#8217;s HQ is located in United Kingdom when your plan to chat with him.</p>
<p>His email, as well as his Skype, Messenger, ICQ, Yahoo and GTalk ids is Neil[at]FOG[dot]COM</p>
<p>I asked him a couple of questions just to give you as much information as possible</p>
<p><strong>Are you really buying ANY kind of game <code>.fla</code>s?</strong></p>
<p>I primarily buy site locks of games, however if the source is available then we do try and purchase that too. I&#8217;m not out to purchase things left right and centre, all the games that are offered we review meticulously to see if it meets our standards, and at the moment, the majority of submissions are being rejected.</p>
<p><strong>What&#8217;s the meaning of buying source codes? Don&#8217;t you think in most cases the sources would be hard to understand (i.e variable names in foreign languages, no optimization and so on&#8230;)</strong></p>
<p>Sources in other languages aren&#8217;t too much of a concern as we have a multilingual staff base here at fog, if the code is not optimised then our in house programmer will go over it and see what can be done</p>
<p><strong>Do you already have an example of a bought and republished game?</strong></p>
<p>We have plenty of site locked games on our site. for games that we have bought source codes of and redone as fog games, and our own developed games can be seen at <a href="http://www.freegamesforyourwebsite.com/" target ="_blank">www.freegamesforyourwebsite.com</a></p>
<p>a few examples of site locks are</p>
<p><a href="http://www.freeonlinegames.com/rpg-games/pizza-pronto.html" target = "_blank">Pizza Pronto</a><br />
<a href="http://www.freeonlinegames.com/adventure-games/tank-in-action.html" target = "_blank">Tank In Action</a><br />
<a href="http://www.freeonlinegames.com/racing-games/mountain-rescue-driver.html" target = "_blank">Mountain Rescue Driver</a><br />
<a href="http://www.freeonlinegames.com/puzzle-games/perfect-balance-2.html" target = "_blank">Perfect Balance 2</a></p>
<p><strong>How much can a developer earn from <a href="<a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a>?</strong></p>
<p>Generally prices range from $100-$500 for site locks, source code can be anything from $100-$1000 or more depending on the quality&#8230; I don&#8217;t feel that there is a limit on what a developer can earn for a<br />
decent game, if it is really that good and someone wants it they&#8217;ll lay the money on the table to get it.</p>
<p>Hope this will help you to further monetize your games.</p>
<p><strong>** edit **</strong></p>
<p><a href="http://www.emanueleferonato.com/2009/12/09/play-barbalance-my-latest-game/">BarBalance</a> source code sold :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/03/09/sell-sitelocked-version-of-your-flash-games-and-even-fla-sources-to-free-online-games/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Box2D Flash game creation tutorial &#8211; part 2</title>
		<link>http://www.emanueleferonato.com/2010/02/25/box2d-flash-game-creation-tutorial-part-2/</link>
		<comments>http://www.emanueleferonato.com/2010/02/25/box2d-flash-game-creation-tutorial-part-2/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 09:56:23 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Box2D]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2434</guid>
		<description><![CDATA[After seeing the character creation in Box2D Flash game creation tutorial &#8211; part 1, it&#8217;s time to add some coins to collect.
This process will involve some interesting Box2D features, like sensors and custom collision management.
I would suggest to read the basics of sensors at Erase Box: the tutorial and custom collision management at Creation of [...]]]></description>
			<content:encoded><![CDATA[<p>After seeing the character creation in <a href="http://www.emanueleferonato.com/2010/02/19/box2d-flash-game-creation-tutorial-part-1/">Box2D Flash game creation tutorial &#8211; part 1</a>, it&#8217;s time to add some coins to collect.</p>
<p>This process will involve some interesting Box2D features, like sensors and custom collision management.</p>
<p>I would suggest to read the basics of sensors at <a href="http://www.emanueleferonato.com/2009/02/25/erase-box-the-tutorial/">Erase Box: the tutorial</a> and custom collision management at <a href="http://www.emanueleferonato.com/2009/11/23/creation-of-a-flash-stabilize-clone-using-box2d-part-4/">Creation of a Flash Stabilize! clone using Box2D – part 4</a>.</p>
<p>Although they are both referred to an older Box2D version, they&#8217;ll introduce you to sensor and collisions.</p>
<p>Now the concept is simple: we are placing some circular sensors around the stage (the coins), then we&#8217;ll create a custom contact listener class to check whether the player is over a coin or not. If it&#8217;s over, we&#8217;ll remove the coin.</p>
<p>So this is the main script:<span id="more-2434"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">KeyboardEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.Shapes.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #004993;">Math</span>.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ball02 extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #009900;">// world creation</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> world<span style="color: #000000; font-weight: bold;">:</span>b2World=<span style="color: #0033ff; font-weight: bold;">new</span> b2World<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">10.0</span><span style="color: #000000;">&#41;</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> world_scale<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">30</span>;
		<span style="color: #009900;">// the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> player<span style="color: #000000; font-weight: bold;">:</span>b2Body;
		<span style="color: #009900;">// force to apply to the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> force<span style="color: #000000; font-weight: bold;">:</span>b2Vec2;
		<span style="color: #009900;">// variables to store whether the keys are pressed or not</span>
		<span style="color: #009900;">// true = pressed;</span>
		<span style="color: #009900;">// false = unpressed</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">left</span>,<span style="color: #004993;">right</span>,up,down<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
		<span style="color: #009900;">// declaring my custom contact listener class</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> contact_listener=<span style="color: #0033ff; font-weight: bold;">new</span> custom_contact_listener<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ball02<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// assigning the contact listener to the world</span>
			world.SetContactListener<span style="color: #000000;">&#40;</span>contact_listener<span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// calling debug draw function</span>
			debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// drawing the boundaries</span>
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;ground&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">200</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;left&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">200</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;right&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;roof&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// adding the player at 250,200</span>
			add_player<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// adding some coins</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">1</span>; i<span style="color: #000000; font-weight: bold;">&lt;</span>=<span style="color: #000000; font-weight:bold;">5</span>; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				draw_coin<span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">50</span>,<span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">300</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">50</span>,<span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900;">// listeners needed for the game to work</span>
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>, update<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">KeyboardEvent</span>.<span style="color: #004993;">KEY_DOWN</span>,on_key_down<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">KeyboardEvent</span>.<span style="color: #004993;">KEY_UP</span>,on_key_up<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// according to the key pressed, set the proper variable to &quot;true&quot;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> on_key_down<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">keyCode</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">37</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">left</span>=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">38</span> <span style="color: #000000; font-weight: bold;">:</span>
					up=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">39</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">right</span>=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">40</span> <span style="color: #000000; font-weight: bold;">:</span>
					down=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// according to the key released, set the proper variable to &quot;false&quot;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> on_key_up<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">keyCode</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">37</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">left</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">38</span> <span style="color: #000000; font-weight: bold;">:</span>
					up=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">39</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">right</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">40</span> <span style="color: #000000; font-weight: bold;">:</span>
					down=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function to draw a coin</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> draw_coin<span style="color: #000000;">&#40;</span>px,py,r<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_circle<span style="color: #000000; font-weight: bold;">:</span>b2CircleShape=<span style="color: #0033ff; font-weight: bold;">new</span> b2CircleShape<span style="color: #000000;">&#40;</span>r<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_circle;
			<span style="color: #009900;">// look! it's a sensor!!</span>
			my_fixture.isSensor=<span style="color: #0033ff; font-weight: bold;">true</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> world_body<span style="color: #000000; font-weight: bold;">:</span>b2Body=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			world_body.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// simple function to draw a box</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> draw_box<span style="color: #000000;">&#40;</span>px,py,w,h,<span style="color: #004993;">d</span>,ud<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">d</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				my_body.<span style="color: #004993;">type</span>=b2Body.b2_dynamicBody;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_box<span style="color: #000000; font-weight: bold;">:</span>b2PolygonShape = <span style="color: #0033ff; font-weight: bold;">new</span> b2PolygonShape<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_box.SetAsBox<span style="color: #000000;">&#40;</span>w<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">/</span>world_scale, h<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_box;
			<span style="color: #6699cc; font-weight: bold;">var</span> world_body<span style="color: #000000; font-weight: bold;">:</span>b2Body=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			world_body.SetUserData<span style="color: #000000;">&#40;</span>ud<span style="color: #000000;">&#41;</span>;
			world_body.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function to add the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> add_player<span style="color: #000000;">&#40;</span>px,py<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">type</span>=b2Body.b2_dynamicBody;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_circle<span style="color: #000000; font-weight: bold;">:</span>b2CircleShape=<span style="color: #0033ff; font-weight: bold;">new</span> b2CircleShape<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_circle;
			player=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			player.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// debug draw</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> debug_draw<span style="color: #000000; font-weight: bold;">:</span>b2DebugDraw = <span style="color: #0033ff; font-weight: bold;">new</span> b2DebugDraw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> debug_sprite<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>debug_sprite<span style="color: #000000;">&#41;</span>;
			debug_draw.SetSprite<span style="color: #000000;">&#40;</span>debug_sprite<span style="color: #000000;">&#41;</span>;
			debug_draw.SetDrawScale<span style="color: #000000;">&#40;</span>world_scale<span style="color: #000000;">&#41;</span>;
			debug_draw.SetFlags<span style="color: #000000;">&#40;</span>b2DebugDraw.e_shapeBit<span style="color: #000000;">&#41;</span>;
			world.SetDebugDraw<span style="color: #000000;">&#40;</span>debug_draw<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function to be executed at every frame</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// setting the force to null</span>
			force=<span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// according to the key(s) pressed, add the proper vector force</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">left</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">right</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>up<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>down<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900;">// if there is any force, then apply it</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>force.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">||</span>force.<span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				player.ApplyForce<span style="color: #000000;">&#40;</span>force,player.GetWorldCenter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			world.Step<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
			world.ClearForces<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// scanning through all bodies</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> worldbody<span style="color: #000000; font-weight: bold;">:</span>b2Body = world.GetBodyList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; worldbody; worldbody = worldbody.GetNext<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">// if a body is marked as &quot;remove&quot;...</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>worldbody.GetUserData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>==<span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #009900;">// ... just remove it!!</span>
					world.DestroyBody<span style="color: #000000;">&#40;</span>worldbody<span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
			world.DrawDebugData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Let&#8217;s see the interesting lines:</p>
<p><strong>Line 22</strong>: declaring my <code>contact_listener</code> variable, as <code>custom_contact_listener</code> type</p>
<p><strong>Line 25</strong>: assigning my custom contact listener class to Box2D world</p>
<p><strong>Lines 36-38</strong>: calling five times the <code>draw_coin</code> function passing three parameters: x position, y position and radius.</p>
<p><strong>Lines 79-89</strong>: the draw_coin function&#8230; just a basic function that draw a circle&#8230; just notice at <strong>line 86</strong> how I am declaring the circle as a sensor. This way the circle exists in the world but won&#8217;t physically collide with anything. Also, a sensor should be a static body, or it will fall down outside the stage as it won&#8217;t collide with anything.</p>
<p><strong>Lines 150-156</strong>: scanning through all bodies to find, and eventually remove, bodies marked with <code>remove</code>. Such marker is handled by the custom contact listener class, located in the <code>custom_contact_listener.as</code> file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.Shapes.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.Joints.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.Contacts.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #004993;">Math</span>.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #9900cc; font-weight: bold;">class</span> custom_contact_listener extends b2ContactListener <span style="color: #000000;">&#123;</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> BeginContact<span style="color: #000000;">&#40;</span>contact<span style="color: #000000; font-weight: bold;">:</span>b2Contact<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// getting the fixtures that collided</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> fixtureA<span style="color: #000000; font-weight: bold;">:</span>b2Fixture=contact.GetFixtureA<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> fixtureB<span style="color: #000000; font-weight: bold;">:</span>b2Fixture=contact.GetFixtureB<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// if the fixture is a sensor, mark the parent body to be removed</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>fixtureB.IsSensor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				fixtureB.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>fixtureA.IsSensor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				fixtureA.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><code>BeginContact</code> function will give us the fixtures involved in the collision. Then at <strong>lines 15-17</strong> and <strong>18-20</strong> I am checking if the fixture is a sensor, then eventually mark its parent body to be removed.</p>
<p><strong>Important</strong>: don&#8217;t try to remove the body inside this function, because bodies have a <code>locked</code> status while they are in the middle of a timestep, so you should remove a body only after you performed the <code>Step</code> (<strong>line 147</strong> of the main file). This gave me a little headache, so you&#8217;ve been warned!</p>
<p>This is the result:</p>
<p><embed src="/wp-content/uploads/2010/02/ball02.swf" allowscriptaccess="always" menu="false" quality="high" width="500" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
<p>Pick up all little circles moving the player tapping on arrow keys.</p>
<p><a href="/wp-content/uploads/2010/02/ball02.zip">Download the source code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/25/box2d-flash-game-creation-tutorial-part-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>11 Flash isometric engines you can use in your games</title>
		<link>http://www.emanueleferonato.com/2010/02/23/11-flash-isometric-engines-you-can-use-in-your-games/</link>
		<comments>http://www.emanueleferonato.com/2010/02/23/11-flash-isometric-engines-you-can-use-in-your-games/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 14:45:02 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2400</guid>
		<description><![CDATA[I am playing isometric games for more than 20 years&#8230; probably started with Q*bert, one of the oldest games I played is Head Over Heels on my Commodore 64, and I was an hardcore player of UFO: Enemy Unknown.
As you should know, isometric projection is a method of visually representing three-dimensional objects in two dimensions, [...]]]></description>
			<content:encoded><![CDATA[<p>I am playing isometric games for more than 20 years&#8230; probably started with <a href="http://en.wikipedia.org/wiki/Q*bert" target = "_blank">Q*bert</a>, one of the oldest games I played is <a href="http://en.wikipedia.org/wiki/Head_Over_Heels_(video_game)" target = "_blank">Head Over Heels</a> on my Commodore 64, and I was an hardcore player of <a href="http://en.wikipedia.org/wiki/UFO:_Enemy_Unknown" target = "_blank">UFO: Enemy Unknown</a>.</p>
<p>As you should know, isometric projection is a method of visually representing three-dimensional objects in two dimensions, in which the three coordinate axes appear equally foreshortened and the angles between any two of them are 120 degrees. A great way to represent 3D worlds on old 8-bit computers since their CPUs did not handle a real 3D world, and a great way to create casual adventure games nowadays.</p>
<p>I am showing you a list of 11 Flash isometric engines, some of them are free, others are commercial, and some still unreleased. I am writing to all authors to have more info about their engines, meanwhile this the most complete list I was able to make.</p>
<p>Engines are listed in alphabetical order.</p>
<p><strong>2D isometric engine</strong> &#8211; Free</p>
<p><a href="http://code.google.com/p/2d-isometric-engine/" target = "_blank">http://code.google.com/p/2d-isometric-engine/</a></p>
<p>Open source, multilevel and multiplayer tilebased isometric engine, reviewed in <a href="http://www.emanueleferonato.com/2009/08/18/as3-isometric-engine/">this post</a></p>
<p><strong>as3isolib</strong> &#8211; Free</p>
<p><img src="/wp-content/uploads/2010/02/engines_as3isolib.jpg" /></p>
<p><a href="http://as3isolib.wordpress.com/" target = "_blank">http://as3isolib.wordpress.com/</a></p>
<p>As3isolib is an open-source ActionScript 3.0 Isometric Library developed to assist in creating isometrically projected content (such as games and graphics) targeted for the Flash player platform. As3isolib includes utilities, primitives and views. As3isolib was developed with simplicity, speed and performance in mind so that developers can focus on actual implementations rather than having to learn a complex API.</p>
<p>You can see latest project using this engine at <a href="http://apps.facebook.com/downtowngame/" target = "_blank">http://apps.facebook.com/downtowngame/</a><span id="more-2400"></span></p>
<p><strong>FFilmation</strong> &#8211; Free</p>
<p><img src="/wp-content/uploads/2010/02/engines_ffilmation.jpg" /></p>
<p><a href="http://www.ffilmation.org/" target ="_blank">http://www.ffilmation.org/</a></p>
<p>The FFilmation Engine is an AS3 isometric programing engine, focused mainly on game development. The aim of the project is providing a robust development platform, where game designers can work on the game’s details and forget about the render engine. It is intended to be really usable from a “real production scenario” point of view.</p>
<p>See a demo playing <a href="http://www.ffilmation.org/mynameisponcho/" target = "_blank">My Name is Poncho</a></p>
<p><strong>Flash 3D Isometric Game Engine</strong> &#8211; Unreleased</p>
<p><a href="http://actionscripter.co.uk/blog/?page_id=76" target = "_blank">http://actionscripter.co.uk/blog/?page_id=76</a></p>
<p>Vector isometric engine allowing to zoom, rotate and pan the environment in a &#8220;real&#8221; 3D world. I&#8217;m asking the author more information, stay tuned</p>
<p><strong>isoengineas3</strong> &#8211; Free</p>
<p><a href="http://isoengineas3.sourceforge.net/" target = "_blank">http://isoengineas3.sourceforge.net/</a></p>
<p>2D Isometric Engine project build with Flash AS3. It is an open source, multilevel and multiplayer tilebased isometric engine. No more information.</p>
<p><strong>Isometric Game Engine</strong> &#8211; Unreleased</p>
<p><a href="http://www.davidworks.com/?id=int_iso" target = "_blank">http://www.davidworks.com/?id=int_iso</a></p>
<p>An isometric engine built from scratch for an online virtual campus. No more info.</p>
<p>The <a href="http://www.davidworks.com/content/int_iso/core.htm">demo</a> is quite interesting so I am going to contact the author for more information.</p>
<p><strong>Isometric terrain engine</strong> &#8211; Free</p>
<p><a href="http://yaief.wordpress.com/2008/12/05/isometric-terrain-engine/" target = "_blank">http://yaief.wordpress.com/2008/12/05/isometric-terrain-engine/</a></p>
<p>This is an isometric terrain generator, actually an abandoned project but still an inspiration.</p>
<p><strong>OpenSpace</strong> &#8211; Commercial &#8211; Trial version available</p>
<p><img src="/wp-content/uploads/2010/02/engines_openspace.jpg" /></p>
<p><a href="http://www.openspace-engine.com/">http://www.openspace-engine.com/</a></p>
<p>OpenSpace is a powerful Flash based isometric engine and framework for rapid development of multi-user virtual worlds and MMO communities.</p>
<p>Check <a href="http://www.footballvillage.net/" target ="_blank">Football Village</a> to see it in action.</p>
<p>OpenSpace is licensed on a &#8220;per-seat&#8221; basis: a separate license is required for each user working with OpenSpace.</p>
<p><strong>Sean Cooper Isometric Engine</strong> &#8211; Commercial</p>
<p><a href="http://www.games.seantcooper.com/IsometricEngine.aspx" target ="_blank">http://www.games.seantcooper.com/IsometricEngine.aspx</a></p>
<p>Made by Sean &#8220;BoxHead&#8221; Cooper, the engine is based on some techniques used in the PC game Syndicate, which he wrote in 1993. The technique is simple and extremely fast, well suited to Flash and will run fast on most machines.</p>
<p>At the moment there isn&#8217;t any project showcase, just a demo in the <a href="http://www.games.seantcooper.com/IsometricEngine.aspx" target ="_blank">official page</a>, and no info about the license, but being developed by a PROgrammer like Sean makes this engine quite interesting.</p>
<p><strong>TheoWorlds</strong> &#8211; Commercial</p>
<p><img src="/wp-content/uploads/2010/02/engines_theoworlds.jpg" /></p>
<p><a href="http://www.theoworlds.com/products.php">http://www.theoworlds.com/products.php</a></p>
<p>TheoWorlds Builder SDK v2 is a kit that will help you develop online virtual worlds much faster, without starting from scratch. At its core it contains the original Theo Isometric Engine™ that lets you create pseudo-3D maps, place on them objects and characters, and organize the interaction between them.</p>
<p>You can test the engine playing <a href="http://www.theoworlds.com/games/th/" target = "_blank">Treasure Hunter</a></p>
<p>TheoWorlds Builder SDK v2 is priced $3,200, while the light SDK v1 $799</p>
<p><strong>T.I.L.E. (Tangerine Isometric Level Editor)</strong> &#8211; Commercial</p>
<p><img src="/wp-content/uploads/2010/02/engines_tangerine.jpg" /></p>
<p><a href="http://www.tangerinepop.com/" target ="_blank">http://www.tangerinepop.com/</a> then click on &#8220;tech&#8221;</p>
<p>According to the site, T.I.L.E. provides the ability to rapidly build a standard lock &#038; key adventure game with hundreds of rooms. It also provides the primary software framework needed to build a quality MMO with numerous maps and new play modes via in increasing list of new game mechanics.</p>
<p>An example of a game developed with this technology is <a href="http://www.tangerinepop.com/GraveShift/" target = "_blank">GraveShift</a></p>
<p>Prices range from (as said on the site) &#8220;half to less than half the costs of building it yourself&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/23/11-flash-isometric-engines-you-can-use-in-your-games/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Monetize your Flash games with GamesChart</title>
		<link>http://www.emanueleferonato.com/2010/02/23/monetize-your-flash-games-with-gameschart/</link>
		<comments>http://www.emanueleferonato.com/2010/02/23/monetize-your-flash-games-with-gameschart/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 22:23:00 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Monetize]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Users contributions]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2403</guid>
		<description><![CDATA[Do you remember Emanuele Ornella from Mind the Move? It&#8217;s the guy behind the Come2Play multiplayer API tutorial posted about a month ago.
Now he is explaining us a new way to monetize Flash games: GamesChart
&#171; When I first saw the announcement on Flash Game Developers group on www.linkedIn.com about the GamesChart beta program I immediately [...]]]></description>
			<content:encoded><![CDATA[<p>Do you remember <strong>Emanuele Ornella</strong> from <a target = "_blank" href="http://www.mindthemove.com/">Mind the Move</a>? It&#8217;s the guy behind the <a href="http://www.emanueleferonato.com/2010/01/14/come2play-multiplayer-api-tutorial/">Come2Play multiplayer API tutorial</a> posted about a month ago.</p>
<p>Now he is explaining us a new way to monetize Flash games: <strong><a href="http://gameschart.com/" target = "_blank">GamesChart</a></strong></p>
<p>&laquo; When I first saw the announcement on <a href="http://www.linkedin.com/groups?home=&#038;gid=121017" target = "_blank">Flash Game Developers group</a> on www.linkedIn.com about the <strong><a href="http://gameschart.com/" target = "_blank">GamesChart</a></strong> beta program I immediately thought to participate. It was a surprise to me to find that my game <a href="http://gameschart.com/games/Haunted-House" target = "_blank">Haunted House</a> was at first position for the entire 4 weeks of the beta program!</p>
<p>Actually also my <a href="http://gameschart.com/games/Alice-Memory-1" target = "_blank">Alice Memory</a> game is also on the chart, even if never more than in the 6th position.</p>
<p><img src="/wp-content/uploads/2010/02/gc01.jpg" /></p>
<p>What <strong><a href="http://gameschart.com/" target = "_blank">GamesChart</a></strong> is about?</p>
<p>It’s another way to generate money from you Flash games. The nice thing is that it is not an alternative to the traditional banner you place during the loading of the game. But it goes together.<br />
The main idea is to have publisher to “bid” for which game will be in the chart and this will generate extra revenue to the developer, to the publisher who correctly bid and of course to the GamesChart organization.</p>
<p>This is from <strong>Barry White</strong> directly from linkedIn group.<span id="more-2403"></span></p>
<p>I thought I&#8217;d include some more information about how GamesChart can earn developers money:</p>
<p>+ Every game that has the GamesChart API embedded in it is tracked by GamesChart.</p>
<p>+ The developer can also choose to enable or disable a series of dynamic charts that actually display within the Flash game itself.</p>
<p>+ The most popular games each week make their way to the top of the charts.</p>
<p>+ Any gamers who click on a game listed in these charts is taken to play that game on another portal.</p>
<p>+ Publishers use an advanced pay per click bidding system to purchase this traffic and drive users back to their own sites to play the games they have bid on.</p>
<p>+ Games need to be uploaded to the Publishers portal before they can receive traffic. (great for seeding)</p>
<p>+ Developers receive up to a 50% revenue share of any outbound clicks generated from within their game should they choose to display the charts. (also full blacklisting available)</p>
<p>+ Publishers also receive 10% of total revenues generated from any GamesChart enabled games featured on their site.</p>
<p>I am going to explain the very easy steps to follow to have a game added to this GamesChart.</p>
<p>In order to do so I am going to provide my other game <a href="http://gameschart.com/games/Tokyo-Train" target = "_blank">Tokyo Train</a> with this service as well.</p>
<p>First thing you need to register as developer, if you don’t already. This is quite easy to do, just follow instruction on the site.</p>
<p>You then are prompted to add a game:</p>
<p><img src="/wp-content/uploads/2010/02/gc02.jpg" /></p>
<p>So do not hesitate: go to click the button and create the new game:</p>
<p><img src="/wp-content/uploads/2010/02/gc03.jpg" /></p>
<p>Instructions are easy and nice to follow: I have to admit they did a very good job on make your job easy.</p>
<p><img src="/wp-content/uploads/2010/02/gc04.jpg" /></p>
<p>You are now prompted with the game id that you need to put on the component property to have your game identified.<br />
Of course first of all you need to download the API library from the <a href="http://wiki.gameschart.com/index.php/Getting_Started" target = "_blank">“GamesChart Wiki” link</a>.</p>
<p>You have the choice to get the component for Adobe Flash IDE or the complete API if you use FlashDevelop and for both choices you can choose between AS3 and AS2. My choice was for the component and AS3.</p>
<p>The very first time you download the zip pack, you need to double click on the GamesChartAPI-AS3.mpx:</p>
<p><img src="/wp-content/uploads/2010/02/gc05.jpg" /></p>
<p>This will install the component, and that’s the only thing you really need to install: brilliant.</p>
<p>Now open your FLA and browse for the components (Windows > Components menu): you will find the GamesChartAPI one.</p>
<p><img src="/wp-content/uploads/2010/02/gc06.jpg" /></p>
<p>Now, again it’s easy: drag and drop the component onto the stage (better if at the top layer):</p>
<p><img src="/wp-content/uploads/2010/02/gc07.jpg" /></p>
<p>Do not worry about the position: it will be hidden once the game starts. Do you remember the game id? Go to grab it and paste it in the component inspector:</p>
<p><img src="/wp-content/uploads/2010/02/gc08.jpg" /></p>
<p>That’s all! You can now publish the game: you will notice a small G icon on top right of the stage.</p>
<p>You can force to have this cute icon can be hidden or display when you want. Or you can also move it.</p>
<p>I would suggest you to leave it for the entire game and in that position: it’s the best position, just adjust your buttons if you have any conflict.</p>
<p>In this way a player can click on the icon anytime during the game. This will let him vote your game and show chart. In fact when the icon is clicked the chart will appear and will let you open a new window with the games on the list.</p>
<p><img src="/wp-content/uploads/2010/02/gc09.jpg" /></p>
<p>You need one more thing: to publish the game. You can get your SWF file or you can first upload on MochiAds with version control as I am doing. This is the best solution because your game will be updated all over the world with the cute G icon.<br />
That’s all!<br />
Enjoy!</p>
<p>PS.: I just discovered that Haunted House is no more on first position! So let’s go there and click the cute “G” icon!! &raquo;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/23/monetize-your-flash-games-with-gameschart/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Box2D Flash game creation tutorial &#8211; part 1</title>
		<link>http://www.emanueleferonato.com/2010/02/19/box2d-flash-game-creation-tutorial-part-1/</link>
		<comments>http://www.emanueleferonato.com/2010/02/19/box2d-flash-game-creation-tutorial-part-1/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 00:16:24 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Box2D]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2395</guid>
		<description><![CDATA[My first Flash game tutorial ever was Flash game creation tutorial – part 1.
It was the first of a series to create a game like jmtb&#8217;s ball games. It was an old AS2 series, and some steps have been ported in AS3 with Create a Flash ball game using AS3.
The &#8220;ball&#8221; game is so simple [...]]]></description>
			<content:encoded><![CDATA[<p>My first Flash game tutorial ever was <a href="http://www.emanueleferonato.com/2006/10/29/flash-game-creation-tutorial-part-1/">Flash game creation tutorial – part 1</a>.</p>
<p>It was the first of a series to create a game like <a href="http://jmtb02.com/" target = "_blank">jmtb</a>&#8217;s ball games. It was an old AS2 series, and some steps have been ported in AS3 with <a href="http://www.emanueleferonato.com/2008/03/24/create-a-flash-ball-game-using-as3/">Create a Flash ball game using AS3</a>.</p>
<p>The &#8220;ball&#8221; game is so simple yet addictive and customizable that I think it&#8217;s the perfect game to start a tutorial series based on a new language.</p>
<p>This time I am not covering a new language but the famous Box2D library, but I am going to add all necessary features to make it an interesting game to play.</p>
<p>In this first chapter, I am going to create the ball and the way you control it, by tapping arrow keys.</p>
<p>I am using the basics of <a href="http://www.emanueleferonato.com/2010/02/16/understanding-box2d-applicable-forces/">Understanding Box2D applicable forces</a> and <a href="http://www.emanueleferonato.com/2010/02/01/box2d-tutorial-for-the-absolute-beginners-revamped/">Box2D tutorial for the absolute beginners – revamped</a>, which I recommend you to read.</p>
<p>Now this is the code:<span id="more-2395"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">KeyboardEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.Shapes.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #004993;">Math</span>.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ball01 extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #009900;">// world creation</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> world<span style="color: #000000; font-weight: bold;">:</span>b2World=<span style="color: #0033ff; font-weight: bold;">new</span> b2World<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">10.0</span><span style="color: #000000;">&#41;</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> world_scale<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">30</span>;
		<span style="color: #009900;">// the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> player<span style="color: #000000; font-weight: bold;">:</span>b2Body;
		<span style="color: #009900;">// force to apply to the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> force<span style="color: #000000; font-weight: bold;">:</span>b2Vec2;
		<span style="color: #009900;">// variables to store whether the keys are pressed or not</span>
		<span style="color: #009900;">// true = pressed;</span>
		<span style="color: #009900;">// false = unpressed</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">left</span>,<span style="color: #004993;">right</span>,up,down<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ball01<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// calling thebug draw function</span>
			debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// drawing the boundaries</span>
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;ground&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">200</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;left&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">200</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;right&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;roof&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// adding the player at 250,200</span>
			<span style="color: #009900;">// some listeners</span>
			add_player<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>, update<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">KeyboardEvent</span>.<span style="color: #004993;">KEY_DOWN</span>,on_key_down<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">KeyboardEvent</span>.<span style="color: #004993;">KEY_UP</span>,on_key_up<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// according to the key pressed, set the proper variable to &quot;true&quot;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> on_key_down<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">keyCode</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">37</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">left</span>=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">38</span> <span style="color: #000000; font-weight: bold;">:</span>
					up=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">39</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">right</span>=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">40</span> <span style="color: #000000; font-weight: bold;">:</span>
					down=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// according to the key released, set the proper variable to &quot;false&quot;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> on_key_up<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">keyCode</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">37</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">left</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">38</span> <span style="color: #000000; font-weight: bold;">:</span>
					up=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">39</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">right</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">40</span> <span style="color: #000000; font-weight: bold;">:</span>
					down=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// simple function to draw a box</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> draw_box<span style="color: #000000;">&#40;</span>px,py,w,h,<span style="color: #004993;">d</span>,ud<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">d</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				my_body.<span style="color: #004993;">type</span>=b2Body.b2_dynamicBody;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_box<span style="color: #000000; font-weight: bold;">:</span>b2PolygonShape = <span style="color: #0033ff; font-weight: bold;">new</span> b2PolygonShape<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_box.SetAsBox<span style="color: #000000;">&#40;</span>w<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">/</span>world_scale, h<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_box;
			<span style="color: #6699cc; font-weight: bold;">var</span> world_body<span style="color: #000000; font-weight: bold;">:</span>b2Body=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			world_body.SetUserData<span style="color: #000000;">&#40;</span>ud<span style="color: #000000;">&#41;</span>;
			world_body.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function to add the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> add_player<span style="color: #000000;">&#40;</span>px,py<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">type</span>=b2Body.b2_dynamicBody;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_circle<span style="color: #000000; font-weight: bold;">:</span>b2CircleShape=<span style="color: #0033ff; font-weight: bold;">new</span> b2CircleShape<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_circle;
			player=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			player.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// debug draw</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> debug_draw<span style="color: #000000; font-weight: bold;">:</span>b2DebugDraw = <span style="color: #0033ff; font-weight: bold;">new</span> b2DebugDraw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> debug_sprite<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>debug_sprite<span style="color: #000000;">&#41;</span>;
			debug_draw.SetSprite<span style="color: #000000;">&#40;</span>debug_sprite<span style="color: #000000;">&#41;</span>;
			debug_draw.SetDrawScale<span style="color: #000000;">&#40;</span>world_scale<span style="color: #000000;">&#41;</span>;
			debug_draw.SetFlags<span style="color: #000000;">&#40;</span>b2DebugDraw.e_shapeBit<span style="color: #000000;">&#41;</span>;
			world.SetDebugDraw<span style="color: #000000;">&#40;</span>debug_draw<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// functiojn to be executed at every frame</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// setting the force to null</span>
			force=<span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// according to the key(s) pressed, add the proper vector force</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">left</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">right</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>up<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>down<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900;">// if there is any force, then apply it</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>force.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">||</span>force.<span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				player.ApplyForce<span style="color: #000000;">&#40;</span>force,player.GetWorldCenter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			world.Step<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
			world.ClearForces<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			world.DrawDebugData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>As you can see, I did not change that much from <a href="http://www.emanueleferonato.com/2010/02/16/understanding-box2d-applicable-forces/">Understanding Box2D applicable forces</a> and <a href="http://www.emanueleferonato.com/2010/02/01/box2d-tutorial-for-the-absolute-beginners-revamped/">Box2D tutorial for the absolute beginners – revamped</a>.</p>
<p><code>draw_circle </code> function at <strong>lines 19-30</strong> in <a href="http://www.emanueleferonato.com/2010/02/01/box2d-tutorial-for-the-absolute-beginners-revamped/">Box2D tutorial for the absolute beginners – revamped</a> now is called add_player (<strong>lines 86-95</strong>) and places a circle in the (<code>px</code>,<code>py</code>) coordinates.</p>
<p>The body is named <code>player</code> and is declared in the class at <strong>line 14</strong>, then is used at <strong>line 125</strong> to have the force applied with ApplyForce explained at <a href="http://www.emanueleferonato.com/2010/02/16/understanding-box2d-applicable-forces/">Understanding Box2D applicable forces</a>.</p>
<p>Notice how different forces are applied according to the arrow key pressed&#8230; playing with these values will change the gameplay&#8230; which values would you use?</p>
<p>This is the result:</p>
<p><embed src="/wp-content/uploads/2010/02/ball01.swf" allowscriptaccess="always" menu="false" quality="high" width="500" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
<p>Tap arrow keys to move the ball.</p>
<p><a href="/wp-content/uploads/2010/02/ball01.zip">Download the source code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/19/box2d-flash-game-creation-tutorial-part-1/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Flash AS3 Pixel based circle collision engine</title>
		<link>http://www.emanueleferonato.com/2010/02/13/flash-as3-pixel-based-circle-collision-engine/</link>
		<comments>http://www.emanueleferonato.com/2010/02/13/flash-as3-pixel-based-circle-collision-engine/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 23:37:07 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Users contributions]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2368</guid>
		<description><![CDATA[After seeing the Lineball video teaser I got some email asking me how did I make the hollow circle with Box2D, and how to get a smooth drawing using box primitives.
Well, I have to say I didn&#8217;t use Box2d, but another library called Collision Detection Kit.
I&#8217;ll publish some tutorial about it once I&#8217;ll complete the [...]]]></description>
			<content:encoded><![CDATA[<p>After seeing the <a href="http://www.emanueleferonato.com/2010/02/11/lineball-video-teaser/">Lineball video teaser</a> I got some email asking me how did I make the hollow circle with Box2D, and how to get a smooth drawing using box primitives.</p>
<p>Well, I have to say I didn&#8217;t use Box2d, but another library called <a href="http://www.coreyoneil.com/portfolio/index.php?project=5" target = "_blank">Collision Detection Kit</a>.</p>
<p>I&#8217;ll publish some tutorial about it once I&#8217;ll complete the game, but it&#8217;s not the point of today&#8217;s post.</p>
<p>A reader from Argentina, <strong>Adolfo Chacon</strong>, sent me an AS3 basic engine to do the same thing (maybe even better) using the concepts I explained soooooo long ago in the <a href="http://www.emanueleferonato.com/2007/01/08/create-a-flash-draw-game-like-line-rider-or-others-part-1/">Create a flash draw game like Line Rider or others</a> series.</p>
<p>It&#8217;s a basic, uncommented script because it&#8217;s just a prototype&#8230; basically Adolfo took my old script, adjusted trigonometry and did the magic dividing the simulation in steps to manage slower speeds.</p>
<p>I resized it, changed variable names (translating from spanish) and some operators since the auto format option gave me errors when trying to format <code>a&lt;-b</code>, forcing me to change into <code>a&lt;b*-1</code>.</p>
<p>Now enjoy the script<span id="more-2368"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> pixel_engine extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> ball_radius<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> precision<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">120</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> degrees_to_radians<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0.0174532925</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> x_speed<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> y_speed<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> friction<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0.9</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> max_speed<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">15</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> gravity<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0.98</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> steps=<span style="color: #000000; font-weight:bold;">2</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> ball<span style="color: #000000; font-weight: bold;">:</span>ball_mc = <span style="color: #0033ff; font-weight: bold;">new</span> ball_mc<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> terrain<span style="color: #000000; font-weight: bold;">:</span>terrain_mc = <span style="color: #0033ff; font-weight: bold;">new</span> terrain_mc<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> pixel_engine<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>ball<span style="color: #000000;">&#41;</span>;
			ball.<span style="color: #004993;">x</span>=<span style="color: #000000; font-weight:bold;">250</span>;
			ball_radius=ball.<span style="color: #004993;">width</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>terrain<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>, update<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_DOWN</span>, reverse_gravity<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> reverse_gravity<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			gravity<span style="color: #000000; font-weight: bold;">*</span>=<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span>e <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>ball.y<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				ball.y<span style="color: #000000; font-weight: bold;">-</span>=<span style="color: #000000; font-weight:bold;">400</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>ball.y<span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				ball.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">+</span>=<span style="color: #000000; font-weight:bold;">400</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> j<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">1</span>; j<span style="color: #000000; font-weight: bold;">&lt;</span>=steps; j<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> number_of_collisions<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">0</span>;
				<span style="color: #6699cc; font-weight: bold;">var</span> sum_x_collision<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0</span>;
				<span style="color: #6699cc; font-weight: bold;">var</span> sum_y_collision<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0</span>;
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>x_speed<span style="color: #000000; font-weight: bold;">&gt;</span>max_speed<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					x_speed=max_speed;
				<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>x_speed<span style="color: #000000; font-weight: bold;">&lt;</span>max_speed<span style="color: #000000; font-weight: bold;">*-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
						x_speed=<span style="color: #000000; font-weight: bold;">-</span> max_speed;
					<span style="color: #000000;">&#125;</span>
				<span style="color: #000000;">&#125;</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>y_speed<span style="color: #000000; font-weight: bold;">&gt;</span>max_speed<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					y_speed=max_speed;
				<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>y_speed<span style="color: #000000; font-weight: bold;">&lt;</span>max_speed<span style="color: #000000; font-weight: bold;">*-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
						y_speed=<span style="color: #000000; font-weight: bold;">-</span> max_speed;
					<span style="color: #000000;">&#125;</span>
				<span style="color: #000000;">&#125;</span>
				ball.<span style="color: #004993;">x</span>=ball.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">+</span>x_speed<span style="color: #000000; font-weight: bold;">/</span>steps;
				ball.<span style="color: #004993;">y</span>=ball.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">+</span>y_speed<span style="color: #000000; font-weight: bold;">/</span>steps;
				y_speed=y_speed<span style="color: #000000; font-weight: bold;">+</span>gravity<span style="color: #000000; font-weight: bold;">/</span>steps;
				<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">1</span>; i<span style="color: #000000; font-weight: bold;">&lt;</span>=precision; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #6699cc; font-weight: bold;">var</span> x_test<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=ball.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">+</span>ball_radius<span style="color: #000000; font-weight: bold;">*</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">sin</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">360</span><span style="color: #000000; font-weight: bold;">/</span>precision<span style="color: #000000; font-weight: bold;">*</span>degrees_to_radians<span style="color: #000000;">&#41;</span>;
					<span style="color: #6699cc; font-weight: bold;">var</span> y_test<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=ball.y<span style="color: #000000; font-weight: bold;">-</span>ball_radius<span style="color: #000000; font-weight: bold;">*</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">cos</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">360</span><span style="color: #000000; font-weight: bold;">/</span>precision<span style="color: #000000; font-weight: bold;">*</span>degrees_to_radians<span style="color: #000000;">&#41;</span>;
					<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>terrain.<span style="color: #004993;">hitTestPoint</span><span style="color: #000000;">&#40;</span>x_test,y_test,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
						number_of_collisions<span style="color: #000000; font-weight: bold;">++</span>;
						sum_x_collision=sum_x_collision<span style="color: #000000; font-weight: bold;">+</span>x_test;
						sum_y_collision=sum_y_collision<span style="color: #000000; font-weight: bold;">+</span>y_test;
					<span style="color: #000000;">&#125;</span>
				<span style="color: #000000;">&#125;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> average_x<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=sum_x_collision<span style="color: #000000; font-weight: bold;">/</span>number_of_collisions;
				<span style="color: #6699cc; font-weight: bold;">var</span> average_y<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=sum_y_collision<span style="color: #000000; font-weight: bold;">/</span>number_of_collisions;
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>number_of_collisions<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #6699cc; font-weight: bold;">var</span> collision_angle<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #004993;">Math</span>.<span style="color: #004993;">atan2</span><span style="color: #000000;">&#40;</span>ball.x<span style="color: #000000; font-weight: bold;">-</span>average_x,ball.y<span style="color: #000000; font-weight: bold;">-</span>average_y<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span>degrees_to_radians<span style="color: #000000; font-weight: bold;">*-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">90</span>;
					<span style="color: #6699cc; font-weight: bold;">var</span> collision_x<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = ball.<span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">-</span> ball_radius <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">sin</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>collision_angle <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">90</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> degrees_to_radians<span style="color: #000000;">&#41;</span>;
					<span style="color: #6699cc; font-weight: bold;">var</span> collision_y<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = ball.<span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span> ball_radius <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">cos</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>collision_angle <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">90</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> degrees_to_radians<span style="color: #000000;">&#41;</span>;
					<span style="color: #6699cc; font-weight: bold;">var</span> delta_x<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span>collision_x <span style="color: #000000; font-weight: bold;">-</span> ball.<span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span> ball_radius <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>;
					<span style="color: #6699cc; font-weight: bold;">var</span> delta_y<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span>collision_y <span style="color: #000000; font-weight: bold;">-</span> ball.<span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span> ball_radius <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>;
					<span style="color: #6699cc; font-weight: bold;">var</span> speed<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #004993;">Math</span>.<span style="color: #004993;">sqrt</span><span style="color: #000000;">&#40;</span>x_speed<span style="color: #000000; font-weight: bold;">*</span>x_speed<span style="color: #000000; font-weight: bold;">+</span>y_speed<span style="color: #000000; font-weight: bold;">*</span>y_speed<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span>friction;
					<span style="color: #6699cc; font-weight: bold;">var</span> bounce<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #004993;">Math</span>.<span style="color: #004993;">atan2</span><span style="color: #000000;">&#40;</span>x_speed,y_speed<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span>degrees_to_radians<span style="color: #000000; font-weight: bold;">*-</span><span style="color: #000000; font-weight:bold;">1</span>;
					<span style="color: #6699cc; font-weight: bold;">var</span> ricochet<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">*</span>collision_angle<span style="color: #000000; font-weight: bold;">-</span>bounce<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">180</span>;
					x_speed=<span style="color: #004993;">Math</span>.<span style="color: #004993;">sin</span><span style="color: #000000;">&#40;</span>ricochet<span style="color: #000000; font-weight: bold;">*</span>degrees_to_radians<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span>speed;
					y_speed=<span style="color: #000000; font-weight: bold;">-</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">cos</span><span style="color: #000000;">&#40;</span>ricochet<span style="color: #000000; font-weight: bold;">*</span>degrees_to_radians<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span>speed;
					<span style="color: #0033ff; font-weight: bold;">while</span> <span style="color: #000000;">&#40;</span>terrain.<span style="color: #004993;">hitTestPoint</span><span style="color: #000000;">&#40;</span>collision_x, collision_y,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
						ball.<span style="color: #004993;">x</span>=ball.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">+</span>delta_x;
						ball.<span style="color: #004993;">y</span>=ball.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">+</span>delta_y;
						collision_x=ball.x<span style="color: #000000; font-weight: bold;">-</span>delta_x<span style="color: #000000; font-weight: bold;">*</span>ball_radius;
						collision_y=ball.y<span style="color: #000000; font-weight: bold;">-</span>delta_y<span style="color: #000000; font-weight: bold;">*</span>ball_radius;
					<span style="color: #000000;">&#125;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>And play with the result&#8230; just watch the simulation and press left mouse button to reverse gravity.</p>
<p><embed src="/wp-content/uploads/2010/02/pixel_engine.as_.swf" allowscriptaccess="always" menu="false" quality="high" width="500" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
<p><a href="/wp-content/uploads/2010/02/pixel_engine.as_.zip">Download the source code</a>. Who said draw games are dead?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/13/flash-as3-pixel-based-circle-collision-engine/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Lineball video teaser</title>
		<link>http://www.emanueleferonato.com/2010/02/11/lineball-video-teaser/</link>
		<comments>http://www.emanueleferonato.com/2010/02/11/lineball-video-teaser/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 23:13:00 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Monetize]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2364</guid>
		<description><![CDATA[This is a quick video teaser of my upcoming game (probably) called Lineball.
It&#8217;s a draw game, a classic in which you must draw a line to make a ball reach the goal, but with some twists, such as the ability to control ball&#8217;s speed with arrow keys, red zones that will kill your ball if [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick video teaser of my upcoming game (probably) called <strong>Lineball</strong>.</p>
<p>It&#8217;s a draw game, a classic in which you must draw a line to make a ball reach the goal, but with some twists, such as the ability to control ball&#8217;s speed with arrow keys, red zones that will kill your ball if it touches the lines you drew, 42 levels some of them with moving environment, and so on.</p>
<p><object width="520" height="410"><param name="movie" value="http://www.youtube.com/v/8Laujool81U&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/8Laujool81U&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="520" height="410"></embed></object></p>
<p>The engine is almost complete, and at the moment I am working on level design, then I&#8217;ll retouch the graphics and polish some details, and it will be completed.</p>
<p>As you can see, I am keeping the menu very simple, with only two buttons, and some space for the sponsors. In the level selection screen, there is also a lot of space for sponsor logos.</p>
<p>The only thing I still have to decide is how to save level progression&#8230; I don&#8217;t know if I should use a Mochi account, or simply save it as a shared object, or using Mochi Coins to unlock some levels, or allowing to play some levels only on the official site&#8230;</p>
<p>The game will be completed in about a week, if there is anyone interested in sponsoring it, I am open to any deal since I am still working on the game&#8230; just drop me a mail at info[at]emanueleferonato[dot]com.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/11/lineball-video-teaser/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>PixelBlitz AS3 game framework</title>
		<link>http://www.emanueleferonato.com/2010/02/04/pixelblitz-as3-game-framework/</link>
		<comments>http://www.emanueleferonato.com/2010/02/04/pixelblitz-as3-game-framework/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 22:52:47 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2324</guid>
		<description><![CDATA[PixelBlitz Engine is an old game framework for Actionscript3 created by Richard Davey from Photon Storm.

As said, it&#8217;s not that new, there isn&#8217;t any documentation or tutorial or even a feature list.
So, you may wonder why should I write about it, considering it&#8217;s a bitmap-based framework just like Flixel, which has a better documentation.
Well, the [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://www.photonstorm.com/pixelblitz-engine" target = "_blank">PixelBlitz Engine</a></strong> is an old game framework for Actionscript3 created by <strong>Richard Davey</strong> from <a href="http://www.photonstorm.com/" target = "_blank">Photon Storm</a>.</p>
<p><a href="http://www.photonstorm.com/pixelblitz-engine" target = "_blank"><img src="/wp-content/uploads/2010/02/pixelblitz.png" alt="pixelblitz" title="pixelblitz" /></a></p>
<p>As said, it&#8217;s not that new, there isn&#8217;t any documentation or tutorial or even a feature list.</p>
<p>So, you may wonder why should I write about it, considering it&#8217;s a bitmap-based framework just like <a href="http://www.emanueleferonato.com/2009/09/02/flixel-for-absolute-beginners/">Flixel</a>, which has a better documentation.</p>
<p>Well, the main reason is the blog is mine :) &#8230; the second reason is PixelBlitz supports the Flash IDE, and this means you can use the library with Flash, while Flixel only supports Adobe Flex Builder or FlashDevelop.</p>
<p>In the downloadable package you can find at <a href="http://code.google.com/p/pixelblitz/" target = "_blank">Google Code</a> you can find some examples but they are incomplete&#8230; you will only find the <code>.as</code> files, without the <code>.fla</code>.</p>
<p>So I took the most promising example (in my opinion) and created a complete project, with the .fla file and all needed objects (well, just one object, but it&#8217;s everything you need to make it work).</p>
<p>This is the script, let the comments guide you through the entire process. <span id="more-2324"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">Point</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.normsoule.pixelblitz.core.Renderer2D;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.normsoule.pixelblitz.effects.TrailsEffect;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.normsoule.pixelblitz.<span style="color: #004993;">elements</span>.PixelSprite;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.normsoule.pixelblitz.layers.RenderLayer;
&nbsp;
	<span style="color: #3f5fbf;">/**
	 * This example bounces 20 PixelSprites around the stage. Click on a PixelSprite and it will be removed.
	 *
	 * This demonstrates several of the basic ingredients in using the PixelBlitz engine: 
	 *
	 *create the main renderer, 
	 *create a renderLayer and add it to the renderer,
	 *create some PixelSprites and add them to the renderLayer,
	 *create and apply an effect to a layer,
	 *check mouse interaction using the getCollisionPoint method
	 *properly remove PixelSprites and make them available for garbage collection
	 * and lastly call the renderer.render() method to render the PixelClips to the screen
	 */</span> 
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> pixelblitz extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> const <span style="color: #004993;">stageWidth</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> const <span style="color: #004993;">stageHeight</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span>;
		<span style="color: #009900;">// main renderer</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> renderer<span style="color: #000000; font-weight: bold;">:</span>Renderer2D=<span style="color: #0033ff; font-weight: bold;">new</span> Renderer2D<span style="color: #000000;">&#40;</span><span style="color: #004993;">stageWidth</span>,<span style="color: #004993;">stageHeight</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #009900;">// renderLayer to hold the PixelClips</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> layer<span style="color: #000000; font-weight: bold;">:</span>RenderLayer = <span style="color: #0033ff; font-weight: bold;">new</span> RenderLayer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #009900;">// array to hold a reference to all of the PixelClips</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> holder<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> pixelblitz<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">20</span>; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">// create 20 pixelClips</span>
				spawn<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900;">// add the layer to the renderer</span>
			renderer.addLayer<span style="color: #000000;">&#40;</span> layer <span style="color: #000000;">&#41;</span>;
			layer.effect = <span style="color: #0033ff; font-weight: bold;">new</span> TrailsEffect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>, update <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_DOWN</span>, mouseHandler <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> renderer <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> spawn<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// create a new PixelSprite with the library linked symbol BoxHead</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> ps<span style="color: #000000; font-weight: bold;">:</span>PixelSprite = <span style="color: #0033ff; font-weight: bold;">new</span> PixelSprite<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> BoxHead<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// center on the x axis</span>
			ps.<span style="color: #004993;">x</span>=<span style="color: #004993;">stageWidth</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>;
			<span style="color: #009900;">// center on the y axis</span>
			ps.<span style="color: #004993;">y</span>=<span style="color: #004993;">stageHeight</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>;
			<span style="color: #009900;">// assign a random x velocity</span>
			ps.vx=<span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">12</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">6</span>;
			<span style="color: #009900;">// assign a random y velocity</span>
			ps.vy=<span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">12</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">6</span>;
			<span style="color: #009900;">// add the PixelSprite to the layer</span>
			layer.addItem<span style="color: #000000;">&#40;</span> ps <span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// store a reference to the PixelSprite in the holder array</span>
			holder.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span> ps <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> mouseHandler<span style="color: #000000;">&#40;</span> event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// loop backwards through the holder array to check the top-most clips first</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = holder.<span style="color: #004993;">length</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span>; i <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>; i<span style="color: #000000; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">// reference to each PixelSprite</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> ps<span style="color: #000000; font-weight: bold;">:</span>PixelSprite=holder<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>;
				<span style="color: #009900;">// check if the current mouse position is within a PixelSprite</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>ps.getCollisionPoint<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseX</span>,<span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #009900;">// remove the pixelSprite and clear internal data</span>
					ps.<span style="color: #004993;">dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #009900;">// destroy the reference to the PixelSprite to make it available for garbage collection</span>
					holder.<span style="color: #004993;">splice</span><span style="color: #000000;">&#40;</span> i, <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span>;
					<span style="color: #009900;">// break out of the loop to avoid removing more than one per click</span>
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span> event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> holder.<span style="color: #004993;">length</span>; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">// grab a reference to each PixelSprite</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> ps<span style="color: #000000; font-weight: bold;">:</span>PixelSprite=holder<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>;
				<span style="color: #009900;">// bounce off of the walls</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>ps.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">+</span>ps.width<span style="color: #000000; font-weight: bold;">&gt;</span>stageWidth<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					ps.<span style="color: #004993;">x</span>=stageWidth<span style="color: #000000; font-weight: bold;">-</span>ps.<span style="color: #004993;">width</span>;
					ps.vx=<span style="color: #000000; font-weight: bold;">-</span> ps.vx;
				<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span> ps.<span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					ps.<span style="color: #004993;">x</span>=<span style="color: #000000; font-weight:bold;">0</span>;
					ps.vx=<span style="color: #000000; font-weight: bold;">-</span> ps.vx;
				<span style="color: #000000;">&#125;</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>ps.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">+</span>ps.height<span style="color: #000000; font-weight: bold;">&gt;</span>stageHeight<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					ps.<span style="color: #004993;">y</span>=stageHeight<span style="color: #000000; font-weight: bold;">-</span>ps.<span style="color: #004993;">height</span>;
					ps.vy=<span style="color: #000000; font-weight: bold;">-</span> ps.vy;
				<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span> ps.<span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					ps.<span style="color: #004993;">y</span>=<span style="color: #000000; font-weight:bold;">0</span>;
					ps.vy=<span style="color: #000000; font-weight: bold;">-</span> ps.vy;
				<span style="color: #000000;">&#125;</span>
				<span style="color: #009900;">// move on the x axis</span>
				ps.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">+</span>=ps.vx;
				<span style="color: #009900;">// move on the y axis</span>
				ps.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">+</span>=ps.vy;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900;">// render everything</span>
			renderer.<span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>And this is the result:</p>
<p><embed src="/wp-content/uploads/2010/02/pixelblitz.swf" allowscriptaccess="always" menu="false" quality="high" width="500" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></p>
<p>click on the sprites to make them disappear</p>
<p><a href="/wp-content/uploads/2010/02/pixelblitz.zip">Download the source code</a>, library included.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/04/pixelblitz-as3-game-framework/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
