SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
Thursday, May 12, 2011   1
Thursday, May 12, 2011   2
Kick-Ass Game Programming
     with Google Web Toolkit
     Ray Cromwell, Philip Rogers
     May 11th, 2011




Thursday, May 12, 2011             2
Thursday, May 12, 2011   3
Demo time!



Thursday, May 12, 2011   3
What’s covered in this session
      • Intro / Why GWT?
      • Architecting a game
      • Introducing ForPlay
      • Let’s build a game
           – and share it
      • Advanced Topics
           – Android
           – Flashy




     4


Thursday, May 12, 2011                4
Why use GWT for games?
      GWT = Game Web Toolkit?


      • Leverage familiar Java toolchain (debugger, IDE, etc.)


      • Share code between client, server... and other platforms?


      • Produce small, fast JavaScript & HTML5




     5


Thursday, May 12, 2011                                              5
Leveraging familiar Java tools and libraries
      Port a physics engine

                         Box2D                          JBox2D                      GWTBox2D

                          C++                                                        Java and
                                                         Java
                                                                                     Javascript

      • 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
           – “Porting” 11,000 lines took ~30 minutes. (removed ThreadLocal, etc.)

     6


Thursday, May 12, 2011                                                                            6
Faster and Smaller

      • GWT Compiler optimizes code for size
           – Removes unused code
           – Evaluates, when possible, code at compile time
           – Inlines functions
           – Heavily obfuscates the result
      • Smaller code loads faster
      • Perfect Caching avoids need for network I/O
      • Inlining helps code run faster




     7


Thursday, May 12, 2011                                        7
HTML5 for games
      • Formal HTML5
           – New HTML Elements
                 • 2D Canvas, great for curves and text (GWT 2.2)
                 • Audio, Video (GWT 2.2)
           – Application Cache (GWT 3.0)
           – Much, much more...
      • Colloquial “HTML5”
           – 3D Canvas (WebGL) (GWTGL)
                 • OpenGL ES 2.0 made JavaScript friendly
                 • Important for 2D games due to acceleration
           – CSS3
                 • Supports hardware accelerated transforms

     8


Thursday, May 12, 2011                                              8
Thursday, May 12, 2011   9
Architecting a game



Thursday, May 12, 2011      9
Overview of a game




                         The Game Loop        I/O System            Asset Management
                  init()                 keyboard, pointer, touch   loading
                  update(delta)          audio, graphics            saving
                  paint(delta)           storage, network           caching




     10


Thursday, May 12, 2011                                                                 10
Challenges of a cross-platform game


                         The Game Loop            I/O System              Asset Management



              Keeping graphics, update,   Not always available/accel:   Loading
               and I/O in sync.            WebGL, CSS3, Canvas          Caching assets
              RequestAnimationFrame       Audio                         Application Cache
              Interpolation in paint()    Inputs: touch, mouse, etc.




     11


Thursday, May 12, 2011                                                                       11
Thursday, May 12, 2011   12
Abstraction is key



     GWT abstracts away browser differences.
     Let’s apply that to cross-platform games.




Thursday, May 12, 2011                           12
Introducing ForPlay
      GWT abstraction layer for games


      • A small API for building fast cross-platform games
           – Core game can be platform-agnostic


      • Written in Java so you get a familiar language and toolset
           – And a great debugging environment


      • GWT-compatible so you can compile to JavaScript/HTML5


      • Free and open source (alpha version)
           – http://code.google.com/p/forplay
     13


Thursday, May 12, 2011                                               13
Introducing ForPlay
      • Think: Service Provider Interface (SPI)



                                            ForPlay API




                    Java impl.   GWT/JS impl.         Android impl.   ... Flash impl?




     14


Thursday, May 12, 2011                                                                  14
Thursday, May 12, 2011   15
Demo time



Thursday, May 12, 2011   15
Components of ForPlay

                         The Game Loop                  I/O System              Asset Management



              Extend ForPlay.Game              import static core.ForPlay.*   assetManager()
                  init()                       audio(), graphics(), net()      .getImage(String path)
                  update(float delta)                                          .getSound(String path)
                  paint(float delta)           Pointers & Keyboard input       .getText(String path)
                                               Layers for fast graphics       also ResourceCallback




      • ForPlay provides the cross platform magic to make these abstractions transparent
           – Core game has no platform-specific calls
     16


Thursday, May 12, 2011                                                                                  16
The Game   I/O System      Asset
     Components of ForPlay                                      Loop                  Management

      • Just extend implement ForPlay.Game

                             public class MyGame implements Game {
                                 public void init() {
                                     // init game
                                 }
                                 public void update(float deltaTime) {
                                     // update
                                 }
                                 public void paint(float deltaTime) {
                                     // paint
                                 }
                         }

     17


