<?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>zedia flash blog &#187; Games</title>
	<atom:link href="http://www.zedia.net/tag/games/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zedia.net</link>
	<description>Flash, ActionScript, SEO and everything in between</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:58:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Workin and playin</title>
		<link>http://www.zedia.net/2011/workin-and-playin/</link>
		<comments>http://www.zedia.net/2011/workin-and-playin/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 03:48:46 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Kid Icarus]]></category>
		<category><![CDATA[newgrounds]]></category>
		<category><![CDATA[The Binding of Isaac]]></category>
		<category><![CDATA[Zelda]]></category>

		<guid isPermaLink="false">http://www.zedia.net/?p=862</guid>
		<description><![CDATA[I have been working, on my projects and on paid work, and it&#8217;s been good. My own project is moving along fine and I should have something new to show pretty soon. As for work, well it&#8217;s going. I haven&#8217;t got much to write about, what about is mostly some little quirks inside of Flash [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working, on my projects and on paid work, and it&#8217;s been good. My own project is moving along fine and I should have something new to show pretty soon. As for work, well it&#8217;s going. I haven&#8217;t got much to write about, what about is mostly some little quirks inside of Flash Professional itself.</p>
<p>But I want to write about this little game I found: The binding of Isaac. I am pretty sure it was made in Flash and a demo of it can be found on <a title="The binding of Isaac" href="http://www.newgrounds.com/portal/view/581168" target="_blank">Newgrounds</a>. It&#8217;s a pretty well done game and it reminds me of the dungeons in Zelda and Kid Icarus. It&#8217;s got that same feeling, with upgraded graphics. The lore is also pretty funny, it&#8217;s got a really skewed sense of humor but everything fits and I find it very funny. Now the concept is really simple, but because they created so many power ups (each with their own hilarious visual) it makes it so that every run of the dungeon is different and it adds a lot of replayability.  Anyway, that is the kinda game I aspire to make. I advise you to go buy it on <a title="The binding of Isaac" href="http://store.steampowered.com/app/113200/" target="_blank">Steam</a>, it&#8217;s only 5$.</p>
<p><a href="http://www.zedia.net/wp-content/uploads/2011/10/the-binding-of-isaac-20110718043913374-000.jpg"><img class="aligncenter size-full wp-image-863" title="the-binding-of-isaac-20110718043913374-000" src="http://www.zedia.net/wp-content/uploads/2011/10/the-binding-of-isaac-20110718043913374-000.jpg" alt="" width="400" height="304" /></a></p>
 <p><a href="http://www.zedia.net/?flattrss_redirect&amp;id=862&amp;md5=f1723a6e9f89ec850aea768c27303db5" title="Flattr" target="_blank"><img src="http://www.zedia.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2011/workin-and-playin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>On my own; two weeks after</title>
		<link>http://www.zedia.net/2011/on-my-own-two-weeks-after/</link>
		<comments>http://www.zedia.net/2011/on-my-own-two-weeks-after/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 20:46:28 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[B-Reel]]></category>
		<category><![CDATA[Freelance]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[lifestyle]]></category>
		<category><![CDATA[Montreal]]></category>

		<guid isPermaLink="false">http://www.zedia.net/?p=857</guid>
		<description><![CDATA[So from my last post you know that I left B-Reel and that I am back in Montreal. I haven&#8217;t posted much because I haven&#8217;t been working much. It&#8217;s been really good times, but not that good work wise. There are a lot of reasons for that, but mostly because I am in what I [...]]]></description>
			<content:encoded><![CDATA[<p>So from <a title="Goodbye B-Reel" href="http://www.zedia.net/2011/goodbye-b-reel-and-on-to-the-next-one-again/">my last post</a> you know that I left B-Reel and that I am back in Montreal. I haven&#8217;t posted much because I haven&#8217;t been working much. It&#8217;s been really good times, but not that good work wise. There are a lot of reasons for that, but mostly because I am in what I would call a transition state. I am not living in my apartment yet (September 1st) and that causes my lifestyle to be quite different (lots of travel time, no desk, no office, no gym, lots of food). But I did get some work done just not that much as I could have.</p>
<h3>Building games is not building websites</h3>
<p>It is quite different to be franc, mostly because the challenges are different and because of that I haven&#8217;t found much topics to write for this blog. I think it is my fault a bit, I chose to do a game that is very close to an application and doesn&#8217;t rely so much on the graphics. I thought this would be a better idea, because I could save a lot of time by doing so. The good thing also is that it is based on a lot of interfaces (visual, not code) and I website building made me very good at making interfaces. The challenge that I face is more about where to put the logic and how to organise my code.</p>
<h3>Finding how to make it work (or make me work)</h3>
<p>My trick right now is to go to a coffee place and work from there. That has been working quite well for now, but starting Tuesday I will have an office space and I really look forward to it. Working from home is just not doing it for me, I watch TV or do some other random stuff that I won&#8217;t do if I am in a working place. Now all I have to figure out is how to wake up earlier in the morning.</p>
 <p><a href="http://www.zedia.net/?flattrss_redirect&amp;id=857&amp;md5=c151e429ca1140c8691d9dffd2aa623f" title="Flattr" target="_blank"><img src="http://www.zedia.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2011/on-my-own-two-weeks-after/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Porting a game in ActionScript 2 to ActionScript 3</title>
		<link>http://www.zedia.net/2007/porting-a-game-in-actionscript-2-to-actionscript-3/</link>
		<comments>http://www.zedia.net/2007/porting-a-game-in-actionscript-2-to-actionscript-3/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 03:14:21 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[ActionScript 2]]></category>
		<category><![CDATA[ActionScript 3]]></category>

		<guid isPermaLink="false">http://www.zedia.net/2007/porting-a-game-in-actionscript-2-to-actionscript-3/</guid>
		<description><![CDATA[Yesterday I blogged about a post on Emanuele Feronato&#8217;s blog. Today he put on is blog some code on an artillery game. It is nice code, but it is in ActionScript 2. I thought it would be fun to try to make the same thing in ActionScript 3. Here is the code from is post [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I blogged about a post on <a href="http://www.emanueleferonato.com/" title="Emanuele Feronato's blog">Emanuele Feronato&#8217;s blog</a>. Today he put on is blog some <a href="http://www.emanueleferonato.com/2007/10/29/artillery-with-bounce-a-modification-of-artillery-tutorial/#more-146" title="AS2 artillery game code" target="_blank">code on an artillery game</a>. It is nice code, but it is in ActionScript 2. I thought it would be fun to try to make the same thing in ActionScript 3. Here is the code from is post</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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">Mouse</span>.<span style="color: #0066CC;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
gravity = <span style="color: #cc66cc;">2</span>;
<span style="color: #0066CC;">attachMovie</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;crosshair&quot;</span>, <span style="color: #ff0000;">&quot;crosshair&quot;</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">attachMovie</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;tank&quot;</span>, <span style="color: #ff0000;">&quot;tank&quot;</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">_x</span>:<span style="color: #cc66cc;">230</span>, <span style="color: #0066CC;">_y</span>:<span style="color: #cc66cc;">350</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
crosshair.<span style="color: #0066CC;">onEnterFrame</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_x</span> = <span style="color: #0066CC;">_xmouse</span>;
  <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_y</span> = <span style="color: #0066CC;">_ymouse</span>;
<span style="color: #66cc66;">&#125;</span>;
tank.<span style="color: #0066CC;">onEnterFrame</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  mousex = _xmouse-<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_x</span>;
  mousey = <span style="color: #66cc66;">&#40;</span>_ymouse-<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_y</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span>-<span style="color: #cc66cc;">1</span>;
  angle = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan</span><span style="color: #66cc66;">&#40;</span>mousey<span style="color: #66cc66;">/</span>mousex<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>mousex<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    angle += <span style="color: #cc66cc;">180</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>mousex<span style="color: #66cc66;">&gt;</span>=<span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&amp;&amp;</span> mousey<span style="color: #66cc66;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    angle += <span style="color: #cc66cc;">360</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>angle<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">160</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    angle = <span style="color: #cc66cc;">160</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>angle<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    angle = <span style="color: #cc66cc;">20</span>;
  <span style="color: #66cc66;">&#125;</span>
  firepower = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sqrt</span><span style="color: #66cc66;">&#40;</span>mousex<span style="color: #66cc66;">*</span>mousex+mousey<span style="color: #66cc66;">*</span>mousey<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>firepower<span style="color: #66cc66;">&gt;</span><span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    firepower = <span style="color: #cc66cc;">200</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #0066CC;">this</span>.<span style="color: #006600;">cannon</span>.<span style="color: #0066CC;">_rotation</span> = angle<span style="color: #66cc66;">*</span>-<span style="color: #cc66cc;">1</span>;
<span style="color: #66cc66;">&#125;</span>;
<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">onMouseDown</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  angle = tank.<span style="color: #006600;">cannon</span>._rotation-<span style="color: #cc66cc;">1</span>;
  start_ball_x = tank.<span style="color: #0066CC;">_x</span>+<span style="color: #cc66cc;">48</span><span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span>angle<span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span>;
  start_ball_y = tank.<span style="color: #0066CC;">_y</span>+<span style="color: #cc66cc;">48</span><span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span>angle<span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span>;
  cannonball_fired = <span style="color: #0066CC;">attachMovie</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;cannonball&quot;</span>, <span style="color: #ff0000;">&quot;cannonball_&quot;</span>+<span style="color: #0066CC;">_root</span>.<span style="color: #0066CC;">getNextHighestDepth</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #0066CC;">_root</span>.<span style="color: #0066CC;">getNextHighestDepth</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">_x</span>:start_ball_x, <span style="color: #0066CC;">_y</span>:start_ball_y<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
  cannonball_fired.<span style="color: #006600;">dirx</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span>angle<span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span>firepower;
  cannonball_fired.<span style="color: #006600;">diry</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span>angle<span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span>firepower;
  cannonball_fired.<span style="color: #0066CC;">onEnterFrame</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">this</span>.<span style="color: #006600;">diry</span> += gravity;
    <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_x</span> += <span style="color: #0066CC;">this</span>.<span style="color: #006600;">dirx</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">50</span>;
    <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_y</span> += <span style="color: #0066CC;">this</span>.<span style="color: #006600;">diry</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">50</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_y</span>+<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_height</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&gt;</span><span style="color: #cc66cc;">350</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_y</span> = <span style="color: #cc66cc;">350</span>-<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_height</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>;
      <span style="color: #0066CC;">this</span>.<span style="color: #006600;">diry</span> = -<span style="color: #0066CC;">this</span>.<span style="color: #006600;">diry</span><span style="color: #66cc66;">*</span>.3;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>This code is on the first frame of the fla file. To transfer this in ActionScript 3 and in an object oriented way (I am just starting to learn object oriented programming so if you see way I could improve the code just tell me so). In order to do so I divided his code into 4 classes. One class for the document class,  one class for the  crosshair (I don&#8217;t think I needed to make this as a class but it seemed like a good way to divide things), one class for the tank and one class for the cannonball. Here is the code for the document class saved in a file called artillery9AS3.as since my fla is named artillery9AS3.fla:</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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">&nbsp;
package<span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">ui</span>.<span style="color: #0066CC;">Mouse</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #66cc66;">*</span>;
  <span style="color: #0066CC;">import</span> artillery.<span style="color: #66cc66;">*</span>;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> artillery9AS3 <span style="color: #0066CC;">extends</span> Sprite<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> gravity:<span style="color: #0066CC;">int</span>;
    <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> firepower:<span style="color: #0066CC;">Number</span>;
    <span style="color: #000000; font-weight: bold;">var</span> crosshair:Crosshair;
    <span style="color: #000000; font-weight: bold;">var</span> tank:Tank;
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> artillery9AS3<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
      <span style="color: #0066CC;">Mouse</span>.<span style="color: #0066CC;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
      gravity = <span style="color: #cc66cc;">2</span>;
      crosshair = <span style="color: #000000; font-weight: bold;">new</span> Crosshair<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
      addChild<span style="color: #66cc66;">&#40;</span>crosshair<span style="color: #66cc66;">&#41;</span>;
      tank = <span style="color: #000000; font-weight: bold;">new</span> Tank<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">230</span>, <span style="color: #cc66cc;">350</span><span style="color: #66cc66;">&#41;</span>;
      addChild <span style="color: #66cc66;">&#40;</span>tank<span style="color: #66cc66;">&#41;</span>;
      <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, doEnterFrame<span style="color: #66cc66;">&#41;</span>;
      <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>, doMouseDown<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> doEnterFrame<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
      crosshair.<span style="color: #006600;">setPos</span><span style="color: #66cc66;">&#40;</span>mouseX, mouseY<span style="color: #66cc66;">&#41;</span>;
      <span style="color: #000000; font-weight: bold;">var</span> newMousex:<span style="color: #0066CC;">Number</span> = mouseX-tank.<span style="color: #006600;">x</span>;
      <span style="color: #000000; font-weight: bold;">var</span> newMousey:<span style="color: #0066CC;">Number</span> = <span style="color: #66cc66;">&#40;</span>mouseY-tank.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span>-<span style="color: #cc66cc;">1</span>;
      <span style="color: #000000; font-weight: bold;">var</span> newAngle:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan</span><span style="color: #66cc66;">&#40;</span>newMousey<span style="color: #66cc66;">/</span>newMousex<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>newMousex<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
         newAngle += <span style="color: #cc66cc;">180</span>;
      <span style="color: #66cc66;">&#125;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>newMousex<span style="color: #66cc66;">&gt;</span>=<span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&amp;&amp;</span> newMousey<span style="color: #66cc66;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        newAngle += <span style="color: #cc66cc;">360</span>;
      <span style="color: #66cc66;">&#125;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>newAngle<span style="color: #66cc66;">&gt;</span><span style="color: #cc66cc;">160</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
         newAngle = <span style="color: #cc66cc;">160</span>;
      <span style="color: #66cc66;">&#125;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>newAngle<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        newAngle = <span style="color: #cc66cc;">20</span>;
      <span style="color: #66cc66;">&#125;</span>
      tank.<span style="color: #006600;">setAngle</span><span style="color: #66cc66;">&#40;</span>newAngle<span style="color: #66cc66;">&#41;</span>;
      firepower = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sqrt</span><span style="color: #66cc66;">&#40;</span>newMousex<span style="color: #66cc66;">*</span>newMousex+newMousey<span style="color: #66cc66;">*</span>newMousey<span style="color: #66cc66;">&#41;</span>;
      <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>firepower<span style="color: #66cc66;">&gt;</span><span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        firepower = <span style="color: #cc66cc;">200</span>;
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> doMouseDown<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">var</span> angle:<span style="color: #0066CC;">Number</span> = tank.<span style="color: #006600;">getAngle</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - <span style="color: #cc66cc;">1</span>;
      <span style="color: #000000; font-weight: bold;">var</span> start_ball_x:<span style="color: #0066CC;">Number</span> = tank.<span style="color: #006600;">x</span> + <span style="color: #cc66cc;">48</span><span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span>angle<span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #000000; font-weight: bold;">var</span> start_ball_y:<span style="color: #0066CC;">Number</span> = tank.<span style="color: #006600;">y</span> + <span style="color: #cc66cc;">48</span><span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span>angle<span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #000000; font-weight: bold;">var</span> dirX:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span>angle<span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span>firepower;
      <span style="color: #000000; font-weight: bold;">var</span> dirY:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span>angle<span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span>firepower;
      addChild<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Cannonball<span style="color: #66cc66;">&#40;</span>start_ball_x, start_ball_y, dirX, dirY, gravity<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Mostly what I am doing here is three things,  I create the tank and the crosshair,  I add the ENTER_FRAME and the MOUSE_DOWN listeners and I handle these events. In the ENTER_FRAME handler I give the new position to the crosshair, and the new angle to the tank. In the MOUSE_DOWN handler, I create a new cannonball and I give it its parameters so that it can update itself alone.</p>
<p>The code for the crosshair and the tank is pretty straight forward  so I won&#8217;t paste it here, but download the zip file if you want to see it.</p>
<p>Here is the code for the cannonball</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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">&nbsp;
package artillery<span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #66cc66;">*</span>;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Cannonball <span style="color: #0066CC;">extends</span> Sprite<span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> dirX:<span style="color: #0066CC;">Number</span>;
  <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> dirY:<span style="color: #0066CC;">Number</span>;
  <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> gravity:<span style="color: #0066CC;">Number</span>;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Cannonball<span style="color: #66cc66;">&#40;</span>xpos:<span style="color: #0066CC;">Number</span>, ypos:<span style="color: #0066CC;">Number</span>, newDirX:<span style="color: #0066CC;">Number</span>, newDirY:<span style="color: #0066CC;">Number</span>, newGravity:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    x = xpos;
    y = ypos;
    dirX = newDirX;
    dirY = newDirY;
    gravity = newGravity;
    addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, doEnterFrame<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> doEnterFrame<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
    dirY += gravity;
    x += dirX<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">50</span>;
    y += dirY<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">50</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>y+ <span style="color: #0066CC;">height</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&gt;</span><span style="color: #cc66cc;">350</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      y = <span style="color: #cc66cc;">350</span>- <span style="color: #0066CC;">height</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>;
      dirY = - dirY <span style="color: #66cc66;">*</span> .3;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>x <span style="color: #66cc66;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
       removeEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, doEnterFrame<span style="color: #66cc66;">&#41;</span>;
       <span style="color: #0066CC;">this</span>.<span style="color: #006600;">parent</span>.<span style="color: #006600;">removeChild</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>This code is saved in a file named Cannonball.as in the folder artillery.  Basically it updates its position based on the direction it had was it was created. I modified one thing in this code. When the cannonball x position is less than, I remove the ENTER_FRAME listener and I remove this cannonball from the display list. I do this because, for one the cannonball is not visible anymore so we should not calculate its position. Also, with the previous code, all the cannonballs that you had shot would continue to use up memory, so if you played for a long time, you would eventually run out of memory. By removing the listener and the display object, the garbage collector will remove the unused cannonballs thereby freeing memory.</p>
<p>Also, I mostly used Sprites since there was no timelines involved (the cannon is still a MovieClip, I didn&#8217;t take the time to convert it). This is good for the crosshair and the tank, but I think the cannonballs should have stayed a MovieClips since eventually you will want these cannonballs to explode and use a timeline in order to animate the explosions.</p>
<p>Well that is about it for now, feel free to download the files to look at the source code.</p>
<p><a href="http://www.zedia.net/wp-content/uploads/2007/10/artillerysource.zip" title="Source of the artillery game">Source of the artillery game</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2007/porting-a-game-in-actionscript-2-to-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Games, Flash and money</title>
		<link>http://www.zedia.net/2007/games-flash-and-money/</link>
		<comments>http://www.zedia.net/2007/games-flash-and-money/#comments</comments>
		<pubDate>Sun, 28 Oct 2007 19:36:43 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[money]]></category>

		<guid isPermaLink="false">http://www.zedia.net/2007/games-flash-and-money/</guid>
		<description><![CDATA[This guy blogs about how to monetize a game you made in flash and what type of game you should target. It&#8217;s a nice article, the guy even made a game to experiment with and the game is pretty fun and really simple. I always wanted to make flash games and I have ideas that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.emanueleferonato.com/2007/10/28/experiment-monetizing-a-flash-game/" title="How to monetize a flash game" target="_blank">This guy blogs about how to monetize a game</a> you made in flash and what type of game you should target. It&#8217;s a nice article, the guy even made a game to experiment with and the game is pretty fun and really simple. I always wanted to make flash games and I have ideas that have been in my head for years but I never took the time to sit down and do them. Also it got me thinking about Air and flash games, now that you can make a desktop version of your game without too much trouble, it gives you another way to monetize your gave by making a small version online and a big version for the desktop.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2007/games-flash-and-money/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More 3D, but from Alternativa Games</title>
		<link>http://www.zedia.net/2007/more-3d-but-from-alternativa-games/</link>
		<comments>http://www.zedia.net/2007/more-3d-but-from-alternativa-games/#comments</comments>
		<pubDate>Sat, 27 Oct 2007 22:05:04 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[Alternativa]]></category>
		<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://www.zedia.net/2007/more-3d-but-from-alternativa-games/</guid>
		<description><![CDATA[You can see a really cool demo of a 3D engine all in flash here. It runs nicely when you lower the settings a bit and doesn&#8217;t seems too slow. The sprites need some touch-ups but it&#8217;s only a demo so we can hope for the best. I don&#8217;t think they are going to release [...]]]></description>
			<content:encoded><![CDATA[<p>You can see a really cool <a href="http://blog.alternativagame.com/en/2007/10/25/3d-engine-demo/" title="3D engine in flash" target="_blank">demo of a 3D engine all in flash here</a>. It runs nicely when you lower the settings a bit and doesn&#8217;t seems too slow. The sprites need some touch-ups but it&#8217;s only a demo so we can hope for the best. I don&#8217;t think they are going to release the code for us to play with it, but it&#8217;s nice to see that this can be done with flash. It confirms that being a flash programmer is really a good career choice because there is going to be a lot of good jobs in that domain in the future. As the computers get better and better, we will be allowed to program more complex stuff and no designers will be able to do it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2007/more-3d-but-from-alternativa-games/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

