How to build Kick Ass Games in the Cloud
Upcoming SlideShare
Loading in...5
×
 

How to build Kick Ass Games in the Cloud

on

  • 4,528 views

This is a presentation given by Googlers Chris Schalk and Johan Euphrosine (Proppy) at GDD Sydney 2011 on how to build multi-platform video games using PlayN.

This is a presentation given by Googlers Chris Schalk and Johan Euphrosine (Proppy) at GDD Sydney 2011 on how to build multi-platform video games using PlayN.

Statistics

Views

Total Views
4,528
Views on SlideShare
4,444
Embed Views
84

Actions

Likes
3
Downloads
31
Comments
0

4 Embeds 84

http://moodle.i3s.unice.fr 63
http://www.gaecupboard.com 11
http://localhost 7
http://moodle.polytech.unice.fr 3

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

How to build Kick Ass Games in the Cloud How to build Kick Ass Games in the Cloud Presentation Transcript

  • Christian SchalkGoogle Developer AdvocateWith special guest speaker, Proppy! How to Build Kick Ass Games in the Cloud
  • About the Speaker Christian Schalk Day Job ● Developer Advocate for Googles Cloud Technology ○ App Engine, Google Storage, Prediction API, BigQuery ... ● Mostly Server-Side Java Background ○ "JavaServer Faces: The Complete Reference" Co-Author ● Havent developed video games since the Commodore-64! Yes, Im old school ;-)
  • Agenda ● PlayN Technology ● Hands on with PlayN ○ Getting Started ○ Building a game from scratch w/ Proppy ● Deploying your game to the cloud ● Setting up an RPC mechanism ● Integrating w/ Google Plus ● Summary
  • First, Some Questions... ● Thinking of building a game for the Web? ? ○ Would you use Flash? ○ or HTML5? ● What if you wanted to port your game to Mobile? ○ Do you need an entirely separate code base?
  • First, Some Questions... ● Thinking of building a game for the Web? ? ○ Would you use Flash? ○ or HTML5? ○ Answer: Doesnt Matter!! Can do both! ● What if you wanted to port your game to Mobile? ○ Do you need an entirely separate code base? ○ Answer: NO!
  • First, Some Questions... ● Thinking of building a game for the Web? ? ○ Would you use Flash? ○ or HTML5? ○ Answer: Doesnt Matter!! Can do both! ● What if you wanted to port your game to Mobile? ○ Do you need an entirely separate code base? ○ Answer: NO! How is this Possible!??
  • Introducing PlayN!! One Game. Many Platforms.Formerly known as "ForPlay"
  • What is PlayN? ● An open source technology for building cross-platform games ● Core game code is platform agnostic ● Develop games in Java ○ Familiar language/toolset ● Leverages Google Web Toolkit ○ Compiles to JS/HTML5, (among other platforms) ● Free and Open Source (alpha) ○ http://code.google.com/p/playn
  • PlayN API Structure PlayN API Flash impl.Implementations for Java, HTML5(GWT/JS), Android, Flash
  • Components of PlayNExtend PlayN.Game PlayN.*Fully generic gaming components. Core game logic is fully platformindependent!
  • PlayN Cross Platform Magic● Game uses core PlayN abstractions, is unaware of which platform is running● The only platform-specific code is in the entry point for each platform: PlayN.run(new MyGame()); PlayN.run(new MyGame());
  • Other PlayN Benefits● Built-in physics engine based on proven OpenSource technologies ● Box2D ○ C++ 2D Physics engine by Erin Catto ● JBox2D ○ A port of Box2D from C++ to Java ● GWTBox2D ○ A port of JBox2D from Java to JavaScript
  • Benefits of GWT Abstraction● GWT Compiler optimizes code for size ○ Removes unused code ○ Evaluates when possible at compile time ○ Heavily obfuscated result code● Smaller compiled code - faster load time● Optimized caching, avoids unnecessary network IO
  • The PlayN Game LoopSimilar to other gaming platforms public class MyGame implements Game { public void init() { // initialize game. } public void update(float delta) { // update world. } public void paint(float alpha) { // render world. } }
  • PlayN RenderingCan easily with different screen parameters // Resize to the available resolution on the current device. graphics().setSize( graphics().screenWidth(), graphics().screenHeight() ); // Keep the same aspect ratio. float sx = graphics().screenWidth() / (float) WIDTH; float sy = graphics().screenHeight() / (float) HEIGHT; // Fit to the available screen without stretching. graphics().rootLayer().setScale(Math.min(sx, sy));
  • PlayN Drawing API
  • PlayN Layer System
  • Layer Types● Layers have distinct sizes and transforms● Used to optimize
  • IO System: Platform Abstractions ● Pointer ○ Most general screen event ○ Works everywhere ● Mouse ○ Left, right, mid buttons & wheel ● Touch ○ Pressure, size, multitouch
  • IO System: Input Devices pointer().setListener(new Pointer.Adapter() { public void onPointerStart(Pointer.Event event) { // Handle mouse down event. } // ...Same pattern for onPointerEnd, onPointerDrag }); keyboard().setListener(new Keyboard.Adapter() { public void onKeyDown(Event event) { // Handle key down event. } // ... Same pattern for onKeyUp });
  • Asset Management public interface AssetManager { Image getImage(String path); Sound getSound(String path); void getText(String path, ResourceCallback callback); boolean isDone(); int getPendingRequestCount(); }
  • Agenda ● PlayN Technology ● Hands on with PlayN ○ Getting Started ○ Building a game from scratch w/ Proppy ● Deploying your game to the cloud ● Setting up an RPC mechanism ● Integrating w/ Google Plus ● Summary
  • Requirements for getting started with PlayN ● Core Requirements ○ Java 6 SDK ○ Apache Ant ○ Maven ○ App Engine SDK ○ Android SDK ● Requirements with Eclipse ○ Eclipse IDE Indigo 3.7 (Or earlier version w/ Maven) ○ Google Plugin for Eclipse ○ Android Plugin for Eclipse
  • Building/Installing PlayN ● PlayN 1.0 is now available in Maven Central! ○ Wiki will be updated soon, but can simply create a Maven project ● Or can clone a copy of PlayN ○ git clone https://code.google.com/p/playn ● Then... ○ cd playn (directory where your copy is location) ○ mvn install (or ant install) ● Running showcase sample app with Mvn ○ cd playn/sample/showcase/core ○ mvn compile exec:java ● Running showcase sample app with Ant ○ cd playn/sample/showcase ○ ant run-java
  • Demo: How to get started w/ PlayN http://code.google.com/p/playn
  • Building a new project in PlayN● From the command line: ○ mvn archetype:generate -DarchetypeGroupId=com.googlecode.playn -DarchetypeArtifactId=playn-archetype ○ ...● From Eclipse ○ Select File → New → Project..., then select Maven → Maven Project in the dialog that pops up, then click Next. ■ Click Next again unless you wish to specify a custom workspace location. ■ Check Include snapshot archetypes in the dialog and then double click on the playn-archetype in the list of archetypes ○ ...
  • Demo: Building a new Game in PlayN
  • Agenda ● PlayN Technology ● Hands on with PlayN ○ Getting Started ○ Building a game from scratch w/ Proppy ■ http://proppy-playn101.appspot.com/ ● Deploying your game to the cloud ● Setting up an RPC mechanism ● Integrating w/ Google Plus ● Summary
  • Agenda ● PlayN Technology ● Hands on with PlayN ○ Getting Started ○ Building a game from scratch w/ Proppy ● Deploying your game to the cloud ● Setting up an RPC mechanism ● Integrating w/ Google Plus ● Summary
  • Deploy your HTML project to the Cloud ● For Google App Engine Deployment, you can easily convert the project to an App Engine Project
  • Deploy your HTML project to the Cloud ● After converting your HTML project to an App Engine project you will have to do... ● Add a WEB-INF/lib/appengine-web.xml file ○ Note: Click Quick Fix in the Errors console of Eclipse ● Before deployment make sure your WEB-INF/lib has the necessary runtime App Engine jar files.
  • Agenda ● PlayN Technology ● Hands on with PlayN ○ Getting Started ○ Building a game from scratch w/ Proppy ● Deploying your game to the cloud ● Setting up an RPC mechanism ● Integrating w/ Google Plus ● Summary
  • Setting up an RPC mechanism ● Building your client code ○ You can use PlayNs Net().Post() call to send data to a server ● Building Your Server ○ PlayN comes with a preliminary Server example code that uses Jetty ■ Is not needed if deploying to App Engine ■ Instead, you can implement your own server by adding an HttpServlet to your project ■ Have it implement the doPost() method ■ Can map it to url: /rpc in web.xml
  • Setting up an RPC mechanism ● Example: A client method to persist a score private void postScore(String payload) { net().post("/rpc", payload, new Callback<String>() { @Override public void onSuccess(String response) { // TODO } @Override public void onFailure(Throwable error) { // TODO } });}
  • Setting up an RPC mechanism ● Example: Server method to persist score sent from clientprotected void doPost(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException { String payload = readFully(req.getReader()); Json.Object data = json().parse(payload); String score = data.getString("score"); if (score != null){ persistScore(score, id); } }private void persistScore(String score) {...}
  • Agenda ● PlayN Technology ● Hands on with PlayN ○ Getting Started ○ Building a game from scratch w/ Proppy ● Deploying your game to the cloud ● Setting up an RPC mechanism ● Integrating w/ Google Plus ● Summary
  • Integrating your game with Google+ Visit http://developers.google.com/+ Download the Java Starter App
  • Integrating your game with GooglePlusSample Starter App contains... ● README.txt with steps on: ○ Visiting https://code.google.com/apis/console to enable Google Plus API access for your app ■ To generate your ■ oauth_client_id, ■ oauth_client_secret, ■ google_api_key ● Sample Java classes to redirect game users for OAuth authentication
  • Integrating your game with GooglePlusTo access GooglePlus profile data.. Person profile; try { profile = plus.people.get("me").execute(); } catch (HttpResponseException e) { log.severe(Util.extractError(e)); return; }
  • Integrating your game with GooglePlus Accessing GooglePlus profile data in a JSP page...<a href="<%= profile.getUrl() %>"> <img src="<%= profile.getImage().getUrl() %>?sz=100"/></a>Welcome, <%= profile.getDisplayName() %>
  • Demo: Introducing Cloud WarriorApp Engine Google Storage Game Assets (images/sounds) Game Scores Profile Data http://ae-cloudwarrior.appspot.com
  • PlayN Summary● Open source, cross-platform game abstraction layer ○ Core game logic is platform agnostic● ForPlay abstracts away the core components of a game ○ The game loop, I/O system, and asset management● Write in familiar Java, get performance on multiple platforms ○ Superior Java development/debug ○ GWT allows compilation to fast JavaScript/HTML5● Your assignment: ○ Install PlayN and build a game! ○ http://code.google.com/p/playn/
  • Announcing the New PlayN Developer Site! http://developers.google.com/playn/
  • Q&Aprofiles.google.com/proppyprofiles.google.com/cschalk
  • Thank You!