Thursday, May 12, 2011                                                                         17
The Game         I/O System      Asset
     Components of ForPlay                                      Loop                        Management

      • Delta in paint() can be used for interpolation

                             public class MyGame implements Game {


                                 public void paint(float delta) {
                                     float xInterp = (delta) * x + (1-delta) * prevX;
                                     float yInterp = (delta) * y + (1-delta) * prevY;
                                     layer.setTranslation(xInterp, yInterp);
                                 }


                         }




     18


Thursday, May 12, 2011                                                                               18
The Game         I/O System      Asset
     Components of ForPlay                                      Loop                        Management

      • Input devices

                             public class MyGame implements Game, Pointer, Keyboard {
                                 public void onPointerMove(int x, int y) {
                                     // handle pointer movement
                                 }
                                 public void onPointerScroll(int velocity) {
                                     // handle zoom, etc.
                                 }
                                 public void onKeyDown(int keyCode) {
                                     // handle keypress
                                 }
                         }

     19


Thursday, May 12, 2011                                                                               19
The Game            I/O System         Asset
     Components of ForPlay                                            Loop                              Management

      • Images - using the ForPlay layer system

                                          Layer
                                   Scale, Rotate, Translate




             GroupLayer               ImageLayer              SurfaceLayer
            List<Layer> children   Image image, setRepeat()      Surface surface




                                          Image                    Surface                            Canvas
                                         width, height        drawImage(), fillRect()           strokePath(), drawArc(),
                                                                                                      drawText()




     20


Thursday, May 12, 2011                                                                                                     20
The Game   I/O System      Asset
     Components of ForPlay     Loop                  Management




     21


