<?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>prototyprally &#187; 4k</title>
	<atom:link href="http://prototyprally.com/category/4k/feed/" rel="self" type="application/rss+xml" />
	<link>http://prototyprally.com</link>
	<description>rapid prototyping of games using flash</description>
	<lastBuildDate>Mon, 17 May 2010 10:54:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Another forty bytes the dust.</title>
		<link>http://prototyprally.com/another-forty-bytes-the-dust/</link>
		<comments>http://prototyprally.com/another-forty-bytes-the-dust/#comments</comments>
		<pubDate>Sun, 10 May 2009 20:12:58 +0000</pubDate>
		<dc:creator>grapefrukt</dc:creator>
				<category><![CDATA[4k]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://prototyprally.com/?p=322</guid>
		<description><![CDATA[I really should let this whole 4k game thing go. But as I was sitting on the train today, idly hacking away at a completely different game I remembered a curious thing that I didn&#8217;t have time to investigate then. The mysterious bytes.
 The compiled size of the same actionscript file will vary with up [...]]]></description>
			<content:encoded><![CDATA[<p>I <em>really </em>should let this whole <a href="http://prototyprally.com/a-steroids4k/">4k game</a> thing go. But as I was sitting on the train today, idly hacking away at a completely different game I remembered a curious thing that I didn&#8217;t have time to investigate then. The mysterious bytes.</p>
<p><span id="more-322"></span> The compiled size of the same actionscript file will vary with up 4 bytes between compiles. You can really just bring up the command line and recompile the same file a couple of times and it will be 4098 bytes the first time and 4094 the next. Very strange.  I <a href="http://twitter.com/grapefrukt">tweeted</a> about this suspecting some kind of metadata was stored inside the file, someone told me this shouldn&#8217;t be the case so I let it go.  Turns out <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_16.html#145380">metadata <strong>is</strong> stored</a>, and more than you&#8217;d think. A standard swf compiled with mxmlc can have these values:</p>
<ul>
<li>contributor</li>
<li>creator</li>
<li>date</li>
<li>description</li>
<li>language</li>
<li>localized-description</li>
<li>localized-title</li>
<li>publisher</li>
<li>title</li>
</ul>
<p>The mysterious bytes come from the fact that there is a timestamp embedded, this will affect the compression of the swf making it compress a few bytes smaller if you&#8217;re lucky and a bit bigger on other occasions.  These have default values, and these may be useful to keep track of stuff, they&#8217;re just a bunch of bloat to a 4k game. Luckily they&#8217;re a piece of cake to get rid off. Add these options to the compiler to set them all to be empty:</p>

<div class="wp_syntax"><div class="code"><pre class="as3" style="font-family:monospace;">-contributor=''
-creator=''
-date=''
-description=''
-language=''
-publisher=''
-title=''</pre></div></div>

<p>(In FlashDevelop you set these options in Project Properties -&gt; Compiler Options -&gt; Additional Compiler Options)  However, the swf will still be up to three bytes bigger on occasion, I think the time still gets in there somehow. Nevertheless, this shaves of a whopping 40 bytes on my current version of asteroids4k!</p>
]]></content:encoded>
			<wfw:commentRss>http://prototyprally.com/another-forty-bytes-the-dust/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>a-steroids4k</title>
		<link>http://prototyprally.com/a-steroids4k/</link>
		<comments>http://prototyprally.com/a-steroids4k/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 19:43:27 +0000</pubDate>
		<dc:creator>grapefrukt</dc:creator>
				<category><![CDATA[4k]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://prototyprally.com/?p=289</guid>
		<description><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_asteroids_230957974"
			class="flashmovie"
			width="500"
			height="500">
	<param name="movie" value="http://prototyprally.com/wp-content/uploads/2009/03/asteroids.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://prototyprally.com/wp-content/uploads/2009/03/asteroids.swf"
			name="fm_asteroids_230957974"
			width="500"
			height="500">
	<!--<![endif]-->
		


	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
So, here it is, the full 4089 bytes of it, a-steroids4k for the gamepoetry 4k flash game compo.
I&#8217;ve been wanting to remake an old retro game with new mechanics for some time now but I&#8217;ve never had an idea I though worthwhile, there&#8217;s way too many half assed [...]]]></description>
			<content:encoded><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_asteroids_1221104127"
			class="flashmovie"
			width="500"
			height="500">
	<param name="movie" value="http://prototyprally.com/wp-content/uploads/2009/03/asteroids.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://prototyprally.com/wp-content/uploads/2009/03/asteroids.swf"
			name="fm_asteroids_1221104127"
			width="500"
			height="500">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>So, here it is, the full 4089 bytes of it, a-steroids4k for the <a href="http://www.gamepoetry.com/blog/2009/01/30/a-flash-4k-game-competition/">gamepoetry 4k flash game compo.</a></p>
<p>I&#8217;ve been wanting to remake an old retro game with new mechanics for some time now but I&#8217;ve never had an idea I though worthwhile, there&#8217;s way too many half assed remakes out there and it&#8217;s hard to beat really innovative ones like <a href="http://www.tetris1d.org/">1D tetris</a> or some crazy space invaders version. This is my take on asteroids. I played the original on the proper hardware a few weeks ago and was amazed by two things; The XY-vector screen is *really* bright and it&#8217;s hard. Very hard.</p>
<p>So I wanted to juxtapose the underpowered feel and make the player way more powerful, this is a bit tricky without making the game far too easy. The easyness wouldn&#8217;t be a problem in itself, but to feel really powerful you need to have a baseline of &#8220;weakness&#8221; to contrast against.</p>
<p>The basic mechanics came to me on a train ride, luckily I had my trusty laptop near and could churn out some quick proof of concept code then and there. It was only later the 4k competition was announced. I&#8217;ve done a game for a 5k compo in the past and enjoyed it immensely, the result of this was lost in a hdd crash and is unfortunately not available anymore. When I started slimming down the game was at about 29k. I ripped out all the sound and got down to 18k (yes, the sounds were tiny). I&#8217;d love to post screenshots, but, honestly the game has looked more or less the same ever since it&#8217;s conception. Ever since then it&#8217;s been a lot of aggressive cutting and small amounts of putting back in.</p>
<p>The <a href="http://prototyprally.com/wp-content/uploads/2009/03/a-steroids4k.zip">full source code</a> is under the  MIT License, but a word of warning is in place, this is essentially obfuscated code seeing that I needed to shave of some extra bytes to get the text in there.  I also put it up <a href="http://wonderfl.kayac.com/code/6c59e44794258d28e0ad8edd507fefd4f8a161b2">on wonderfl for your fiddling pleasure</a>. I bet there&#8217;s a good 20% of savings in there that I just missed, I&#8217;ll be thrilled by any modifications to it!</p>
]]></content:encoded>
			<wfw:commentRss>http://prototyprally.com/a-steroids4k/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>4k &#8211; Tiny Keyboard Handler</title>
		<link>http://prototyprally.com/4k-tiny-keyboard-handler/</link>
		<comments>http://prototyprally.com/4k-tiny-keyboard-handler/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 06:00:29 +0000</pubDate>
		<dc:creator>grapefrukt</dc:creator>
				<category><![CDATA[4k]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://prototyprally.com/?p=232</guid>
		<description><![CDATA[I&#8217;ve been toying with an entry into the 4k game competition held at gamepoetry. The game I&#8217;m making uses the keyboard for controls which is a bit rare for me.
AS2 had a very useful method called Key.isDown() whose functionality is pretty self explanatory. This isn&#8217;t available in the much more event driven AS3, but when [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been toying with an entry into the <a href="http://www.gamepoetry.com/blog/2009/02/06/flash-4k-game-competition-prizes-and-rules/">4k game competition held at gamepoetry</a>. The game I&#8217;m making uses the keyboard for controls which is a bit rare for me.</p>
<p>AS2 had a very useful method called Key.isDown() whose functionality is pretty self explanatory. This isn&#8217;t available in the much more event driven AS3, but when doing something as tiny as 4k it&#8217;s a pretty useful thing to have. So I wrote my own tiny little version of it. A bare bones swf with nothing but this code weighs in at about 750bytes, but it&#8217;s not that big of an addition to your filesize since the swf has some basic stuff that adds to the size. The demo code adds another 200 bytes, but that&#8217;s meant to be stripped out.</p>
<p>Note that the trick is to add this into your main class, not to put is as a class of it&#8217;s own. That adds too much to your filesize.</p>
<p>I also recently discovered <a href="http://wonderfl.kayac.com/">wonderfl</a> which is a crazy cool online actionscript editor thingie. <a href="http://wonderfl.kayac.com/code/862c23aba45cea86eda47339f28f1db7f2c2ba8c">You can try the code live there!</a> or the new <a href="http://wonderfl.kayac.com/code/ec9e82d9f9bf25f1a3adbc666574e8065e3d10fe/edit">even smaller version</a>.</p>
<p>If that&#8217;s not your cup of tea, here&#8217;s the code in plain old boring text:<br />
(This is an updated version, a whopping 17 bytes smaller)</p>

<div class="wp_syntax"><div 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;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> STKI extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
        <span style="color: #009900;">// this stores all key states</span>
        <span style="color: #009900;">// For some reason this seems to be smaller when typed</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> k<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>;
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> block<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span>;
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> STKI <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
            k = <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span>;    <span style="color: #009900;">// shorthand for initializing a object</span>
&nbsp;
			<span style="color: #009900;">// the trick is to use the dynamic nature of objects, </span>
			<span style="color: #009900;">// if the property exists it's overwritten, </span>
			<span style="color: #009900;">// if it doesn't it's created</span>
			<span style="color: #009900;">// the function actually gets a KeyboardEvent, but</span>
			<span style="color: #009900;">// having it untyped makes it smaller</span>
			<span style="color: #009900;">// So does using a regular (&quot;keyDown&quot;) string instead </span>
			<span style="color: #009900;">// of the static one provided by the event. </span>
            <span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;keyDown&quot;</span>, <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:*</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> k<span style="color: #000000;">&#91;</span>e<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;keyCode&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#125;</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: #990000;">&quot;keyUp&quot;</span>, <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:*</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> k<span style="color: #000000;">&#91;</span>e<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;keyCode&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
            <span style="color: #009900;">// this is just to show that it works</span>
            block = <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>;
            block.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0xff00ff<span style="color: #000000;">&#41;</span>;
            block.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">4</span>, <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">4</span>, <span style="color: #000000; font-weight:bold;">8</span>, <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span>;
            block.<span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">250</span>;
            block.<span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">250</span>;
            <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>block<span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;enterFrame&quot;</span>, handleEnterFrame<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> handleEnterFrame<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:*</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>
&nbsp;
            <span style="color: #009900;">// this is how you use it, just access the keyCode</span>
            <span style="color: #009900;">// in the object, it acts just as good old Key.isDown</span>
            <span style="color: #009900;">// from AS2</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>k<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">37</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #009900;">//left</span>
                block.<span style="color: #004993;">x</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;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>k<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">39</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #009900;">// right</span>
                block.<span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000; font-weight:bold;">1</span>;
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>k<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">38</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span> <span style="color: #009900;">// up</span>
                block.<span style="color: #004993;">y</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;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>k<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">40</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #009900;">// down</span>
                block.<span style="color: #004993;">y</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: #000000;">&#125;</span>
&nbsp;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://prototyprally.com/4k-tiny-keyboard-handler/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
