SlideShare una empresa de Scribd logo
1 de 119
Descargar para leer sin conexión
Getting Started with
   iPhone Game
   Development
 with Amanda Wixted and David Cairns
Outline
• Game demo
• General Architecture of games
• Input Modes
• Code tour
• Networking
• Sound
• Tips & Tricks
TwitterGame demo at

http://amandawixted.com/TwitterGameDemo.mov
Outline
• Game demo
• General Architecture of games
• Input Modes
• Code tour
• Networking
• Sound
• Tips & Tricks
General Structure of Games
General Structure of Games
              main




      paint          update
General Structure of Games
              main




      paint          update
General Structure of Games
              main




      paint          update
General Structure of Games
              main




      paint          update
General Structure of Games
              main




      paint          update
General Structure of Games
                     main




             paint          update
background



  objects
  in view


  heads
up display
General Structure of Games
                     main




             paint          update
background



  objects
  in view


  heads
up display
General Structure of Games
                     main




             paint          update
background



  objects
  in view


  heads
up display
General Structure of Games
                     main




             paint              update
background
                                                      game
                                                      state
                                         particle    changes
  objects                                effects
                            avatar’s
  in view
                            position

                                            bad        camera
  heads                                    guys’       position
up display                               positions
General Structure of Games
                     main




             paint              update
background
                                                      game
                                                      state
                                         particle    changes
  objects                                effects
                            avatar’s
  in view
                            position

                                            bad        camera
  heads                                    guys’       position
up display                               positions
General Structure of Games
                     main




             paint              update
background
                                                      game
                                                      state
                                         particle    changes
  objects                                effects
                            avatar’s
  in view
                            position

                                            bad        camera
  heads                                    guys’       position
up display                               positions
General Structure of Games
                             main




              paint                     update
background
                                                              game
                                                              state
                                                 particle    changes
  objects                                        effects
                                    avatar’s
  in view
                                    position
                        set flags                    bad        camera
  heads               in the data                  guys’       position
up display              models                   positions

             I/O
Outline
• Game demo
• General Architecture of games
• Input Modes
• Code tour
• Networking
• Sound
• Tips & Tricks
Input Modes
how and when to use touch and tilt as game controls
Input Modes

        PAC-MAN:
choice of 3 control modes:

      Swipe (best)
  Accelerometer (okay)
     D-Pad (sucks)
Touch Input
• whenever the user needs to touch the
  screen, they’re blocking what they can see
  • fine in puzzle games
  • less fine in platformers/fps/non-puzzle
• keep the users’ fingers off to the sides or
  only on the screen for a short time (swipe)
Good Examples

•   iMech - steering/aiming
    wheels out of the way

•   Dropship - wheels
    anywhere user touches
    down, so motion is
    relative
Accelerometer Input
     Take out your iPhone
Chart of Bubble Level’s
      low-pass filter
                Accelerometer output
         1.00




         0.75




output   0.50




         0.25




           0


                time t
Accelerometer input

• use a filter function that works for your
  game
• maximize controllability and sensitivity
• play around with it until you (and your
  friends) feel it’s right
Accelerometer input
position.x += 8.0 * acceleration.x;


• TwitterGame: we used tilt to move left/
  right
• simple: adjust the avatar’s position by a
  (constant factor * raw data)
• at 60hz sample rate, avatar moves 480px/s
  at a force of acceleration.x =1.0
Common mistakes

• don’t require the user to tilt the device to
  an angle where they can no longer see the
  screen
• iterate until your controls feel right
• don’t use the accelerometer for menu
  navigation
Outline
• Game demo
• General Architecture of games
• Input Modes
• Code tour
• Networking
• Sound
• Tips & Tricks
From Swipe to Jump
 an illustrated tour of TwitterGame’s code
From Swipe to Jump

           touchesEnded

            Game
EAGLView
           Controller

           touchesBegan
From Swipe to Jump

           touchesEnded

            Game
EAGLView
           Controller

           touchesBegan
From Swipe to Jump

           touchesEnded

            Game
EAGLView
           Controller

           touchesBegan
From Swipe to Jump

           touchesEnded

            Game
EAGLView
           Controller

           touchesBegan
From Swipe to Jump

           touchesEnded

            Game
EAGLView
           Controller

           touchesBegan
From Swipe to Jump

           touchesEnded

            Game
EAGLView
           Controller

           touchesBegan
From Swipe to Jump

           touchesEnded

            Game
EAGLView
           Controller

           touchesBegan
From Swipe to Jump

paint       update
From Swipe to Jump

in the Avatar class:
From Swipe to Jump
the Avatar’s update method, called from the game loop:
From Swipe to Jump
From Swipe to Jump
From Swipe to Jump
From Swipe to Jump
From Swipe to Jump
From Swipe to Jump
   Can you see what would happen if we instead
checked whether the avatar’s frame was intersecting
                with a platform?


  What if we used current position and previous
                position instead?
Outline
• Game demo
• General Architecture of games
• Input Modes
• Code tour
• Networking
• Sound
• Tips & Tricks
Networking
• You have the usual options available:
 • sockets, URL requests
• GameKit - a (disappointingly-named) networking framework


 • local bluetooth connections
 • voice chat over the internet
 • GK doesn’t do anything but networking
Networking
           Task                         Tool            Read

getting/posting to a
                            NSURLConnection    URL Loading System
webserver


interacting with a
                                               CFNetwork Programming
gameserver using a constant CFSocket
                                               Guide
connection


creating a local peer-to-peer                  GameKit Programming
                              GameKit