Thursday, May 12, 2011                                        21
The Game      I/O System      Asset
     Components of ForPlay                                  Loop                     Management

          Loading and displaying images

                         Image image = assetManager().getImage(“myImage.png”);
                         image.addCallback(new ResourceCallback<Image>() {
                             public void done(Image image) {
                                 // handle new image
                             }
                         }




     22


Thursday, May 12, 2011                                                                        22
The Game      I/O System      Asset
     Components of ForPlay                                  Loop                     Management

          The AssetWatcher

                         AssetWatcher watcher = new AssetWatcher(new Listener() {
                           public void done() {
                               startMyGame();
                           }
                         });


                         watcher.add(image1);
                         watcher.add(image2);
                         watcher.start();




     23


Thursday, May 12, 2011                                                                        23
ForPlay cross platform magic
      • Game uses core ForPlay abstractions, is unaware of which platform is running
      • The only platform-specific code is in the entry point for each platform:

     public class MyGameHtml extends HtmlGame {       public class MyGameJava {
              public void start() {                       public static void main(String[] args){
                         HtmlPlatform.register();             JavaPlatform.register();
                         ForPlay.run(new MyGame());           ForPlay.run(new MyGame());
              }                                           }
     }                                                }




     24


Thursday, May 12, 2011                                                                              24
ForPlay wrap-up
      • Open source, cross-platform game abstraction layer
           – Where the core game is platform-agnostic


      • ForPlay abstracts away the core components of a game
           – The game loop, I/O system, and asset management


      • Write in Java, get performance on multiple platforms
           – Java provides a great debug environment
           – GWT allows compilation to fast JavaScript/HTML5


      • Lets build a game!

     25


Thursday, May 12, 2011                                         25
Thursday, May 12, 2011   26
Demo of building peas



Thursday, May 12, 2011        26
Building Peas
      • Familiar tools
           – Write and debug in Java
           – Eclipse and GPE
           – Compile to Java and JavaScript/HTML5
           – Hosting on AppEngine is a click away




     27


Thursday, May 12, 2011                              27
Releasing to the Chrome Web Store
      1. Visit http://appmator.com, enter the URL of your game, and download a zip file.
      2. Upload the zip file to the Chrome Web Store using the Developer Dashboard
       ...




     28


Thursday, May 12, 2011                                                                     28
Releasing to the Chrome Web Store
      1. Visit http://appmator.com, enter the URL of your game, and download a zip file.
      2. Upload the zip file to the Chrome Web Store using the Developer Dashboard
       ...
      3. Profit!




     29


Thursday, May 12, 2011                                                                     29
One more thing...
      • That game we just built using ForPlay?
           – It runs as a Java desktop app too




     30


Thursday, May 12, 2011                           30
One more thing...
      • That game we just built using ForPlay?
           – It runs as a Java desktop app too
           – And an Android app




     31


Thursday, May 12, 2011                           31
ForPlay for Android
      • GWT code is already in Java
      • Compile straight to Dalvik and package as an APK


                         public class MyGameAndroid {
                             public static void main(String[] args){
                                 AndroidPlatform.register();
                                 ForPlay.run(new MyGame());
                             }
                         }




     32


Thursday, May 12, 2011                                                 32
One more thing...
      • That game we just built using ForPlay?
           – It runs as a Java desktop app too
           – And an Android app
           – And in Flash




     33


Thursday, May 12, 2011                           33
ForPlay for Flash
      • GWT to Flex compiler
           – Compiles to ActionScript3/Flex4 SDK
           – Provides Java overlay types for flash.{events|net|display|media|etc} API
           – Specialized GWT linker produces SWF

                                public class MyGameFlash {
                                     public static void main(String[] args){
                                          FlashPlatform.register();
                                          ForPlay.run(new MyGame());
                                     }
                                }




     34


Thursday, May 12, 2011                                                                  34
Wrap-up
      • Why GWT?
           – Performance, ease of writing code, portability
      • Architecting a game
           – Core components: the game loop, I/O system, and asset management
      • Abstraction is key
           – ForPlay is a cross-platform game abstraction layer
           – Easy to write in, performant
      • Go build a game!
           – ForPlay is open source, easy to use, and really fun!
           – http://code.google.com/p/forplay




     35


Thursday, May 12, 2011                                                          35
Links and Thanks
      • ForPlay (alpha)
           – http://code.google.com/p/forplay


      • Angry Birds
           – http://chrome.angrybirds.com




                                                ------
     36


Thursday, May 12, 2011                                   36
Links and Thanks
      • ForPlay (alpha)
           – http://code.google.com/p/forplay


      • Angry Birds
           – http://chrome.angrybirds.com




     36


Thursday, May 12, 2011                          36
Thursday, May 12, 2011   37

Contenu connexe

En vedette

Take control of big data, 18 july 2012
Take control of big data, 18 july 2012Take control of big data, 18 july 2012
Take control of big data, 18 july 2012Rachel Aldighieri
 
From letterbox to inbox building consumer relationships 15 october 2013
From letterbox to inbox building consumer relationships 15 october 2013From letterbox to inbox building consumer relationships 15 october 2013
From letterbox to inbox building consumer relationships 15 october 2013Rachel Aldighieri
 
Planning advertising mail into an integrated campaign
Planning advertising mail into an integrated campaignPlanning advertising mail into an integrated campaign
Planning advertising mail into an integrated campaignRachel Aldighieri
 
10 lbs apps from china worth attention
10 lbs apps   from china worth attention  10 lbs apps   from china worth attention
10 lbs apps from china worth attention momobeijing
 
Html5与i pad交互杂志
Html5与i pad交互杂志Html5与i pad交互杂志
Html5与i pad交互杂志momobeijing
 
Html5与i pad交互杂志
Html5与i pad交互杂志Html5与i pad交互杂志
Html5与i pad交互杂志momobeijing
 
From letterbox to inbox building consumer relationships 15 october 2013
From letterbox to inbox building consumer relationships 15 october 2013From letterbox to inbox building consumer relationships 15 october 2013
From letterbox to inbox building consumer relationships 15 october 2013Rachel Aldighieri
 
从产品到应用+开发+产学研
从产品到应用+开发+产学研从产品到应用+开发+产学研
从产品到应用+开发+产学研momobeijing
 
DMA North: Making mobile marketing work
DMA North: Making mobile marketing workDMA North: Making mobile marketing work
DMA North: Making mobile marketing workRachel Aldighieri
 
DMA - DPC Workshop - 23 October 2013
DMA - DPC Workshop - 23 October 2013DMA - DPC Workshop - 23 October 2013
DMA - DPC Workshop - 23 October 2013Rachel Aldighieri
 
An introduction to data protection - 30 Jan 2014
An introduction to data protection - 30 Jan 2014An introduction to data protection - 30 Jan 2014
An introduction to data protection - 30 Jan 2014Rachel Aldighieri
 
Panel - SNS Game
Panel - SNS GamePanel - SNS Game
Panel - SNS Gamemomobeijing
 

En vedette (20)

Take control of big data, 18 july 2012
Take control of big data, 18 july 2012Take control of big data, 18 july 2012
Take control of big data, 18 july 2012
 
Almost Extinct
Almost ExtinctAlmost Extinct
Almost Extinct
 
From letterbox to inbox building consumer relationships 15 october 2013
From letterbox to inbox building consumer relationships 15 october 2013From letterbox to inbox building consumer relationships 15 october 2013
From letterbox to inbox building consumer relationships 15 october 2013
 
Pinnock SGP
Pinnock SGPPinnock SGP
Pinnock SGP
 
Chris Martin
Chris MartinChris Martin
Chris Martin
 
Planning advertising mail into an integrated campaign
Planning advertising mail into an integrated campaignPlanning advertising mail into an integrated campaign
Planning advertising mail into an integrated campaign
 
Edu 290
Edu 290Edu 290
Edu 290
 
10 lbs apps from china worth attention
10 lbs apps   from china worth attention  10 lbs apps   from china worth attention
10 lbs apps from china worth attention
 
DMA North: Legal Update
DMA North: Legal UpdateDMA North: Legal Update
DMA North: Legal Update
 
Html5与i pad交互杂志
Html5与i pad交互杂志Html5与i pad交互杂志
Html5与i pad交互杂志
 
Html5与i pad交互杂志
Html5与i pad交互杂志Html5与i pad交互杂志
Html5与i pad交互杂志
 
From letterbox to inbox building consumer relationships 15 october 2013
From letterbox to inbox building consumer relationships 15 october 2013From letterbox to inbox building consumer relationships 15 october 2013
From letterbox to inbox building consumer relationships 15 october 2013
 
从产品到应用+开发+产学研
从产品到应用+开发+产学研从产品到应用+开发+产学研
从产品到应用+开发+产学研
 
MWC2011
MWC2011MWC2011
MWC2011
 
MoMo beijing
MoMo beijingMoMo beijing
MoMo beijing
 
DMA North: Making mobile marketing work
DMA North: Making mobile marketing workDMA North: Making mobile marketing work
DMA North: Making mobile marketing work
 
DMA - DPC Workshop - 23 October 2013
DMA - DPC Workshop - 23 October 2013DMA - DPC Workshop - 23 October 2013
DMA - DPC Workshop - 23 October 2013
 
An introduction to data protection - 30 Jan 2014
An introduction to data protection - 30 Jan 2014An introduction to data protection - 30 Jan 2014
An introduction to data protection - 30 Jan 2014
 
Young marketers rising
Young marketers risingYoung marketers rising
Young marketers rising
 
Panel - SNS Game
Panel - SNS GamePanel - SNS Game
Panel - SNS Game
 

Similaire à Google kick ass-game_programming_with_gwt

Java: Rumours of my demise are greatly exaggerated
Java: Rumours of my demise are greatly exaggeratedJava: Rumours of my demise are greatly exaggerated
Java: Rumours of my demise are greatly exaggeratedSteve Dalton
 
JSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklJSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklChristoph Pickl
 
Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)Noam Gat
 
