Using Chipmunk Physics to create a iOS Game - Scott Lembcke

1,249 views

Published on

Scott's 3/21 presentation at Mobile March 2013

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,249
On SlideShare
0
From Embeds
0
Number of Embeds
427
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Using Chipmunk Physics to create a iOS Game - Scott Lembcke

  1. 1. Chipmunk Physics and Cocos2D Scott Lembcke, Howling Moon Software 1Saturday, March 23, 13
  2. 2. What is Chipmunk? 2Saturday, March 23, 13
  3. 3. What is Chipmunk? • Open source 2D rigid body physics engine • Rigid body == non-deformable shapes • Collision detection • Joints (and other constraints) • Queries (point, raycast, etc) 3Saturday, March 23, 13
  4. 4. Fancy Features • Collision: spatial indexing, filtering, event callbacks, collision forces • Object sleeping • Contact graph • Joint callbacks • Pro features: NEON / multicore, autogeometry, Obj-C binding. 4Saturday, March 23, 13
  5. 5. What is Cocos2D • Open source 2D game framework • Scene graphs (sprites, particles, shaders, ...) • Game states • Transitions, input, timers, menus • Asset management (sounds, textures, ...) • Popularity: tool support, cross-platform 5Saturday, March 23, 13
  6. 6. Shapes Body Joint Body 6 SpaceSaturday, March 23, 13
  7. 7. Chipmunk Spaces • Global values (gravity, damping, quality, etc) • Has lists of bodies, shapes and constraints • cpSpaceStep() - updates time • Tracks collision callbacks • Queries (point, raycast, shape, bounds) 7Saturday, March 23, 13
  8. 8. Chipmunk Bodies • Physical properties (mass, moment) • Location/movement • Position, velocity, force • Angle, angular velocity, torque • Has no shape or size on its own • Can be static, dynamic or rogue 8Saturday, March 23, 13
  9. 9. Chipmunk Shapes • Gives shape to rigid bodies • Allows them to collide • Material properties (friction, bounciness) • Circles, line segments, convex polygons • Multiple shapes per body allowed • Always filled (no hollow shapes) 9Saturday, March 23, 13
  10. 10. Simple Matching Game • Ignore scoring logic • Basic mechanics: • Match groups of 4 - collision callbacks • Tap a ball to remove it - queries • Horses! 10Saturday, March 23, 13
  11. 11. Code Time! 11Saturday, March 23, 13
  12. 12. Fixed Time Steps • Not required, but a really good idea • “Fix your timestep” - gafferongames.com 12Saturday, March 23, 13
  13. 13. Get the Source Code github.com/slembcke/ChipmunkColorMatch 13Saturday, March 23, 13

×