game connection                                Guide
Outline
• Game demo
• General Architecture of games
• Input Modes
• Code tour
• Networking
• Sound
• Tips & Tricks
Sound
        Task                   Tool                  Read
Games where sound timing                     AV Foundation Framework
    is not essential       AVAudioPlayer            Reference


    3D Games                 OpenAL             OpenAL.org
Games where sound timing                      Audio Queue Services
      is essential         AudioQueue              Reference

                            AudioToolbox/     System Sound Services
 UI/Menu Sounds             AudioToolbox.h          Reference
Sound
• Use AVAudioSession to tell the device how
  to handle your app’s audio
• Set your category to
  AVAudioSessionCategoryAmbient so that
  users can listen to their iPod while they
  play your game
Outline
• Game demo
• General Architecture of games
• Input Modes
• Code tour
• Networking
• Sound
• Tips & Tricks
General Tips & Tricks
    Miscellany from experience
Do Quick Prototyping
•   We wrote a simple UIView animation-based
    implementation just as a proof-of-concept in about
    2 hours

•   Doesn’t need to be nice, only needs to
    approximate what you want

•   Helps you work out issues you hadn’t thought
    about with your basic gameplay before you get
    caught up in your real implementation
Have Randomness


• Randomly generated scenery
• User input * random number = just enough
  frustration to keep the user interested
Adjust values until they
       feel right

• Have lots of tweakable constants
• Don’t spend too much time being true to
  theoretical physics
• Iterate on your input handling sections
OpenGL
OpenGL ES 1.1
Immediate Mode
 position
  color
tex coord



 position
  color
tex coord         OpenGL

 position
  color
tex coord
Immediate Mode
glBegin(GL_TRIANGLES);

       glColor4f(1.0, 0.0, 0.0, 1.0);
       glTexCoord2f(0.0, 0.0);
       glVertex3f(-1.0, -1.0, 0.0);

       glColor4f(1.0, 1.0, 0.0, 1.0);
       glTexCoord2f(1.0, 0.0);
       glVertex3f(1.0, -1.0, 0.0);

    /* additional vertices... */

glEnd();
Vertex Arrays
           Main Memory

position                          OpenGL
              color

                      tex coord
position

              color

                      tex coord
position

              color

                      tex coord
position

              color

                      tex coord
Vertex Arrays
glVertexPointer(3,          // 3 components / vertex
                GL_FLOAT,   // type of data
                0,          // stride (tightly-packed)
                positions); // pointer to data
glEnableClientState(GL_VERTEX_ARRAY);



/* Set up color, normal, tex coord arrays... */



glDrawArrays(GL_TRIANGLES,
          0,               // Starting at vertex zero...
          6);              // ... Render 6 vertices
OpenGL ES 1.1

• Fewer geometry types
• No display lists
• No direct-to-framebuffer blitting
• No automatic format conversions
• Fixed function pipeline only
OpenGL ES 2.0
OpenGL ES 2.0

• No fixed-function pipeline
• Programmable pipeline ONLY
• No implicit vertex attributes
Vertex Specification


 attribute vec4 position;
 attribute vec4 color;
 attribute vec2 texCoord;
 ...
Fragment Shader

precision mediump float;

void main() {
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
Fragment Shader

precision mediump float;

void main() {
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader,       // shader object’s name
               1,                  // number of strings
               &vertexSource,      // array of strings
               NULL);              // array of lengths
glCompileShader(vertexShader);

GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader, 1, &fragmentSource, NULL);
glCompileShader(fragmentShader);
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);

glLinkProgram(program);

glUseProgram(program);
Vertex Attribute Arrays
           Main Memory
Attrib 0

              Attrib 1
                                    OpenGL
value 0
                         Attrib 2
              value 0

                         value 0
value 1

              value 1

                         value 1
value 2

              value 2

                         value 2
  …

                …

                           …
glVertexAttribPointer(positionIndex, // attrib index for position
                      3,             // 3 components / vertex
                      GL_FLOAT,      // type of data
                      GL_FALSE,      // don’t normalize
                      0,             // stride (tightly-packed)
                      vertices);     // pointer to data
glEnableVertexAttribArray(positionIndex);



/* Set up color, normal, tex coord arrays... */



glDrawArrays(GL_TRIANGLES, 0, 6);
• GL 101
• Texture Atlases
• Vertex Buffer Objects
• Interleaved Arrays
• Texture Compression
GL 101


• As few draw calls as possible
• Minimize changes in GL state
Background
Characters
Power-ups and
   objects
position 3         position 2
tex coord (0, 1)   tex coord (1, 1)




   position 0         position 1
tex coord (0, 0)   tex coord (1, 0)
position 3         position 2
tex coord (0, 1)   tex coord (1, 1)




   position 0         position 1
tex coord (0, 0)   tex coord (1, 0)
position 2         position 3
                  tex coord (0, 1)   tex coord (1, 1)




                     position 0         position 1
                  tex coord (0, 0)   tex coord (1, 0)




 Position Array


Tex Coord Array
position 2                      position 3
                  tex coord (0, 1)                tex coord (1, 1)




                     position 0                      position 1
                  tex coord (0, 0)                tex coord (1, 0)




 Position Array       p0        p1      p2       p2       p1          p3      …


Tex Coord Array     (0, 0)    (1, 0)   (0, 1)   (0, 1)   (1, 0)      (1, 1)   …
Material
 • Blending Mode
 • Lighting parameters
 • Texture binding
Material               Material   Material




Create a material from
each of the unique objects
we want to draw, that
encapsulates all of the
object’s rendering state.
Sort each of the objects into buckets keyed by material.
Now you don’t have to change any state bet ween drawing like objects!     How can we reduce state
                                                                          changes / draw calls even