GDD 2011 - How to build kick ass video games for the cloud
GDD 2011 - How to build kick ass video games for the cloudGDD 2011 - How to build kick ass video games for the cloud
GDD 2011 - How to build kick ass video games for the cloudChris Schalk
 
PDE2011 pythonOCC project status and plans
PDE2011 pythonOCC project status and plansPDE2011 pythonOCC project status and plans
PDE2011 pythonOCC project status and plansThomas Paviot
 
Pure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RacePure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RaceBaruch Sadogursky
 
Season 7 Episode 1 - Tools for Data Scientists
Season 7 Episode 1 - Tools for Data ScientistsSeason 7 Episode 1 - Tools for Data Scientists
Season 7 Episode 1 - Tools for Data Scientistsaspyker
 
Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with GroovyJames Williams
 
Introduction to html5 game programming with impact js
Introduction to html5 game programming with impact jsIntroduction to html5 game programming with impact js
Introduction to html5 game programming with impact jsLuca Galli
 
3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time 3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time Pascal Rettig
 
Building iPhone Apps: From Flash Lite to Corona
Building iPhone Apps: From Flash Lite to CoronaBuilding iPhone Apps: From Flash Lite to Corona
Building iPhone Apps: From Flash Lite to CoronaAnscamobile
 
Casual Engines 2009
Casual Engines 2009Casual Engines 2009
Casual Engines 2009David Fox
 
RSJ2011 OSS Robotics and Tools OpenHRI Intro
RSJ2011 OSS Robotics and Tools OpenHRI IntroRSJ2011 OSS Robotics and Tools OpenHRI Intro
RSJ2011 OSS Robotics and Tools OpenHRI IntroYosuke Matsusaka
 
JBUG 11 - Outside The Java Box
JBUG 11 - Outside The Java BoxJBUG 11 - Outside The Java Box
JBUG 11 - Outside The Java BoxTikal Knowledge
 
GT Logiciel Libre - Convention Systematic 2011
GT Logiciel Libre - Convention Systematic 2011GT Logiciel Libre - Convention Systematic 2011
GT Logiciel Libre - Convention Systematic 2011Stefane Fermigier
 
