JavaScript is
good now

Talk by Matthew Gatland / @mgatland

¯\_(ツ)_/¯

What about

no mobile version…

no mobile version…

no mobile version…

no mobile version…

Unity makes it easy, but not that easy…

JavaScript is different.

What if I could tell you...

  • You can make a game today
  • And release it on iPhone tonight

What if I could tell you...

  • You can learn ONE progamming language
  • And release on EVERY platform
  • (no more Xcode!)

* M A G I C *

No App Store

(Actually, you can still use the app store if you want to)

(We'll talk about this later)

That's cool, but

can i make a real game?

Is JavaScript good enough?

  • graphics
  • smooth framerate
  • audio
  • controls
  • networking
  • App stores

Graphics

2D, 3D, all devices

Going fullscreen

Going fullscreen

Going fullscreen

iOS 7.1+


<meta name="viewport" content="minimal-ui">
					

Android


element.requestFullscreen();
					

Framerate


window.requestAnimationFrame(update) //called on every screen refresh
					

(Before this, there was no accurate timing in JavaScript!)

Audio

This used to be really bad

(especially on iPhone)


Now it's good – we can play multiple channels, change volume, use special effects, everything.


(remember the unmute hack)

Input

I don't want any browser rubbish

  • NO double tap to zoom-in
  • NO swipe left to go back
  • Arrow keys should NOT scroll
  • ...

We can disable MOST default browser actions with one line:


...
  e.preventDefault();
...
					

(There are a few you can't disable)

Network

Networking is a little complex, so I use a framework – socket.io


  var socket = io.connect("http://mgatland.com/server");

  //send a message
  var messageType = "state";
  var message = {x:10, y:10, health:99};
  socket.emit(messageType, message);

  //receive a message
  socket.on("state", function (data) {
  	//do stuff
  })
...
					

JSON is easy, but inefficient... you can use binary instead.

Network limitations

Websockets can only do reliable connections.
We can't send unreliable (UDP) data.

WebRTC supports unreliable data, but it's not in iOS, Safari or Internet Explorer.

And Finally...

Distribution

Distributing your game as a website is super easy.

(See Gridland and 2048)

But if you wanna get rich, you need to play in the App Store...

Cocoon.js

turns your JavaScript game into an app

free (for now)

totally easy

(they add a splash screen)

Cocoon.js (continued)

You can test this in < 5 minutes

Doing it for real is almost as easy - you need icons, licence keys...

PhoneGap is an open source alternative.

Conclusion

You can make a game today that people can play on every platform, right now.

You can distribute it on the web with NO DRAMA

(No expensive licence)

(No Xcode crashing all the time)

(No learning a new language for every platform)

(You don't even have to make a new build for each platform)

Conclusion

You can put it in the app store with ALMOST NO DRAMA

(Still no Xcode! :)

But you will need a developer account

Image credits for Creative Commons images:

  • 11.6" MacBook Air by Paul Hudson
  • My iPhone by Marck170601
  • Samsung Galaxy S4 Mini by GalaxyOptimus
  • Skeptical? by Mark Skipper – https://www.flickr.com/photos/bitterjug/6278390124/
  • Little Flame Character by Skorpio - http://opengameart.org/content/little-flame-character
  • App Store icon from iOS 7-inspired Mac icon set by Tristan Edwards https://www.iconfinder.com/icons/171355/app_store_icon

Browser logos from https://github.com/alrra/browser-logos

THE END

BY Matthew Gatland / matthewgatland.com