Also, because we don’t have to change any state bet ween draws, we        more? Texture atlases!
can aggregate all the geometry into a single buffer / single draw call.




 Material                                        Material                           Material



      Geometry Buffer                                 Geometry Buffer                    Geometry Buffer
• GL 101
• Texture Atlases
• Vertex Buffer Objects
• Interleaved Arrays
• Texture Compression
Texture Atlases
• GL 101
• Texture Atlases
• Vertex Buffer Objects
• Interleaved Arrays
• Texture Compression
Vertex Buffer Objects
   Hinted better-vertex-storage™
Vertex Arrays
 RAM
                             GPU
position 0



position 1
                  Bus
position 2
Vertex Buffer Objects
                     GPU

 RAM               Video Memory
             Bus
position 0           position 0



position 1           position 1



position 2           position 2
Vertex Buffer Objects
                     GPU

 RAM               Video Memory
             Bus
position 0           position 0



position 1           position 1



position 2           position 2
Vertex Buffer Objects

GLuint vboName;
glGenBuffers(1, &vboName);
glBindBuffer(GL_ARRAY_BUFFER, vboName);

glBufferData(GL_ARRAY_BUFFER,   //   binding point
             bufferSize,        //   size of buffer
             bufferPointer,     //   pointer to buffer in RAM
             GL_STATIC_DRAW);   //   usage hint
STATIC: Written once, used many times

DYNAMIC: Modified a lot, used often

STREAM: Modified once, used only a few times




              ES 1.1                                 ES 2.0
    •     GL_STATIC_DRAW                       •   GL_STATIC_DRAW

    •     GL_DYNAMIC_DRAW                      •   GL_DYNAMIC_DRAW

                                               •   GL_STREAM_DRAW
Using VBOs… ES 1.1

// Bind our buffer.
glBindBuffer(GL_ARRAY_BUFFER, vboName);

// Tell GL where the geometry is.
glVertexPointer(3, GL_FLOAT, 0,   // same as before
                0x0);             // offset into the buffer
glEnableClientState(GL_VERTEX_ARRAY);

glDrawArrays( ... );
Using VBOs… ES 2.0

// Bind our buffer.
glBindBuffer(GL_ARRAY_BUFFER, vboName);

// Tell GL where the geometry is.
glVertexAttribPointer(positionIndex, 3, GL_FLOAT, GL_FALSE 0,
                      0x0);     // offset into the buffer
glEnableVertexAttribArray(positionIndex);

glDrawArrays( ... );
Changing VBO Data

glBindBuffer(GL_ARRAY_BUFFER, vboName);

glBufferSubData(GL_ARRAY_BUFFER,
                offset,            // offset into VBO
                size,              // size of dataPointer
                dataPointer);      // pointer to new data
Changing VBO Data

glBindBuffer(GL_ARRAY_BUFFER, vboName);

char *buffer = glMapBuffer(GL_ARRAY_BUFFER,
                           access);           // read and/or write

/* Manipulate the contents of the buffer... */

// Tell GL we’re done.
glUnmapBuffer(GL_ARRAY_BUFFER);
• GL 101
• Texture Atlases
• Vertex Buffer Objects
• Interleaved Arrays
• Texture Compression
Interleaved Arrays
Non-Interleaved Arrays
           Memory

position                        OpenGL
            color

                    tex coord
position

            color

                    tex coord
position

            color

                    tex coord
position

            color

                    tex coord
Interleaved Arrays
Memory
            OpenGL
 position
  color
tex coord

 position
  color
tex coord

 position
  color
tex coord

 position
  color
tex coord
Interleaved Arrays
typedef struct {
    float position[3];
    float color[3];
    float texCoord[2];
} VertexData;

VertexData *interleavedData;
… in ES 1.1
glVertexPointer(3, GL_FLOAT,
                sizeof(VertexData),                   // stride
                &interleavedData[0].position[0]);     // first position

glColorPointer(3, GL_FLOAT,
               sizeof(VertexData),
               &interleavedData[0].color[0]);

glTexCoordPointer(2, GL_FLOAT,
                  sizeof(VertexData),
                  &interleavedData[0].texCoord[0]);
… in ES 2.0

glVertexAttribPointer(positionIndex, 3, GL_FLOAT, GL_FALSE,
                      sizeof(VertexData),
                      &interleavedData[0].position[0]);

                               ...
• GL 101
• Texture Atlases
• Vertex Buffer Objects
• Interleaved Arrays
• Texture Compression
PVR Texture
Compression
Texture Compression
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool




texturetool
                      [-m]              # Generate mipmaps
     [-e encoding options]              # PVRTC, bpp
       -o “out_file.pvrtc”
               [-f format]              # PVR or Raw
             “in_file.png”
Input Requirements

• Must be square
• Dimensions must be a power-of-two
• Must be at least 8 x 8
glCompressedTexImage2D(GL_TEXTURE_2D,
                       level,           # mipmap level
                       format,
                       width, height,
                       0,               # border (must be zero!)
                       size,            # size of data
                       dataPointer);    # pointer to data
RGB                                 RGBA


2 bits / pixel   GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG   GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG




4 bits / pixel   GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG   GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
GL Reference
developer.apple.com

 lighthouse3d.com

    opengl.org
Special Thanks
                 Libraries used:
        Matt Gemmell - MGTwitterEngine
Michael Daley and Ben Britten - Sound Engine core
      Tim Omernick - GLTexture class core

              Direct Contributors:
         Jeff Osborne - Game Sounds
       Duncan Stanley - Game Design help
          Wil Shipley - code pimping
        Twitter and our friends - tweets
         Timothy Fitz - debugging help
