<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5756594577450809773</id><updated>2025-08-22T10:11:51.886-07:00</updated><category term="Example"/><category term="HTML5"/><category term="user input"/><category term="Snippet"/><category term="canvas"/><category term="Audio"/><category term="Physics"/><category term="HUD"/><category term="WebGL"/><category term="quick tip"/><category term="3D"/><category term="Browsers"/><category term="Hardware Acceleration"/><category term="JavaScript"/><category term="Maths"/><category term="Video"/><category term="background"/><title type='text'>SlashGame - HTML5 Game Development</title><subtitle type='html'>Games development infos and indie game developer</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>37</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-7808071694921998895</id><published>2013-04-24T11:25:00.002-07:00</published><updated>2013-04-24T12:43:38.423-07:00</updated><title type='text'>Put Ads in Windows 8 Apps (HTML5)</title><content type='html'>&amp;nbsp;Note: The following tutorial is for HTML5 app development. &lt;br /&gt;
&lt;br /&gt;
So you want to get into, or you&#39;re already in Windows 8 App development?&lt;br /&gt;
You&#39;ll surely want to know how to monetize your apps. And the simplest way to do that is to put ads in your app or game. You can also have in-app purchases, or even make it a paid app. However in-app purchases is a little bit more difficult (although it isn&#39;t that bad, I&#39;ll write about that in a later article), and to have any notable success with a paid app, you want to make sure it&#39;s a damn good app or game.&lt;br /&gt;
&lt;br /&gt;
So, how do we put ads in our Windows 8 Store apps?&lt;br /&gt;
&lt;br /&gt;
First you need an ad provider. You can use any ad provider that meets Microsoft&#39;s standards. But at the moment, I&#39;m sticking with Microsoft&#39;s pubCenter, because it&#39;s actually the only provider I can find right now that you can use. AdSense is apparently out the picture. So, I&#39;ll show the ropes with pubCenter. Also note that pubCenter isn&#39;t great yet. There&#39;s not a whole lot of advertisers with them yet, so quite often you will find your app not even displaying ads. Ads are displayed more in America than anywhere else, which isn&#39;t too bad since America will usually be the biggest audience of any app. I can also see pubCenter growing rapidly, so you may as well get yourself prepared.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Get the SDK&lt;/h3&gt;
First off, get the &lt;a href=&quot;http://adsinapps.microsoft.com/sdk&quot;&gt;Microsoft Advertising SDK for Windows 8&lt;/a&gt;, click &quot;direct download&quot; at the top right of the page, and install it. Now Visual Studio has what it needs to work with ads.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Set up pubCenter Account&lt;/h3&gt;
Then you should get started with pubCenter, for in-depth description, have a look at &lt;a href=&quot;http://adsinapps.microsoft.com/pubcenter&quot;&gt;How to Use pubCenter&lt;/a&gt;. But it&#39;s pretty simple, just &lt;a href=&quot;https://pubcenter.microsoft.com/Login&quot;&gt;log in with your Microsoft ID&lt;/a&gt;&lt;span style=&quot;font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;, you&#39;ll see the &quot;sign in with microsoft account&quot; link.&lt;/span&gt; Then you&#39;ll be able to set up your first ad unit for your app.&lt;br /&gt;
&lt;br /&gt;
When you create your ad unit, you will have a unit ID and an application ID, both of which you will need later for your code.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Placing the HTML code&lt;/h3&gt;
First go to your default.html or the page you are placing the ad on.&lt;br /&gt;
In the &amp;lt;head&amp;gt; part, put this line *after* you include default.js:&lt;br /&gt;
&lt;script src=&quot;http://pastebin.com/embed_js.php?i=nMUkdRV3&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;br /&gt;
Now in the &amp;lt;body&amp;gt; section, use this code:&lt;br /&gt;
&lt;script src=&quot;http://pastebin.com/embed_js.php?i=dnEZwFFi&quot;&gt;&lt;/script&gt;This example places a 292px by 60px ad at the bottom left of the page. You can change the position values as you like, and the size values should be the values you made your unit.&lt;br /&gt;
Important note: The application ID used here is what you need to use for testing purposes, and the unit ID is what you need to use if you are going to have a 292 by 60 ad. For other sizes, look at the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/advertising-windows-test-mode-values%28v=msads.10%29.aspx&quot;&gt;Test Mode Values Table&lt;/a&gt; and make sure you take the Unit ID of the size you intend to use.&lt;br /&gt;
&lt;br /&gt;
Using your own application ID and unit ID will not show anything when testing, you must wait until you have finished making your game before switching these values with your actual ad IDs.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
&lt;/h4&gt;
&lt;h3&gt;
Next Requirements&lt;/h3&gt;
There are a couple of things you need to do if you&#39;re going to have ads in your app. The first is very simple, just go to your app manifest and make sure you&#39;ve ticked the &quot;Internet (Client)&quot; box under the &quot;Capabilities&quot; tab.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Privacy Policy&lt;/b&gt;&lt;br /&gt;
The second thing you need to make sure you have is a Privacy Policy. If you don&#39;t have a privacy policy when Internet connection is enabled, your app will be rejected.&lt;br /&gt;
The privacy policy is used to state what information is being transferred or used. If you are not using any personal information and you&#39;re just providing ads, you simply have to state that.&lt;br /&gt;
For example, &quot;This application does not collect any personal information. Internet connection is used to provide advertisements.&quot;&lt;br /&gt;
&lt;br /&gt;
You will need to have your privacy policy posted on a web page with a URL you can link in your app&#39;s description section when submitting your app.&lt;br /&gt;
You also must include your privacy policy in the Settings Charm of your app.&lt;br /&gt;
&lt;br /&gt;
To do this, go to your default.js file, and locate the part that should look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;http://pastebin.com/embed_js.php?i=nggaSgzu&quot;&gt;&lt;/script&gt;Then make the code look more like this:&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;http://pastebin.com/embed_js.php?i=c6UCCiPp&quot;&gt;&lt;/script&gt;&lt;br /&gt;
You&#39;ll notice that in that code I referenced a &quot;privacy.html&quot; page. All you have to do is make another html page in the project, and for example&#39;s sake, here&#39;s my privacy.html page for my Holy Diver game:&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;http://pastebin.com/embed_js.php?i=9ZUemgvb&quot;&gt;&lt;/script&gt;&lt;br /&gt;
And that should be it! You&#39;re now fully equipped to put ads in your app. Now go make a badass game and get it plenty of traffic. Enjoy.</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/7808071694921998895/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/put-ads-in-windows-8-apps-html5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/7808071694921998895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/7808071694921998895'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/put-ads-in-windows-8-apps-html5.html' title='Put Ads in Windows 8 Apps (HTML5)'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-3751271154570593592</id><published>2013-04-19T07:55:00.000-07:00</published><updated>2013-04-19T07:55:24.991-07:00</updated><title type='text'>GameJam Results In</title><content type='html'>The results are in from the GameJam that was held at University of the West of Scotland.&lt;br /&gt;
The winner is Martin Grant! Check out his website &lt;a href=&quot;http://www.martingrant.net/&quot;&gt;here&lt;/a&gt; for info on his game, &quot;Unicorn Space Command&quot;, and his other work.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
His game is real fun, I had hardly expected to win over this. If you have Windows 8, you should give it a blast, search the store for &quot;Unicorn Space Command&quot;, or follow&amp;nbsp;&lt;a href=&quot;http://apps.microsoft.com/windows/en-US/app/unicorn-space-command/0619cb06-5e86-4002-bfb8-9accf68d9f1f&quot;&gt;this link&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://media.tumblr.com/720b570599f1572d683cddc60608f0eb/tumblr_inline_mlcnyv9stR1qz4rgp.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;376&quot; src=&quot;http://media.tumblr.com/720b570599f1572d683cddc60608f0eb/tumblr_inline_mlcnyv9stR1qz4rgp.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/3751271154570593592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/gamejam-results-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/3751271154570593592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/3751271154570593592'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/gamejam-results-in.html' title='GameJam Results In'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-194934057084065314</id><published>2013-04-18T15:03:00.001-07:00</published><updated>2013-04-19T06:24:16.289-07:00</updated><title type='text'>Shotgun Steve In Development</title><content type='html'>Another game in the pipeline. While I work on Damn Zombies, I&#39;ll be splitting my attention onto this new game Shotgun Steve. And as with my other stuff, this will be available on the Windows 8 App Store.&lt;br /&gt;
&lt;br /&gt;
The basis of this game will be to shoot some kind of bad guy flying from the platforms at the sides, staying alive as long as possible, as it gets harder and harder. Not sure what the bad guys will be like. Maybe some kind of ninja style shiz. Anyhow, I do believe this game will be great fun, it&#39;s just a silly, casual, time-killing game.&lt;br /&gt;
&lt;br /&gt;
Screenshot of the game early in development, most of the graphics here are temporary, but it&#39;ll be along these lines, in terms of style.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMBEoNqpG33KPM6UtEjLAlOz7K6VHnzDGEJFE0QOnLzhiUDu5h5nisdUOFmQwBteKLL37-WsFqhVifDCEyX1VQmZIYeG_R-uMc_rF92hSvEQocpWt4Pt2v7-WHd7l9fHcATllUki6xDzo/s1600/screenshot1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMBEoNqpG33KPM6UtEjLAlOz7K6VHnzDGEJFE0QOnLzhiUDu5h5nisdUOFmQwBteKLL37-WsFqhVifDCEyX1VQmZIYeG_R-uMc_rF92hSvEQocpWt4Pt2v7-WHd7l9fHcATllUki6xDzo/s640/screenshot1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/194934057084065314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/shotgun-steve-in-development.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/194934057084065314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/194934057084065314'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/shotgun-steve-in-development.html' title='Shotgun Steve In Development'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMBEoNqpG33KPM6UtEjLAlOz7K6VHnzDGEJFE0QOnLzhiUDu5h5nisdUOFmQwBteKLL37-WsFqhVifDCEyX1VQmZIYeG_R-uMc_rF92hSvEQocpWt4Pt2v7-WHd7l9fHcATllUki6xDzo/s72-c/screenshot1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-6464913514286036041</id><published>2013-04-11T14:07:00.003-07:00</published><updated>2013-04-11T14:07:45.220-07:00</updated><title type='text'>Holy Diver Released</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://apps.microsoft.com/windows/app/holy-diver/84921736-c997-4750-9199-76df6ed8c317&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img align=&quot;left&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Dhq6UkPbdwFu-zTa8qnO8bfgPlUullMDmURxmIKNXfyAfnELE686EA4I400SngWT5j0L5U1OeicuijFjfSbmiIFQgwmCkrfWKhncOi093ksyZtRaXkKCGFE8X40Hyn0nIblNdza3Q-g/s1600/poster1.png&quot; style=&quot;margin-top: 25px; padding-right: 10px;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Holy Diver is now released to the Windows 8 App Store. If you&#39;ve got Windows 8, follow this link: &lt;a href=&quot;http://apps.microsoft.com/windows/app/holy-diver/84921736-c997-4750-9199-76df6ed8c317&quot;&gt;Holy Diver - Windows 8 App Store&lt;/a&gt;, or search the app store for &quot;Holy Diver&quot;.&lt;br /&gt;
&lt;br /&gt;
The game involves an angel diving from the sky, dodging spiky &quot;devil clouds&quot;, then when you reach the ground, you swoop through a tunnel trying not to hit the walls.&lt;br /&gt;
On a touch screen device such as a tablet, the default controls are to basically move your finger to where you want the angel to horizontally move to. On a PC, the default controls are keyboard controls (A/D or Left/Right), however you can press M to switch to mouse movements and back.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This game was very quickly developed, as it is a submission to a competition I took part in at the University of the West of Scotland.&lt;br /&gt;
The competition was spanned over 3 days, and a decent chunk of the time was used learning new things. And honestly, I love making games for the Windows Store.&lt;br /&gt;
To all casual games developers, I really do suggest getting Windows 8 (even if you&#39;d rather dual boot it) so you can take part in this up-and-coming market.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So, as I said, this was a quick development, so it&#39;s not an overly impressive game. Although it can be rather addictive. I didn&#39;t expect myself to get that effect from the game, but I did. And since I enjoy it myself so much, I intend on building on the game after the competition has been judged. The game will be much more featureful and professional feeling.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii6fdVyYYx5Oy8iWGaRzBNLFi0RTH-3k7SuNtqxo1ELK0XACNiMXzYWbJzIEe0_qLgvPBgOFTchhMRn4oRa45GTUC0Xy1FVLIK4wDJibDbsBSA62a_XXp44aNq8v4t42QZPXwm2hrqlHc/s1600/screenshot_04052013_154106.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;356&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii6fdVyYYx5Oy8iWGaRzBNLFi0RTH-3k7SuNtqxo1ELK0XACNiMXzYWbJzIEe0_qLgvPBgOFTchhMRn4oRa45GTUC0Xy1FVLIK4wDJibDbsBSA62a_XXp44aNq8v4t42QZPXwm2hrqlHc/s640/screenshot_04052013_154106.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/6464913514286036041/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/holy-diver-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/6464913514286036041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/6464913514286036041'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/holy-diver-released.html' title='Holy Diver Released'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Dhq6UkPbdwFu-zTa8qnO8bfgPlUullMDmURxmIKNXfyAfnELE686EA4I400SngWT5j0L5U1OeicuijFjfSbmiIFQgwmCkrfWKhncOi093ksyZtRaXkKCGFE8X40Hyn0nIblNdza3Q-g/s72-c/poster1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-7446306745683204604</id><published>2013-04-09T16:53:00.003-07:00</published><updated>2013-04-09T16:53:54.315-07:00</updated><title type='text'>Damn Zombies - Early Sneek Peak</title><content type='html'>While Holy Diver is in the process of being published to the Windows 8 App Store, I decided to start work on a new game.&lt;br /&gt;
&lt;br /&gt;
Damn Zombies will be a simple top-down zombie shooter, with basic controls, a range of weapons and defense upgrades. This game will be on the Windows 8 App Store, so available to Windows 8 PC users, as well as Windows 8 tablet users. I also intend on releasing the game on the Windows Phone Store too.&lt;br /&gt;
&lt;br /&gt;
Keep an eye out for updates, the game won&#39;t take long to finish. You can follow me on twitter &lt;a href=&quot;http://twitter.com/slashgame&quot;&gt;@SlashGame&lt;/a&gt;, or Like the new Facebook page &lt;a href=&quot;http://facebook.com/SlashGameNet&quot;&gt;SlashGameNet&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Here&#39;s a screenshot of gameplay, very early in development. As you&#39;ll see, there&#39;s still not even a gun in the player&#39;s hands yet.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrM345yfk-YJ9trd9dM2E_qd2qtG1lCLyPrZI8yImaj_1HwyrnT6-kcA4BGq4iJWwmKWBJbCY4m6TqYFtibvaEvweKLvOxFaeVKnpZAUeptf_x6QN0WBLQMr9Nj_YUJrOwSLj08EKbTSA/s1600/early+screenshot+1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrM345yfk-YJ9trd9dM2E_qd2qtG1lCLyPrZI8yImaj_1HwyrnT6-kcA4BGq4iJWwmKWBJbCY4m6TqYFtibvaEvweKLvOxFaeVKnpZAUeptf_x6QN0WBLQMr9Nj_YUJrOwSLj08EKbTSA/s1600/early+screenshot+1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/7446306745683204604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/damn-zombies-early-sneek-peak.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/7446306745683204604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/7446306745683204604'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/damn-zombies-early-sneek-peak.html' title='Damn Zombies - Early Sneek Peak'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrM345yfk-YJ9trd9dM2E_qd2qtG1lCLyPrZI8yImaj_1HwyrnT6-kcA4BGq4iJWwmKWBJbCY4m6TqYFtibvaEvweKLvOxFaeVKnpZAUeptf_x6QN0WBLQMr9Nj_YUJrOwSLj08EKbTSA/s72-c/early+screenshot+1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-9015566789233020420</id><published>2013-04-05T13:14:00.000-07:00</published><updated>2013-04-09T17:20:11.201-07:00</updated><title type='text'>SlashGame&#39;s First Official Game on Windows 8 Store!</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Dhq6UkPbdwFu-zTa8qnO8bfgPlUullMDmURxmIKNXfyAfnELE686EA4I400SngWT5j0L5U1OeicuijFjfSbmiIFQgwmCkrfWKhncOi093ksyZtRaXkKCGFE8X40Hyn0nIblNdza3Q-g/s1600/poster1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img align=&quot;left&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Dhq6UkPbdwFu-zTa8qnO8bfgPlUullMDmURxmIKNXfyAfnELE686EA4I400SngWT5j0L5U1OeicuijFjfSbmiIFQgwmCkrfWKhncOi093ksyZtRaXkKCGFE8X40Hyn0nIblNdza3Q-g/s1600/poster1.png&quot; style=&quot;padding-right: 10px; margin-top: 25px;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
For the past 3 days I&#39;ve been at a GameJam (game development competition) at the University of the West of Scotland. Our task was to make a game to put on the Windows 8 App Store; something I had never done before.&lt;br /&gt;
&lt;br /&gt;
The process of developing for the Windows Store was great, I could have chosen from a lot of languages to write the game in, and I could have picked from a range of third party frameworks. A lot of the other competitors used Construct 2, and I saw some pretty decent looking games coming from them.&lt;br /&gt;
I on the other hand, stuck with Visual Studio 2012, and I chose to write the game in JavaScript, so it is indeed a HTML5 game.&lt;br /&gt;
&lt;br /&gt;
Since I gave SlashGame such a high focus in HTML5 games, I thought I may as well make the game an official release for SlashGame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Holy Diver&lt;/b&gt;&lt;br /&gt;
My original idea for the name was actually &quot;Angel Dive&quot;, as the game involves an angel diving from the heavens then straight into the ground and through a tunnel.&lt;br /&gt;
However, I was driving along to the university today, and in popped the Dio song &quot;Holy Diver&quot; to my head. Obviously that fit just perfectly, so indeed the game is now named Holy Diver.&lt;br /&gt;
&lt;br /&gt;
There is much still to add to the game. Rest assured that the game will be fully featured soon after the competitors have been judged.&lt;br /&gt;
&lt;br /&gt;
The game will be free on the Windows App store, and I may at some point post a &quot;How I made it&quot; article or video.&lt;br /&gt;
&lt;br /&gt;
As for the GameJam, there was good competition, so I eagerly await to hear the winner, and I shall post the results, whether it&#39;s me or not.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiieO8jn9yCHaH53jndezhmaH_kUFyNGqjBNwPg7BZWE3AtQVBl5Cj3rNXSGTN6vYXIfuxSLLzmeg1EKXXyz2Eae2sILRWy8Ilm25W7ZpXA9ZymoI4U-g3tJ1Y2BRkAZlT1Y1-V2Pkk7b0/s1600/screenshot_04052013_154106.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;356&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiieO8jn9yCHaH53jndezhmaH_kUFyNGqjBNwPg7BZWE3AtQVBl5Cj3rNXSGTN6vYXIfuxSLLzmeg1EKXXyz2Eae2sILRWy8Ilm25W7ZpXA9ZymoI4U-g3tJ1Y2BRkAZlT1Y1-V2Pkk7b0/s640/screenshot_04052013_154106.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/9015566789233020420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/slashgames-first-official-game-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/9015566789233020420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/9015566789233020420'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2013/04/slashgames-first-official-game-on.html' title='SlashGame&#39;s First Official Game on Windows 8 Store!'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Dhq6UkPbdwFu-zTa8qnO8bfgPlUullMDmURxmIKNXfyAfnELE686EA4I400SngWT5j0L5U1OeicuijFjfSbmiIFQgwmCkrfWKhncOi093ksyZtRaXkKCGFE8X40Hyn0nIblNdza3Q-g/s72-c/poster1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-3462110098015594420</id><published>2013-01-20T05:06:00.000-08:00</published><updated>2013-01-22T08:48:54.963-08:00</updated><title type='text'>How to Make a HTML5 Game (HTML5 Game Development Guide)</title><content type='html'>In this blog, I&#39;ve got helpful tips spread out everywhere, so in this post I will organize a list of links to the posts I think would be most helpful.&lt;br /&gt;
&lt;br /&gt;
I&#39;ll keep this list updated when I think of more stuff to put in it. And I&#39;m open to suggestions, if you have any, you can contact me via @SlashGame on twitter (By the way, I&#39;m more likely to see a mention than a Private Message).
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;21/01/201&lt;span style=&quot;font-size: x-small;&quot;&gt;3: Updates &lt;span style=&quot;font-size: x-small;&quot;&gt;to these pages have begun.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;22/01/2013: Information improved in Game Loop and Simple Game Phsyics articles. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;The first thing is, you should understand what the canvas is.&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/05/html5.html&quot;&gt;HTML5 Canvas Explained.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Then, you&#39;re going to want to know how to render an image or text to the canvas.&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/05/display-image-on-canvas.html&quot;&gt;Display Image on Canvas&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/06/canvas-background-image.html&quot;&gt;Canvas Background Image&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/06/quick-tip-filltext-javascript-function.html&quot;&gt;Draw Text to the Canvas&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Then, for the actual game, you need to be able to set up what&#39;s known as a &quot;Game Loop&quot; in order to show moving characters and such based on user input.&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/05/game-loop.html&quot;&gt;Game Loop&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/05/user-input-make-it-easier-on-yourself.html&quot;&gt;Keyboard Input (helpful function you can use)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/06/user-input-mouse-input.html&quot;&gt;Mouse Input&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Now, all you need to know is the fancy stuff that you may want to use to make the game feel right.&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/05/simple-game-physics_24.html&quot;&gt;Simple Game Physics&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/05/rotate-image-on-canvas.html&quot;&gt;Rotating Image on Canvas&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/06/quick-tip-html5-audio-for-game.html&quot;&gt;HTML5 Audio&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you like to learn things visually, then I&#39;ve got a video on how to make a simple game.&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/06/video-intro-to-html5-game-dev.html&quot;&gt;Video Introduction to HTML5 Game Development&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
And I have a list of helpful snippets of code.&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/07/snippet-list.html&quot;&gt;Snippet List&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
If you want to make money from your games, I suggest you take a look at this:&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/09/how-to-make-money-from-your-games.html&quot;&gt;How to Make Money From Your Games&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/3462110098015594420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/how-to-make-html5-game.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/3462110098015594420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/3462110098015594420'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/how-to-make-html5-game.html' title='How to Make a HTML5 Game (HTML5 Game Development Guide)'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-9014190506744439264</id><published>2012-12-05T09:37:00.003-08:00</published><updated>2012-12-05T09:37:56.479-08:00</updated><title type='text'>SlashGame Revamp</title><content type='html'>Hey guys.&lt;br /&gt;
&lt;br /&gt;
I&#39;ve decided I want to revamp SlashGame as well as possible, so here&#39;s what&#39;s coming soon:&lt;br /&gt;
- I&#39;ll go through all my previous posts and update them&lt;br /&gt;
- add a newly organized menu&lt;br /&gt;
- update theme&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then soon after that:&lt;br /&gt;
- New static SlashGame website with all tutorial resources&lt;br /&gt;
- A new &lt;b&gt;projects section&lt;/b&gt; in the new website where you can see all official projects and take part in them, and even start up your own project to show users and get help and team members!&lt;br /&gt;
- A games section where you can view all official games and user&#39;s project games who allow public access&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This will be coming soon, I plan on making this a &lt;b&gt;great community and learning center&lt;/b&gt;, so keep an eye out.&lt;br /&gt;
&lt;br /&gt;
~ See you around.</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/9014190506744439264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2012/12/slashgame-revamp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/9014190506744439264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/9014190506744439264'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2012/12/slashgame-revamp.html' title='SlashGame Revamp'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-3865580583036663080</id><published>2012-12-01T17:12:00.000-08:00</published><updated>2013-04-21T18:35:44.381-07:00</updated><title type='text'>Holy Diver Privacy Policy</title><content type='html'>Holy Diver does not collect any personal information.&lt;br /&gt;
Internet access is only used to provide ads in the application.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://apps.microsoft.com/windows/en-US/app/holy-diver/84921736-c997-4750-9199-76df6ed8c317&quot;&gt;- Store Link for Holy Diver&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/3865580583036663080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2012/12/holy-diver-privacy-policy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/3865580583036663080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/3865580583036663080'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2012/12/holy-diver-privacy-policy.html' title='Holy Diver Privacy Policy'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-4451550046277352703</id><published>2012-12-01T10:12:00.000-08:00</published><updated>2013-01-21T07:55:49.582-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Audio"/><category scheme="http://www.blogger.com/atom/ns#" term="canvas"/><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="HTML5"/><category scheme="http://www.blogger.com/atom/ns#" term="Physics"/><category scheme="http://www.blogger.com/atom/ns#" term="user input"/><title type='text'>HTML5 Game Development Tutorial</title><content type='html'>If you want to make a HTML5 game and just want a nice reference page you can go back to, or if you are a complete beginner and need to learn as much as possible step-by-step, then you&#39;re at the right place.&lt;br /&gt;
I also have a guide split into multiple pages here, if you prefer that: &lt;a href=&quot;http://html5gamedev.blogspot.com/2011/07/how-to-make-html5-game.html&quot;&gt;HTML5 Game Development Guide&lt;/a&gt;.&lt;br /&gt;
There&#39;s also a video tutorial for the basics of HTML5 game development: &lt;a href=&quot;http://html5gamedev.blogspot.com/2011/06/video-intro-to-html5-game-dev.html&quot;&gt;Video Intro to HTML5 Game Dev&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#39;t know much about JavaScript, then have a look at the &lt;a href=&quot;http://html5gamedev.blogspot.com/2011/08/introduction-to-javascript.html&quot;&gt;Introduction to JavaScript&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
If you want to know how to make money from your games, have a look at this article:&lt;br /&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/09/how-to-make-money-from-your-games.html&quot;&gt;How to Make Money From Your Games&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If I post any little snippets here, feel free to use them in any way.&lt;br /&gt;
Although if you use a lot of it, it would be appreciated if you place something like this in your JavaScript:&lt;br /&gt;
/* Some code taken from www.slashgame.net */ &lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;Contents&lt;/a&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#what-is-html5-canvas&quot;&gt;What is the HTML5 Canvas?&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#draw-image-to-html5-canvas&quot;&gt;How to Draw an Image to the Canvas&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#draw-text-to-html5-canvas&quot;&gt;How to Draw Text to the Canvas&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#set-up-game-loop&quot;&gt;Set up a Game Loop&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#keyboard-input&quot;&gt;Keyboard Input&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#mouse-input&quot;&gt;Mouse Input&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#add-simple-game-physics&quot;&gt;Add Simple Game Physics&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#rotate-image-on-html5-canvas&quot;&gt;How to Rotate an Image on Canvas&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#use-html5-audio&quot;&gt;Use HTML5 Audio&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#conclusion&quot;&gt;Conclusion of Tutorial&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#what-is-html5-canvas&quot; name=&quot;what-is-html5-canvas&quot;&gt;What is the HTML5 Canvas?&lt;/a&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;(back to top)&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
The &lt;i&gt; &amp;lt;canvas&amp;gt; HTML element,&lt;/i&gt; which came to us in&lt;i&gt; HTML5&lt;/i&gt; was the first step towards HTML5 games becoming big.&lt;br /&gt;
&lt;br /&gt;
The canvas allows so many things that you wouldn&#39;t have been able to do otherwise, and does it rather efficiently.&lt;br /&gt;
&lt;br /&gt;
Canvas renders 2D graphics onto a given area in the browser window. It does this dynamically via scripting (i.e. JavaScript). The shapes and images which are rendered on the canvas can be manipulated in several ways. The most obvious and useful ways are &lt;i&gt;scaling&lt;/i&gt; and&lt;i&gt; rotating the image&lt;/i&gt;; which you would not have been able to do without the canvas, unless you did some rather inefficient and complicated php scripting to alter an image at the pixel-level to make it appear to do a similar thing.&lt;br /&gt;
&lt;br /&gt;
JavaScript has a &lt;i&gt;2D graphics API&lt;/i&gt; which accesses the &lt;i&gt;HTML5 canvas&lt;/i&gt; drawing area, which is how games can be written. But just because it only has a 2D API, don&#39;t let that make you think 3D isn&#39;t possible.&lt;br /&gt;
&lt;br /&gt;
For a start, you could simply write your own JavaScript 3D engine, which uses normal 2D functions to generate a 3D object and render the &lt;i&gt;2D projection&lt;/i&gt; on the canvas. Doing so just requires a bit of mathematics. But making it a huge and playable game is where it gets difficult.&lt;br /&gt;
&lt;br /&gt;
You could create a whole 3D engine if you wanted, but there is a &lt;i&gt;3D graphics API&lt;/i&gt; available. It&#39;s called &lt;i&gt;WebGL&lt;/i&gt;, and it does what I just described, but it simplifies it by allowing you to just call the functions, rather than having to think up all that complicated stuff yourself. It also means that the 3D engine already has optimized code, meaning it will run faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#draw-image-to-html5-canvas&quot; name=&quot;draw-image-to-html5-canvas&quot;&gt;How to Draw an Image to the Canvas&lt;/a&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;(back to top)&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
This is just about the simplest example of the use of HTML5 canvas you can get. This is just to show how to set up a canvas and draw in it.&lt;br /&gt;
&lt;br /&gt;
Firstly, you would have something like this in the HTML of the page: &lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;lt;canvas height=&quot;400&quot; id=&quot;canvas&quot; width=&quot;400&quot;&amp;gt;&lt;br /&gt;Browser not compatible with HTML5 canvas&lt;br /&gt;&amp;lt;/canvas&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
The id of the canvas element can be anything, but here it has been set to &quot;canvas&quot;. This is used so the JavaScript can identify the correct canvas element to manipulate.&lt;br /&gt;
&lt;br /&gt;
I&#39;ve set the width and height of the canvas to 400px. It normally wouldn&#39;t be a perfect square for a game, but this is just an example.&lt;br /&gt;
&lt;br /&gt;
And if an incompatible browser is used, it will display the text &quot;Browser not compatible with HTML5 canvas&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The JavaScript goes in the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: small;&quot;&gt;&lt;head&gt;&lt;/head&gt;&lt;/span&gt; section of the page.&lt;br /&gt;
You could have all the code in &lt;i&gt;script tags&lt;/i&gt; (&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;lt;script&amp;gt;CODE HERE&amp;lt;/script&amp;gt;&lt;/span&gt;) or have it in a seperate .js file and call it from &lt;i&gt;src&lt;/i&gt; attribute of script tags&amp;nbsp;(&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;lt;script&lt;span style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;src&quot;javascriptfile&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;.js&quot;&amp;gt;&amp;lt;/scri&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;pt&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;)&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
Here is an example of the kind of JavaScript you could use to draw an image:&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;var canvas = document.getElementById(&#39;canvas&#39;);
var context2D = canvas.getContext(&#39;2d&#39;);

var img = new Image();
img.src = &quot;http://www.blogger.com/img/logo40.png&quot;;
context2D.drawImage(img, 100, 50);
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
So first it gets the canvas element by using the id we gave it. It then creates the 2D context with that canvas element.&lt;br /&gt;
&lt;br /&gt;
It then loads a new Image object and then tells it to use the image from the location we give it by assigning it to the &lt;i&gt;src variable of the Image object&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Then it uses the 2D graphics API by calling the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: small;&quot;&gt;drawImg()&lt;/span&gt; function.&lt;br /&gt;
&lt;br /&gt;
The first parameter of the function is looking for an &lt;i&gt;image object&lt;/i&gt; to draw, the second is the &lt;i&gt;x-position&lt;/i&gt; and the third is the &lt;i&gt;y-position&lt;/i&gt;. The positions are always relative to the top left corner by default.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#draw-text-to-html5-canvas&quot; name=&quot;draw-text-to-html5-canvas&quot;&gt;How to Draw Text to the Canvas&lt;/a&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;(back to top)&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;pre&gt;context2D.fillStyle = &quot;white&quot;;
context2D.font = &#39;bold 30px sans-serif&#39;;
context2D.fillText(&quot;POINTS: &quot;+numOfPoints, canvas.width-200, 30);
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
That right there is an example of drawing text to the canvas. It writes it on the top right of the canvas. That particular example is what would serve as part of the HUD in a game.&lt;br /&gt;
Here is a little function that draws text to the canvas with a specified position, color and font. This also shows you the different things you can do with text.&lt;br /&gt;
However, you may want to use this function just as a means to being able to not worry about remembering the different parts to it. &lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;function drawCanvasText(txt, pX, pY, clr, fnt) {
 context2D.fillStyle = clr; // color
 context2D.font = fnt; // font
 context2D.fillText(txt, pX, pY); // text at position X, Y
}
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;b&gt;Example Usage:&lt;/b&gt;
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;drawCanvasText(&quot;drawing text yas&quot;, 50, 50, &quot;black&quot;, &quot;bold 30px sans-serif&quot;);&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#set-up-game-loop&quot; name=&quot;set-up-game-loop&quot;&gt;Set up a Game Loop&lt;/a&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;(back to top)&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
A game loop is the normal structure a game would be build in. This is something you would find in any kind of game, not just HTML5 games.&lt;br /&gt;
First it would initiate the loop (what I tend to do is trigger the initiation function when the window is loaded), then the loop would involve checking for user input, then doing what needs to be done to all the objects, then rendering/drawing the scene, and start again from checking user input.&lt;br /&gt;
This is an example of doing this in javascript:&lt;br /&gt;
&lt;div style=&quot;height: 500px; overflow: auto; width: 600px;&quot;&gt;
&lt;blockquote&gt;
&lt;pre&gt;const FPS = 30;

var playerPosX = 0;
var playerPosY = 0;

var playerImg = new Image();
playerImg.src = &quot;http://filevaults.com/media/Slash/553481-smiley.png&quot;;

var canvas = null;
var context2D = null;
var keys = new Array();

window.onload = init;

window.addEventListener(&#39;keydown&#39;,keyDown,true);
window.addEventListener(&#39;keyup&#39;,keyUp,true);
function keyDown(evt){
 keys[evt.keyCode] = true;
}
function keyUp(evt){
 keys[evt.keyCode] = false;
}

function init()
{
 canvas = document.getElementById(&#39;canvas&#39;);
 context2D = canvas.getContext(&#39;2d&#39;);
 setInterval(draw, 1000 / FPS);
}

function draw()
{
 if ((37 in keys &amp;amp;amp;&amp;amp;amp; keys[37]) || (65 in keys &amp;amp;amp;&amp;amp;amp; keys[65])){ //left
  playerPosX -= 2;
 }
 if ((39 in keys &amp;amp;amp;&amp;amp;amp; keys[39]) || (68 in keys &amp;amp;amp;&amp;amp;amp; keys[68])){ //right
  playerPosX += 2;
 }
 
 context2D.clearRect(0, 0, canvas.width, canvas.height);
 context2D.drawImage(playerImg, playerPosX, playerPosY);
}

&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
The code initiates the loop in the init() function, which is called as soon as the window is loaded up. This function uses the setInterval() function to call the draw() function 30 times per second (it uses the FPS variable to determine that frame rate).&lt;br /&gt;
&lt;br /&gt;
It then adds an &quot;event listener&quot; for key being pressed, and for key being released.
This means that when a key is pressed, it calls the function which adds the key&#39;s code to an array. When the key is released, another function is called which sets the value of that array element to false.
This means that every time the loop comes to the point where it checks for user input, all it has to do is look in the array and see if it&#39;s there and that it is set to true.&lt;br /&gt;
&lt;br /&gt;
Once it knows if the key is pressed, it then decides what to do with the playerPos variables. This is the stage where it changes the &quot;virtual world&quot;.&lt;br /&gt;
&lt;br /&gt;
Then the last stage of the loop is rendering/drawing the scene based on the &quot;virtual world&#39;s&quot; variables.&lt;br /&gt;
To do so, it clears the canvas fully then draws the image in the correct spot.&lt;br /&gt;
&lt;br /&gt;
Here&#39;s the result of the example I just gave (use arrow keys or A and D to move left and right): &lt;a href=&quot;http://slashgame.net/html5gamedevexample2.php&quot;&gt;http://slashgame.net/html5gamedevexample2.php&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From the knowledge you have learned so far, you can make a simple game, if you have the ability to figure things out. However, I will continue and explain things in further detail and bring up new points of interest.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#keyboard-input&quot; name=&quot;keyboard-input&quot;&gt;Keyboard Input&lt;/a&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;(back to top)&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
As explained in the Game Loop section of this post (just above this section); it goes through the loop, and each time, it checks if the key is pressed by checking an array to see if it is set to true or false.&lt;br /&gt;
An event listener calls a function when a key is pressed down, and sets the array element of the ASCII code of the key, and sets it to true. And another event listener checks for keys being released, and sets the element value to false.&lt;br /&gt;
&lt;br /&gt;
Looking up ASCII values all the time can sometimes be a pain in the ass, so what I&#39;ve done is made a little snippet of code you can paste into your code which allows you to simply call the function with the key you want to check as a parameter. This is simple enough to use.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Examples of use:&lt;/span&gt;&lt;br /&gt;
If you wanted to check if the A key is pressed down:
&lt;br /&gt;
&lt;pre&gt;if (isKeyPressed(&#39;a&#39;)==true) { /* do whatever */ }&lt;/pre&gt;
If you wanted to check for the left arrow key being pressed:
&lt;br /&gt;
&lt;pre&gt;isKeyPressed(&#39;left&#39;)&lt;/pre&gt;
For escape key:
&lt;br /&gt;
&lt;pre&gt;isKeyPressed(&#39;esc&#39;)&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;The Code:&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;height: 500px; overflow: auto; width: 600px;&quot;&gt;
&lt;pre&gt;window.addEventListener(&#39;keydown&#39;,keyPressDown,true);
window.addEventListener(&#39;keyup&#39;,keyPressUp,true);

function keyPressDown(evt){
 keys[evt.keyCode] = true;
}
function keyPressUp(evt){
 keys[evt.keyCode] = false;
}


function isKeyPressed(checkKey) {
 
 // alphabet
 if ((checkKey == &#39;a&#39; || checkKey == &#39;A&#39;) &amp;amp;amp;&amp;amp;amp; (65 in keys &amp;amp;amp;&amp;amp;amp; keys[65])){
  return true;
 }
 else if ((checkKey == &#39;b&#39; || checkKey == &#39;B&#39;) &amp;amp;amp;&amp;amp;amp; (66 in keys &amp;amp;amp;&amp;amp;amp; keys[66])){
  return true;
 }
 else if ((checkKey == &#39;c&#39; || checkKey == &#39;C&#39;) &amp;amp;amp;&amp;amp;amp; (67 in keys &amp;amp;amp;&amp;amp;amp; keys[67])){
  return true;
 }
 else if ((checkKey == &#39;d&#39; || checkKey == &#39;D&#39;) &amp;amp;amp;&amp;amp;amp; (68 in keys &amp;amp;amp;&amp;amp;amp; keys[68])){
  return true;
 }
 else if ((checkKey == &#39;e&#39; || checkKey == &#39;E&#39;) &amp;amp;amp;&amp;amp;amp; (69 in keys &amp;amp;amp;&amp;amp;amp; keys[69])){
  return true;
 }
 else if ((checkKey == &#39;f&#39; || checkKey == &#39;F&#39;) &amp;amp;amp;&amp;amp;amp; (70 in keys &amp;amp;amp;&amp;amp;amp; keys[70])){
  return true;
 }
 else if ((checkKey == &#39;g&#39; || checkKey == &#39;G&#39;) &amp;amp;amp;&amp;amp;amp; (71 in keys &amp;amp;amp;&amp;amp;amp; keys[71])){
  return true;
 }
 else if ((checkKey == &#39;h&#39; || checkKey == &#39;H&#39;) &amp;amp;amp;&amp;amp;amp; (72 in keys &amp;amp;amp;&amp;amp;amp; keys[72])){
  return true;
 }
 else if ((checkKey == &#39;i&#39; || checkKey == &#39;I&#39;) &amp;amp;amp;&amp;amp;amp; (73 in keys &amp;amp;amp;&amp;amp;amp; keys[73])){
  return true;
 }
 else if ((checkKey == &#39;j&#39; || checkKey == &#39;J&#39;) &amp;amp;amp;&amp;amp;amp; (74 in keys &amp;amp;amp;&amp;amp;amp; keys[74])){
  return true;
 }
 else if ((checkKey == &#39;k&#39; || checkKey == &#39;K&#39;) &amp;amp;amp;&amp;amp;amp; (75 in keys &amp;amp;amp;&amp;amp;amp; keys[75])){
  return true;
 }
 else if ((checkKey == &#39;l&#39; || checkKey == &#39;L&#39;) &amp;amp;amp;&amp;amp;amp; (76 in keys &amp;amp;amp;&amp;amp;amp; keys[76])){
  return true;
 }
 else if ((checkKey == &#39;m&#39; || checkKey == &#39;M&#39;) &amp;amp;amp;&amp;amp;amp; (77 in keys &amp;amp;amp;&amp;amp;amp; keys[77])){
  return true;
 }
 else if ((checkKey == &#39;n&#39; || checkKey == &#39;N&#39;) &amp;amp;amp;&amp;amp;amp; (78 in keys &amp;amp;amp;&amp;amp;amp; keys[78])){
  return true;
 }
 else if ((checkKey == &#39;o&#39; || checkKey == &#39;O&#39;) &amp;amp;amp;&amp;amp;amp; (79 in keys &amp;amp;amp;&amp;amp;amp; keys[79])){
  return true;
 }
 else if ((checkKey == &#39;p&#39; || checkKey == &#39;P&#39;) &amp;amp;amp;&amp;amp;amp; (80 in keys &amp;amp;amp;&amp;amp;amp; keys[80])){
  return true;
 }
 else if ((checkKey == &#39;q&#39; || checkKey == &#39;Q&#39;) &amp;amp;amp;&amp;amp;amp; (81 in keys &amp;amp;amp;&amp;amp;amp; keys[81])){
  return true;
 }
 else if ((checkKey == &#39;r&#39; || checkKey == &#39;R&#39;) &amp;amp;amp;&amp;amp;amp; (82 in keys &amp;amp;amp;&amp;amp;amp; keys[82])){
  return true;
 }
 else if ((checkKey == &#39;s&#39; || checkKey == &#39;S&#39;) &amp;amp;amp;&amp;amp;amp; (83 in keys &amp;amp;amp;&amp;amp;amp; keys[83])){
  return true;
 }
 else if ((checkKey == &#39;t&#39; || checkKey == &#39;T&#39;) &amp;amp;amp;&amp;amp;amp; (84 in keys &amp;amp;amp;&amp;amp;amp; keys[84])){
  return true;
 }
 else if ((checkKey == &#39;u&#39; || checkKey == &#39;U&#39;) &amp;amp;amp;&amp;amp;amp; (85 in keys &amp;amp;amp;&amp;amp;amp; keys[85])){
  return true;
 }
 else if ((checkKey == &#39;v&#39; || checkKey == &#39;V&#39;) &amp;amp;amp;&amp;amp;amp; (86 in keys &amp;amp;amp;&amp;amp;amp; keys[86])){
  return true;
 }
 else if ((checkKey == &#39;w&#39; || checkKey == &#39;W&#39;) &amp;amp;amp;&amp;amp;amp; (87 in keys &amp;amp;amp;&amp;amp;amp; keys[87])){
  return true;
 }
 else if ((checkKey == &#39;x&#39; || checkKey == &#39;X&#39;) &amp;amp;amp;&amp;amp;amp; (88 in keys &amp;amp;amp;&amp;amp;amp; keys[88])){
  return true;
 }
 else if ((checkKey == &#39;y&#39; || checkKey == &#39;Y&#39;) &amp;amp;amp;&amp;amp;amp; (89 in keys &amp;amp;amp;&amp;amp;amp; keys[89])){
  return true;
 }
 else if ((checkKey == &#39;z&#39; || checkKey == &#39;Z&#39;) &amp;amp;amp;&amp;amp;amp; (90 in keys &amp;amp;amp;&amp;amp;amp; keys[90])){
  return true;
 }
 
 
 //numbers
 else if ((checkKey == &#39;0&#39;) &amp;amp;amp;&amp;amp;amp; (48 in keys &amp;amp;amp;&amp;amp;amp; keys[48])){
  return true;
 }
 else if ((checkKey == &#39;1&#39;) &amp;amp;amp;&amp;amp;amp; (49 in keys &amp;amp;amp;&amp;amp;amp; keys[49])){
  return true;
 }
 else if ((checkKey == &#39;2&#39;) &amp;amp;amp;&amp;amp;amp; (50 in keys &amp;amp;amp;&amp;amp;amp; keys[50])){
  return true;
 }
 else if ((checkKey == &#39;3&#39;) &amp;amp;amp;&amp;amp;amp; (51 in keys &amp;amp;amp;&amp;amp;amp; keys[51])){
  return true;
 }
 else if ((checkKey == &#39;4&#39;) &amp;amp;amp;&amp;amp;amp; (52 in keys &amp;amp;amp;&amp;amp;amp; keys[52])){
  return true;
 }
 else if ((checkKey == &#39;5&#39;) &amp;amp;amp;&amp;amp;amp; (53 in keys &amp;amp;amp;&amp;amp;amp; keys[53])){
  return true;
 }
 else if ((checkKey == &#39;6&#39;) &amp;amp;amp;&amp;amp;amp; (54 in keys &amp;amp;amp;&amp;amp;amp; keys[54])){
  return true;
 }
 else if ((checkKey == &#39;7&#39;) &amp;amp;amp;&amp;amp;amp; (55 in keys &amp;amp;amp;&amp;amp;amp; keys[55])){
  return true;
 }
 else if ((checkKey == &#39;8&#39;) &amp;amp;amp;&amp;amp;amp; (56 in keys &amp;amp;amp;&amp;amp;amp; keys[56])){
  return true;
 }
 else if ((checkKey == &#39;9&#39;) &amp;amp;amp;&amp;amp;amp; (57 in keys &amp;amp;amp;&amp;amp;amp; keys[57])){
  return true;
 }
 
 
 // special keys
 else if ((checkKey == &#39;left&#39; || checkKey == &#39;LEFT&#39;) &amp;amp;amp;&amp;amp;amp; (37 in keys &amp;amp;amp;&amp;amp;amp; keys[37])){
  return true;
 }
 else if ((checkKey == &#39;right&#39; || checkKey == &#39;RIGHT&#39;) &amp;amp;amp;&amp;amp;amp; (39 in keys &amp;amp;amp;&amp;amp;amp; keys[39])){
  return true;
 }
 else if ((checkKey == &#39;up&#39; || checkKey == &#39;UP&#39;) &amp;amp;amp;&amp;amp;amp; (38 in keys &amp;amp;amp;&amp;amp;amp; keys[38])){
  return true;
 }
 else if ((checkKey == &#39;down&#39; || checkKey == &#39;DOWN&#39;) &amp;amp;amp;&amp;amp;amp; (40 in keys &amp;amp;amp;&amp;amp;amp; keys[40])){
  return true;
 }
 else if ((checkKey == &#39;esc&#39; || checkKey == &#39;ESC&#39; || checkKey == &#39;escape&#39; || checkKey == &#39;ESCAPE&#39; ) &amp;amp;amp;&amp;amp;amp; (27 in keys &amp;amp;amp;&amp;amp;amp; keys[27])){
  return true;
 }
 
}&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#mouse-input&quot; name=&quot;mouse-input&quot;&gt;Mouse Input&lt;/a&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;(back to top)&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
It&#39;s fairly simple to add mouse input to your game; just use an eventListener for the event &quot;mousemove&quot; and use a function that takes the event as a parameter (in my example below, I used mouseMoved(e)), and use the e.pageX and e.pageY for the mouse&#39;s X and Y position.&lt;br /&gt;
&lt;br /&gt;
And for mouse clicks, just use eventListener for the &quot;click&quot; event, and use a function that does whatever. In the example I give, it sets the position of an image to the position of the mouse at the point it is clicked. In this case, a bullethole in the position the cursor was pointing at.&lt;br /&gt;
&lt;br /&gt;
Here is the code:
&lt;br /&gt;
&lt;div style=&quot;height: 500px; overflow: auto; width: 600px;&quot;&gt;
&lt;pre&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
const FPS = 60;

var canvas = null;
var context2D = null;

var cursorImg = new Image();
cursorImg.src = &quot;images/cursorexample.png&quot;;

var bulletHoleImg = new Image();
bulletHoleImg.src = &quot;images/bullethole.png&quot;;
var bulletHolesX = new Array();
var bulletHolesY = new Array();
for (var i=0; i&amp;lt;50; i++) {
 bulletHolesX[i] = -500;
 bulletHolesY[i] = -500;
}
bulletNum = 0;

window.addEventListener(&#39;mousemove&#39;, mouseMoved, true);
window.addEventListener(&#39;click&#39;, clicked, true);
var mouseX = 0;
var mouseY = 0;

window.onload = init;
function init() {
 canvas = document.getElementById(&#39;canvas1&#39;);
 context2D = canvas.getContext(&#39;2d&#39;);
 
 setInterval(draw, 1000/FPS);
}

function draw() {
 context2D.clearRect(0, 0, canvas.width, canvas.height);
 for (var i=0; i&amp;lt;50; i++) {
  context2D.drawImage(bulletHoleImg, bulletHolesX[i]-(bulletHoleImg.width/2), bulletHolesY[i]-(bulletHoleImg.height/2));
 }
 context2D.drawImage(cursorImg, mouseX-(cursorImg.width/2), mouseY-(cursorImg.width/2));
}

function mouseMoved(e) {
 
 mouseX = e.pageX;
 mouseY = e.pageY;
 
}

function clicked(e) {
 
 bulletHolesX[bulletNum] = mouseX;
 bulletHolesY[bulletNum] = mouseY;
 bulletNum++;
 if (bulletNum &amp;gt; 50) {
  bulletNum = 0;
 }
 
}
&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body style=&quot;padding: 0px; margin: 0px;&quot;&amp;gt;
 &amp;lt;canvas id=&quot;canvas1&quot; width=&quot;600&quot; height=&quot;480&quot; style=&quot;background-color: #A9A9A9;&quot;&amp;gt;
 Browser not compatible with HTML5 canvas
 &amp;lt;/canvas&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#add-simple-game-physics&quot; name=&quot;add-simple-game-physics&quot;&gt;Add Simple Game Physics&lt;/a&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;(back to top)&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
Even the simplest physics can make a game look and feel so much better. Instead of just suddenly moving full speed to the right when you press right key, it can be that the character builds speed until they reach normal speed. It could be a case of only taking 1-2 seconds to build the speed, or it could take more like 10 seconds. It all depends on your game.&lt;br /&gt;
And there&#39;s gravity. There needs to be a fairly realistic rate of falling towards the ground. I don&#39;t mean close to earth&#39;s gravity, I just mean it can&#39;t just fall at a constant speed towards the ground. It needs to accelerate. (Although, this does depend on the game. There may be certain instances where a constant velocity is fine)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So let&#39;s start with a canvas of width 500x500. So that there will be room to move, to appreciate the physics a bit more.&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;&amp;lt;canvas height=&quot;500&quot; id=&quot;canvas&quot; style=&quot;background-color: darkgrey;&quot; width=&quot;500&quot;&amp;gt;
Browser not compatible with HTML5 canvas
&amp;lt;/canvas&amp;gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
Now here&#39;s the javascript:
&lt;br /&gt;
&lt;div style=&quot;height: 500px; overflow: auto; width: 600px;&quot;&gt;
&lt;blockquote&gt;
&lt;pre&gt;const FPS = 30;

var playerPosX = 0;
var playerPosY = 0;
var playerVelX = 0;
var playerVelY = 0;

var onGround = 0;

var playerImg = new Image();
playerImg.src = &quot;http://filevaults.com/media/Slash/553481-smiley.png&quot;;

var canvas = null;
var context2D = null;
var keys = new Array();

window.onload = init;

window.addEventListener(&#39;keydown&#39;,keyDown,true);
window.addEventListener(&#39;keyup&#39;,keyUp,true);
function keyDown(evt){
 keys[evt.keyCode] = true;
}
function keyUp(evt){
 keys[evt.keyCode] = false;
}

function init()
{
 canvas = document.getElementById(&#39;canvas&#39;);
 context2D = canvas.getContext(&#39;2d&#39;);
 setInterval(draw, 1000 / FPS);
}

function draw()
{
 // detect user input
 if ((37 in keys &amp;amp;amp;&amp;amp;amp; keys[37]) || (65 in keys &amp;amp;amp;&amp;amp;amp; keys[65])){ //left
  playerVelX -= 3;
 }
 if ((39 in keys &amp;amp;amp;&amp;amp;amp; keys[39]) || (68 in keys &amp;amp;amp;&amp;amp;amp; keys[68])){ //right
  playerVelX += 3;
 }
 if ((38 in keys &amp;amp;amp;&amp;amp;amp; keys[38]) || (87 in keys &amp;amp;amp;&amp;amp;amp; keys[87])){ //up
  jump();
 }
 
 addPhysics();
 
 context2D.clearRect(0, 0, canvas.width, canvas.height);
 context2D.drawImage(playerImg, playerPosX, playerPosY);
}

function jump() {
 if (onGround == 1) {
  playerVelY -= 30;
 }
}

function addPhysics() {

 // because of these two lines, motion can be set using velocity variables
 playerPosX += playerVelX;
 playerPosY += playerVelY;
 
 
if (playerPosY &amp;amp;gt; canvas.height-playerImg.height) {
 onGround = 1;
}
else {
 onGround = 0;
}

// stop character from building up too much speed
// this means the character can realistically accelerate and continue at normal speed
 if (playerVelX &amp;amp;gt;= 10) {
  playerVelX = 10;
 } else if (playerVelX &amp;amp;lt;= -10) {
  playerVelX = -10;
 }
 
// friction
playerVelX *= 0.85;
if (playerVelX &amp;amp;lt; 0.2 &amp;amp;amp;&amp;amp;amp; playerVelX &amp;amp;gt; -0.2)
{ // so that it leaves it as a clean zero when it gets to a stop.
 playerVelX = 0;
}

 // gravity (acceleration of the velocity towards the ground)
 if (onGround == 0) {
 playerVelY += 3;
 }
 else {
 playerVelY = 0; // when on ground, gravity doesn&#39;t pull you through the floor
 }
 
}
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
Result here: &lt;a href=&quot;http://slashgame.net/html5physics.php&quot;&gt;http://slashgame.net/html5physics.php&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#rotate-image-on-html5-canvas&quot; name=&quot;rotate-image-on-html5-canvas&quot;&gt;How to Rotate an Image on Canvas&lt;/a&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;(back to top)&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
Rotation is a tricky one to understand fully, especially for beginners. A lot of people prefer to just blindy accept the way of coding it, and other like to know what the heck they are actually coding. So I&#39;ll give the opportunity for both types of people here.&lt;br /&gt;
&lt;br /&gt;
Firstly, I&#39;ll put this function here for you to use, this is helpful for any kind of person, but for those of you who just want the code, you only need to take the function and read my bit on how to use it. I&#39;ll then explain how rotation works, if you&#39;re interested.&lt;br /&gt;
&lt;br /&gt;
Here&#39;s the function:&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;function drawImg(img, pX, pY, oX, oY, w, h, rot) {
 context2D.save();
  context2D.translate(pX+oX, pY+oY);
  context2D.rotate(rot * Math.PI / 180);
  context2D.drawImage(img, 0, 0, w, h, -(oX), -(oY), w, h);
 context2D.restore();
}
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;How it&#39;s used:&lt;/span&gt;&lt;br /&gt;
img: the image object&lt;br /&gt;
pX: the x position of the image&lt;br /&gt;
pY: the y position of the image&lt;br /&gt;
oX: how far across the image that the origin is&lt;br /&gt;
oY: how far down the image that the origin is&lt;br /&gt;
w: width of the image&lt;br /&gt;
h: height of the image&lt;br /&gt;
rot: angle of rotation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ok, so it&#39;s not as simple as just &quot;rotate image&quot;. There&#39;s a lot more to it. It&#39;s more like rotating the canvas, then setting the image&#39;s orientation, then resetting the canvas.&lt;br /&gt;
&lt;br /&gt;
- So first it saves the canvas the way it is.&lt;br /&gt;
- Then the translate line makes the &quot;start&quot; of the image at the origin you want it to spin.&lt;br /&gt;
- It then rotates the actual canvas the amount you want the player to rotate.&lt;br /&gt;
- Then the image is drawn, but because the start of the image has changed place, it needs to start drawing at a different place (at the origin).&lt;br /&gt;
- It then brings the canvas back to where it was before, leaving the drawn image still showing as rotated.&lt;br /&gt;
&lt;br /&gt;
It took me a while to figure that out at first. I was never able to find a good explanation of how it works. I just hope this helps you readers better.&lt;br /&gt;
Although to be honest, it isn&#39;t incredibly important that you know how it works. Just that you know how to use it.
&lt;br /&gt;
Here&#39;s an example usage of rotation with canvas:  &lt;a href=&quot;http://slashgame.net/html5gamedevexample4.php&quot;&gt;http://slashgame.net/html5gamedevexample4.php&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#use-html5-audio&quot; name=&quot;use-html5-audio&quot;&gt;Use HTML5 Audio&lt;/a&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;(back to top)&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
I&#39;ll just show HTML5 Audio being used with javascript without a canvas. Using it in canvas you just include it in the javascript like normal by calling the function that plays the sound. I very much so assume that by this point you can figure that kind of thing out yourself.&lt;br /&gt;
The JavaScript accesses the HTML5 audio, and in effect makes an &lt;audio&gt; element. But it&#39;s good this way, as it&#39;s less cluttered without the tags actually being there or being created.&lt;/audio&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Example:&lt;/span&gt;&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;var boingSound = new Audio(&quot;http://slashgame.net/boing.wav&quot;);
function playSound() {
 boingSound.currentTime = 0;
 boingSound.play();
}
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
Notice how it sets the currentTime to 0 before playing. This is because you can&#39;t play the same sound object twice without moving the time back to the start again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is a use of the result of that:&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var boingSound = new Audio(&quot;http://slashgame.net/boing.wav&quot;);
function playSound() {
 boingSound.currentTime = 0;
 boingSound.play();
}
&lt;/script&gt;
&lt;span onclick=&quot;playSound();&quot; onmouseover=&quot;this.style.cursor=&#39;pointer&#39;;&quot; style=&quot;font-weight: bold;&quot;&gt;---CLICK HERE---&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#conclusion&quot; name=&quot;conclusion&quot;&gt;Conclusion of Tutorial&lt;/a&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=5756594577450809773#contents&quot; name=&quot;contents&quot;&gt;(back to top)&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
So, by now you should be able to put your wonderful imagination to use, and put your new knowledge of HTML5 game development to practice, and create something awesome.&lt;br /&gt;
&lt;br /&gt;
There may be some things that I haven&#39;t explained, but my hope is that I&#39;ve explained enough so that you are able to figure new things out yourself. Things like complicated physics can be figured out with some Maths knowledge, and game design for the most part comes from your imagination and your ability to understand what people like in games.</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/4451550046277352703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2013/01/html5-game-development-tutorial.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/4451550046277352703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/4451550046277352703'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2013/01/html5-game-development-tutorial.html' title='HTML5 Game Development Tutorial'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-4541045534433805282</id><published>2012-11-29T10:21:00.000-08:00</published><updated>2012-11-29T10:35:52.354-08:00</updated><title type='text'>SlashGame Coming Back</title><content type='html'>Hi guys.&lt;br /&gt;
&lt;br /&gt;
SlashGame has been gone for nearly a year. It&#39;s making a comeback, but it&#39;s been left in a mess.&lt;br /&gt;
&lt;br /&gt;
There are a lot of things not working on the site at the moment. However, the most useful part of it is still here. Check out the &lt;a href=&quot;http://html5gamedev.blogspot.co.uk/2011/08/html5-game-development-tutorial.html&quot;&gt;HTML5 Game Development Tutorial&lt;/a&gt; for a single page teaching you a lot of the basics of HTML5 game development.&lt;br /&gt;
&lt;br /&gt;
Or if you&#39;d prefer this kind of layout, check out the &lt;a href=&quot;http://html5gamedev.blogspot.co.uk/2011/07/how-to-make-html5-game.html&quot;&gt;HTML5 Game Development Guide&lt;/a&gt;, which is a bit more extensive and is broken up into different bits.</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/4541045534433805282/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2012/11/slashgame-coming-back.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/4541045534433805282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/4541045534433805282'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2012/11/slashgame-coming-back.html' title='SlashGame Coming Back'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-1780056123878507035</id><published>2011-12-08T20:54:00.001-08:00</published><updated>2011-12-12T07:49:24.915-08:00</updated><title type='text'>Bouncy Jump - Game by SlashGame up for Testing</title><content type='html'>Our first official game has been under slow development and has been linked on the slashgame.net homepage for a while now.&lt;br /&gt;
&lt;br /&gt;
I&#39;ve decided to put it up for beta testing now, as I feel it&#39;s at a point where it actually is a game. There&#39;s many planned features still to be implemented, and some bugs to fix, but it&#39;s still a playable game.&lt;br /&gt;
Also note that current artwork is mostly temporary. A lot of the art will change.&lt;br /&gt;
&lt;br /&gt;
Any feedback can be put as a reply to this blog post or we&#39;re on twitter at &lt;a href=&quot;http://twitter.com/#%21/SlashGame&quot;&gt;@SlashGame&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://slashgame.net/bouncyjump.php&quot;&gt;&lt;img src=&quot;http://slashgame.net/images/bouncyjumpscreenie.jpg&quot; /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
Right now, it&#39;s compatible with recent versions of &lt;b&gt;Mozilla Firefox, Google Chrome, Opera&lt;/b&gt; and &lt;b&gt;Safari. &lt;/b&gt;&lt;i&gt;Internet Explorer compatibility will come later&lt;/i&gt;, and possibly smartphone compatibility.&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/1780056123878507035/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/12/bouncy-jump-game-by-slashgame-up-for.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/1780056123878507035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/1780056123878507035'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/12/bouncy-jump-game-by-slashgame-up-for.html' title='Bouncy Jump - Game by SlashGame up for Testing'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-8702579759600453967</id><published>2011-09-04T10:22:00.000-07:00</published><updated>2013-01-12T20:42:21.530-08:00</updated><title type='text'>How to Make Money From an HTML5 Game (Adsense, Merchandise, etc.)</title><content type='html'>Making a game is only half the battle if you are looking to make money from your creations. Once you&#39;ve made the game, you will want to think of ways to make money from it.&lt;br /&gt;
A lot of what I&#39;m going to go into in this post applies to any kind of game, although I&#39;m using &lt;b&gt;HTML5 games&lt;/b&gt; as the focused example.&lt;br /&gt;
&lt;br /&gt;
One way would be having a donate button, but personally I like to stay away from donate buttons, because it feels a bit like begging. I rather make money through giving a service to people.&lt;br /&gt;
There are three main services you can provide; merchandise, advertising and in-game purchases.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Merchandise:&lt;/b&gt; I haven&#39;t really focused on selling merchandise much, I&#39;ve only set up a small test store at CafePress, however I may focus more on that in the future.&lt;br /&gt;
Setting up a CafePress store is pretty simple, you just sign up, and pick an item, and add your artwork to it. (Note that it needs to be your own artwork, copyrighted materials is a huge no-no)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Advertising:&lt;/b&gt; There are many ways to go about this. The most popular way to advertise on a web page is to use Google Adsense. You just set up an account, get your site approved, then add a little block of code which generates adverts from the sites that people using adwords have created. Adwords is where people put up their sites looking for traffic, Adsense is where people put those ads on their website to give them traffic and get money in return (which the Adwords people are paying).&lt;br /&gt;
There are many other services similar to Adsense, but none are close to being as profitable. The only case that I would suggest you use a service other than Adsense is if you have pornographic material, or something else which goes against Google&#39;s terms.&lt;br /&gt;
There is one other way, which takes a lot more effort, although has potential to make more money. Making deals with people individually. This means you directly talk to someone to make a deal that you give them traffic for whatever price. The deal would specify how the traffic is given (text link/banner image/whatever).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Where to put the ads?&lt;/b&gt; You could put the ads around the page that the HTML5, Flash or Java game is on (this requires the game to not be full screen). The page this article is written on has Adsense ads around the place, that is an example of where ads can go, and same applies to pages HTML5 games etc are on too.&lt;br /&gt;
Another place they can go is in a pause menu of a HTML5 game. This works for full-screen games and non-full-screen games. What you&#39;d do for that is, put the ad&#39;s code inside a &lt;i&gt;&amp;lt;div id=&quot;whatever&quot; style=&quot;display: none;&quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;/i&gt;. This will load the ad, but it will be invisible. In the game&#39;s code, you just have to make it that when the game is paused, it makes it appear.&lt;br /&gt;
Example:&lt;br /&gt;
&lt;i&gt;document.getElementById(&#39;whatever&#39;).style.display=&quot;&quot;;&lt;/i&gt;&lt;br /&gt;
Then when the game is unpaused, use:&lt;br /&gt;
&lt;i&gt;document.getElementById(&#39;whatever&#39;).style.display=&quot;none&quot;;&lt;/i&gt;&lt;br /&gt;
&lt;a href=&quot;http://slashgame.net/adsenseexample.php&quot;&gt;Here is an example of adsense in a pause menu of a canvas game&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How much money do the ads make?&lt;/b&gt; This is a pretty big question. It is dependent on so many different things. It would depend on what ads actually show up, which depends on both your target audience, and the topic of the game. It also depends on how much traffic you get to your site. You need hundreds to thousands of visits per day to make any amount of money. And a huge problem is that people don&#39;t trust ads any more. The ad services that aren&#39;t Adsense have put up so many scammy ads that it gave the reputation of internet ads so much shit. However, Adsense ads are very trustworthy and they very often provide quality and interesting links.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;In-game Purchases:&lt;/b&gt; Depending on what kind of game it is, you could have things like purchasable clothes for your character, or vehicles, etc.&lt;br /&gt;
Firstly, you&#39;ll need to set up a database to hold usernames, encrypted passwords and what purchases have been made by whom. When you have the database set up, you will be able to have a php script that deals with it, and you can then use AJAX in your HTML5 game&#39;s JavaScript which runs the script, putting in parameters like &quot;username&quot; and &quot;itemtobuy&quot;.&lt;br /&gt;
From there it will be able to access something like PayPal to accept a payment. Then, in your game you will be able to have it check for what purchases have been made, and it can decide what things to show up.&lt;br /&gt;
You could also use a service specifically for In-App purchases. Such as Google In-App purchases.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is a lot harder to make money than people think. And the best way to make sure you do make money, is to &lt;b&gt;make sure your game will appeal to people.&lt;/b&gt;
A lot of people have the wrong idea of what kind of games will appeal to people. Too many people think it just needs to be &quot;cool&quot;, but it actually doesn&#39;t.&lt;br /&gt;
It needs to be addictive. And to do that, it either needs to be simple enough to just lazily do without too much thought, or complex enough that it fucks you in the mind and you just need to keep trying until you get it right.&lt;br /&gt;
There&#39;s a whole lot more to it than that, but I&#39;m just giving you some food for thought.</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/8702579759600453967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/09/how-to-make-money-from-your-games.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/8702579759600453967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/8702579759600453967'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/09/how-to-make-money-from-your-games.html' title='How to Make Money From an HTML5 Game (Adsense, Merchandise, etc.)'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-5248840379907839594</id><published>2011-08-20T07:57:00.000-07:00</published><updated>2011-09-12T08:03:05.798-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><title type='text'>Introduction to JavaScript</title><content type='html'>It just occurred to me that I&#39;ve been going on about how to make a HTML5 game, while there&#39;s people who want to make a game who haven&#39;t even started with programming/scripting at all yet.&lt;br/&gt;
Before you get started with games development, you&#39;re going to want to have a little bit of experience with the coding first.&lt;br/&gt;
&lt;br/&gt;
So, what I&#39;ll do here is introduce you to the basics of JavaScript. I&#39;ll go into enough that will allow you to start learning to make HTML5 games.&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;JavaScript is not Java&lt;/b&gt;. This is something too many people get confused with. JavaScript is a scripting language, whereas Java is a compiled language. JavaScript is very loosely based off of the Java language.&lt;br/&gt;
And when I say that Java is a compiled language, what I mean by that is, once you write the code, you have to run a compiler to then get the file that you actually run as the program. Scripting languages on the other hand are run line-by-line without compiling the whole code into a file. This means all you have to do is write the code and run the program. (In JavaScript&#39;s case, you just write the code then open the web page, and it&#39;s running)&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
Ok so that&#39;s what JavaScript is, now let&#39;s get into how to write code.&lt;br/&gt;
&lt;b&gt;Here is a little snippet of code, I&#39;ll then explain it:&lt;/b&gt;
&lt;pre&gt;&lt;blockquote&gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
&amp;nbsp;&amp;nbsp;var string = &quot;Hello&quot;;
&amp;nbsp;&amp;nbsp;function writeSomeText() 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;document.write(string+&quot; World&quot;);
&amp;nbsp;&amp;nbsp;}
&amp;lt;/script&amp;gt;

&amp;lt;a onmouseover=&quot;this.style.cursor=&#39;pointer&#39;;&quot; onclick=&quot;writeSomeText();&quot;&amp;gt;
CLICK HERE
&amp;lt;/a&amp;gt;
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;br/&gt;
&lt;b&gt;So, you see the &amp;lt;script&amp;gt; HTML tags. That is where the JavaScript goes in.&lt;/b&gt;&lt;br/&gt;
The first line of JavaScript there is &lt;i&gt;var string = &quot;Hello&quot;;&lt;/i&gt;&lt;br/&gt;
That line creates a &lt;i&gt;variable&lt;/i&gt; called &lt;i&gt;string&lt;/i&gt;, and gives it a value of &quot;Hello&quot;. The semi-colon at the end of the line is part of the JavaScript syntax, it splits the lines up so that when the code is run, it knows how to execute it.&lt;br/&gt;
JavaScript is quite good with variables, because it decides itself what type a variable is. In other languages, you may have to tell it what type it is, but JavaScript automatically knows that it is a string value. And if we gave the variable a value of &lt;i&gt;500&lt;/i&gt; instead of &lt;i&gt;&quot;Hello&quot;&lt;/i&gt;, it would have known that it was a numeric value. However, &lt;i&gt;&quot;500&quot;&lt;/i&gt; is counted as a string.&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;Now, the next block of code is creating a function.&lt;/b&gt;&lt;br/&gt;
To make a function, you do &lt;i&gt;function functionName(params) { functionCode }&lt;/i&gt;&lt;br/&gt;
In my example, I didn&#39;t give it any params (parameters), but they are basically for the purpose of passing in a variable for the function to use when you call the function. I&#39;ll get to function calling later.&lt;br/&gt;
The function code in my example writes text to the document screen. &lt;i&gt;document&lt;/i&gt; is an object which holds a function called write(). It takes a parameter which the function then takes and writes to the screen.&lt;br/&gt;
In my example, it takes the &lt;i&gt;string&lt;/i&gt; variable that we set outside the function, and attaches &quot; World&quot; to it. It joins up to make a string value of &quot;Hello World&quot;, but does not change the value of the variable.&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;Function calling:&lt;/b&gt; Outside the &amp;lt;script&amp;gt; tags, we see an &amp;lt;a&amp;gt; element. Since there is no href attribute given, I had to manually add the code that makes the mouse cursor change to the pointer when you mouse over the link. This was done with a line of JavaScript triggered by an event. The event was onmouseover.&lt;br/&gt;
The other event I used was onclick, which I used to trigger a line of JavaScript which called our writeSomeText() function. This is where the JavaScript calls up the function with that name and executes the code inside the function.&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
So, that&#39;s my Intro to JavaScript. It&#39;s purpose is to show you the syntax, and hopefully allow you to better understand my HTML5 game development guides.&lt;br/&gt;
You can move onto this &lt;a href=&quot;http://html5gamedev.blogspot.com/2011/08/html5-game-development-tutorial.html&quot;&gt;Full HTML5 Game Development Tutorial&lt;/a&gt; if you want.</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/5248840379907839594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/08/introduction-to-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/5248840379907839594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/5248840379907839594'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/08/introduction-to-javascript.html' title='Introduction to JavaScript'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-1458740393392141522</id><published>2011-07-31T16:32:00.001-07:00</published><updated>2011-07-31T17:22:39.097-07:00</updated><title type='text'>Another Example Site Using HTML5 Stuff</title><content type='html'>This site has a cool use of HTML5. You&#39;ll see what I&#39;m talking about when you visit the site. It doesn&#39;t work so well on Internet Explorer (what a surprise).&lt;br/&gt;
Here you go: &lt;a href=&quot;http://whenyouseeityoullshitbricks.com/&quot;&gt;When you see it you&#39;ll shit bricks&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/1458740393392141522/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/another-example-site-using-html5-stuff.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/1458740393392141522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/1458740393392141522'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/another-example-site-using-html5-stuff.html' title='Another Example Site Using HTML5 Stuff'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-3745925753415711738</id><published>2011-07-17T09:20:00.000-07:00</published><updated>2011-07-17T09:28:11.841-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Snippet"/><title type='text'>Snippet List</title><content type='html'>I&#39;ll be writing a bunch of snippets for you guys to use as you please. I&#39;m sure you will find a lot of use with them for making games, and probably other stuff too.&lt;br/&gt;
&lt;br/&gt;
I&#39;ll keep this list updated when I think of more stuff to put in it. And I&#39;m open to suggestions, if you have any, you can contact me via @SlashGame on twitter (By the way, I&#39;m more likely to see a mention than a Private Message).&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/07/snippet-draw-image-with-rotation.html&quot;&gt;Draw Image with Rotation&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/07/snippet-draw-text-to-canvas.html&quot;&gt;Draw Text to Canvas&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/07/snippet-play-sound-html5-audio.html&quot;&gt;Play Sound (HTML5 Audio)&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/07/snippet-mouse-input.html&quot;&gt;Mouse Input&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/07/snippet-keyboard-input.html&quot;&gt;Keyboard Input&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://html5gamedev.blogspot.com/2011/07/snippet-ajax.html&quot;&gt;AJAX&lt;/a&gt;&lt;br/&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/3745925753415711738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-list.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/3745925753415711738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/3745925753415711738'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-list.html' title='Snippet List'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-2722534730642535086</id><published>2011-07-17T08:56:00.000-07:00</published><updated>2011-09-12T12:48:20.214-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="Snippet"/><title type='text'>Snippet - AJAX</title><content type='html'>This is useful for many things with HTML5 game development. You could use it as a means to pass a user&#39;s score to a php script which adds it to a database.&lt;br/&gt;
Or you could do it the other way round, and make it get the highscores from the database, and the function would return the script&#39;s response, which could be used to then write the scores on the canvas, or wherever.&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;span style=&quot;font-weight:bold;&quot;&gt;For Example:&lt;/span&gt;&lt;br/&gt;
&lt;span style=&quot;font-weight:bold;&quot;&gt;ajaxCall(&quot;addScore.php?username=Slash&amp;score=500&quot;);&lt;/span&gt;&lt;br/&gt;
&lt;br/&gt;
That would have called the php script in addScore.php, and passed in the username and score parameters.&lt;br/&gt;
The php script could have simply been written to take those parameters with $_GET[&#39;username&#39;] and $_GET[&#39;score&#39;], and insert the values into a MySQL database.&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
This is just a snippet. I might later make a full tutorial on how to keep a scoreboard. But this function &lt;span style=&quot;font-weight:bold;&quot;&gt;will allow you to call any php script with AJAX and use it&#39;s responseText if necessary.&lt;/span&gt;&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;span style=&quot;font-weight:bold;&quot;&gt;The JavaScript Code:&lt;/span&gt;
&lt;blockquote&gt;&lt;pre&gt;
function ajaxCall(scriptURL) {
  var xmlhttp;
  if(window.XMLHttpRequest)
  {
    xmlhttp=new XMLHttpRequest();
  }
  else
  {
    xmlhttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
  }
  xmlhttp.onreadystatechange=function()
  {
     if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
     {
       return xmlhttp.responseText;
     }
  }
  
  xmlhttp.open(&quot;GET&quot;, scriptURL, true);
  xmlhttp.send();
}
&lt;/pre&gt;&lt;/blockquote&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;Example PHP Script:&lt;/b&gt;
&lt;div style=&quot;overflow: auto; height: 300px; width: 600px;&quot;&gt;
&lt;blockquote&gt;&lt;pre&gt;
// set up connection
$con = mysql_connect(&quot;localhost&quot;, &quot;DBuser&quot;,&quot;DBpass&quot;) or die(mysql_error());
mysql_select_db(&quot;DBname&quot;, $con) or die(mysql_error());

// Get params from the url used
$username = mysql_real_escape_string($_GET[&#39;username&#39;]);
$score = mysql_real_escape_string($_GET[&#39;score&#39;]);

// insert the score into the scores table for the user
$query = &quot;INSERT INTO scores (username, score) VALUES (&#39;&quot; . $username . &quot;&#39;, &#39;&quot; . $score . &quot;&#39;)&quot;;
mysql_query($query, $con) or die(mysql_error());

&lt;/pre&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;br/&gt;
This example PHP script will work for the stuff I mentioned earlier, calling the JavaScript function with something like &lt;b&gt;ajaxCall(&quot;addScore.php?username=Slash&amp;score=500&quot;);&lt;/b&gt;&lt;br/&gt;
&lt;br/&gt;
Note that this is an example to show what goes on with AJAX. However, in a professional situation, PDO would be used rather than MySQL, and jQuery would often be used in the JavaScript. Libraries are used a lot because they are already optimized code and you also have less code to write yourself.</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/2722534730642535086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-ajax.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/2722534730642535086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/2722534730642535086'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-ajax.html' title='Snippet - AJAX'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-3703588650783430585</id><published>2011-07-17T08:48:00.000-07:00</published><updated>2011-09-12T08:05:04.308-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="Snippet"/><category scheme="http://www.blogger.com/atom/ns#" term="user input"/><title type='text'>Snippet - Keyboard Input for HTML5 Games</title><content type='html'>&lt;span style=&quot;font-weight:bold;&quot;&gt;Examples of use:&lt;/span&gt;&lt;br/&gt;
If you wanted to check if the A key is pressed down:
&lt;pre&gt;if (isKeyPressed(&#39;a&#39;)==true) { /* do whatever */ }&lt;/pre&gt;
If you wanted to check for the left arrow key being pressed:
&lt;pre&gt;isKeyPressed(&#39;left&#39;)&lt;/pre&gt;
For escape key:
&lt;pre&gt;isKeyPressed(&#39;esc&#39;)&lt;/pre&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;span style=&quot;font-weight:bold;&quot;&gt;The Code:&lt;/span&gt;
&lt;div style=&quot;overflow: auto; height: 500px; width: 600px;&quot;&gt;&lt;pre&gt;
window.addEventListener(&#39;keydown&#39;,keyPressDown,true);
window.addEventListener(&#39;keyup&#39;,keyPressUp,true);

function keyPressDown(evt){
 keys[evt.keyCode] = true;
}
function keyPressUp(evt){
 keys[evt.keyCode] = false;
}


function isKeyPressed(checkKey) {
 
 // alphabet
 if ((checkKey == &#39;a&#39; || checkKey == &#39;A&#39;) &amp;&amp; (65 in keys &amp;&amp; keys[65])){
  return true;
 }
 else if ((checkKey == &#39;b&#39; || checkKey == &#39;B&#39;) &amp;&amp; (66 in keys &amp;&amp; keys[66])){
  return true;
 }
 else if ((checkKey == &#39;c&#39; || checkKey == &#39;C&#39;) &amp;&amp; (67 in keys &amp;&amp; keys[67])){
  return true;
 }
 else if ((checkKey == &#39;d&#39; || checkKey == &#39;D&#39;) &amp;&amp; (68 in keys &amp;&amp; keys[68])){
  return true;
 }
 else if ((checkKey == &#39;e&#39; || checkKey == &#39;E&#39;) &amp;&amp; (69 in keys &amp;&amp; keys[69])){
  return true;
 }
 else if ((checkKey == &#39;f&#39; || checkKey == &#39;F&#39;) &amp;&amp; (70 in keys &amp;&amp; keys[70])){
  return true;
 }
 else if ((checkKey == &#39;g&#39; || checkKey == &#39;G&#39;) &amp;&amp; (71 in keys &amp;&amp; keys[71])){
  return true;
 }
 else if ((checkKey == &#39;h&#39; || checkKey == &#39;H&#39;) &amp;&amp; (72 in keys &amp;&amp; keys[72])){
  return true;
 }
 else if ((checkKey == &#39;i&#39; || checkKey == &#39;I&#39;) &amp;&amp; (73 in keys &amp;&amp; keys[73])){
  return true;
 }
 else if ((checkKey == &#39;j&#39; || checkKey == &#39;J&#39;) &amp;&amp; (74 in keys &amp;&amp; keys[74])){
  return true;
 }
 else if ((checkKey == &#39;k&#39; || checkKey == &#39;K&#39;) &amp;&amp; (75 in keys &amp;&amp; keys[75])){
  return true;
 }
 else if ((checkKey == &#39;l&#39; || checkKey == &#39;L&#39;) &amp;&amp; (76 in keys &amp;&amp; keys[76])){
  return true;
 }
 else if ((checkKey == &#39;m&#39; || checkKey == &#39;M&#39;) &amp;&amp; (77 in keys &amp;&amp; keys[77])){
  return true;
 }
 else if ((checkKey == &#39;n&#39; || checkKey == &#39;N&#39;) &amp;&amp; (78 in keys &amp;&amp; keys[78])){
  return true;
 }
 else if ((checkKey == &#39;o&#39; || checkKey == &#39;O&#39;) &amp;&amp; (79 in keys &amp;&amp; keys[79])){
  return true;
 }
 else if ((checkKey == &#39;p&#39; || checkKey == &#39;P&#39;) &amp;&amp; (80 in keys &amp;&amp; keys[80])){
  return true;
 }
 else if ((checkKey == &#39;q&#39; || checkKey == &#39;Q&#39;) &amp;&amp; (81 in keys &amp;&amp; keys[81])){
  return true;
 }
 else if ((checkKey == &#39;r&#39; || checkKey == &#39;R&#39;) &amp;&amp; (82 in keys &amp;&amp; keys[82])){
  return true;
 }
 else if ((checkKey == &#39;s&#39; || checkKey == &#39;S&#39;) &amp;&amp; (83 in keys &amp;&amp; keys[83])){
  return true;
 }
 else if ((checkKey == &#39;t&#39; || checkKey == &#39;T&#39;) &amp;&amp; (84 in keys &amp;&amp; keys[84])){
  return true;
 }
 else if ((checkKey == &#39;u&#39; || checkKey == &#39;U&#39;) &amp;&amp; (85 in keys &amp;&amp; keys[85])){
  return true;
 }
 else if ((checkKey == &#39;v&#39; || checkKey == &#39;V&#39;) &amp;&amp; (86 in keys &amp;&amp; keys[86])){
  return true;
 }
 else if ((checkKey == &#39;w&#39; || checkKey == &#39;W&#39;) &amp;&amp; (87 in keys &amp;&amp; keys[87])){
  return true;
 }
 else if ((checkKey == &#39;x&#39; || checkKey == &#39;X&#39;) &amp;&amp; (88 in keys &amp;&amp; keys[88])){
  return true;
 }
 else if ((checkKey == &#39;y&#39; || checkKey == &#39;Y&#39;) &amp;&amp; (89 in keys &amp;&amp; keys[89])){
  return true;
 }
 else if ((checkKey == &#39;z&#39; || checkKey == &#39;Z&#39;) &amp;&amp; (90 in keys &amp;&amp; keys[90])){
  return true;
 }
 
 
 //numbers
 else if ((checkKey == &#39;0&#39;) &amp;&amp; (48 in keys &amp;&amp; keys[48])){
  return true;
 }
 else if ((checkKey == &#39;1&#39;) &amp;&amp; (49 in keys &amp;&amp; keys[49])){
  return true;
 }
 else if ((checkKey == &#39;2&#39;) &amp;&amp; (50 in keys &amp;&amp; keys[50])){
  return true;
 }
 else if ((checkKey == &#39;3&#39;) &amp;&amp; (51 in keys &amp;&amp; keys[51])){
  return true;
 }
 else if ((checkKey == &#39;4&#39;) &amp;&amp; (52 in keys &amp;&amp; keys[52])){
  return true;
 }
 else if ((checkKey == &#39;5&#39;) &amp;&amp; (53 in keys &amp;&amp; keys[53])){
  return true;
 }
 else if ((checkKey == &#39;6&#39;) &amp;&amp; (54 in keys &amp;&amp; keys[54])){
  return true;
 }
 else if ((checkKey == &#39;7&#39;) &amp;&amp; (55 in keys &amp;&amp; keys[55])){
  return true;
 }
 else if ((checkKey == &#39;8&#39;) &amp;&amp; (56 in keys &amp;&amp; keys[56])){
  return true;
 }
 else if ((checkKey == &#39;9&#39;) &amp;&amp; (57 in keys &amp;&amp; keys[57])){
  return true;
 }
 
 
 // special keys
 else if ((checkKey == &#39;left&#39; || checkKey == &#39;LEFT&#39;) &amp;&amp; (37 in keys &amp;&amp; keys[37])){
  return true;
 }
 else if ((checkKey == &#39;right&#39; || checkKey == &#39;RIGHT&#39;) &amp;&amp; (39 in keys &amp;&amp; keys[39])){
  return true;
 }
 else if ((checkKey == &#39;up&#39; || checkKey == &#39;UP&#39;) &amp;&amp; (38 in keys &amp;&amp; keys[38])){
  return true;
 }
 else if ((checkKey == &#39;down&#39; || checkKey == &#39;DOWN&#39;) &amp;&amp; (40 in keys &amp;&amp; keys[40])){
  return true;
 }
 else if ((checkKey == &#39;esc&#39; || checkKey == &#39;ESC&#39; || checkKey == &#39;escape&#39; || checkKey == &#39;ESCAPE&#39; ) &amp;&amp; (27 in keys &amp;&amp; keys[27])){
  return true;
 }
 
}
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/3703588650783430585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-keyboard-input.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/3703588650783430585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/3703588650783430585'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-keyboard-input.html' title='Snippet - Keyboard Input for HTML5 Games'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-7908179154739371688</id><published>2011-07-16T13:17:00.000-07:00</published><updated>2011-09-12T08:05:21.620-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="Snippet"/><category scheme="http://www.blogger.com/atom/ns#" term="user input"/><title type='text'>Snippet - Mouse Input for HTML5 Games</title><content type='html'>The following code can all be copy-pasted to your javascript and used how you wish.&lt;br/&gt;
Keep in mind the clicked() function is empty, because you chose what goes in there if you need to use it. The rest simply set variables that can be used later in the code. (i.e. mouseX, mouseY and ismousedown)&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;blockquote&gt;&lt;pre&gt;
var mouseX = 0;
var mouseY = 0;
window.addEventListener(&#39;mousemove&#39;, mouseMoved, true);
function mouseMoved(e) {
 mouseX = e.pageX;
 mouseY = e.pageY;
}
// ^put that in your code and you will be able
// to use mouseX and mouseY variables anywhere in that code.


window.addEventListener(&#39;click&#39;, clicked, true);
function clicked(e) {
 // you can put whatever you want in here
 // for example, you could use the mouseX and mouseY variables
 // to place a bullet-hole image where the mouse was when clicked
}


var ismousedown = 0;
window.onmousedown = function(e) {
 ismousedown = 1;
}
window.onmouseup = function(e) {
 ismousedown = 0;
}
// ^with this code, you can now check the ismousedown variables
// at any time to check if the mouse is being clicked
// useful for mouse dragging or for holding the &quot;shoot button&quot;, etc.
&lt;/pre&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/7908179154739371688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-mouse-input.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/7908179154739371688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/7908179154739371688'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-mouse-input.html' title='Snippet - Mouse Input for HTML5 Games'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-8918750086352918471</id><published>2011-07-16T12:58:00.000-07:00</published><updated>2011-07-16T13:06:27.682-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Audio"/><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="HTML5"/><category scheme="http://www.blogger.com/atom/ns#" term="Snippet"/><title type='text'>Snippet - Play Sound (HTML5 Audio)</title><content type='html'>Very simple set up and function:&lt;br/&gt;
&lt;blockquote&gt;&lt;pre&gt;
var boingSound = new Audio(&quot;http://slashgame.net/boing.wav&quot;);
function playSound() {
 boingSound.currentTime = 0;
 boingSound.play();
}
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br/&gt;
&lt;br/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var boingSound = new Audio(&quot;http://slashgame.net/boing.wav&quot;);
function playSound() {
 boingSound.currentTime = 0;
 boingSound.play();
}
&lt;/script&gt;
Example usage: &lt;span style=&quot;font-weight:bold;&quot; onmouseover=&quot;this.style.cursor=&#39;pointer&#39;;&quot; onclick=&quot;playSound();&quot;&gt;---CLICK HERE---&lt;/span&gt;
&lt;br/&gt;
&lt;br/&gt;
Taken from &lt;a href=&quot;http://html5gamedev.blogspot.com/2011/06/quick-tip-html5-audio-for-game.html&quot;&gt;HTML5 Audio Quick Tip&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/8918750086352918471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-play-sound-html5-audio.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/8918750086352918471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/8918750086352918471'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-play-sound-html5-audio.html' title='Snippet - Play Sound (HTML5 Audio)'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-8919920185755157265</id><published>2011-07-16T09:57:00.000-07:00</published><updated>2011-09-12T08:05:38.518-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="HUD"/><category scheme="http://www.blogger.com/atom/ns#" term="Snippet"/><title type='text'>Snippet - Draw Text to HTML5 Canvas</title><content type='html'>This function draws text to the canvas with a specified position, color and font.

&lt;blockquote&gt;&lt;pre&gt;
function drawCanvasText(txt, pX, pY, clr, fnt) {
 context2D.fillStyle = clr; // color
 context2D.font = fnt; // font
 context2D.fillText(txt, pX, pY); // text at position X, Y
}
&lt;/pre&gt;&lt;/blockquote&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;Example Usage:&lt;/b&gt;&lt;br/&gt;
&lt;blockquote&gt;&lt;pre&gt;drawCanvasText(&quot;drawing text yas&quot;, 50, 50, &quot;black&quot;, &quot;bold 30px sans-serif&quot;);&lt;/pre&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/8919920185755157265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-draw-text-to-canvas.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/8919920185755157265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/8919920185755157265'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-draw-text-to-canvas.html' title='Snippet - Draw Text to HTML5 Canvas'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-8400730193187492007</id><published>2011-07-16T09:45:00.000-07:00</published><updated>2011-09-12T08:06:21.641-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="Snippet"/><title type='text'>Snippet - Draw Image with Rotation (HTML5 Games)</title><content type='html'>This is a function that draws an image with specified rotation.&lt;br/&gt;
(I first posted this function in the &lt;a href=&quot;http://html5gamedev.blogspot.com/2011/05/rotate-image-on-canvas.html&quot;&gt;Rotate Image on Canvas&lt;/a&gt; tutorial.&lt;br/&gt;
&lt;br/&gt;
&lt;blockquote&gt;&lt;pre&gt;function drawImg(img, pX, pY, oX, oY, w, h, rot) {
 context2D.save();
  context2D.translate(pX+oX, pY+oY);
  context2D.rotate(rot * Math.PI / 180);
  context2D.drawImage(img, 0, 0, w, h, -(oX), -(oY), w, h);
 context2D.restore();
}
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br/&gt;
&lt;span style=&quot;font-weight:bold;&quot;&gt;Note:&lt;/span&gt;&lt;br/&gt;
img: the image object&lt;br/&gt;
pX: the x position of the image&lt;br/&gt;
pY: the y position of the image&lt;br/&gt;
oX: how far across the image that the origin is&lt;br/&gt;
oY: how far down the image that the origin is&lt;br/&gt;
w: width of the image&lt;br/&gt;
h: height of the image&lt;br/&gt;
rot: angle of rotation&lt;br/&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/8400730193187492007/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-draw-image-with-rotation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/8400730193187492007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/8400730193187492007'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/07/snippet-draw-image-with-rotation.html' title='Snippet - Draw Image with Rotation (HTML5 Games)'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-8036663662087343353</id><published>2011-06-27T13:07:00.000-07:00</published><updated>2013-01-21T08:42:46.153-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="canvas"/><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="user input"/><title type='text'>User Input - Mouse Input for HTML5 Games</title><content type='html'>&lt;b&gt;Note: This page has broken links and non-existant images. The code is correct, but you won&#39;t be able to use the exact code I give. Use your own images or learn from the code.&lt;br/&gt;
Note to self: Update this page :P&lt;/b&gt;&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;

A while ago I showed you guys how to do keyboard input &lt;a href=&quot;http://html5gamedev.blogspot.com/2011/05/game-loop.html&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://html5gamedev.blogspot.com/2011/05/user-input-make-it-easier-on-yourself.html&quot;&gt;here&lt;/a&gt;. Now I&#39;ll show you how to do mouse input.&lt;br/&gt;
&lt;br/&gt;
It&#39;s fairly simple, just use an eventListener for the event &quot;mousemove&quot; and use a function that takes the event as a parameter, and use the e.pageX and e.pageY for the mouse&#39;s X and Y position.&lt;br/&gt;
&lt;br/&gt;
And for mouse clicks, just use eventListener for the &quot;click&quot; event, and use a function that does whatever. In the example I give, it sets the position of an image to the position of the mouse at the point it is clicked. In this case, a bullethole in the position the cursor was pointing at.&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
Here is the code:
&lt;div style=&quot;overflow: auto; height: 500px; width: 600px;&quot;&gt;&lt;pre&gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
const FPS = 60;

var canvas = null;
var context2D = null;

var cursorImg = new Image();
cursorImg.src = &quot;images/cursorexample.png&quot;;

var bulletHoleImg = new Image();
bulletHoleImg.src = &quot;images/bullethole.png&quot;;
var bulletHolesX = new Array();
var bulletHolesY = new Array();
for (var i=0; i&lt;50; i++) {
 bulletHolesX[i] = -500;
 bulletHolesY[i] = -500;
}
bulletNum = 0;

window.addEventListener(&#39;mousemove&#39;, mouseMoved, true);
window.addEventListener(&#39;click&#39;, clicked, true);
var mouseX = 0;
var mouseY = 0;

window.onload = init;
function init() {
 canvas = document.getElementById(&#39;canvas1&#39;);
 context2D = canvas.getContext(&#39;2d&#39;);
 
 setInterval(draw, 1000/FPS);
}

function draw() {
 context2D.clearRect(0, 0, canvas.width, canvas.height);
 for (var i=0; i&lt;50; i++) {
  context2D.drawImage(bulletHoleImg, bulletHolesX[i]-(bulletHoleImg.width/2), bulletHolesY[i]-(bulletHoleImg.height/2));
 }
 context2D.drawImage(cursorImg, mouseX-(cursorImg.width/2), mouseY-(cursorImg.width/2));
}

function mouseMoved(e) {
 
 mouseX = e.pageX;
 mouseY = e.pageY;
 
}

function clicked(e) {
 
 bulletHolesX[bulletNum] = mouseX;
 bulletHolesY[bulletNum] = mouseY;
 bulletNum++;
 if (bulletNum &gt; 50) {
  bulletNum = 0;
 }
 
}
&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body style=&quot;padding: 0px; margin: 0px;&quot;&amp;gt;
 &amp;lt;canvas id=&quot;canvas1&quot; width=&quot;600&quot; height=&quot;480&quot; style=&quot;background-color: #A9A9A9;&quot;&amp;gt;
 Browser not compatible with HTML5 canvas
 &amp;lt;/canvas&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;br/&gt;
&lt;br/&gt;
Here is the result: &lt;a href=&quot;http://slashgame.net/mouseinput.php&quot;&gt;here&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/8036663662087343353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/06/user-input-mouse-input.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/8036663662087343353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/8036663662087343353'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/06/user-input-mouse-input.html' title='User Input - Mouse Input for HTML5 Games'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-4030055534548857073</id><published>2011-06-20T15:21:00.000-07:00</published><updated>2013-01-21T08:53:50.539-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Audio"/><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="HTML5"/><category scheme="http://www.blogger.com/atom/ns#" term="quick tip"/><title type='text'>Quick Tip - HTML5 Audio for Game</title><content type='html'>&lt;b&gt;Note: Audio file used in this page is non-existant. Must update this page soon.&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
I&#39;ll just show HTML5 Audio being used with javascript without a canvas. Using it in canvas you just include it in the javascript like normal by calling the function that plays the sound.&lt;br /&gt;
The JavaScript accesses the HTML5 audio, and in effect makes an &amp;lt;audio&amp;gt; element. But it&#39;s good this way, as it&#39;s less cluttered without the tags actually being there or being created.
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Example:&lt;/span&gt;
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;var boingSound = new Audio(&quot;http://slashgame.net/boing.wav&quot;);
function playSound() {
 boingSound.currentTime = 0;
 boingSound.play();
}
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
Notice how it sets the currentTime to 0 before playing. This is because you can&#39;t play the same sound object twice without moving the time back to the start again.
&lt;br /&gt;
&lt;br /&gt;
Here is a use of the result of that:&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var boingSound = new Audio(&quot;http://slashgame.net/boing.wav&quot;);
function playSound() {
 boingSound.currentTime = 0;
 boingSound.play();
}
&lt;/script&gt;
&lt;span onclick=&quot;playSound();&quot; onmouseover=&quot;this.style.cursor=&#39;pointer&#39;;&quot; style=&quot;font-weight: bold;&quot;&gt;---CLICK HERE---&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/4030055534548857073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/06/quick-tip-html5-audio-for-game.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/4030055534548857073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/4030055534548857073'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/06/quick-tip-html5-audio-for-game.html' title='Quick Tip - HTML5 Audio for Game'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5756594577450809773.post-248249050900165059</id><published>2011-06-19T13:16:00.000-07:00</published><updated>2013-01-21T08:37:27.108-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="canvas"/><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="HTML5"/><category scheme="http://www.blogger.com/atom/ns#" term="HUD"/><category scheme="http://www.blogger.com/atom/ns#" term="quick tip"/><title type='text'>Quick Tip - fillText JavaScript Function - HUD</title><content type='html'>&lt;blockquote&gt;
&lt;pre&gt;context2D.fillStyle = &quot;white&quot;;
context2D.font = &#39;bold 30px sans-serif&#39;;
context2D.fillText(&quot;POINTS: &quot;+numOfPoints, canvas.width-200, 30);
&lt;/pre&gt;
&lt;/blockquote&gt;
That right there is an example of drawing text to the canvas. It writes it on the top right of the canvas. That particular example is what would serve as the HUD in a game.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here it is in practise:&lt;br /&gt;
(you get points for moving right and left)&lt;br /&gt;
&lt;canvas height=&quot;200&quot; id=&quot;canvas332872&quot; style=&quot;background-color: darkgrey;&quot; width=&quot;500&quot;&gt;
&lt;b&gt;Browser not compatible.&lt;/b&gt;&lt;br /&gt;
Recent versions of Firefox, Opera, Google Chrome and Safari work for this game.&lt;br /&gt;
If you are using Internet Explorer; Stop using it immediately before you die of idiocy.
&lt;/canvas&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
const FPS332872 = 30;

var playerPosX332872 = 0;
var playerPosY332872 = 0;
var numOfPoints = 0;

var playerImg332872 = new Image();
playerImg332872.src = &quot;http://i.imgur.com/nEYjaIe.png&quot;;

var canvas332872 = null;
var context2D332872 = null;
var keys332872 = new Array();

window.onload = init332872;

window.addEventListener(&#39;keydown&#39;,keyDown332872,true);
window.addEventListener(&#39;keyup&#39;,keyUp332872,true);
function keyDown332872(evt){
 keys332872[evt.keyCode] = true;
}
function keyUp332872(evt){
 keys332872[evt.keyCode] = false;
}

function init332872()
{
 canvas332872 = document.getElementById(&#39;canvas332872&#39;);
 context2D332872 = canvas332872.getContext(&#39;2d&#39;);
 setInterval(draw332872, 1000 / FPS332872);
}

function draw332872()
{
 if ((37 in keys332872 &amp;&amp; keys332872[37]) || (65 in keys332872 &amp;&amp; keys332872[65])){ //left
  playerPosX332872 -= 3;
  numOfPoints += 0.1;
 }
 if ((39 in keys332872 &amp;&amp; keys332872[39]) || (68 in keys332872 &amp;&amp; keys332872[68])){ //right
  playerPosX332872 += 3;
  numOfPoints += 0.1;
 }
 
 context2D332872.clearRect(0, 0, canvas332872.width, canvas332872.height);
 context2D332872.drawImage(playerImg332872, playerPosX332872, playerPosY332872);
context2D332872.fillStyle = &quot;white&quot;;
context2D332872.font = &#39;bold 30px sans-serif&#39;;
context2D332872.fillText(&quot;POINTS: &quot;+Math.floor(numOfPoints), canvas332872.width-200, 30);
}
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://html5gamedev.blogspot.com/feeds/248249050900165059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://html5gamedev.blogspot.com/2011/06/quick-tip-filltext-javascript-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/248249050900165059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5756594577450809773/posts/default/248249050900165059'/><link rel='alternate' type='text/html' href='http://html5gamedev.blogspot.com/2011/06/quick-tip-filltext-javascript-function.html' title='Quick Tip - fillText JavaScript Function - HUD'/><author><name>Stephen</name><uri>http://www.blogger.com/profile/00219053447967835585</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>