GPU Programming 360iDev
GPU Programming 360iDevGPU Programming 360iDev
GPU Programming 360iDevJanie Clayton
 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x EngineDuy Tan Geek
 

Similaire à Google kick ass-game_programming_with_gwt (20)

Java: Rumours of my demise are greatly exaggerated
Java: Rumours of my demise are greatly exaggeratedJava: Rumours of my demise are greatly exaggerated
Java: Rumours of my demise are greatly exaggerated
 
JSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklJSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph Pickl
 
Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)
 
GDD 2011 - How to build kick ass video games for the cloud
GDD 2011 - How to build kick ass video games for the cloudGDD 2011 - How to build kick ass video games for the cloud
GDD 2011 - How to build kick ass video games for the cloud
 
PDE2011 pythonOCC project status and plans
PDE2011 pythonOCC project status and plansPDE2011 pythonOCC project status and plans
PDE2011 pythonOCC project status and plans
 
Pure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RacePure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools Race
 
Season 7 Episode 1 - Tools for Data Scientists
Season 7 Episode 1 - Tools for Data ScientistsSeason 7 Episode 1 - Tools for Data Scientists
Season 7 Episode 1 - Tools for Data Scientists
 
Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with Groovy
 
Introduction to html5 game programming with impact js
Introduction to html5 game programming with impact jsIntroduction to html5 game programming with impact js
Introduction to html5 game programming with impact js
 
3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time 3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time
 
Building iPhone Apps: From Flash Lite to Corona
Building iPhone Apps: From Flash Lite to CoronaBuilding iPhone Apps: From Flash Lite to Corona
Building iPhone Apps: From Flash Lite to Corona
 
Casual Engines 2009
Casual Engines 2009Casual Engines 2009
Casual Engines 2009
 
RSJ2011 OSS Robotics and Tools OpenHRI Intro
RSJ2011 OSS Robotics and Tools OpenHRI IntroRSJ2011 OSS Robotics and Tools OpenHRI Intro
RSJ2011 OSS Robotics and Tools OpenHRI Intro
 
JBUG 11 - Outside The Java Box
JBUG 11 - Outside The Java BoxJBUG 11 - Outside The Java Box
JBUG 11 - Outside The Java Box
 
GT Logiciel Libre - Convention Systematic 2011
GT Logiciel Libre - Convention Systematic 2011GT Logiciel Libre - Convention Systematic 2011
GT Logiciel Libre - Convention Systematic 2011
 
What's New in GWT 2.2
What's New in GWT 2.2What's New in GWT 2.2
What's New in GWT 2.2
 
GPU Programming 360iDev
GPU Programming 360iDevGPU Programming 360iDev
GPU Programming 360iDev
 
netty_qcon_v4
netty_qcon_v4netty_qcon_v4
netty_qcon_v4
 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x Engine
 
Play ja kansai
Play ja kansaiPlay ja kansai
Play ja kansai
 

Plus de momobeijing

MoMo Beijing introduction to thai mobile environment - 14th may 2012
MoMo Beijing   introduction to thai mobile environment - 14th may 2012MoMo Beijing   introduction to thai mobile environment - 14th may 2012
MoMo Beijing introduction to thai mobile environment - 14th may 2012momobeijing
 
Touch china en_mm
Touch china en_mmTouch china en_mm
Touch china en_mmmomobeijing
 
Design startup-asia-sharable
Design startup-asia-sharableDesign startup-asia-sharable
Design startup-asia-sharablemomobeijing
 
宝宝日历演示201205定稿
宝宝日历演示201205定稿宝宝日历演示201205定稿
宝宝日历演示201205定稿momobeijing
 
共享妈妈晒201205定稿
共享妈妈晒201205定稿共享妈妈晒201205定稿
共享妈妈晒201205定稿momobeijing
 
Mobile africa 2011
Mobile africa 2011Mobile africa 2011
Mobile africa 2011momobeijing
 
Nokia NFC Presentation
Nokia NFC PresentationNokia NFC Presentation
Nokia NFC Presentationmomobeijing
 
勤奋小强项目介绍
勤奋小强项目介绍勤奋小强项目介绍
勤奋小强项目介绍momobeijing
 
Skyhook mo mo beijing
Skyhook mo mo beijingSkyhook mo mo beijing
Skyhook mo mo beijingmomobeijing
 
Jiayuan overview & wireless orange labs
Jiayuan overview & wireless   orange labsJiayuan overview & wireless   orange labs
Jiayuan overview & wireless orange labsmomobeijing
 
