<?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>Play My Code</title>
	<atom:link href="http://www.playmycode.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.playmycode.com/blog</link>
	<description>Play, Build and Share games Online!</description>
	<lastBuildDate>Wed, 23 May 2012 16:27:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>Updates: Touch Controls, API Additions, Teacher&#8217;s Notes, New Compiler and More</title>
		<link>http://www.playmycode.com/blog/2012/05/updates-touch-controls-api-additions-teachers-notes-new-compiler-and-more/</link>
		<comments>http://www.playmycode.com/blog/2012/05/updates-touch-controls-api-additions-teachers-notes-new-compiler-and-more/#comments</comments>
		<pubDate>Tue, 22 May 2012 07:45:08 +0000</pubDate>
		<dc:creator>Seb</dc:creator>
				<category><![CDATA[Play My Code Announcements]]></category>

		<guid isPermaLink="false">http://www.playmycode.com/blog/?p=633</guid>
		<description><![CDATA[Apologies for not posting for so long: we&#8217;ve been very busy working on a whole host of improvements and additions to Play My Code. Not to mention we&#8217;ve been presenting some talks about PMC, are preparing to open source some &#8230; <a href="http://www.playmycode.com/blog/2012/05/updates-touch-controls-api-additions-teachers-notes-new-compiler-and-more/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Apologies for not posting for so long: we&#8217;ve been very busy working on a whole host of improvements and additions to Play My Code. Not to mention we&#8217;ve been presenting some talks about PMC, are preparing to open source some of our underlying tech, have some teacher&#8217;s notes to share and much more. Full details below&#8230;</p>
<h4 class="pink">Experimental Touch Controls Added</h4>
<p>We&#8217;ve begun adding touch controls to Play My Code. Currently an experimental feature, a single touch is available which emulates the mouse- but even at this early stage, most mouse-driven PMC games are now playable on an iPad or iPhone, including <a href="http://www.playmycode.com/play/game/sharfah/wacky-cannon" class="blue bold">Wacky Cannon</a>, <a href="http://www.playmycode.com/play/game/joe/ourobo-ware" class="blue bold">Oroubo Ware</a>, <a href="http://www.playmycode.com/play/game/jayenkai/Spike+Dislike" class="blue bold">Spike Dislike</a>, <a href="http://www.playmycode.com/play/game/seb/colourbreak" class="blue bold">Colourbreak</a> and many more. Merely adding mouse controls should make your game touch compatible, so long as you don&#8217;t rely on the mouse buttons too much!</p>
<p>We&#8217;re also working on touch equivalents for button presses, multitouch and more, whilst hopefully we&#8217;ll get it working on Android at some point too (thanks <a href="http://www.twitter.com/krakatomato" class="blueCharcoal bold">krakatomato</a> for testing this for us!). Meanwhile, we&#8217;ll also have some documentation and perhaps even a tutorial post about adding touch soon.</p>
<h4 class="pink">Play My Code at Mobile Monday &amp; Hydrahack</h4>
<p>Recently we gave two show &amp; tells about Play My Code, the first taking place at <a href="http://launchconference.co.uk/mobilemonday-mobile-gaming/" class="blueCharcoal bold">Mobile Monday Birmingham</a> on Monday 30th April at Faraday Wharf, Birmingham Science Park. We gave a talk about PMC in general in front of an audience of 130 developers, entrepreneurs and general industry types before revealing Play My Code&#8217;s added touch functionality, mere hours after its implementation. Those who are interested can find some photos from the event <a class="blueCharcoal bold" href="http://launchconference.co.uk/mobile-monday-photos/">here</a>.</p>
<p>Our second talk was slightly more informal, yet no less exciting: taking place at <a href="http://www.meetup.com/hydrahack/" class="blueCharcoal bold">Hydrahack</a>, a meetup for Birmingham web developers. We demoed PMC&#8217;s features, and even <a href="http://www.playmycode.com/play/game/seb/hydrahack" class="blue bold">live-coded and released</a> a small demo to showcase the ease Play My Code offers in terms of both development and deployment. Again, find some <a href="http://www.meetup.com/hydrahack/photos/7952182/" class="blueCharcoal bold">photos right here</a>.</p>
<h4>Play My Code Intro Notes for Teachers</h4>
<p>Tim Scratcherd of the <a href="http://www.shpartners.net/" class="blueCharcoal bold">School House Partnership</a> was kind enough to <a href='http://www.playmycode.com/blog/wp-content/uploads/2012/05/PlayMyCodesupport.zip' class="pink bold">share some notes</a> he&#8217;d put together which provide an intro to Play My Code for teachers who might be new to PMC, or even computer science in general. Centred around our <a href="http://www.playmycode.com/blog/2011/04/building-a-game-from-start-to-finish-with-play-my-code-part-1/" class="pink bold">Bombs &#8216;n&#8217; Booty</a> tutorial, the notes provide general introduction and guidance plus code samples intended for educators. If you&#8217;re a teacher currently using PMC in the classroom then <a href='http://www.playmycode.com/blog/wp-content/uploads/2012/05/PlayMyCodesupport.zip' class="pink bold">please check them out</a>, and do get in touch should you need any help or advice.</p>
<h4>API Additions</h4>
<p>We&#8217;ve made a few minor additions to the Play My Code API.</p>
<p>First off, <a href='/docs/reference/core/string-class/toint' class='purple bold'>String.toInt()</a> and <a href='/docs/reference/core/string-class/tonumber' class='purple bold'>String.toNumber()</a> are functions which make converting numeric strings easier. As you might guess, toInt() will only return a whole number, whilst toNumber() will return either whole or decimal numbers and also works with hexadecimal.</p>
<p><a href='http://www.playmycode.com/docs/reference/core/string-class/split' class='purple bold'>String.split()</a> is a function which splits a string into an array. A given separator is used to determine where to split the string.</p>
<p>Finally, <a href='http://www.playmycode.com/docs/reference/core/array-class/includes' class='purple bold'>Array.includes()</a> returns true if an array contains a given element.</p>
<p>Click the respective function, above, to read more details about it in the docs.</p>
<h4 class="pink">Play My Code Player Improvements</h4>
<p>You may or may not have noticed that we&#8217;ve buffed and shined the Play My Code game player: games can now be shared on Facebook and Twitter straight from the menu bar. Check it out, let us know what you think, and get sharing.</p>
<h4 class="pink">Coming Soon: New Compiler</h4>
<p>A lot of our time over the last few months has gone into into rebuilding our language compiler. It&#8217;s not yet quite complete, but the worst is behind us. The current compiler uses a library called JS/CC- excellent for getting our language built quickly, but over time it&#8217;s ended up holding us back. Adding new syntax is somewhere between difficult and nightmarish, but the new compiler addresses this- making it easier for us to add improvements. Once it&#8217;s in expect to see modules, mixins and other improvements finally cropping up.</p>
<p>A change that users will also see straight away is that syntax error messages are drastically improved!</p>
<h4>Open Sourcing</h4>
<p>We recently open sourced SkyBrush, the painting app which features as part of our IDE. We use a lot of open source technology here, so we&#8217;d like to give back to the community and offer up some of the cool things we&#8217;ve been building. <a href="https://github.com/PlayMyCode/SkyBrush" class="blueCharcoal bold">Go checkout SkyBrush on GitHub</a> if you want a painting application for your own site.</p>
<p>After SkyBrush, we also plan to open source our Quby language, plus the parser building library too. We&#8217;ve had a lot of people asking about using it for scripting in their own projects, as there aren&#8217;t many languages out there which compile to JS while offering sandboxing. We will announce when a stable version is online, so watch this space.</p>
<p>Finally, for those of you who do web development: we have a complete PHP MVC framework that we built for PMC, called Flexi. We built it as it allows us to do more with less code &#8211; and less configuration &#8211; than some of the other (still awesome) frameworks out there. Just like our other tools, there is no reason why we should be the only ones taking advantage of this.</p>
<p>Anyway, til next time&#8230; Follow <a href="http://www.twitter.com/playmycode" class="pink bold">@playmycode</a> on Twitter for the very latest news.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playmycode.com/blog/2012/05/updates-touch-controls-api-additions-teachers-notes-new-compiler-and-more/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Guardian Coverage, Play My Code Stickers, Global Game Jam and More</title>
		<link>http://www.playmycode.com/blog/2012/01/guardian-coverage-play-my-code-stickers-global-game-jam-and-more/</link>
		<comments>http://www.playmycode.com/blog/2012/01/guardian-coverage-play-my-code-stickers-global-game-jam-and-more/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 20:48:44 +0000</pubDate>
		<dc:creator>Seb</dc:creator>
				<category><![CDATA[Play My Code Announcements]]></category>

		<guid isPermaLink="false">http://www.playmycode.com/blog/?p=618</guid>
		<description><![CDATA[We&#8217;ve had an extremely busy couple of weeks, to say the least&#8230; Here&#8217;s some details on what we&#8217;ve been up to: Play My Code Mentioned on Guardian Newspaper Site We were mentioned on the website of popular UK broadsheet paper &#8230; <a href="http://www.playmycode.com/blog/2012/01/guardian-coverage-play-my-code-stickers-global-game-jam-and-more/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p></a><img src="http://www.playmycode.com/blog/wp-content/uploads/2012/01/stickers_horiz.png" alt="Play My Code Stickers" title="Play My Code Stickers" width="600" height="250" class="alignleft size-full wp-image-624" /></p>
<p>We&#8217;ve had an <em>extremely</em> busy couple of weeks, to say the least&#8230; Here&#8217;s some details on what we&#8217;ve been up to:</p>
<h4 class="pink">Play My Code Mentioned on Guardian Newspaper Site</h4>
<p><a href="http://www.guardian.co.uk/teacher-network/2012/jan/24/top-ten-computer-science-teaching-resources" class="blueCharcoal bold">We were mentioned</a> on the website of popular UK broadsheet paper The Guardian, in a piece written by the fantastic <a href="http://www.twitter.com/teknoteacher" class="blueCharcoal bold">@teknoteacher</a>. The article, a list of useful resources for teaching computer science, is an interesting read for anyone regardless of whether you&#8217;re a teacher, student, hacker or whatever- so go check it out. It&#8217;s an absolute honour to be mentioned in the same breath as the Royal Christmas Lectures, Twitter and the National Museum of Computing.</p>
<h4 class="pink">Want a Play My Code Sticker?</h4>
<p>We&#8217;ve had some gorgeous die-cut vinyl stickers done (see above picture), and we want you to have one too. If you&#8217;d like one then drop us a line- either email <a href="mailto:hello@playmycode.com" class="pink bold">hello@playmycode.com</a>, or send us a tweet and we&#8217;ll stick one in the post to you, absolutely free. Move quickly, stock is becoming quite scarce now!</p>
<h4 class="pink">Play My Code at Global Game Jam</h4>
<p>We spent most of last weekend at Millennium Point in Birmingham, developing a game for <a href="http://globalgamejam.org/" class="blueCharcoal bold">Global Game Jam 2012</a> based around the (slightly bizarre) theme of <a href="http://globalgamejam.org/news/2012/01/27/and-ggj-2012-theme" class="blueCharcoal bold">Ouroboros</a>, the serpent which symbolises the perpetual cycle of life, death and rebirth. Our response to this brief was <a href="http://www.playmycode.com/play/game/joe/ourobo-ware" class="blue bold">Ourobo Ware</a>, a WarioWare-inspired microgame collection themed around snakes, most of which want to swallow their own tails in one way or another, and we won a prize too! As of writing, our game has clocked up almost 1000 plays since it went live- play it below if you&#8217;ve not already.</p>
<p><iframe width="620" height="438" src="http://www.playmycode.com/play/embed/Joe/ourobo-ware" marginheight="0" marginwidth="0" scrolling="no" frameborder="0" style="border: none; border-size: 0; overflow: hidden; overflow-x: hidden; overflow-y: hidden;"></iframe></p>
<h4 class="pink">Play My Code at Hack to the Future</h4>
<p>We will be attending <a href="http://hackademy3.eventbrite.co.uk/" class="blueCharcoal bold">Hack to the Future</a> on Saturday February 18th, a BarCamp-style programming event for children which takes place at Our Lady&#8217;s High School, Preston. We&#8217;ll be manning a Play My Code zone, offering support to kids who&#8217;re just starting out with programming. Come say hi if you&#8217;re going!</p>
<h4 class="pink">Play My Code on Google Plus &#038; Elsewhere</h4>
<p>Play My Code Users on Google Plus: <a href="https://plus.google.com/110823409044093848964/" class="pink bold">we&#8217;ve set up a page for PMC</a>, add it to your circles! Don&#8217;t forget also that we&#8217;re on both <a href="http://www.facebook.com/playmycode" class="pink bold">Facebook</a> and <a href="http://www.twitter.com/playmycode" class="pink bold">Twitter</a>.</p>
<p>Anyway, that&#8217;s about it for the time being- we&#8217;re currently working hard on an update to Play My Code, so watch this space.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playmycode.com/blog/2012/01/guardian-coverage-play-my-code-stickers-global-game-jam-and-more/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Updates: New Front Page, Painter Fixes, and API Additions</title>
		<link>http://www.playmycode.com/blog/2012/01/updates-new-front-page-painter-fixes-and-api-additions/</link>
		<comments>http://www.playmycode.com/blog/2012/01/updates-new-front-page-painter-fixes-and-api-additions/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 15:13:09 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Play My Code Announcements]]></category>

		<guid isPermaLink="false">http://www.playmycode.com/blog/?p=591</guid>
		<description><![CDATA[We very recently rolled out a Play My Code update featuring additions to the API, keyboard shortcuts for our integrated paint application SkyBrush, a refreshed front page and a whole range of other bugfixes and tweaks. Read on for details&#8230; &#8230; <a href="http://www.playmycode.com/blog/2012/01/updates-new-front-page-painter-fixes-and-api-additions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We very recently rolled out a Play My Code update featuring additions to the API, keyboard shortcuts for our integrated paint application SkyBrush, a refreshed front page and a whole range of other bugfixes and tweaks. Read on for details&#8230;</p>
<h4>API Additions</h4>
<h5>Mouse Pressed &amp; Key Raised</h5>
<p>Long-time member <a class="bold blue" href="/play/user/Giorgio_Sotiro">Giorgio</a> suggested we add more methods for detecting the precise state of the mouse and keyboard. These come in the form of <a class="bold purple" href="http://www.playmycode.com/docs/reference/controls/controls-class/isleftpressed">isLeftPressed</a>, <a class="bold purple" href="http://www.playmycode.com/docs/reference/controls/controls-class/ismiddlepressed">isMiddlePressed</a>, <a class="bold purple" href="http://www.playmycode.com/docs/reference/controls/controls-class/isrightpressed">isRightPressed</a> and <a class="bold purple" href="http://www.playmycode.com/docs/reference/controls/controls-class/iskeyreleased">isKeyReleased</a>, and allow more precise control over how you detect user interaction. Click into each one for full details on how they work.</p>
<h5>setTransform &amp; transform functions</h5>
<p>Requested by <a class="bold blue" href="http://www.playmycode.com/play/user/krakatomato">Krakatomato</a> following his recent (excellent) 3D engine building experiment, we&#8217;ve added <a class="bold purple" href="http://www.playmycode.com/docs/reference/graphics/transformations/settransform">setTransform</a> and <a class="bold purple" href="http://www.playmycode.com/docs/reference/graphics/transformations/transform">transform</a> functions.</p>
<p> Also, check out just one of his wonderful demos below- find more in our <a href="/play/games/experiments" class="blue bold">experiments section</a>.</p>
<p><iframe width="620" height="438" src="http://www.playmycode.com/play/embed/krakatomato/3d-engine-rewritten" marginheight="0" marginwidth="0" scrolling="no" frameborder="0" style="border: none; border-size: 0; overflow: hidden; overflow-x: hidden; overflow-y: hidden;"></iframe></p>
<p>setTransform and transform are both intended for advanced users, and they allow manipulation of the &#8216;transformation matrix&#8217; used when drawing- this is what allows you to rotate, skew or scale graphics. setTransform replaces the current matrix, whilst transform applies the given matrix against the current matrix. Not to worry if you don&#8217;t understand this- it&#8217;s relatively advanced stuff.</p>
<h4>SkyBrush Keyboard Shortcuts</h4>
<p>As well as a range of bugfixes, we&#8217;ve spent a considerable amount of time adding keyboard shortcuts to SkyBrush, our (recently rebranded) integrated painting app. You can now switch to any tool using the keyboard, which makes life much easier for more experienced users.</p>
<p>The colour picker can be accessed by holding down the alt key, and some tools now have an alternate command through holding shift- for example, the zoom tool will zoom in the opposite direction, the pencil and brush will switch to the eraser, rectangles and circles will toggle between drawing outline or filled, and the line will change between smooth and pixelated.
</p>
<p>You can find a full list of the shortcuts <a class="bold purple" href="http://www.playmycode.com/docs/editor">right here</a>. Incidentally, SkyBrush was recently accepted as a <a class="bold blueCharcoal" href="http://www.chromeexperiments.com/detail/skybrush/">Chrome Experiment</a>!</p>
<p>We hope everyone likes the new changes, more will be coming from Play My Code over the rest of the year. Do please keep in touch via the <a href="/forum" class="red bold">forum</a> or <a href="http://www.twitter.com/playmycode" class="pink bold">@playmycode</a> on Twitter- we love hearing your suggestions and take note of every last scrap of feedback we receive.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playmycode.com/blog/2012/01/updates-new-front-page-painter-fixes-and-api-additions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Play My Code in Education?</title>
		<link>http://www.playmycode.com/blog/2012/01/play-my-code-in-education/</link>
		<comments>http://www.playmycode.com/blog/2012/01/play-my-code-in-education/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 09:50:28 +0000</pubDate>
		<dc:creator>Seb</dc:creator>
				<category><![CDATA[Play My Code Announcements]]></category>

		<guid isPermaLink="false">http://www.playmycode.com/blog/?p=580</guid>
		<description><![CDATA[It would seem that 2012 is shaping up to be a year of programming hitting mainstream education in the UK, with the Raspberry Pi finally gearing up for release and Michael Gove&#8217;s recent announcement that computer science will replace the &#8230; <a href="http://www.playmycode.com/blog/2012/01/play-my-code-in-education/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It would seem that 2012 is shaping up to be a year of programming hitting mainstream education in the UK, with the <a href="http://www.raspberrypi.org/" class="blueCharcoal bold">Raspberry Pi</a> finally gearing up for release and <a href="http://www.bbc.co.uk/news/education-16493929" class="blueCharcoal bold">Michael Gove&#8217;s recent announcement</a> that computer science will replace the useless ICT curriculum, under which the British bedroom coding tradition of the 1980s practically withered up and died. But pleasantly surprising is that Play My Code &#8211; a project conceived initially as little more than an easy way to make browser-based games &#8211; seems to be becoming a part of this.</p>
<p>Today, Preston-based Computer Science teacher Alan O&#8217;Donohoe (aka <a href="http://www.twitter.com/teknoteacher" class="blueCharcoal bold">@teknoteacher</a>) absolutely made our month by releasing some recordings of his pupils&#8217; experiences of using PMC:</p>
<p><object id="boo_embed_618092" width="400" height="129" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="scale" value="noscale" /><param name="salign" value="lt" /><param name="bgColor" value="#FFFFFF" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="window" /><param name="FlashVars" value="mp3=http%3A%2F%2Faudioboo.fm%2Fboos%2F618092-playmycode-pupils-first-impressions.mp3%3Fkeyed%3Dtrue%26source%3Dembed&amp;mp3Title=PlayMyCode+-pupils%27+first+impressions&amp;mp3Time=02.34pm+10+Jan+2012&amp;mp3LinkURL=http%3A%2F%2Faudioboo.fm%2Fboos%2F618092-playmycode-pupils-first-impressions&amp;mp3Author=teknoteacher&amp;rootID=boo_embed_618092" /><param name="src" value="http://abfiles.s3.amazonaws.com/swf/fullsize_player.swf" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="mp3=http%3A%2F%2Faudioboo.fm%2Fboos%2F618092-playmycode-pupils-first-impressions.mp3%3Fkeyed%3Dtrue%26source%3Dembed&amp;mp3Title=PlayMyCode+-pupils%27+first+impressions&amp;mp3Time=02.34pm+10+Jan+2012&amp;mp3LinkURL=http%3A%2F%2Faudioboo.fm%2Fboos%2F618092-playmycode-pupils-first-impressions&amp;mp3Author=teknoteacher&amp;rootID=boo_embed_618092" /><embed id="boo_embed_618092" width="400" height="129" type="application/x-shockwave-flash" src="http://abfiles.s3.amazonaws.com/swf/fullsize_player.swf" scale="noscale" salign="lt" bgColor="#FFFFFF" allowScriptAccess="always" wmode="window" FlashVars="mp3=http%3A%2F%2Faudioboo.fm%2Fboos%2F618092-playmycode-pupils-first-impressions.mp3%3Fkeyed%3Dtrue%26source%3Dembed&amp;mp3Title=PlayMyCode+-pupils%27+first+impressions&amp;mp3Time=02.34pm+10+Jan+2012&amp;mp3LinkURL=http%3A%2F%2Faudioboo.fm%2Fboos%2F618092-playmycode-pupils-first-impressions&amp;mp3Author=teknoteacher&amp;rootID=boo_embed_618092" allowscriptaccess="always" flashvars="mp3=http%3A%2F%2Faudioboo.fm%2Fboos%2F618092-playmycode-pupils-first-impressions.mp3%3Fkeyed%3Dtrue%26source%3Dembed&amp;mp3Title=PlayMyCode+-pupils%27+first+impressions&amp;mp3Time=02.34pm+10+Jan+2012&amp;mp3LinkURL=http%3A%2F%2Faudioboo.fm%2Fboos%2F618092-playmycode-pupils-first-impressions&amp;mp3Author=teknoteacher&amp;rootID=boo_embed_618092" /></object></p>
<p>The implication seems to be that children especially enjoy hacking, forking and modifying code to see what makes it tick, with the suggestion that the user is &#8220;allowed&#8221; to do this on Play My Code being particularly profound in a world which some might argue is <a href="http://boingboing.net/2011/12/27/the-coming-war-on-general-purp.html" class="blueCharcoal bold">rapidly being closed off</a> as far as open computing is concerned. I might be so bold as to compare it to when I was young, breaking open my toys to see what was inside. (PS, we&#8217;ll be getting search in there as soon as we can guys!)</p>
<p>We should also mention that @teknoteacher is involved in organising <a href="http://hackademy3.eventbrite.co.uk/" class="blueCharcoal bold">Hack to the Future</a> &#8211; a Barcamp-style event aimed at children who want to learn programming &#8211; which takes place at Our Lady&#8217;s High School in Preston on February 11th. More details <a href="http://hackademy3.eventbrite.co.uk/" class="blueCharcoal bold">here</a>, apparently there are still limited tickets left for groups of pupils.</p>
<p>Meanwhile, BBC researcher <a href="http://www.twitter.com/sparks_rd" class="blueCharcoal bold">@sparks_rd</a> warmed our hearts with the following tweet: &#8220;Well, @playmycode passes the &#8216;can they (8 &amp; 9 year olds) just get on and make games test&#8217;. Will be making some tutorials over xmas methinks&#8221; <a href="https://twitter.com/sparks_rd/status/147763466726416384" class="blueCharcoal bold">(link to tweet)</a>. The prospect of our site being used as a learning tool by minds so young and inquisitive is genuinely amazing, and the fact that young kids  are taking to it so easily certainly reassures us that PMC is as easy to use as we intended.</p>
<p>Finally, the slightly more mysterious <a href="http://www.playmycode.com/play/user/curtos" class="blue bold">Curtos</a> has also been using Play My Code as a teaching aid, having created a basic yet nicely-written, fully commented Pong game for his class of high schoolers. Do <a href="http://www.playmycode.com/build/edit/708" class="green bold">check it out</a> if you&#8217;re learning the ropes, as it&#8217;s a very good example with plenty of room to take things further- fork it and see what you can do. In fact, this was used as the basis of another of @teknoteacher&#8217;s lessons:</p>
<p><object data="http://abfiles.s3.amazonaws.com/swf/fullsize_player.swf" height="129" id="boo_embed_619439" type="application/x-shockwave-flash" width="400"><param name="movie" value="http://abfiles.s3.amazonaws.com/swf/fullsize_player.swf" /><param name="scale" value="noscale" /><param name="salign" value="lt" /><param name="bgColor" value="#FFFFFF" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="window" /><param name="FlashVars" value="mp3=http%3A%2F%2Faudioboo.fm%2Fboos%2F619439-extracts-from-year-7-computing-lesson-play-my-code-playmycode.mp3%3Fkeyed%3Dtrue%26source%3Dembed&amp;mp3Title=Extracts+from+Year+7+Computing+lesson+%27Play+My+Code%27+%40playmycode&amp;mp3Time=12.25pm+11+Jan+2012&amp;mp3LinkURL=http%3A%2F%2Faudioboo.fm%2Fboos%2F619439-extracts-from-year-7-computing-lesson-play-my-code-playmycode&amp;mp3Author=teknoteacher&amp;rootID=boo_embed_619439" /><a href="http://audioboo.fm/boos/619439-extracts-from-year-7-computing-lesson-play-my-code-playmycode.mp3?keyed=true&amp;source=embed">Extracts from Year 7 Computing lesson &#8220;Play My Code&#8221; @playmycode (mp3)</a></object></p>
<p>All of this has left us wondering: what is Play My Code, and where do we take things from here? We originally intended to create a &#8220;YouTube of games&#8221; of sorts, and rather short-sightedly never even considered the possibility of it being used as an educational tool. We&#8217;ll certainly be thinking about the direction things will be taking from here on in.</p>
<p>One thing we do know is: if you&#8217;re reading this, are an educator and are interested in using Play My Code as part of your class, please do get in touch via <a href="http://www.twitter.com/playmycode" class="pink bold">Twitter</a>, the <a href="http://www.playmycode.com/forum" class="red bold">forum</a> or just drop me a line at <a href="mailto:seb@playmycode.com" class="pink bold">seb@playmycode.com</a>- we would be both thrilled &amp; honoured to offer any help and support we can.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playmycode.com/blog/2012/01/play-my-code-in-education/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
<enclosure url="http://audioboo.fm/boos/619439-extracts-from-year-7-computing-lesson-play-my-code-playmycode.mp3?keyed=true&amp;amp" length="0" type="audio/mpeg" />
		</item>
		<item>
		<title>Huge Update: Painter, Full Screen IDE, Optimisations and More</title>
		<link>http://www.playmycode.com/blog/2011/12/huge-update-painter-full-screen-ide-optimisations-and-more/</link>
		<comments>http://www.playmycode.com/blog/2011/12/huge-update-painter-full-screen-ide-optimisations-and-more/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 18:52:36 +0000</pubDate>
		<dc:creator>Seb</dc:creator>
				<category><![CDATA[Play My Code Announcements]]></category>

		<guid isPermaLink="false">http://www.playmycode.com/blog/?p=560</guid>
		<description><![CDATA[Hello! We&#8217;re back, with a major addition to Play My Code which cements its position as a one-stop-shop for browser game creation, as well as a usual collection of slightly more minor language refinements, bugfixes and optimisations. Integrated Painting Application &#8230; <a href="http://www.playmycode.com/blog/2011/12/huge-update-painter-full-screen-ide-optimisations-and-more/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hello! We&#8217;re back, with a major addition to Play My Code which cements its position as a one-stop-shop for browser game creation, as well as a usual collection of slightly more minor language refinements, bugfixes and optimisations.</p>
<h4>Integrated Painting Application</h4>
<p><img src="http://www.playmycode.com/blog/wp-content/uploads/2011/12/painter_screen.png" alt="Play My Code Integrated Painting Application" title="Play My Code Integrated Painting Application" width="600" height="365" class="alignnone size-full wp-image-570" /></p>
<p>Play My Code&#8217;s suite of tools now includes a full, integrated art package for creating and editing assets, meaning those of you not lucky enough to have access to decent graphic tools can now create assets directly in your browser.</p>
<p>The art package &#8211; known simply as &#8216;Painter&#8217; &#8211; is fully-featured and comes with a variety of graphic tools including brushes, primitive shapes, undo/redo and zoom, whilst assets of any dimensions can be created and edited.</p>
<p>Painter can be found in the IDE, via the assets pane- you should notice the addition of a New button next to the existing image upload tools, whilst there are also controls to edit any uploaded assets. Once inside, you can create, edit and save assets to your heart&#8217;s content. The tools should be pretty familiar to anyone who&#8217;s used a basic art package, plus don&#8217;t forget <a href="/build/sandbox" class="green bold">you can try the IDE and Painter</a> without even signing up for an account.</p>
<p>We hope you find this new addition useful and inspirational. We intend to keep adding &#038; refining features over time, and would love to know your thoughts- please leave any feedback, problems and suggestions in <a class="red bold" href="/forum/topic/61">this forum thread right here</a>.</p>
<h4>Fullscreen IDE</h4>
<p>We&#8217;ve made a much-requested improvement to our IDE: the code area now expands, to fill the otherwise empty space at the sides on large monitors. Hopefully writing code should now feel a bit less claustrophobic.</p>
<p><span id="more-560"></span></p>
<h4>Play My Code on Facebook</h4>
<p>Play My Code now has a Facebook page, at <a href="http://www.facebook.com/playmycode" class="pink bold">http://www.facebook.com/playmycode</a>. Check it out &amp; give us a like!</p>
<h4>API Additions</h4>
<p>As usual, we&#8217;ve made a number of additions &amp; refinements to the API.</p>
<h5>Easier 2D Arrays</h5>
<p>As requested on our forums, we&#8217;ve made some changes to the way 2D arrays are created. It&#8217;s now as easy as this:</p>
<pre>
grid = new Array( width, height )
</pre>
<h5>Array.fill</h5>
<p>A new fill method for the array, to replace all, or just some, of the elements already contained within the array. It can also be useful for padding an array out with a new element.</p>
<pre>
ns = [ 1, 2, 3, 4, 5 ]
ns.fill( 6 )

// prints out [ 6, 6, 6, 6, 6 ]
console( ns )
</pre>
<p>Find more info about arrays in the <a href="/docs/reference/core/array-class" class="purple bold">Array Class documentation</a>.</p>
<h5>Blocks for Mouse Click &amp; Down</h5>
<p>When you check if the mouse button is clicked or down, it&#8217;s common to also want to check the mouse location. To make this a little easier, you can now attach a block onto isLeftClick, isMiddleClick, isRightClick, isLeftDown, isMiddleDown and isRightDown. In all cases, the block is only called if the method would return true (if the mouse is clicked or down), and passes the mouse x and y location into the block.</p>
<pre>
/* Moves the player to the current mouse location,
 * when the mouse button is down. */
getControls().isLeftDown() do |x, y|
    player.setLocation( x, y )
end
</pre>
<p>More information about everything to do with mouse control can be found in the <a href="http://pmc.localhost/docs/reference/controls/controls-class" class="purple bold">Controls Class documentation</a>. </p>
<h5>controls.getMouseXY</h5>
<p>You can now retrieve the mouse x &#038;amp y location using a block, via the getMouseXY method:</p>
<pre>
getControls().getMouseXY() do |x, y|
    // use the x and y location here
end
</pre>
<p>More info about this can be found <a href="docs/reference/controls/controls-class/getmousexy" class="purple bold">here</a>.</p>
<h4>Optimisations</h4>
<p>Play My Code is quicker than ever before, thanks to a load of optimisations and improvements. Amongst other improvements, image tinting is now around 6 times faster than it was before, whilst speed has improved across the board when playing PMC games in Google Chrome.</p>
<p>That&#8217;s about it for now: as ever, feel free to drop us a line if you have any feedback or suggestions on the above or any other aspect of Play My Code. Leave a comment on this post, <a href="/forum" class="red bold">drop us a line via the forums</a> or send a tweet to <a href="http://www.twitter.com/playmycode" class="pink bold">@playmycode on Twitter</a>. See you soon, and happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playmycode.com/blog/2011/12/huge-update-painter-full-screen-ide-optimisations-and-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updates: Forking &amp; Copying, Experiments Section, Language Improvements and More</title>
		<link>http://www.playmycode.com/blog/2011/10/updates-forking-copying-experiments-section-language-improvements-and-more/</link>
		<comments>http://www.playmycode.com/blog/2011/10/updates-forking-copying-experiments-section-language-improvements-and-more/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 17:55:45 +0000</pubDate>
		<dc:creator>Seb</dc:creator>
				<category><![CDATA[Play My Code Announcements]]></category>

		<guid isPermaLink="false">http://www.playmycode.com/blog/?p=530</guid>
		<description><![CDATA[Our latest update is out and ready, including project copying &#038; forking, a new Experiments section intended for demo and test projects, plus language additions &#038; improvements as well as a round of under-the-hood improvements. Forking &#038; Copying Projects First &#8230; <a href="http://www.playmycode.com/blog/2011/10/updates-forking-copying-experiments-section-language-improvements-and-more/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Our latest update is out and ready, including project copying &#038; forking, a new Experiments section intended for demo and test projects, plus language additions &#038; improvements as well as a round of under-the-hood improvements.</p>
<h4>Forking &#038; Copying Projects</h4>
<p>First off, Play My Code projects can now be copied and forked; highly-requested features useful not just for those who like to build multiple games from a common codebase (such as <a href="/play/user/jayenkai" class="blue bold">Jayenkai</a>) but also for users who like to modify and extend the creations of others.</p>
<p>Copying works pretty much as one might imagine: clicking the Copy button (found alongside any of your projects on the My Games page) will create a new copy of that project &#8211; code, assets and all. &#8216;Forking&#8217; refers to the copying of projects written by others, enabling users to create their own version of someone else&#8217;s code to modify as they see fit. The Fork button can be found underneath any game on the site. Currently, any project on Play My Code can be forked, but those worried about their work being &#8220;ripped off&#8221; should be pleased to know that the original source is quoted on a forked project.</p>
<h4>Experiments Section</h4>
<p>Play My Code is primarily built for creating and sharing games, the intention being to create the world&#8217;s biggest user-generated gaming portal &#8211; however, lots of users write tests, demos and experimental code which doesn&#8217;t really fit in with the &#8220;finished&#8221; titles one currently finds on the Play page. Currently there&#8217;s no way to easily browse through these projects, so we&#8217;ve added an Experiments section to the Play page which will enable experimental projects to gain more recognition.</p>
<p>This ties into project forking too &#8211; users may find an effect or test which they wish to study or use in their own game. To enable your code to appear in the Experiments section, set it as &#8220;Experiment&#8221; from the drop-down menu on the My Games page. The Experiment category replaces the Demo category, so any project currently previously set as Demo will appear in the Experiments section automatically.</p>
<h4>new Array( size )</h4>
<p>A common case for writing code is to build a new array, pre-initialized with a number of elements. Until now you&#8217;ve had to do this yourself, but with this update Arrays now have proper constructors. There are several ways you can use them.</p>
<p>The first way is to just pass in a size when you create an Array, and all elements will be initialized to &#8216;null&#8217;.</p>
<pre>// make an Array containing 5 nulls
// old way
arr = [ null, null, null, null, null ]

// new way
arr = new Array( 5 )</pre>
<p>What if you don&#8217;t want to default each element to &#8216;null&#8217;? You can pass the default value in as the second argument:</p>
<pre>// creates the array: [ 0, 0, 0, 0, 0 ]
ns = new Array( 5, 0 )</pre>
<p>Finally, you can also attach a block and initialize each element using that, for more advanced cases:</p>
<pre>images = new Array( 5 ) do |i|
    return new Image( 'player_animation_' + i + '.png' )
end</pre>
<p>Full documentation on Array constructors is available <a href="/docs/reference/core/array-class/new" class="purple bold">here</a>.</p>
<p><span id="more-530"></span></p>
<h4>array.random()</h4>
<p>Another feature for arrays is the &#8216;random&#8217; element. This will return a random entry from the array. This is useful for retrieving a random enemy factory, a random image, or some other random value from a collection.</p>
<pre>tetrisBlocks = [ squareBlock, iBlock, jBlock,
        lBlock sBlock, tBlock, zBlock ]

nextBlock = tetrisBlocks.random()</pre>
<p>You can find documentation about this <a href="/docs/reference/core/array-class/random" class="purple bold">here</a>.</p>
<h4>Multi-line String improvements</h4>
<p>We have always supported multi-line strings, using the &#8216;\n&#8217; character. However, using the enter key has not been supported until now:</p>
<pre>text = "A multi line
string that
is spread over
multiple
lines"</pre>
<h4>Delta Time Improvements</h4>
<p>The delta time value retrieved has previously been a little hackish, often jumping around wildly, and sometimes this can mess up games. So we&#8217;ve looked at this and added maximum/minimum bounds, so the delta time no longer jumps to extremes. This will make any game currently using delta time much more stable.</p>
<h4>getDelta()</h4>
<p>We&#8217;ve also streamlined how you can work with delta time. Currently, you can get the delta time using the &#8216;onEachFrame&#8217; function:</p>
<pre>onEachFrame() do |delta|
    // pass delta in to other parts of the game
    updatePlayer( delta )
    updateEnemies( delta )
    updateBullets( delta )
end</pre>
<p>However, you then need to pass this into any function or method that uses delta time, and this can be annoying. To improve this, we&#8217;ve added the <a href="/docs/reference/utility/getdelta" class="purple bold">getDelta</a> function for retrieving the delta time for the current frame anywhere.</p>
<pre>x = x + speedY*getDelta()
    y = y + speedY*getDelta()</pre>
<p>This is the same value as the &#8216;delta&#8217; value you can retrieve from &#8216;onEachFrame&#8217;. Find full documentation <a href="/docs/reference/utility/getdelta" class="purple bold">here</a>.</p>
<h4>multAlpha( alpha )</h4>
<p>When using multiple nested &#8216;setAlpha&#8217; blocks, you often want to have the alpha value depend on the outside one. For example:</p>
<pre>setAlpha( fade ) do
    setAlpha( 0.3*getAlpha() ) do
        drawShadows()
    end
    setAlpha( 1*getAlpha() ) do
        drawPlayer()
    end
    setAlpha( 0.8*getAlpha() ) do
        drawHealth()
    end
end</pre>
<p>Here, the inner sections will draw at their own alpha values, multiplied against the outer &#8216;fade&#8217; value, which is retrieved using &#8216;getAlpha&#8217;. To make that a little more terse, &#8216;multAlpha&#8217; will do that multiplication for you.</p>
<pre>setAlpha( fade ) do
    multAlpha( 0.3 ) do
        drawShadows()
    end
    multAlpha( 1 ) do
        drawPlayer()
    end
    multAlpha( 0.8 ) do
        drawHealth()
    end
end</pre>
<p>It makes juggling alpha values a little easier. Find the documentation <a href="/docs/reference/graphics/multalpha" class="purple bold">here</a>.</p>
<h4>timer.onExpire()</h4>
<p>We provide a Timer class to help build animations. It allows you to retrieve a value whilst the timer lives. However, it&#8217;s very common that you want to perform an action when the Timer ends, and currently you have to manually check for this and perform the appropriate action yourself. To make this easier, we&#8217;ve added the &#8216;onExpire&#8217; method.</p>
<pre>color = :blue

// In 1 second,
// change the colour from blue to red.
t = new Timer( 1000 ).onExpire() do
    color = :red
end

onEachFrame() do
    fill( :black )
    
    setColor( color ) do
        fillRect( 100, 100, 50, 50, true )
    end
end</pre>
<p>You can find the documentation for this <a href="/docs/reference/utility/timer-class/onexpire" class="purple bold">here</a>. onExpire can also be cancelled, and the method to do this is documented <a href="/docs/reference/utility/timer-class/cancelexpires" class="purple bold">here</a>.</p>
<h4>Bugfixes and Tweaks</h4>
<p>We&#8217;ve made many and various bugfixes, tweaks and optimisations with this release, including:</p>
<ul>
<li>If statements are now faster</li>
<li>Scaling drawRotatedImage() would sometimes crash &#8211; fixed</li>
<li>Some documentation layout bugs fixed</li>
<li>Some IE9 CSS bugs fixed</li>
<li>The Number.wrap() method didn&#8217;t work under certain circumstances &#8211; fixed</li>
<li>Some Asset Manager corner case bugs have been fixed alongside some subtle tweaks, making it slightly nicer to use</li>
<li>If .play() is called on a sound which is still playing, it will retrigger it without .stop() needing to be called first</li>
<li>Number.toString() now works as advertised, rather than returning a string with the value &#8216;Number&#8217; as it did before</li>
<li>Error messages in the IDE have been improved</li>
<li>Opera-specific bug where a crash could occur when manipulating an image&#8217;s pixels &#8211; fixed</li>
</ul>
<p>As always, we greatly value your feedback and input when it comes to updates and improvements &#8211; leave a comment on this post, send <a href="http://www.twitter.com/playmycode" class="pink bold">@playmycode</a> a tweet, leave a post on <a href="/forum" class="red bold">our forum</a> or use the feedback form to drop us a line (find the tab on the left-hand side of the screen) if you&#8217;ve got any suggestions or impressions. Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playmycode.com/blog/2011/10/updates-forking-copying-experiments-section-language-improvements-and-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update: API Additions, Bug Fixes</title>
		<link>http://www.playmycode.com/blog/2011/10/update-api-additions-bug-fixes/</link>
		<comments>http://www.playmycode.com/blog/2011/10/update-api-additions-bug-fixes/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 21:30:35 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Play My Code Announcements]]></category>

		<guid isPermaLink="false">http://www.playmycode.com/blog/?p=501</guid>
		<description><![CDATA[Following our last major release, we&#8217;ve rolled out an incremental update which includes a few handy API additions we didn&#8217;t have time to get out the door last time &#8217;round, as well as some extra polish and a number of &#8230; <a href="http://www.playmycode.com/blog/2011/10/update-api-additions-bug-fixes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following our last major release, we&#8217;ve rolled out an incremental update which includes a few handy API additions we didn&#8217;t have time to get out the door last time &#8217;round, as well as some extra polish and a number of bug fixes.</p>
<h4>Controls Class: getKeysDown() &amp; getKeysPressed()</h4>
<p>One can check if a key is down, but what if you want to get the names of the currently pressed keys? The new Controls class methods getKeysDown() and getKeysPressed() make this a snap. </p>
<pre>
    controls = getControls()

    // an array of keys which are currently down
    down = controls.getKeysDown()
    
    // an array of keys pressed on this frame only
    pressed = controls.getKeysPressed()
</pre>
<p>Test the new functionality in the demo below (<a href="/build/edit/423" class="green bold">code here</a>):</p>
<p><iframe width="620" height="438" src="/play/embed/Joe/keys-down-or-pressed" marginheight="0" marginwidth="0" scrolling="no" frameborder="0" style="border: none; border-size: 0; overflow: hidden; overflow-x: hidden; overflow-y: hidden;"></iframe></p>
<p>More info about both of these can be found in the docs: <a href="/docs/reference/controls/controls-class/getkeysdown" class="purple bold">getKeysDown</a> and <a href="/docs/reference/controls/controls-class/getkeyspressed" class="purple bold">getKeysPressed</a>. These are perfect if you&#8217;re planning on building a typing game!</p>
<h4>Number Class: Wrap</h4>
<p>Often, you might want to build a game world where going off the side of the screen makes you reappear on the opposite side. You can call this &#8216;wrapping&#8217; or &#8216;rolling&#8217; over the edge. Another case when you need to do this: when you want to either add or subtract from an array index, and again have it wrap over either edge so it doesn&#8217;t go out of bounds.</p>
<p>Whilst one could use modulus (the % symbol) to ensure values wrap within certain bounds, the <a href="/docs/reference/core/number-class/wrap" class="purple bold">wrap</a> method makes this a lot easier to understand and use.</p>
<pre>
    x = 800
    // x will roll over either edge
    x.wrap( 0, getScreenWidth() )
</pre>
<p>If the number is less or greater than the range given, than a value which wraps around that range is returned.</p>
<h4>Segments &amp; Inner Segments</h4>
<p>Finally, we&#8217;ve added some more sets of drawing functions, both for drawing to the screen as well as for drawing on images. <a href="/docs/reference/graphics/drawsegment" class="purple bold">drawSegment</a> and <a href="/docs/reference/graphics/fillsegment" class="purple bold">fillSegment</a> are used for drawing a segment (or sector) of a circle.</p>
<p>We&#8217;ve also added <a href="/docs/reference/graphics/drawinnersegment" class="purple bold">drawInnerSegment</a> and <a href="/docs/reference/graphics/fillinnersegment" class="purple bold">fillInnerSegment</a>. These allow you to draw a segment where the inner section is cleared out, like a wide arc. Check out the example below for a demonstration (<a href="/build/edit/403" class="green bold">code here</a>):</p>
<p><iframe width="620" height="438" src="http://www.playmycode.com/play/embed/Joe/a-simple-clock" marginheight="0" marginwidth="0" scrolling="no" frameborder="0" style="border: none; border-size: 0; overflow: hidden; overflow-x: hidden; overflow-y: hidden;"></iframe></p>
<p>As always, if you&#8217;ve any suggestions or feedback then do please let us know via <a href="/forum" class="red bold">our forums</a>, <a href="http://www.twitter.com/playmycode" class="pink bold">@playmycode on Twitter</a> or via the Feedback tab you&#8217;ll find at the top left of this page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playmycode.com/blog/2011/10/update-api-additions-bug-fixes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updates: In-API Docs, Game Comments, New API Features and Much More</title>
		<link>http://www.playmycode.com/blog/2011/09/updates-in-api-docs-game-comments-new-api-features-and-much-more/</link>
		<comments>http://www.playmycode.com/blog/2011/09/updates-in-api-docs-game-comments-new-api-features-and-much-more/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 16:42:55 +0000</pubDate>
		<dc:creator>Seb</dc:creator>
				<category><![CDATA[Play My Code Announcements]]></category>

		<guid isPermaLink="false">http://www.playmycode.com/blog/?p=486</guid>
		<description><![CDATA[Following a huge amount of work, we&#8217;ve just rolled out one of our biggest updates yet: taking in an overhauled docs system, game comments, API additions &#38; improvements and much more. In-IDE Documentation Developers can now access a reference to &#8230; <a href="http://www.playmycode.com/blog/2011/09/updates-in-api-docs-game-comments-new-api-features-and-much-more/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following a huge amount of work, we&#8217;ve just rolled out one of our biggest updates yet: taking in an overhauled docs system, game comments, API additions &amp; improvements and much more.</p>
<h4>In-IDE Documentation</h4>
<p>Developers can now access a reference to the Quby language and Play My Code API, right from the build page IDE- just click the Reference button in the top-right corner on the IDE page. The documentation can be shown and hidden at will without you losing your place, whilst there&#8217;s also an Index button providing an easy-to-browse list of sections. We&#8217;ve only had the time to implement the Quby and API reference so far, but are looking to improve upon this in the coming months, streamlining it while adding more in the way of general guides and tutorials. Let us know what you think, and what improvements and additions might be useful.</p>
<p>On top of this, we&#8217;ve also overhauled the way the language and API reference in the regular <a href="/docs" class="purple bold">Docs section</a> is organised. No longer all dumped onto one page, we&#8217;ve broken everything down into neat little individual sections and pages. Not only this, but we&#8217;ve rewritten a fair bit of it too, adding examples and in some cases snippets of code which can be copy-pasted and run there and then.</p>
<p>We hope that these changes will make Play My Code more accessible for beginners, as well as more convenient for the more experienced developers out there- again, please do let us know what you think. <a href="/forum/topic/43" class="red bold">We&#8217;ve begun a thread on our forums regarding the new documentation</a>, so if you find any bugs or errors then please post away.</p>
<h4>Game Comments</h4>
<p>Registered users can now leave comments and feedback on any game. If you&#8217;ve enjoyed a particular title (or perhaps not!), be sure to let the game author know with a comment. On any game&#8217;s page you will find a form beneath the game which allows you to post comments. We&#8217;ve also got a notification system in the pipeline to inform developers when someone has commented on their game, hopefully this will be present in the next update.</p>
<h4>Syntax Error Highlighting</h4>
<p>The IDE now features a system which will catch certain syntax errors, highlighting them in red as you type. While it&#8217;s not 100% foolproof it will catch obvious errors such as unclosed strings, meaning less frustration and time wasted looking for mistyped characters. We hope it proves useful.</p>
<h4>setBlend</h4>
<p>One of our more requested additions is the ability to alter how colours are blended. With <a href="/docs/api/graphics/setblend" class="purple bold">setBlend</a>, one can now mix colours using additive blending- adding colour to the target rather than merely using the alpha value as the default blending mode does.</p>
<p>It also supports &#8216;clear&#8217; and &#8216;stencil&#8217; modes, which are useful for drawing on images. Using these, the standard drawing commands become clear commands. This means anything you can draw to an image (rectangles, circles, lines, polygons or even other images) can also be erased from that image, leaving the area transparent. This is useful for building very complex overlays, such as cloud, fog and darkness effects.</p>
<p>Find more information about setBlend <a href="/docs/api/graphics/setblend" class="purple bold">right here</a>.</p>
<p><span id="more-486"></span></p>
<h4>Timer Class</h4>
<p>One of the big issues in games is time. When should a period of time expire (like the time for reloading a gun)? And how do you animate between the start and the end of that period? These are both problems that the <a href="/docs/api/utility/timer-class" class="purple bold">Timer class</a> aims to solve.</p>
<p>When you create a Timer object, you pass in how long it will last, in milliseconds. It will start a timer right now, the moment it is created, and will expire once that amount of time has (approximately) passed. How accurate this is depends on your browser.</p>
<pre>
    // a timer that lasts 2 seconds
    t = new Timer( 2000 )
</pre>
<p>Calling <a href="/docs/api/utility/timer-class/isexpired" class="purple bold">isExpired</a> allows you to check if the 2 seconds has passed yet, allowing you to decide what to do based on that.</p>
<p>Next, you might want to have an animation between now and when it expires. For this you can get a &#8216;percent&#8217;, which returns how far the duration is along the timer&#8217;s lifetime. This is a value from 0.0, to 1.0, and can be retrieved using <a href="/docs/api/utility/timer-class/getpercent" class="purple bold">getPercent</a> (or <a href="/docs/api/utility/timer-class/getpercent" class="purple bold">getPercentLeft</a> for the inverse). In turn, you can multiply this value against locations, colours, alpha values or anything else to create an animation which moves from the beginning to the moment the Timer expires.</p>
<pre>
    /**
     * Counts down, and then shows the timer expired.
     */
    message = "EXPIRED! Click to Reset."
    t = new Timer( 4000 )
    
    onEachFrame() do |delta|
        fill( :black )
        
        if t.isExpired()
            setColor( :red )
            fillText( message, getScreenWidth()/2, getScreenHeight()/2, true )
            
            if getControls().isLeftClick()
                t.reset()
            end
        else
            setColor( :white ) do
                fillText( t.getDurationLeft(), getScreenWidth()/2, getScreenHeight()/2, true )
            end
        end
    end
</pre>
<p>Finally, it uses <a href="/docs/api/utility/gettime" class="purple bold">getTime</a> internally &#8211; the in-game timer &#8211; which you can also use as a low-level alternative to the Timer class. As it&#8217;s using the real time, no delta values are required so it will be accurate regardless of the current frame rate. You can also reset timers, allowing you to re-use them.</p>
<h4>Min &amp; Max on Sin, Cos and Tan</h4>
<p>The <a href="/docs/api/core/number-class/sin" class="purple bold">Sin</a>, <a href="/docs/api/core/number-class/cos" class="purple bold">Cos</a> and <a href="/docs/api/core/number-class/tan" class="purple bold">Tan</a> methods can now take two values as a range for the result to fall between. For example, you might want to have a wave between 0.0 and 1.0 for animating an alpha value; this makes it easier for you. Cos and Tan feature the same functionality.</p>
<p>Lets say you wanted to animate an alpha value, based on a sine wave. Sine waves go from -1.0 to 1.0, and we are moving this to a range of 0.0 to 1.0 (the range for alpha values). Normally, the maths to do this is:</p>
<pre>
    alpha = 0.5 + 0.5*angle.sin()
</pre>
<p>The above is quite hacky, and doesn&#8217;t express what we are doing. With the new sin method this can be changed to:</p>
<pre>
    alpha = angle.sin( 0.0, 1.0 )
</pre>
<p>This clearly shows we want it between a range of 0.0 and 1.0. Further if we want to change this to be a wave between 0.3 and 1.0, then you just update it accordingly:</p>
<pre>
    alpha = angle.sin( 0.3, 1.0 )
</pre>
<p>The maths is all handled for you.</p>
<p><a href="/docs/api/core/number-class" class="purple bold">Please check out the documentation</a> for more info and examples.</p>
<h4>Chainable Image Methods</h4>
<p>Image methods are now chainable, in a manner you might be used to if you use jQuery. For example:</p>
<pre>img = new Image( 500, 500 )
img.fill( :white ).
        setColor( :pink ).fillRect( 10, 10, 100, 100 ).
        setColor( :red ).fillCircle( 100, 100, 80, true )
</pre>
<p>You don&#8217;t <i>have</i> to go as overboard and chain 5 or more commands right after each other, but this is a useful addition for making those common tasks a little shorter.</p>
<h4>Until Next Time&#8230;</h4>
<p>We&#8217;ve always got new features in the pipeline- if there&#8217;s something you would like to suggest then please drop us a line. And as always, let us know what you think of our latest update: leave a comment with your thoughts, post a message to our forums, tweet us at <a href="http://www.twitter.com/playmycode" class="pink bold">@playmycode</a> on Twitter or drop an email to <a href="mailto:hello@playmycode.com" class="pink bold">hello@playmycode.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playmycode.com/blog/2011/09/updates-in-api-docs-game-comments-new-api-features-and-much-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updates: Game Descriptions and Bug Fixes</title>
		<link>http://www.playmycode.com/blog/2011/08/updates-game-descriptions-and-bug-fixes/</link>
		<comments>http://www.playmycode.com/blog/2011/08/updates-game-descriptions-and-bug-fixes/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 23:39:05 +0000</pubDate>
		<dc:creator>Seb</dc:creator>
				<category><![CDATA[Play My Code Announcements]]></category>

		<guid isPermaLink="false">http://www.playmycode.com/blog/?p=479</guid>
		<description><![CDATA[A small yet very important update for you all this week: we&#8217;ve finally implemented game descriptions into Play My Code. On your Build page you will notice that the &#8220;Rename&#8221; button alongside any and all of your games has now &#8230; <a href="http://www.playmycode.com/blog/2011/08/updates-game-descriptions-and-bug-fixes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A small yet very important update for you all this week: we&#8217;ve finally implemented game descriptions into Play My Code. On your Build page you will notice that the &#8220;Rename&#8221; button alongside any and all of your games has now become &#8220;Details&#8221;, and in here you can enter a description for your games.</p>
<p>This is important, as you can use this not just to flesh out any plot or background for your game but also to provide instructions, eliminating any risk of the player not understanding how to play and thus potentially increasing the amount of exposure your game will receive- no-one wants to play a game they can&#8217;t understand, after all.</p>
<p>So, make sure to log in and get your game descriptions filled out and up-to-date &#8211; your play count will thank you for it.</p>
<h4>API Changes &amp; Bug Fixes</h4>
<p>We made a minor change to the API, adding the ability to enter newlines into text. Entering \n into a text string where you want the newline to be will trigger this. We&#8217;ve applied a few bug fixes too &#8211; <a href="/docs/api#s_collisions_iscircleoverlap_6" class="purple bold">isCircleOverlap</a> now works as advertised, <a href="/docs/api#s_graphics_image_drawRoundedRect_4" class="purple bold">drawRoundedRect</a> now centres like it should and the reset password form has been rebuilt as a couple of bugs stopped it from working properly. Apologies to anyone who might have tried, and failed, to reset their password due to this.</p>
<p>As ever, please do bring any bugs you find to our attention via the <a href="/forum" class="red bold">forums</a>, the feedback tab on the left side of every page, or <a href="http://www.twitter.com/playmycode" class="pink bold">@playmycode</a> on Twitter. Meanwhile, it&#8217;s back to work for us- we&#8217;ve got some big new features in the pipeline. Until next time&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playmycode.com/blog/2011/08/updates-game-descriptions-and-bug-fixes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Game Mainloop in JavaScript</title>
		<link>http://www.playmycode.com/blog/2011/08/building-a-game-mainloop-in-javascript/</link>
		<comments>http://www.playmycode.com/blog/2011/08/building-a-game-mainloop-in-javascript/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 17:07:05 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Game Development]]></category>

		<guid isPermaLink="false">http://www.playmycode.com/blog/?p=453</guid>
		<description><![CDATA[HTML5 is being touted as the next technology for browser games, but even common and straight forward parts like a &#8216;mainloop&#8217; can be difficult to write in JavaScript. This is a thorough explanation of how to go about writing your &#8230; <a href="http://www.playmycode.com/blog/2011/08/building-a-game-mainloop-in-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>HTML5 is being touted as the next technology for browser games, but even common and straight forward parts like a &#8216;mainloop&#8217; can be difficult to write in JavaScript.</p>
<p>This is a thorough explanation of how to go about writing your own, based upon our experiences of building Play My Code. <b>Novice programmers please note:</b> this article applies to JavaScript coding and not to coding using PMC, where we have solved this problem for you already.</p>
<h4>Why?</h4>
<p>Most games update in one of two ways. The first is to wait for input, like a mouse click, and then update or draw the game based on this. Under this system, the game only updates when a user interacts with it. This works well for card and puzzle games, where it&#8217;s normal for nothing to happen for fairly long periods of time.</p>
<p>However most action games, such as a first-person shooters, have to repeatedly update and redraw multiples times a second as they normally contain elements which move and react independently to player input. Essentially:</p>
<pre>    while ( true ) {
        updateGame();
        drawGame();
    }</pre>
<p>This is often referred to as a game&#8217;s &#8216;mainloop&#8217;.</p>
<h4>Getting back to JavaScript</h4>
<p>The first thing to note is that you cannot do the above in JavaScript, because the script must end in order for the browser to update the page. This includes displaying anything you&#8217;ve drawn to the canvas, and allowing the user to interact with the page (and in many cases, the rest of the browser).</p>
<p>So the first step is to break down your mainloop into a function, which will then be called repeatedly.</p>
<pre>    var mainloop = function() {
        updateGame();
        drawGame();
    };
    while ( true ) {
        mainloop();
    }</pre>
<p><span id="more-453"></span></p>
<h4>Remove the while loop</h4>
<p>Again, to stop the page from locking up, we remove the while loop. The easiest way to achieve this is to use <a href="https://developer.mozilla.org/en/window.setInterval" class="blueCharcoal bold">setInterval</a>. Given a function, it will re-call it repeatedly, until we tell it to stop.</p>
<pre>    var mainloop = function() {
        updateGame();
        drawGame();
    };
    setInterval( mainloop, ONE_FRAME_TIME );</pre>
<p>ONE_FRAME_TIME represents how often the function gets called, and ideally this should be run at 60 frames per second (which matches most refresh rates).</p>
<p>The time is in milliseconds, so to work out the time for one frame we divide 1 second (1000 milliseconds) by 60 frames.</p>
<pre>    var ONE_FRAME_TIME = 1000 / 60 ;
    var mainloop = function() {
        updateGame();
        drawGame();
    };
    setInterval( mainloop, ONE_FRAME_TIME );</pre>
<p>It works out to be about around 16.666 milliseconds.</p>
<h4>More Efficient Looping</h4>
<p>However, setInterval is not the most efficient way to build a mainloop. Some modern browsers provide a specialist function that can be used called &#8216;requestAnimationFrame&#8217;. You pass in your function, and the browser will call it later for you.</p>
<pre>    var mainloop = function() {
        updateGame();
        drawGame();
    };
    window.requestAnimationFrame( mainloop );</pre>
<p>It is more efficient because it is built with animation in mind. The browser will try to call it at the right time- so your changes are shown as soon as possible- and the timing code behind it tries to be more accurate then setInterval, to give a more stable frame rate.</p>
<p>However this is an experimental feature, and is not fully supported in all browsers. So you need to ensure you use the &#8216;requestAnimationFrame&#8217; version supported by the host browser. You can do this using:</p>
<pre>    var mainloop = function() {
        updateGame();
        drawGame();
    };

    var animFrame = window.requestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame    ||
            window.oRequestAnimationFrame      ||
            window.msRequestAnimationFrame     ||
            null ;
    animFrame( mainloop );</pre>
<p>It will test for, and return, the first &#8216;requestAnimationFrame&#8217; version it can find, using each of the browser name prefixes. If they fail, then null is returned. I will solve this issue later.</p>
<h4>This Only Calls it Once!</h4>
<p>The above code only calls &#8216;mainloop&#8217; once, not multiple times. To turn it back into a proper loop, we need to call &#8216;mainloop&#8217; multiple times using &#8216;animFrame&#8217;.</p>
<p>We can achieve this by wrapping it up within a closure, which recursively calls itself.</p>
<pre>    var mainloop = function() {
        updateGame();
        drawGame();
    };

    var animFrame = window.requestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame    ||
            window.oRequestAnimationFrame      ||
            window.msRequestAnimationFrame     ||
            null ;

    var recursiveAnim = function() {
        mainloop();
        animFrame( recursiveAnim );
    };

    // start the mainloop
    animFrame( recursiveAnim );</pre>
<h4>What if animFrame === null ?</h4>
<p>If &#8216;requestAnimationFrame&#8217; is not supported (such as in IE 9), then &#8216;animFrame&#8217; will be null. In this case, we fall back onto the &#8216;setInterval&#8217; used earlier.</p>
<pre>    var mainloop = function() {
        updateGame();
        drawGame();
    };

    var animFrame = window.requestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame    ||
            window.oRequestAnimationFrame      ||
            window.msRequestAnimationFrame     ||
            null ;

    if ( animFrame !== null ) {
        var recursiveAnim = function() {
            mainloop();
            animFrame( recursiveAnim );
        };

        // start the mainloop
        animFrame( recursiveAnim );
    } else {
        var ONE_FRAME_TIME = 1000.0 / 60.0 ;
        setInterval( mainloop, ONE_FRAME_TIME );
    }</pre>
<p>Alternatively, you could also use the technique suggested by <a href="http://paulirish.com/2011/requestanimationframe-for-smart-animating/" class="blueCharcoal bold">Paul Irish</a>, which creates a function that essentially looks like requestAnimationFrame.</p>
<h4>WebKit Improvements</h4>
<p>That&#8217;s all you need for a cross browser mainloop, but you can improve it further. WebKit browsers feature a second parameter, where you pass in the canvas you are going to be drawing to. This allows the browser to only update that one area.</p>
<pre>    var mainloop = function() {
        updateGame();
        drawGame();
    };

    var animFrame = window.requestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame    ||
            window.oRequestAnimationFrame      ||
            window.msRequestAnimationFrame     ||
            null ;

    if ( animFrame !== null ) {
        var canvas = $('canvas').get(0);

        var recursiveAnim = function() {
            mainloop();
            animFrame( recursiveAnim, canvas );
        };

        // start the mainloop
        animFrame( recursiveAnim, canvas );
    } else {
        var ONE_FRAME_TIME = 1000.0 / 60.0 ;
        setInterval( mainloop, ONE_FRAME_TIME );
    }</pre>
<p>I&#8217;ve used jQuery above to grab my canvas element, mainly to keep my example as short as possible. You can replace that with your own JavaScript code.</p>
<p>In Firefox and other non-WebKit browsers, passing in the canvas as the second parameter is simply ignored. It either optimises, or does nothing.</p>
<h4>Firefox improvements</h4>
<p>There is a <a href="http://hacks.mozilla.org/2010/08/more-efficient-javascript-animations-with-mozrequestanimationframe/" class="blueCharcoal bold">second way to call the mainloop in FireFox</a>, by attaching it to the &#8216;mozBeforePaint&#8217; event. In my personal experience, I find this gives a minor speed-up (about 10 to 60 milliseconds).</p>
<p>So if we are using Firefox, we should use that instead of the recursive code above. To detect for Firefox, again I am just using jQuery.</p>
<pre>    var mainloop = function() {
        updateGame();
        drawGame();
    };

    var animFrame = window.requestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame    ||
            window.oRequestAnimationFrame      ||
            window.msRequestAnimationFrame     ||
            null ;

    if ( animFrame !== null ) {
        var canvas = $('canvas').get(0);

        if ( $.browser.mozilla ) {
            var recursiveAnim = function() {
                mainloop();
                animFrame();
            };

            // setup for multiple calls
            window.addEventListener("MozBeforePaint", recursiveAnim, false);

            // start the mainloop
            animFrame();
        } else {
            var recursiveAnim = function() {
                mainloop();
                animFrame( recursiveAnim, canvas );
            };

            // start the mainloop
            animFrame( recursiveAnim, canvas );
        }
    } else {
        var ONE_FRAME_TIME = 1000.0 / 60.0 ;
        setInterval( mainloop, ONE_FRAME_TIME );
    }</pre>
<p>Now, in Firefox, when &#8216;animFrame&#8217; is called it tells the browser to repaint. It then then runs the &#8216;MozBeforePaint&#8217; event, where our mainloop sits.</p>
<h4>Alternatively</h4>
<p>This is what it takes to achieve a proper mainloop across browsers. Cross-browser issues like these are what Play My Code helps to solve, by handling these details for you under the hood. So, alternatively you could just build your game here, and save yourself a great deal of time and trouble.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playmycode.com/blog/2011/08/building-a-game-mainloop-in-javascript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
