<?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>Tiny Subversions &#187; game maker</title>
	<atom:link href="http://tinysubversions.com/category/game-maker/feed/" rel="self" type="application/rss+xml" />
	<link>http://tinysubversions.com</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 15:16:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>At Dawn</title>
		<link>http://tinysubversions.com/2011/11/at-dawn/</link>
		<comments>http://tinysubversions.com/2011/11/at-dawn/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 15:26:39 +0000</pubDate>
		<dc:creator>Darius Kazemi</dc:creator>
				<category><![CDATA[game maker]]></category>
		<category><![CDATA[gamejam]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://tinysubversions.com/?p=2098</guid>
		<description><![CDATA[I made a little game-like thing called &#8220;At Dawn&#8221; for the Boston Game Jams HTML5 game jam that ran this past weekend. The theme for the jam was &#8220;Dawn.&#8221; I didn&#8217;t have time to attend for the whole weekend, so instead of making a game I just messed around with building a pixelated sunrise. I [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link"  href="http://tinysubversions.com/2011/11/at-dawn/"  title="Permanent link to At Dawn" ><img class="post_image alignnone"  src="http://tinysubversions.com/pics/atdawn.png"  width="634"  height="119"  alt="Post image for At Dawn" /></a>
</p><p>I made <a href="http://tinysubversions.com/game/atdawn/" >a little game-like thing called &#8220;At Dawn&#8221;</a> for the <a href="http://bostongamejams.com/2011/11/15/html5-game-jam-this-weekend-mocospace-sponsorship-and-impactjs-license/" >Boston Game Jams HTML5 game jam</a> that ran this past weekend.</p>
<p>The theme for the jam was &#8220;Dawn.&#8221; I didn&#8217;t have time to attend for the whole weekend, so instead of making a game I just messed around with building a pixelated sunrise. I built most of the thing in <a href="http://www.yoyogames.com/gamemaker/html5" >GameMaker HTML5</a> (which incidentally now has <a href="http://tinysubversions.com/2011/09/another-gamemaker-html5-port/" >the non-obfuscated debug mode I was asking for</a>!). I say &#8220;most of&#8221; because I put the music in by hand.</p>
<p>The music, by the way, is from <a href="http://ccmixter.org/files/DoKashiteru/21394" >the amazing DoKashiteru</a>, and from the amazing website <a href="http://ccmixter.org/" >CCMixter</a>, which is where I find a lot of the Creative Commons licensed music I use in my stuff.</p>
<p>Building the sunrise was fun. I searched for images of sunrise and dawn until I <a href="http://www.malaga-weather.com/gallery/Your%20Photos/slides/2006-0925%20Dawn%20over%20Platera%20%20Nick%20Fincham.html" >found one that I liked</a>. I poked around and extracted 15 different colors that I wanted to use and put them in a palette:</p>
<p><img class="aligncenter size-full wp-image-2100"  title="palette"  src="http://tinysubversions.com/wp-content/uploads/2011/11/palette.png"  alt="15 sunrise colors."  width="480"  height="32" />It&#8217;s an ordered palette &#8212; my sunrise generator basically says &#8220;if you&#8217;re X distance from the sun, fill in this area with a random choice of colors 0-2&#8243; and has some special case rules for what happens when the sun starts to peek up over the horizon. This creates a banding and dithering effect.</p>
<p>The last bit of the experience, where the screen starts to fill up with light, just came from me messing around with the algorithm and deciding that I liked what that particular effect evoked.</p>
]]></content:encoded>
			<wfw:commentRss>http://tinysubversions.com/2011/11/at-dawn/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Another GameMaker HTML5 port</title>
		<link>http://tinysubversions.com/2011/09/another-gamemaker-html5-port/</link>
		<comments>http://tinysubversions.com/2011/09/another-gamemaker-html5-port/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 13:09:23 +0000</pubDate>
		<dc:creator>Darius Kazemi</dc:creator>
				<category><![CDATA[game maker]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://tinysubversions.com/?p=2059</guid>
		<description><![CDATA[In early 2010 I made my first plane jam game called AF 337. I loaded it into GameMaker HTML5, pressed a button, and it was working in the browser, no extra effort required! I think it&#8217;s running a little slower than the native version, but I&#8217;m pretty pleased with the performance of a completely unoptimized [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>In early 2010 I made my first plane jam game called <a href="http://tinysubversions.com/2010/01/af-337/" >AF 337</a>. I loaded it into GameMaker HTML5, pressed a button, and it was <a href="http://tinysubversions.com/game/af337/" >working in the browser</a>, no extra effort required! I think it&#8217;s running a little slower than the native version, but I&#8217;m pretty pleased with the performance of a completely unoptimized port!</p>
<p><a href="http://tinysubversions.com/game/af337/" >Play the game here!</a></p>
<p>Granted, this is a VERY simple game. I tried the &#8220;one button port&#8221; approach with 9 of my GameMaker games, and only this one managed to be as simple as just pressing a button. I hope to report on more of the issues I&#8217;m having, but some of it so far has to do with Z-indexing and perhaps how it interrelates with code in the Draw event. I think. On the other hand, they&#8217;re fixing bugs daily, so maybe when I try again later it&#8217;ll work.</p>
<p><del>A really big issue I&#8217;m having right now is that sometimes a game will work in Windows, but in HTML5 it&#8217;ll just crash immediately. The problem is I have no way to really debug it when this happens. The code is all minified, so errors come back like &#8220;Undefined variable &#8216;kv&#8217;&#8221;, which isn&#8217;t helpful at all. What I&#8217;d like is a debug mode where I have access to the unminified JavaScript so I can use the great Webkit debug tools to track down issues. I spoke with Russell Kay of YoYoGames on Twitter about it and he said that there might be <a href="http://twitter.com/#!/RussellKay/status/117165222397091840" >something coming soon</a> to help with debugging.</del></p>
<p>(Note on 11/23/11: The above issue is now fixed in GameMaker HTML5. Woo!)</p>
]]></content:encoded>
			<wfw:commentRss>http://tinysubversions.com/2011/09/another-gamemaker-html5-port/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Game Maker and Twitter, United In Spelunky</title>
		<link>http://tinysubversions.com/2009/06/game-maker-and-twitter-united-in-spelunky/</link>
		<comments>http://tinysubversions.com/2009/06/game-maker-and-twitter-united-in-spelunky/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 13:36:00 +0000</pubDate>
		<dc:creator>Darius Kazemi</dc:creator>
				<category><![CDATA[best game ever]]></category>
		<category><![CDATA[game maker]]></category>
		<category><![CDATA[Spelunky]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://tinysubversions.com/?p=1161</guid>
		<description><![CDATA[I love Spelunky. I&#8217;ve been playing it almost every day for the last six months, and I never get tired of it. Sometimes Jeff and I will be at the office, each of us playing Spelunky &#8212; inevitably, one of us will say, &#8220;Oh my god, you&#8217;ll never believe what just happened!&#8221; and then proceed [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I love <span style="font-style: italic;" ><a href="http://forums.tigsource.com/index.php?topic=4017.0" >Spelunky</a></span>. I&#8217;ve been playing it almost every day for the last six months, and I never get tired of it.</p>
<p>Sometimes Jeff and I will be at the office, each of us playing Spelunky &#8212; inevitably, one of us will say, &#8220;Oh my god, you&#8217;ll never believe what just happened!&#8221; and then proceed to regale the other with a story of our latest randomly generated adventure.<br/>
A couple of weeks ago, I got an idea in my head that wouldn&#8217;t go away: what if I could make <span style="font-style: italic;" >Spelunky</span> update Twitter with these stories I love so much? And so I started right in on the project. (You can see the end result here: <a href="http://twitter.com/darius_spelunks" >@darius_spelunks</a>.)</p>
<p>The first step was decompiling the <span style="font-style: italic;" >Spelunky </span>source code. <span style="font-style: italic;" >Spelunky </span>is written in <a href="http://www.yoyogames.com/gamemaker/" >Game Maker 7</a>, and so decompiling is pretty easy if you follow <a href="http://spelunky.wikia.com/wiki/Source_code" >the instructions on the <span style="font-style: italic;" >Spelunky </span>wiki</a>.</p>
<p>The next step was figuring out how to get Game Maker to update Twitter. It doesn&#8217;t come with native support for HTTP Post requests, so I had to improvise. I ended up going with a real kludge of a solution. There&#8217;s a user-contributed Game Maker DLL called <a href="http://gmc.yoyogames.com/index.php?showtopic=181048" >SilentDOS</a>, which lets you run stuff on the Windows command line in the background of your game. (There is a native GM7 function called <span style="font-weight: bold;" >execute_shell()</span>, but the problem with that function is that it opens a cmd.exe window and disrupts your game.) To initialize SilentDOS, make sure that the DLL is in the same directory as your .gmk file, and then run this at the start of the game:</p>
<blockquote><p>global.nnn = external_define(&#8216;silent_dos.dll&#8217;,'RunSilent&#8217;,dll_stdcall, ty_real,2,ty_string,ty_string);</p></blockquote>
<p>I put it in the create script for the oGame object in <span style="font-style: italic; " >Spelunky</span>.</p>
<p>So now I could run Windows command line stuff. This meant I could run <a href="http://www.gnu.org/software/wget/" >wget</a>, which is for making HTTP requests on the command line. Fortunately, it&#8217;s pretty easy to <a href="http://blog.hackers-cafe.net/2009/01/twitter-update-your-status-using-wget.html" >update Twitter with wget</a>. I ended up making a file called <span style="font-weight: bold;" >tweet.bat</span>, and put it in my C:\Windows\System32 directory:</p>
<blockquote><p><span style="font-family:'courier new';" >IF %1==DNT (echo %1) ELSE (wget &#8211;http-user=&#8221;username&#8221; &#8211;http-password=&#8221;password&#8221; &#8211;post-data=&#8221;status=%1&#8243; -b -q http://twitter.com/statuses/update.xml)</span></p></blockquote>
<p>This uses a couple of tricks. First of all, it accepts a command line argument, and &#8220;%1&#8243; is just the argument you pass to it. In this case, it&#8217;s the update you&#8217;re sending to Twitter:</p>
<blockquote><p><span style="font-family:'courier new';" >&gt; tweet.bat &#8220;Test!&#8221;</span></p></blockquote>
<p>The IF statement just says that if the string I send is &#8220;DNT&#8221; (&#8220;Do Not Tweet&#8221;), don&#8217;t send an update to Twitter, just print DNT to the console. Assuming I didn&#8217;t send &#8220;DNT,&#8221; it runs the wget command. The &#8220;-q&#8221; command runs it in quiet mode so it doesn&#8217;t write any log files as outputs. The &#8220;-b&#8221; command runs it as a background process, so that it doesn&#8217;t block <span style="font-style: italic; " >Spelunky</span> while it&#8217;s trying to run. When I run it without &#8220;-b&#8221;, the game will pause for three seconds every time I tweet while I wait for the Twitter server to verify the post.</p>
<p>So now I can tell SilentDOS to run <span style="font-weight: bold;" >tweet.bat</span> with an arbitrary string as an argument. The problem is that if I try to pass it a regular string:</p>
<blockquote><p><span style="font-family:'courier new';" >external_call(global.nnn,&#8221;tweet&#8221;,&#8221;This is my status update.&#8221;); </span></p></blockquote>
<p>the Twitter post ends up saying only &#8220;This&#8221;. It&#8217;s because the command line argument assumes that &#8220;This&#8221; is argument 1, &#8220;is&#8221; is argument 2, etc. So I wrote a helper function called <span style="font-weight: bold;" >format() </span>to replace all spaces with &#8220;%20&#8243;, which is the <a href="http://www.blooberry.com/indexdot/html/topics/urlencoding.htm" >hexadecimal URL encoding</a> for the space character. The function also replaces commas with &#8220;%2C&#8221;:</p>
<blockquote><p><span style="font-family:'courier new';" >message = &#8221; &#8221; + string_replace_all(argument0,&#8221; &#8220;,&#8221;%20&#8243;);</span><br/>
<span style="font-family:'courier new';" >message = string_replace_all(message,&#8221;,&#8221;,&#8221;%2C&#8221;);</span><br/>
<span style="font-family:'courier new';" >return(message);</span></p></blockquote>
<p>So here&#8217;s the actual call to update Twitter from Game Maker:<br/>
<span style="font-family:'courier new';" > </span></p>
<blockquote><p>external_call(global.nnn,&#8221;tweet&#8221;,format(&#8220;Your Twitter update goes here, with commas and everything!&#8221;));</p></blockquote>
<p>At that point it was just a matter of experimenting with where in the code I could put the Twitter calls.  My standard script for generating the text bits looks like this:</p>
<p><span style="font-family:'courier new';" > </span></p>
<blockquote><p><span style="font-family:'courier new';" ><span style="font-size:small;" >if (global.LastTweet == &#8220;scrTEnemySacrifice&#8221;) return &#8220;DNT&#8221;;</span></span><br/>
<span style="font-family:'courier new';" ><span style="font-size:small;" >else global.LastTweet = &#8220;scrTEnemySacrifice&#8221;;</span></span><br/>
<span style="font-family:'courier new';" ><span style="font-size:small;" ><br/>
</span></span><br/>
<span style="font-family:'courier new';" ><span style="font-size:small;" >rInt = floor(random(4));</span></span><br/>
<span style="font-family:'courier new';" ><span style="font-size:small;" >if (rInt == 0) return(&#8220;Kali had better enjoy this here &#8221; + string_lower(argument0) + &#8220;. I work hard to bring her these sacrifices.&#8221;);</span></span><br/>
<span style="font-family:'courier new';" ><span style="font-size:small;" >if (rInt == 1) return(&#8220;I slave all day to bring you this &#8221; + string_lower(argument0) + &#8220;, and what do I get? A random prize determined by a favor counter? Please.&#8221;);</span></span><br/>
<span style="font-family:'courier new';" ><span style="font-size:small;" >if (rInt == 2) return(&#8220;Oboy I love sacrificing a nice &#8221; + string_lower(argument0) + &#8220;.&#8221;);</span></span><br/>
<span style="font-family:'courier new';" ><span style="font-size:small;" >if (rInt == 3) return(&#8220;Sometimes, life is tough for me. But then I sacrifice a &#8221; + string_lower(argument0) + &#8221; on an unholy altar and I remember that others have it worse off.&#8221;);</span></span></p></blockquote>
<p><span style="font-family:'courier new';" > </span><br/>
The first two lines are there because I had a lot of problems with updates that were too repetitive &#8212; who wants to read, &#8220;I whipped a snake&#8221; &#8220;Take that, bat!&#8221; &#8220;Oh man I just whipped a caveman&#8221; all in a row? I wanted more variety in the tweets, so those first lines ask: Did we just tweet about this kind of event? If we did, then don&#8217;t actually update Twitter with this. If we didn&#8217;t, then we pick a random phrase to tweet about. The <span style="font-weight: bold; " >argument0 </span>in these functions is usually the &#8220;type&#8221; field of a given object, which is the English language name of the object. It&#8217;s formatted like &#8220;Caveman&#8221;, which is why I call the <span style="font-weight: bold; " >string_lower()</span> function when appropriate.</p>
<p>So there you have it: a brief tutorial on how to get Game Maker updating Twitter.</p>
]]></content:encoded>
			<wfw:commentRss>http://tinysubversions.com/2009/06/game-maker-and-twitter-united-in-spelunky/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