Contact Us

Amanda Wixted amanda.wixted@gmail.com

    David Cairns drcairns@gmail.com

Más contenido relacionado

La actualidad más candente

Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2dVinsol
 
What Is A Game Engine
What Is A Game EngineWhat Is A Game Engine
What Is A Game EngineSeth Sivak
 
Introduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First GameIntroduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First GameSarah Sexton
 
Joshua meyer y1 gd engine_terminology
Joshua meyer y1 gd engine_terminologyJoshua meyer y1 gd engine_terminology
Joshua meyer y1 gd engine_terminologyJoshCollege
 
Game engines and Their Influence in Game Design
Game engines and Their Influence in Game DesignGame engines and Their Influence in Game Design
Game engines and Their Influence in Game DesignPrashant Warrier
 
Creating a serious game with the Unity 3D Game Engine and the importance of m...
Creating a serious game with the Unity 3D Game Engine and the importance of m...Creating a serious game with the Unity 3D Game Engine and the importance of m...
Creating a serious game with the Unity 3D Game Engine and the importance of m...danielandlubo
 
Presentasi Seminar Unity (AMIKOM Game Dev)
Presentasi Seminar Unity (AMIKOM Game Dev)Presentasi Seminar Unity (AMIKOM Game Dev)
Presentasi Seminar Unity (AMIKOM Game Dev)Mas Bram
 
Production RPG Maker.
Production RPG Maker. Production RPG Maker.
Production RPG Maker. Jordi Martos
 
[Product Design] WSOD March 2014
[Product Design] WSOD March 2014 [Product Design] WSOD March 2014
[Product Design] WSOD March 2014 Marlin Sugama
 
Unity 3D
Unity 3DUnity 3D
Unity 3Dgema123
 
Game engine terminology/glossary
Game engine terminology/glossaryGame engine terminology/glossary
Game engine terminology/glossarygordonpj96
 
XPS™ One™ Sales Aid (2007 2-page flyer)
XPS™ One™ Sales Aid (2007 2-page flyer)XPS™ One™ Sales Aid (2007 2-page flyer)
XPS™ One™ Sales Aid (2007 2-page flyer)Wayne Caswell
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game DevelopmentShaan Alam
 

La actualidad más candente (20)

engine_terminology 2
engine_terminology 2engine_terminology 2
engine_terminology 2
 
Unity 3D VS your team
Unity 3D VS your teamUnity 3D VS your team
Unity 3D VS your team
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2d
 
Display ws50 0613_3
Display ws50 0613_3Display ws50 0613_3
Display ws50 0613_3
 
What Is A Game Engine
What Is A Game EngineWhat Is A Game Engine
What Is A Game Engine
 
Introduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First GameIntroduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First Game
 
Joshua meyer y1 gd engine_terminology
Joshua meyer y1 gd engine_terminologyJoshua meyer y1 gd engine_terminology
Joshua meyer y1 gd engine_terminology
 
Game engines and Their Influence in Game Design
Game engines and Their Influence in Game DesignGame engines and Their Influence in Game Design
Game engines and Their Influence in Game Design
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminology
 
Creating a serious game with the Unity 3D Game Engine and the importance of m...
Creating a serious game with the Unity 3D Game Engine and the importance of m...Creating a serious game with the Unity 3D Game Engine and the importance of m...
Creating a serious game with the Unity 3D Game Engine and the importance of m...
 
Presentasi Seminar Unity (AMIKOM Game Dev)
Presentasi Seminar Unity (AMIKOM Game Dev)Presentasi Seminar Unity (AMIKOM Game Dev)
Presentasi Seminar Unity (AMIKOM Game Dev)
 
Unity 3d Basics
Unity 3d BasicsUnity 3d Basics
Unity 3d Basics
 
Production RPG Maker.
Production RPG Maker. Production RPG Maker.
Production RPG Maker.
 
[Product Design] WSOD March 2014
[Product Design] WSOD March 2014 [Product Design] WSOD March 2014
[Product Design] WSOD March 2014
 
Unity 3D
Unity 3DUnity 3D
Unity 3D
 
Game engine terminology/glossary
Game engine terminology/glossaryGame engine terminology/glossary
Game engine terminology/glossary
 
Unity
UnityUnity
Unity
 
Gaming Process
Gaming ProcessGaming Process
Gaming Process
 
XPS™ One™ Sales Aid (2007 2-page flyer)
XPS™ One™ Sales Aid (2007 2-page flyer)XPS™ One™ Sales Aid (2007 2-page flyer)
XPS™ One™ Sales Aid (2007 2-page flyer)
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game Development
 

Destacado

AAPEX effective tradeshow budgeting
AAPEX effective tradeshow budgetingAAPEX effective tradeshow budgeting
AAPEX effective tradeshow budgetingAAPEX Show
 
03chrishill 110303022415-phpapp02
03chrishill 110303022415-phpapp0203chrishill 110303022415-phpapp02
03chrishill 110303022415-phpapp023GDR
 
What's new in Puppet 3.0
What's new in Puppet 3.0What's new in Puppet 3.0
What's new in Puppet 3.0Eric Sorenson
 

Destacado (7)

AAPEX effective tradeshow budgeting
AAPEX effective tradeshow budgetingAAPEX effective tradeshow budgeting
AAPEX effective tradeshow budgeting
 
Pleno Dementia
Pleno DementiaPleno Dementia
Pleno Dementia
 
03chrishill 110303022415-phpapp02
03chrishill 110303022415-phpapp0203chrishill 110303022415-phpapp02
03chrishill 110303022415-phpapp02
 
