Your SlideShare is downloading. ×
0
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Rawkets - A Massively Multiplayer HTML5 Game [Mozilla GameOn10]

4,109

Published on

This is my 10 minute talk about Rawkets from the Open Web Gaming event put on in London by Mozilla and Six to Start. …

This is my 10 minute talk about Rawkets from the Open Web Gaming event put on in London by Mozilla and Six to Start.

Watch it on YouTube: http://www.youtube.com/watch?v=Z9JM9CpASS0

Published in: Technology
2 Comments
8 Likes
Statistics
Notes
  • Like the best ever slides you’ve ever made!
    And already watched on Mozilla Channel. You’re awesome!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Btw, you can now watch the whole talk on YouTube.

    <br /><object type="application/x-shockwave-flash" data="http://www.youtube.com/v/Z9JM9CpASS0?fs=1&amp;hl=en_GB" width="350" height="288"><param name="movie" value="http://www.youtube.com/v/Z9JM9CpASS0?fs=1&amp;hl=en_GB"></param><embed src="http://www.youtube.com/v/Z9JM9CpASS0?fs=1&amp;hl=en_GB" width="350" height="288" type="application/x-shockwave-flash"></embed></object>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
4,109
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
2
Likes
8
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Hi everyone, I&apos;m going to talk to you briefly about Rawkets, my HTML5 canvas and WebSockets game.\n
  • - For those who don&apos;t know me, which I imagine is a lot of you, my name is Rob Hawkes.\n- If you&apos;re into Twitter, then feel free to follow me, my username is @robhawkes.\n- I&apos;ve worked on all sorts of projects, but the most recent and well known are the HTML5 version of the Google balls logo, and Rawkets.\n- I&apos;m also working on a few things which I hope you don&apos;t mind me mentioning.\n- The first is my book on making games using HTML5 canvas. It&apos;s called Foundation HTML5 Canvas and will be out next spring. If you&apos;re interested in it you can always pre-order it from Amazon right now, it won&apos;t cost you a penny until the book is actually released. I can promise you I&apos;m putting my all into it and I&apos;m really enjoying writing it.\n- The second thing is the Web design and development podcast I co-host, called ExplicitWeb. Myself and my good friends John O&apos;Nolan, and Hannah talk about all thing related to the Web industry in a light-hearted, completely random sort of way. We&apos;re on iTunes if you want to have a listen.\n
  • As I mentioned at the beginning, Rawkets is a game that is built using HTML5 canvas and WebSockets.\n
  • - To be more precise, you could describe it as a massively multiplayer online space shooter game, or a mamossga for short.\n- The purpose of the game is to be&amp;#x2026;\n
  • &amp;#x2026; massive&amp;#x2026;\n
  • &amp;#x2026;simple&amp;#x2026;\n
  • &amp;#x2026; experimental&amp;#x2026;\n
  • &amp;#x2026;and social.\n
  • \n
  • - Rawkets it actually the major project for my university degree in interactive media. It&apos;s still in very early development, in fact it&apos;s not even 2 months old yet.\n- I created it for a few reasons.\n
  • - Firstly, because I&apos;m massively interested in open Web technologies. They fascinate me and I&apos;m constantly left amazed at what can be achieved with them.\n
  • - Secondly, I&apos;m passionate about the Web and technology in general. I thrive on mucking around stuff to see how it works and how I can break it.\n
  • - And finally, I absolutely love learning new things, whether that&apos;s game development theory or WebSockets. If it interests me, I want to learn more about it.\n
  • - Developing Rawkets seemed like the perfect way to satisfy all those things, but really I can&amp;#x2019;t think of a legitimate reason why not to make it!\n
  • - Rawkets came as a result of wanting to learn more about HTML5 canvas and WebSockets, so the technologies behind it were very much decided in advance.\n
  • - On the client-side I&apos;m using HTML5 canvas for the graphics&amp;#x2026;\n
  • - &amp;#x2026;and WebSockets for the communication between the player and the server.\n
  • - On the server-side I&apos;m using node.js for the game logic and WebSockets communication.\n
  • - And, although not implemented yet, data storage on the server is going to be done via MongoDB a document-based database.\n- It&apos;s honestly quite amazing what can be achieved by mashing together a few open technologies.\n
  • - Overall, I&apos;m quite shocked at how well these technologies perform. Even with my shoddy code I&apos;ve been able to knock together a fully functional real-time multiplayer game that is generally very playable.\n- However, there are a few issues with performance that I&apos;d like to highlight.\n
  • &amp;#x2013; The main issues have been with network communication and the WebSockets protocol.\n- For those who aren&apos;t that clued up on WebSockets, it&apos;s basically a way for a server to send data to a user, while at the same time allowing that user to send data back to the server, practically instantaneously. In comparison, Web traffic normally only allows data to be sent in one direction at a time, which can quite slow and annoying if you&apos;re wanting to send lots of data back and forth at the same time.\n- Originally I was sending data, like the position of players, through WebSockets as quite verbose, plain text.\n- This caused a lot of bottlenecks and performance issues because there was helluva lot of position data being sent back and forth.\n- To get around this I did 2 things&amp;#x2026;\n
  • - Firstly, I created a communication protocol that dictated how data would be sent back and forth. I coupled this with the use of BISON (a binary version of JSON), which compressed the data a bit and chopped off anything unnecessary &amp;#x2013; for example, by cutting down large floating point numbers for pixel values.\n- The data is still sent as plain text, such is the nature of WebSockets, but putting this protocol in place cut the size of data immensely, allowing for more users to be on at the same time whilst having less of an impact on network performance.\n
  • - Secondly, I limited the rate position data was sent at. At first I was sending position data every time a keyDown event was fired. What I failed to realise was that this event fired much faster than 30ms, the framerate of the game. By limiting the rate position data is sent to 30ms, it also cut down the amount of data being sent back and forth immensely.\n- Even with these 2 issues solved, each player still currently receives data for all players in the game, regardless of whether they appear on your screen or not. This is a really bad way to do things, for one very good reason. It requires a stupid amount of resources. Let me explain&amp;#x2026;\n
  • - Having only one player in the game is easy, you have one message coming in to the server, saying the player has moved, for example, and one message coming back out, updating the player with details from the server.\n- But one lonely player does not equal a multiplayer game, let alone a massively multiplayer one.\n
  • - So say we now have two players, meaning the game is now technically multiplayer, but still not massively.\n- There is still only 1 message in from each player, but now each player receives 2 messages back from the server; one for them, and one for the other player.\n- This isn&amp;#x2019;t too bad, but notice how the server is having to send 4 messages &amp;#x2013;&amp;#xA0;2 for each player.\n
  • - 4 players now. It&amp;#x2019;s still not quite massive, but look how the server is having to send 16 messages, yet it only receives 4.\n- If you haven&amp;#x2019;t already noticed, the messages out from the server are the square of the number of players.\n- But 16 messages out is alright, it&amp;#x2019;s hardly going to tax the server.\n
  • - So imagine if we now move into properly multiplayer territory, although still not quite massive.\n- 30 players in the game would mean 30 messages coming in to the server, and 900 &amp;#x2013; NINE HUNDRED &amp;#x2013; messages going out, every 30ms. That&amp;#x2019;s a silly amount of data for just 30 people.\n- But let&amp;#x2019;s go further still&amp;#x2026;\n
  • - Say we really do go massive and have 100 players in the game at one time.\n- It&amp;#x2019;s not so bad for each individual player, they send one message in and get 100 back &amp;#x2013; that&amp;#x2019;s bearable. \n- But check out the server, it&amp;#x2019;s getting 100 messages in and is having to send out 10,000 back, every 30ms. That&amp;#x2019;s just a mentally stupid number that&amp;#x2019;s going to cause a lot of grief.\n- Fortunately there is a way around this that cuts down the amount of messages sent from the server; you just need to send data only for players visible to another player, in essence filtering out game data that doesn&apos;t affect the current player. It&amp;#x2019;s such a simple solution, but it&amp;#x2019;s one that I never even considered at first.\n
  • - Now, canvas also has a performance issue, but only really when doing lots of animation &amp;#x2013;&amp;#xA0;it just loves to hog the CPU.\n- Fortunately this will get much better with the introduction of things like hardware accelerated JavaScript that delegates intensive work with canvas to the graphics card.\n
  • - Aside from technical limitations, the main issue has been with cheating, or manipulation of the game code.\n- Because the game is built in JavaScript, the code is easily accessible and is open for attack.\n- But there are ways to stop this&amp;#x2026;\n- One way to foil cheaters would be to perform all important calculations on the server, rather than on the client-side. That way, although the cheater may be able to manipulate his own game, it shouldn&apos;t affect other players.\n- Another way is to use private properties and methods in JavaScript objects in an effort to prevent them from being manipulated. This is a really simple way of making it difficult for cheaters to override the game code.\n- Finally, you could just obfuscate the code and minify it to make it unreadable. That&amp;#x2019;d help too.\n
  • - All in all, I&apos;ve been left enlightened by the open Web technologies that lie behind Rawkets, and its development is proving to be a valuable experience for me. I really hope that it has a bright future ahead of it as I&amp;#x2019;m enjoying developing it.\n- I&apos;ll be putting these slides up soon, so check out my website rawkes.com if you&apos;re interested in seeing them or finding out more about Rawkets and what I get up to.\n
  • Thank you for listening, and I hope you enjoy the rest of your evening.\n
  • ×