Zaizher b plan 9 26 momo update
Zaizher b plan 9 26 momo updateZaizher b plan 9 26 momo update
Zaizher b plan 9 26 momo updatemomobeijing
 
Html5 在中国的机会、风险和矛盾 磊友黄何 english
Html5 在中国的机会、风险和矛盾 磊友黄何 englishHtml5 在中国的机会、风险和矛盾 磊友黄何 english
Html5 在中国的机会、风险和矛盾 磊友黄何 englishmomobeijing
 
Html5 在中国的机会、风险和矛盾 磊友黄何
Html5 在中国的机会、风险和矛盾 磊友黄何Html5 在中国的机会、风险和矛盾 磊友黄何
Html5 在中国的机会、风险和矛盾 磊友黄何momobeijing
 
Html5与i pad交互杂志
Html5与i pad交互杂志Html5与i pad交互杂志
Html5与i pad交互杂志momobeijing
 
设计驱动移动应用创新
设计驱动移动应用创新设计驱动移动应用创新
设计驱动移动应用创新momobeijing
 
汇聚创新的力量 丘总
汇聚创新的力量 丘总汇聚创新的力量 丘总
汇聚创新的力量 丘总momobeijing
 
Orange&innovation
Orange&innovationOrange&innovation
Orange&innovationmomobeijing
 
开放创新日新闻稿1
开放创新日新闻稿1开放创新日新闻稿1
开放创新日新闻稿1momobeijing
 

Plus de momobeijing (20)

MoMo Beijing introduction to thai mobile environment - 14th may 2012
MoMo Beijing   introduction to thai mobile environment - 14th may 2012MoMo Beijing   introduction to thai mobile environment - 14th may 2012
MoMo Beijing introduction to thai mobile environment - 14th may 2012
 
Momo jakob
Momo jakobMomo jakob
Momo jakob
 
Touch china en_mm
Touch china en_mmTouch china en_mm
Touch china en_mm
 
Design startup-asia-sharable
Design startup-asia-sharableDesign startup-asia-sharable
Design startup-asia-sharable
 
宝宝日历演示201205定稿
宝宝日历演示201205定稿宝宝日历演示201205定稿
宝宝日历演示201205定稿
 
共享妈妈晒201205定稿
共享妈妈晒201205定稿共享妈妈晒201205定稿
共享妈妈晒201205定稿
 
Mobile africa 2011
Mobile africa 2011Mobile africa 2011
Mobile africa 2011
 
Nokia NFC Presentation
Nokia NFC PresentationNokia NFC Presentation
Nokia NFC Presentation
 
勤奋小强项目介绍
勤奋小强项目介绍勤奋小强项目介绍
勤奋小强项目介绍
 
Skyhook mo mo beijing
Skyhook mo mo beijingSkyhook mo mo beijing
Skyhook mo mo beijing
 
Ohbaba
OhbabaOhbaba
Ohbaba
 
Jiayuan overview & wireless orange labs
Jiayuan overview & wireless   orange labsJiayuan overview & wireless   orange labs
Jiayuan overview & wireless orange labs
 
Zaizher b plan 9 26 momo update
Zaizher b plan 9 26 momo updateZaizher b plan 9 26 momo update
Zaizher b plan 9 26 momo update
 
Html5 在中国的机会、风险和矛盾 磊友黄何 english
Html5 在中国的机会、风险和矛盾 磊友黄何 englishHtml5 在中国的机会、风险和矛盾 磊友黄何 english
Html5 在中国的机会、风险和矛盾 磊友黄何 english
 
Html5 在中国的机会、风险和矛盾 磊友黄何
Html5 在中国的机会、风险和矛盾 磊友黄何Html5 在中国的机会、风险和矛盾 磊友黄何
Html5 在中国的机会、风险和矛盾 磊友黄何
 
Html5与i pad交互杂志
Html5与i pad交互杂志Html5与i pad交互杂志
Html5与i pad交互杂志
 
设计驱动移动应用创新
设计驱动移动应用创新设计驱动移动应用创新
设计驱动移动应用创新
 
汇聚创新的力量 丘总
汇聚创新的力量 丘总汇聚创新的力量 丘总
汇聚创新的力量 丘总
 
Orange&innovation
Orange&innovationOrange&innovation
Orange&innovation
 
开放创新日新闻稿1
开放创新日新闻稿1开放创新日新闻稿1
开放创新日新闻稿1
 