What's new in Puppet 3.0
What's new in Puppet 3.0What's new in Puppet 3.0
What's new in Puppet 3.0
 
Psicologia do SMS - Acision
Psicologia do SMS - AcisionPsicologia do SMS - Acision
Psicologia do SMS - Acision
 
Antidepresi
AntidepresiAntidepresi
Antidepresi
 
Anymeeting 06.03.2013
Anymeeting 06.03.2013Anymeeting 06.03.2013
Anymeeting 06.03.2013
 

Similar a Getting Started with iPhone Game Development

ميهين
ميهينميهين
ميهينAhmed
 
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...Gerke Max Preussner
 
iBasket: The story of an HTML5 game
iBasket: The story of an HTML5 gameiBasket: The story of an HTML5 game
iBasket: The story of an HTML5 gameIker Jamardo
 
Advanced Silverlight
Advanced SilverlightAdvanced Silverlight
Advanced Silverlightrsnarayanan
 
Y1 gd engine_terminologY
Y1 gd engine_terminologYY1 gd engine_terminologY
Y1 gd engine_terminologYElliotBlack
 
Html5game presentation
Html5game presentationHtml5game presentation
Html5game presentationrandyhoyt
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA GameSohil Gupta
 
Breakout Ball project presentation
Breakout Ball project presentationBreakout Ball project presentation
Breakout Ball project presentationMdThohidulIslam3
 
Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4Michał Kłoś
 
Silverlight as a Gaming Platform
Silverlight as a Gaming PlatformSilverlight as a Gaming Platform
Silverlight as a Gaming Platformgoodfriday
 

Similar a Getting Started with iPhone Game Development (20)

ميهين
ميهينميهين
ميهين
 
Workflow
WorkflowWorkflow
Workflow
 
Drama Dash
Drama DashDrama Dash
Drama Dash
 
Workflow
WorkflowWorkflow
Workflow
 
Game Elements
Game ElementsGame Elements
Game Elements
 
Alexey Savchenko, Unreal Engine
Alexey Savchenko, Unreal EngineAlexey Savchenko, Unreal Engine
Alexey Savchenko, Unreal Engine
 
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...
 
iBasket: The story of an HTML5 game
iBasket: The story of an HTML5 gameiBasket: The story of an HTML5 game
iBasket: The story of an HTML5 game
 
Advanced Silverlight
Advanced SilverlightAdvanced Silverlight
Advanced Silverlight
 
Y1 gd engine_terminologY
Y1 gd engine_terminologYY1 gd engine_terminologY
Y1 gd engine_terminologY
 
Html5game presentation
Html5game presentationHtml5game presentation
Html5game presentation
 
Portfolio
PortfolioPortfolio
Portfolio
 
Gamegame workshop
Gamegame workshopGamegame workshop
Gamegame workshop
 
Engine terminology
Engine terminologyEngine terminology
Engine terminology
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA Game
 
Breakout Ball project presentation
Breakout Ball project presentationBreakout Ball project presentation
Breakout Ball project presentation
 
Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4
 
Md2010 jl-wp7-sl-game-dev
Md2010 jl-wp7-sl-game-devMd2010 jl-wp7-sl-game-dev
Md2010 jl-wp7-sl-game-dev
 
Silverlight as a Gaming Platform
Silverlight as a Gaming PlatformSilverlight as a Gaming Platform
Silverlight as a Gaming Platform
 
Pc54
Pc54Pc54
Pc54
 

Más de John Wilker

Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11John Wilker
 
Introtoduction to cocos2d
Introtoduction to  cocos2dIntrotoduction to  cocos2d
Introtoduction to cocos2dJohn Wilker
 
Getting Started with OpenGL ES
Getting Started with OpenGL ESGetting Started with OpenGL ES
Getting Started with OpenGL ESJohn Wilker
 
User Input in a multi-touch, accelerometer, location aware world.
User Input in a multi-touch, accelerometer, location aware world.User Input in a multi-touch, accelerometer, location aware world.
User Input in a multi-touch, accelerometer, location aware world.John Wilker
 
Physics Solutions for Innovative Game Design
Physics Solutions for Innovative Game DesignPhysics Solutions for Innovative Game Design
Physics Solutions for Innovative Game DesignJohn Wilker
 
Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...John Wilker
 
Internationalizing Your Apps
Internationalizing Your AppsInternationalizing Your Apps
Internationalizing Your AppsJohn Wilker
 
Optimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application ResponsivenessOptimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application ResponsivenessJohn Wilker
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On RailsJohn Wilker
 
Integrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLimeIntegrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLimeJohn Wilker
 
Starting Core Animation
Starting Core AnimationStarting Core Animation
Starting Core AnimationJohn Wilker
 
P2P Multiplayer Gaming
P2P Multiplayer GamingP2P Multiplayer Gaming
P2P Multiplayer GamingJohn Wilker
 
Using Concurrency To Improve Responsiveness
Using Concurrency To Improve ResponsivenessUsing Concurrency To Improve Responsiveness
Using Concurrency To Improve ResponsivenessJohn Wilker
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder BehindJohn Wilker
 
Mobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouchMobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouchJohn Wilker
 
Accelerometer and OpenGL
Accelerometer and OpenGLAccelerometer and OpenGL
Accelerometer and OpenGLJohn Wilker
 
Deep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and FrameworkDeep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and FrameworkJohn Wilker
 
NSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegateNSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegateJohn Wilker
 
From Flash to iPhone
From Flash to iPhoneFrom Flash to iPhone
From Flash to iPhoneJohn Wilker
 

Más de John Wilker (20)

Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11
 
