<?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>benwatts.ca &#187; game</title>
	<atom:link href="http://benwatts.ca/tag/game/feed/" rel="self" type="application/rss+xml" />
	<link>http://benwatts.ca</link>
	<description>Designer and Frontend Developer in Ottawa, Canada</description>
	<lastBuildDate>Fri, 22 Jul 2011 19:00:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Jump Around</title>
		<link>http://benwatts.ca/2009/jump-around/</link>
		<comments>http://benwatts.ca/2009/jump-around/#comments</comments>
		<pubDate>Fri, 01 May 2009 02:01:18 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[jumping]]></category>

		<guid isPermaLink="false">http://www.benwatts.ca/?p=391</guid>
		<description><![CDATA[I&#8217;ve been tinkering with Sprites and the idea of making a silly little game in Flash with AS3, to flex (PUN?) my actionscript chops. This is the meagre progress I&#8217;ve made so far, and I thought I&#8217;d make it open source for all the world to gasp at my horrendous code. I&#8217;m currently at the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been tinkering with Sprites and the idea of making a silly little game in Flash with AS3, to flex (PUN?) my actionscript chops. This is the meagre progress I&#8217;ve made so far, and I thought I&#8217;d make it open source for all the world to gasp at my horrendous code. I&#8217;m currently at the<em> &#8220;HOLY CRAP I MADE A CHARACTER THAT CAN JUMP USING AS3&#8243;</em> stage of development. </p>
<p>How about that linear jump? Needs some gravity love, eh? </p>
<div id="game090430"><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></div>
<p><strong> <a href="/wp-content/storage/mariogame/090430/mario.zip">SOURCE</a> (71 KB, .zip) </strong></p>
<p><small> You might have to click on the swf to give it focus and enable keyboard controls to move/jump. Shift+Left/Right to &#8216;run&#8217; (*his legs don&#8217;t move*). No collision detection whatsoever, yet.</small></p>
<p><script type="text/javascript">
			var flashvars = {};
			var params = {};
			var attributes = {};
			swfobject.embedSWF("/wp-content/storage/mariogame/090430/bin/mario.swf", "game090430", "500", "250", "10.0.0", false, flashvars, params, attributes);
		</script></p>
<p>Below is the event handler I&#8217;m using for jumping, which is called on every frame after the user presses the up key, until the jump is complete:</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> jump<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> jumpDestination<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = groundLevel <span style="color: #000066; font-weight: bold;">-</span> MAX_JUMP_HEIGHT<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// only attempt to stop the jump if you've already left the ground</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> inAir <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #004993;">height</span> == groundLevel <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;dy = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;groundLevel = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;inAir = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> jump<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&gt;</span>= jumpDestination <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; inAir = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dy <span style="color: #000066; font-weight: bold;">-</span>= <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <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> <span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&lt;</span>= jumpDestination <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dy <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #000000;">&#125;</span></div></div>
<p>Eh? Eh? I felt good after figuring that one out. Ahaha. Looking at it though, I think I should be stopping the jump based upon some collision detection. As it stands right now, it wouldn&#8217;t work if you wanted to jump onto something (since it will only stop the jump if you hit the point you&#8217;ve started at. Development is early, what can I say. </p>
]]></content:encoded>
			<wfw:commentRss>http://benwatts.ca/2009/jump-around/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