Dernier

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Dernier (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Google kick ass-game_programming_with_gwt

  • 3. Kick-Ass Game Programming with Google Web Toolkit Ray Cromwell, Philip Rogers May 11th, 2011 Thursday, May 12, 2011 2
  • 6. What’s covered in this session • Intro / Why GWT? • Architecting a game • Introducing ForPlay • Let’s build a game – and share it • Advanced Topics – Android – Flashy 4 Thursday, May 12, 2011 4
  • 7. Why use GWT for games? GWT = Game Web Toolkit? • Leverage familiar Java toolchain (debugger, IDE, etc.) • Share code between client, server... and other platforms? • Produce small, fast JavaScript & HTML5 5 Thursday, May 12, 2011 5
  • 8. Leveraging familiar Java tools and libraries Port a physics engine Box2D JBox2D GWTBox2D C++ Java and Java Javascript • 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 – “Porting” 11,000 lines took ~30 minutes. (removed ThreadLocal, etc.) 6 Thursday, May 12, 2011 6
  • 9. Faster and Smaller • GWT Compiler optimizes code for size – Removes unused code – Evaluates, when possible, code at compile time – Inlines functions – Heavily obfuscates the result • Smaller code loads faster • Perfect Caching avoids need for network I/O • Inlining helps code run faster 7 Thursday, May 12, 2011 7
  • 10. HTML5 for games • Formal HTML5 – New HTML Elements • 2D Canvas, great for curves and text (GWT 2.2) • Audio, Video (GWT 2.2) – Application Cache (GWT 3.0) – Much, much more... • Colloquial “HTML5” – 3D Canvas (WebGL) (GWTGL) • OpenGL ES 2.0 made JavaScript friendly • Important for 2D games due to acceleration – CSS3 • Supports hardware accelerated transforms 8 Thursday, May 12, 2011 8
  • 13. Overview of a game The Game Loop I/O System Asset Management init() keyboard, pointer, touch loading update(delta) audio, graphics saving paint(delta) storage, network caching 10 Thursday, May 12, 2011 10
  • 14. Challenges of a cross-platform game The Game Loop I/O System Asset Management Keeping graphics, update, Not always available/accel: Loading and I/O in sync. WebGL, CSS3, Canvas Caching assets RequestAnimationFrame Audio Application Cache Interpolation in paint() Inputs: touch, mouse, etc. 11 Thursday, May 12, 2011 11
  • 15. Thursday, May 12, 2011 12
  • 16. Abstraction is key GWT abstracts away browser differences. Let’s apply that to cross-platform games. Thursday, May 12, 2011 12
  • 17. Introducing ForPlay GWT abstraction layer for games • A small API for building fast cross-platform games – Core game can be platform-agnostic • Written in Java so you get a familiar language and toolset – And a great debugging environment • GWT-compatible so you can compile to JavaScript/HTML5 • Free and open source (alpha version) – http://code.google.com/p/forplay 13 Thursday, May 12, 2011 13
  • 18. Introducing ForPlay • Think: Service Provider Interface (SPI) ForPlay API Java impl. GWT/JS impl. Android impl. ... Flash impl? 14 Thursday, May 12, 2011 14
  • 19. Thursday, May 12, 2011 15
  • 20. Demo time Thursday, May 12, 2011 15
  • 21. Components of ForPlay The Game Loop I/O System Asset Management Extend ForPlay.Game import static core.ForPlay.* assetManager() init() audio(), graphics(), net() .getImage(String path) update(float delta) .getSound(String path) paint(float delta) Pointers & Keyboard input .getText(String path) Layers for fast graphics also ResourceCallback • ForPlay provides the cross platform magic to make these abstractions transparent – Core game has no platform-specific calls 16 Thursday, May 12, 2011 16
  • 22. The Game I/O System Asset Components of ForPlay Loop Management • Just extend implement ForPlay.Game public class MyGame implements Game { public void init() { // init game } public void update(float deltaTime) { // update } public void paint(float deltaTime) { // paint } } 17 Thursday, May 12, 2011 17
  • 23. The Game I/O System Asset Components of ForPlay Loop Management • Delta in paint() can be used for interpolation public class MyGame implements Game { public void paint(float delta) { float xInterp = (delta) * x + (1-delta) * prevX; float yInterp = (delta) * y + (1-delta) * prevY; layer.setTranslation(xInterp, yInterp); } } 18 Thursday, May 12, 2011 18
  • 24. The Game I/O System Asset Components of ForPlay Loop Management • Input devices public class MyGame implements Game, Pointer, Keyboard { public void onPointerMove(int x, int y) { // handle pointer movement } public void onPointerScroll(int velocity) { // handle zoom, etc. } public void onKeyDown(int keyCode) { // handle keypress } } 19 Thursday, May 12, 2011 19
  • 25. The Game I/O System Asset Components of ForPlay Loop Management • Images - using the ForPlay layer system Layer Scale, Rotate, Translate GroupLayer ImageLayer SurfaceLayer List<Layer> children Image image, setRepeat() Surface surface Image Surface Canvas width, height drawImage(), fillRect() strokePath(), drawArc(), drawText() 20 Thursday, May 12, 2011 20
  • 26. The Game I/O System Asset Components of ForPlay Loop Management 21 Thursday, May 12, 2011 21
  • 27. The Game I/O System Asset Components of ForPlay Loop Management Loading and displaying images Image image = assetManager().getImage(“myImage.png”); image.addCallback(new ResourceCallback<Image>() { public void done(Image image) { // handle new image } } 22 Thursday, May 12, 2011 22
  • 28. The Game I/O System Asset Components of ForPlay Loop Management The AssetWatcher AssetWatcher watcher = new AssetWatcher(new Listener() { public void done() { startMyGame(); } }); watcher.add(image1); watcher.add(image2); watcher.start(); 23 Thursday, May 12, 2011 23
  • 29. ForPlay cross platform magic • Game uses core ForPlay abstractions, is unaware of which platform is running • The only platform-specific code is in the entry point for each platform: public class MyGameHtml extends HtmlGame { public class MyGameJava { public void start() { public static void main(String[] args){ HtmlPlatform.register(); JavaPlatform.register(); ForPlay.run(new MyGame()); ForPlay.run(new MyGame()); } } } } 24 Thursday, May 12, 2011 24
  • 30. ForPlay wrap-up • Open source, cross-platform game abstraction layer – Where the core game is platform-agnostic • ForPlay abstracts away the core components of a game – The game loop, I/O system, and asset management • Write in Java, get performance on multiple platforms – Java provides a great debug environment – GWT allows compilation to fast JavaScript/HTML5 • Lets build a game! 25 Thursday, May 12, 2011 25
  • 31. Thursday, May 12, 2011 26
  • 32. Demo of building peas Thursday, May 12, 2011 26
  • 33. Building Peas • Familiar tools – Write and debug in Java – Eclipse and GPE – Compile to Java and JavaScript/HTML5 – Hosting on AppEngine is a click away 27 Thursday, May 12, 2011 27
  • 34. Releasing to the Chrome Web Store 1. Visit http://appmator.com, enter the URL of your game, and download a zip file. 2. Upload the zip file to the Chrome Web Store using the Developer Dashboard ... 28 Thursday, May 12, 2011 28
  • 35. Releasing to the Chrome Web Store 1. Visit http://appmator.com, enter the URL of your game, and download a zip file. 2. Upload the zip file to the Chrome Web Store using the Developer Dashboard ... 3. Profit! 29 Thursday, May 12, 2011 29
  • 36. One more thing... • That game we just built using ForPlay? – It runs as a Java desktop app too 30 Thursday, May 12, 2011 30
  • 37. One more thing... • That game we just built using ForPlay? – It runs as a Java desktop app too – And an Android app 31 Thursday, May 12, 2011 31
  • 38. ForPlay for Android • GWT code is already in Java • Compile straight to Dalvik and package as an APK public class MyGameAndroid { public static void main(String[] args){ AndroidPlatform.register(); ForPlay.run(new MyGame()); } } 32 Thursday, May 12, 2011 32
  • 39. One more thing... • That game we just built using ForPlay? – It runs as a Java desktop app too – And an Android app – And in Flash 33 Thursday, May 12, 2011 33
  • 40. ForPlay for Flash • GWT to Flex compiler – Compiles to ActionScript3/Flex4 SDK – Provides Java overlay types for flash.{events|net|display|media|etc} API – Specialized GWT linker produces SWF public class MyGameFlash { public static void main(String[] args){ FlashPlatform.register(); ForPlay.run(new MyGame()); } } 34 Thursday, May 12, 2011 34
  • 41. Wrap-up • Why GWT? – Performance, ease of writing code, portability • Architecting a game – Core components: the game loop, I/O system, and asset management • Abstraction is key – ForPlay is a cross-platform game abstraction layer – Easy to write in, performant • Go build a game! – ForPlay is open source, easy to use, and really fun! – http://code.google.com/p/forplay 35 Thursday, May 12, 2011 35
  • 42. Links and Thanks • ForPlay (alpha) – http://code.google.com/p/forplay • Angry Birds – http://chrome.angrybirds.com ------ 36 Thursday, May 12, 2011 36
  • 43. Links and Thanks • ForPlay (alpha) – http://code.google.com/p/forplay • Angry Birds – http://chrome.angrybirds.com 36 Thursday, May 12, 2011 36
  • 44. Thursday, May 12, 2011 37