Introtoduction to cocos2d
Introtoduction to  cocos2dIntrotoduction to  cocos2d
Introtoduction to cocos2d
 
Getting Started with OpenGL ES
Getting Started with OpenGL ESGetting Started with OpenGL ES
Getting Started with OpenGL ES
 
User Input in a multi-touch, accelerometer, location aware world.
User Input in a multi-touch, accelerometer, location aware world.User Input in a multi-touch, accelerometer, location aware world.
User Input in a multi-touch, accelerometer, location aware world.
 
Physics Solutions for Innovative Game Design
Physics Solutions for Innovative Game DesignPhysics Solutions for Innovative Game Design
Physics Solutions for Innovative Game Design
 
Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...
 
Internationalizing Your Apps
Internationalizing Your AppsInternationalizing Your Apps
Internationalizing Your Apps
 
Optimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application ResponsivenessOptimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application Responsiveness
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On Rails
 
Integrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLimeIntegrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLime
 
Starting Core Animation
Starting Core AnimationStarting Core Animation
Starting Core Animation
 
P2P Multiplayer Gaming
P2P Multiplayer GamingP2P Multiplayer Gaming
P2P Multiplayer Gaming
 
Using Concurrency To Improve Responsiveness
Using Concurrency To Improve ResponsivenessUsing Concurrency To Improve Responsiveness
Using Concurrency To Improve Responsiveness
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder Behind
 
Mobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouchMobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouch
 
Accelerometer and OpenGL
Accelerometer and OpenGLAccelerometer and OpenGL
Accelerometer and OpenGL
 
Deep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and FrameworkDeep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and Framework
 
NSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegateNSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegate
 
Using SQLite
Using SQLiteUsing SQLite
Using SQLite
 
From Flash to iPhone
From Flash to iPhoneFrom Flash to iPhone
From Flash to iPhone
 

Último

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

Último (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Getting Started with iPhone Game Development

  • 1. Getting Started with iPhone Game Development with Amanda Wixted and David Cairns
  • 2. Outline • Game demo • General Architecture of games • Input Modes • Code tour • Networking • Sound • Tips & Tricks
  • 4. Outline • Game demo • General Architecture of games • Input Modes • Code tour • Networking • Sound • Tips & Tricks
  • 6. General Structure of Games main paint update
  • 7. General Structure of Games main paint update
  • 8. General Structure of Games main paint update
  • 9. General Structure of Games main paint update
  • 10. General Structure of Games main paint update
  • 11. General Structure of Games main paint update background objects in view heads up display
  • 12. General Structure of Games main paint update background objects in view heads up display
  • 13. General Structure of Games main paint update background objects in view heads up display
  • 14. General Structure of Games main paint update background game state particle changes objects effects avatar’s in view position bad camera heads guys’ position up display positions
  • 15. General Structure of Games main paint update background game state particle changes objects effects avatar’s in view position bad camera heads guys’ position up display positions
  • 16. General Structure of Games main paint update background game state particle changes objects effects avatar’s in view position bad camera heads guys’ position up display positions
  • 17. General Structure of Games main paint update background game state particle changes objects effects avatar’s in view position set flags bad camera heads in the data guys’ position up display models positions I/O
  • 18. Outline • Game demo • General Architecture of games • Input Modes • Code tour • Networking • Sound • Tips & Tricks
  • 19. Input Modes how and when to use touch and tilt as game controls
  • 20. Input Modes PAC-MAN: choice of 3 control modes: Swipe (best) Accelerometer (okay) D-Pad (sucks)
  • 21. Touch Input • whenever the user needs to touch the screen, they’re blocking what they can see • fine in puzzle games • less fine in platformers/fps/non-puzzle • keep the users’ fingers off to the sides or only on the screen for a short time (swipe)
  • 22. Good Examples • iMech - steering/aiming wheels out of the way • Dropship - wheels anywhere user touches down, so motion is relative
  • 23. Accelerometer Input Take out your iPhone
  • 24. Chart of Bubble Level’s low-pass filter Accelerometer output 1.00 0.75 output 0.50 0.25 0 time t
  • 25. Accelerometer input • use a filter function that works for your game • maximize controllability and sensitivity • play around with it until you (and your friends) feel it’s right
  • 26. Accelerometer input position.x += 8.0 * acceleration.x; • TwitterGame: we used tilt to move left/ right • simple: adjust the avatar’s position by a (constant factor * raw data) • at 60hz sample rate, avatar moves 480px/s at a force of acceleration.x =1.0
  • 27. Common mistakes • don’t require the user to tilt the device to an angle where they can no longer see the screen • iterate until your controls feel right • don’t use the accelerometer for menu navigation
  • 28. Outline • Game demo • General Architecture of games • Input Modes • Code tour • Networking • Sound • Tips & Tricks
  • 29. From Swipe to Jump an illustrated tour of TwitterGame’s code
  • 30. From Swipe to Jump touchesEnded Game EAGLView Controller touchesBegan
  • 31. From Swipe to Jump touchesEnded Game EAGLView Controller touchesBegan
  • 32. From Swipe to Jump touchesEnded Game EAGLView Controller touchesBegan
  • 33. From Swipe to Jump touchesEnded Game EAGLView Controller touchesBegan
  • 34. From Swipe to Jump touchesEnded Game EAGLView Controller touchesBegan
  • 35. From Swipe to Jump touchesEnded Game EAGLView Controller touchesBegan
  • 36. From Swipe to Jump touchesEnded Game EAGLView Controller touchesBegan
  • 37. From Swipe to Jump paint update
  • 38. From Swipe to Jump in the Avatar class:
  • 39. From Swipe to Jump the Avatar’s update method, called from the game loop:
  • 45. From Swipe to Jump Can you see what would happen if we instead checked whether the avatar’s frame was intersecting with a platform? What if we used current position and previous position instead?
  • 46. Outline • Game demo • General Architecture of games • Input Modes • Code tour • Networking • Sound • Tips & Tricks
  • 47. Networking • You have the usual options available: • sockets, URL requests • GameKit - a (disappointingly-named) networking framework • local bluetooth connections • voice chat over the internet • GK doesn’t do anything but networking
  • 48. Networking Task Tool Read getting/posting to a NSURLConnection URL Loading System webserver interacting with a CFNetwork Programming gameserver using a constant CFSocket Guide connection creating a local peer-to-peer GameKit Programming GameKit game connection Guide
  • 49. Outline • Game demo • General Architecture of games • Input Modes • Code tour • Networking • Sound • Tips & Tricks
  • 50. Sound Task Tool Read Games where sound timing AV Foundation Framework is not essential AVAudioPlayer Reference 3D Games OpenAL OpenAL.org Games where sound timing Audio Queue Services is essential AudioQueue Reference AudioToolbox/ System Sound Services UI/Menu Sounds AudioToolbox.h Reference
  • 51. Sound • Use AVAudioSession to tell the device how to handle your app’s audio • Set your category to AVAudioSessionCategoryAmbient so that users can listen to their iPod while they play your game
  • 52. Outline • Game demo • General Architecture of games • Input Modes • Code tour • Networking • Sound • Tips & Tricks
  • 53. General Tips & Tricks Miscellany from experience
  • 54. Do Quick Prototyping • We wrote a simple UIView animation-based implementation just as a proof-of-concept in about 2 hours • Doesn’t need to be nice, only needs to approximate what you want • Helps you work out issues you hadn’t thought about with your basic gameplay before you get caught up in your real implementation
  • 55. Have Randomness • Randomly generated scenery • User input * random number = just enough frustration to keep the user interested
  • 56. Adjust values until they feel right • Have lots of tweakable constants • Don’t spend too much time being true to theoretical physics • Iterate on your input handling sections
  • 57.
  • 60. Immediate Mode position color tex coord position color tex coord OpenGL position color tex coord
  • 61. Immediate Mode glBegin(GL_TRIANGLES); glColor4f(1.0, 0.0, 0.0, 1.0); glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 0.0); glColor4f(1.0, 1.0, 0.0, 1.0); glTexCoord2f(1.0, 0.0); glVertex3f(1.0, -1.0, 0.0); /* additional vertices... */ glEnd();
  • 62. Vertex Arrays Main Memory position OpenGL color tex coord position color tex coord position color tex coord position color tex coord
  • 63. Vertex Arrays glVertexPointer(3, // 3 components / vertex GL_FLOAT, // type of data 0, // stride (tightly-packed) positions); // pointer to data glEnableClientState(GL_VERTEX_ARRAY); /* Set up color, normal, tex coord arrays... */ glDrawArrays(GL_TRIANGLES, 0, // Starting at vertex zero... 6); // ... Render 6 vertices
  • 64. OpenGL ES 1.1 • Fewer geometry types • No display lists • No direct-to-framebuffer blitting • No automatic format conversions • Fixed function pipeline only
  • 66. OpenGL ES 2.0 • No fixed-function pipeline • Programmable pipeline ONLY • No implicit vertex attributes
  • 67. Vertex Specification attribute vec4 position; attribute vec4 color; attribute vec2 texCoord; ...
  • 68. Fragment Shader precision mediump float; void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }
  • 69. Fragment Shader precision mediump float; void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }
  • 70. GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, // shader object’s name 1, // number of strings &vertexSource, // array of strings NULL); // array of lengths glCompileShader(vertexShader); GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragmentShader, 1, &fragmentSource, NULL); glCompileShader(fragmentShader);
  • 71. GLuint program = glCreateProgram(); glAttachShader(program, vertexShader); glAttachShader(program, fragmentShader); glLinkProgram(program); glUseProgram(program);
  • 72. Vertex Attribute Arrays Main Memory Attrib 0 Attrib 1 OpenGL value 0 Attrib 2 value 0 value 0 value 1 value 1 value 1 value 2 value 2 value 2 … … …
  • 73. glVertexAttribPointer(positionIndex, // attrib index for position 3, // 3 components / vertex GL_FLOAT, // type of data GL_FALSE, // don’t normalize 0, // stride (tightly-packed) vertices); // pointer to data glEnableVertexAttribArray(positionIndex); /* Set up color, normal, tex coord arrays... */ glDrawArrays(GL_TRIANGLES, 0, 6);
  • 74. • GL 101 • Texture Atlases • Vertex Buffer Objects • Interleaved Arrays • Texture Compression
  • 75. GL 101 • As few draw calls as possible • Minimize changes in GL state
  • 76.
  • 79. Power-ups and objects
  • 80. position 3 position 2 tex coord (0, 1) tex coord (1, 1) position 0 position 1 tex coord (0, 0) tex coord (1, 0)
  • 81. position 3 position 2 tex coord (0, 1) tex coord (1, 1) position 0 position 1 tex coord (0, 0) tex coord (1, 0)
  • 82. position 2 position 3 tex coord (0, 1) tex coord (1, 1) position 0 position 1 tex coord (0, 0) tex coord (1, 0) Position Array Tex Coord Array
  • 83. position 2 position 3 tex coord (0, 1) tex coord (1, 1) position 0 position 1 tex coord (0, 0) tex coord (1, 0) Position Array p0 p1 p2 p2 p1 p3 … Tex Coord Array (0, 0) (1, 0) (0, 1) (0, 1) (1, 0) (1, 1) …
  • 84. Material • Blending Mode • Lighting parameters • Texture binding
  • 85. Material Material Material Create a material from each of the unique objects we want to draw, that encapsulates all of the object’s rendering state.
  • 86. Sort each of the objects into buckets keyed by material. Now you don’t have to change any state bet ween drawing like objects! How can we reduce state changes / draw calls even Also, because we don’t have to change any state bet ween draws, we more? Texture atlases! can aggregate all the geometry into a single buffer / single draw call. Material Material Material Geometry Buffer Geometry Buffer Geometry Buffer
  • 87. • GL 101 • Texture Atlases • Vertex Buffer Objects • Interleaved Arrays • Texture Compression
  • 89.
  • 90.
  • 91. • GL 101 • Texture Atlases • Vertex Buffer Objects • Interleaved Arrays • Texture Compression
  • 92. Vertex Buffer Objects Hinted better-vertex-storage™
  • 93. Vertex Arrays RAM GPU position 0 position 1 Bus position 2
  • 94. Vertex Buffer Objects GPU RAM Video Memory Bus position 0 position 0 position 1 position 1 position 2 position 2
  • 95. Vertex Buffer Objects GPU RAM Video Memory Bus position 0 position 0 position 1 position 1 position 2 position 2
  • 96. Vertex Buffer Objects GLuint vboName; glGenBuffers(1, &vboName); glBindBuffer(GL_ARRAY_BUFFER, vboName); glBufferData(GL_ARRAY_BUFFER, // binding point bufferSize, // size of buffer bufferPointer, // pointer to buffer in RAM GL_STATIC_DRAW); // usage hint
  • 97. STATIC: Written once, used many times DYNAMIC: Modified a lot, used often STREAM: Modified once, used only a few times ES 1.1 ES 2.0 • GL_STATIC_DRAW • GL_STATIC_DRAW • GL_DYNAMIC_DRAW • GL_DYNAMIC_DRAW • GL_STREAM_DRAW
  • 98. Using VBOs… ES 1.1 // Bind our buffer. glBindBuffer(GL_ARRAY_BUFFER, vboName); // Tell GL where the geometry is. glVertexPointer(3, GL_FLOAT, 0, // same as before 0x0); // offset into the buffer glEnableClientState(GL_VERTEX_ARRAY); glDrawArrays( ... );
  • 99. Using VBOs… ES 2.0 // Bind our buffer. glBindBuffer(GL_ARRAY_BUFFER, vboName); // Tell GL where the geometry is. glVertexAttribPointer(positionIndex, 3, GL_FLOAT, GL_FALSE 0, 0x0); // offset into the buffer glEnableVertexAttribArray(positionIndex); glDrawArrays( ... );
  • 100. Changing VBO Data glBindBuffer(GL_ARRAY_BUFFER, vboName); glBufferSubData(GL_ARRAY_BUFFER, offset, // offset into VBO size, // size of dataPointer dataPointer); // pointer to new data
  • 101. Changing VBO Data glBindBuffer(GL_ARRAY_BUFFER, vboName); char *buffer = glMapBuffer(GL_ARRAY_BUFFER, access); // read and/or write /* Manipulate the contents of the buffer... */ // Tell GL we’re done. glUnmapBuffer(GL_ARRAY_BUFFER);
  • 102. • GL 101 • Texture Atlases • Vertex Buffer Objects • Interleaved Arrays • Texture Compression
  • 104. Non-Interleaved Arrays Memory position OpenGL color tex coord position color tex coord position color tex coord position color tex coord
  • 105. Interleaved Arrays Memory OpenGL position color tex coord position color tex coord position color tex coord position color tex coord
  • 106. Interleaved Arrays typedef struct { float position[3]; float color[3]; float texCoord[2]; } VertexData; VertexData *interleavedData;
  • 107. … in ES 1.1 glVertexPointer(3, GL_FLOAT, sizeof(VertexData), // stride &interleavedData[0].position[0]); // first position glColorPointer(3, GL_FLOAT, sizeof(VertexData), &interleavedData[0].color[0]); glTexCoordPointer(2, GL_FLOAT, sizeof(VertexData), &interleavedData[0].texCoord[0]);
  • 108. … in ES 2.0 glVertexAttribPointer(positionIndex, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), &interleavedData[0].position[0]); ...
  • 109. • GL 101 • Texture Atlases • Vertex Buffer Objects • Interleaved Arrays • Texture Compression
  • 111.
  • 112. Texture Compression /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool texturetool [-m] # Generate mipmaps [-e encoding options] # PVRTC, bpp -o “out_file.pvrtc” [-f format] # PVR or Raw “in_file.png”
  • 113. Input Requirements • Must be square • Dimensions must be a power-of-two • Must be at least 8 x 8
  • 114. glCompressedTexImage2D(GL_TEXTURE_2D, level, # mipmap level format, width, height, 0, # border (must be zero!) size, # size of data dataPointer); # pointer to data
  • 115. RGB RGBA 2 bits / pixel GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 4 bits / pixel GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
  • 116.
  • 118. Special Thanks Libraries used: Matt Gemmell - MGTwitterEngine Michael Daley and Ben Britten - Sound Engine core Tim Omernick - GLTexture class core Direct Contributors: Jeff Osborne - Game Sounds Duncan Stanley - Game Design help Wil Shipley - code pimping Twitter and our friends - tweets Timothy Fitz - debugging help
  • 119. Contact Us Amanda Wixted amanda.wixted@gmail.com David Cairns drcairns@gmail.com