SlideShare a Scribd company logo
1 of 13
Download to read offline
Chipmunk Physics
                          and Cocos2D
                         Scott Lembcke, Howling Moon Software




                                          1
Saturday, March 23, 13
What is Chipmunk?




                                 2
Saturday, March 23, 13
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)
                                         3
Saturday, March 23, 13
Fancy Features
                     • Collision: spatial indexing, filtering, event
                         callbacks, collision forces
                     • Object sleeping
                     • Contact graph
                     • Joint callbacks
                     • Pro features: NEON / multicore,
                         autogeometry, Obj-C binding.

                                              4
Saturday, March 23, 13
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
                                             5
Saturday, March 23, 13
Shapes




                                              Body


                                      Joint
                           Body

                                  6                  Space
Saturday, March 23, 13
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)
                                            7
Saturday, March 23, 13
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
                                          8
Saturday, March 23, 13
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)
                                           9
Saturday, March 23, 13
Simple Matching Game

                     • Ignore scoring logic
                     • Basic mechanics:
                      • Match groups of 4 - collision callbacks
                      • Tap a ball to remove it - queries
                     • Horses!
                                           10
Saturday, March 23, 13
Code Time!




                             11
Saturday, March 23, 13
Fixed Time Steps

                     • Not required, but a really good idea
                     • “Fix your timestep” - gafferongames.com



                                         12
Saturday, March 23, 13
Get the Source Code
                          github.com/slembcke/ChipmunkColorMatch




                                            13
Saturday, March 23, 13

More Related Content

More from Mobile March

Using Mobile to Achieve Truly Integrated Marketing - Curt Prins
Using Mobile to Achieve Truly Integrated Marketing - Curt PrinsUsing Mobile to Achieve Truly Integrated Marketing - Curt Prins
Using Mobile to Achieve Truly Integrated Marketing - Curt Prins
Mobile March
 
Dueling Banjos: Inter-app Communication
Dueling Banjos: Inter-app Communication Dueling Banjos: Inter-app Communication
Dueling Banjos: Inter-app Communication
Mobile March
 
Guy Thier Keynote Presentation
Guy Thier Keynote PresentationGuy Thier Keynote Presentation
Guy Thier Keynote Presentation
Mobile March
 
Mobile March Olson presentation 2012
Mobile March Olson presentation 2012Mobile March Olson presentation 2012
Mobile March Olson presentation 2012
Mobile March
 

More from Mobile March (20)

Cross-Platform Mobile Development with PhoneGap-Vince Bullinger
Cross-Platform Mobile Development with PhoneGap-Vince BullingerCross-Platform Mobile Development with PhoneGap-Vince Bullinger
Cross-Platform Mobile Development with PhoneGap-Vince Bullinger
 
You Can’t Ignore the Tablet-Designing & Developing Universal Apps for Phones ...
You Can’t Ignore the Tablet-Designing & Developing Universal Apps for Phones ...You Can’t Ignore the Tablet-Designing & Developing Universal Apps for Phones ...
You Can’t Ignore the Tablet-Designing & Developing Universal Apps for Phones ...
 
Building Wearables-Kristina Durivage
Building Wearables-Kristina DurivageBuilding Wearables-Kristina Durivage
Building Wearables-Kristina Durivage
 
The Blossoming Internet of Things Zach Supalla-Spark
The Blossoming Internet of Things Zach Supalla-SparkThe Blossoming Internet of Things Zach Supalla-Spark
The Blossoming Internet of Things Zach Supalla-Spark
 
LiveCode Cross-Platform Development-Joel Gerdeen
LiveCode Cross-Platform Development-Joel GerdeenLiveCode Cross-Platform Development-Joel Gerdeen
LiveCode Cross-Platform Development-Joel Gerdeen
 
The Mobile Evolution‚ Systems vs. Apps - Matthew David
The Mobile Evolution‚ Systems vs. Apps - Matthew DavidThe Mobile Evolution‚ Systems vs. Apps - Matthew David
The Mobile Evolution‚ Systems vs. Apps - Matthew David
 
Unity-Beyond Games! - Josh Ruis
Unity-Beyond Games! - Josh RuisUnity-Beyond Games! - Josh Ruis
Unity-Beyond Games! - Josh Ruis
 
IP for Mobile Startups -Ernest Grumbles
IP for Mobile Startups -Ernest GrumblesIP for Mobile Startups -Ernest Grumbles
IP for Mobile Startups -Ernest Grumbles
 
Using Mobile to Achieve Truly Integrated Marketing - Curt Prins
Using Mobile to Achieve Truly Integrated Marketing - Curt PrinsUsing Mobile to Achieve Truly Integrated Marketing - Curt Prins
Using Mobile to Achieve Truly Integrated Marketing - Curt Prins
 
Introduction to Core Data - Jason Shapiro
Introduction to Core Data - Jason ShapiroIntroduction to Core Data - Jason Shapiro
Introduction to Core Data - Jason Shapiro
 
Developing Custom iOs Applications for Enterprise
Developing Custom iOs Applications for EnterpriseDeveloping Custom iOs Applications for Enterprise
Developing Custom iOs Applications for Enterprise
 
Product Management for Your App
Product Management for Your AppProduct Management for Your App
Product Management for Your App
 
Robotium Tutorial
Robotium TutorialRobotium Tutorial
Robotium Tutorial
 
Dueling Banjos: Inter-app Communication
Dueling Banjos: Inter-app Communication Dueling Banjos: Inter-app Communication
Dueling Banjos: Inter-app Communication
 
Guy Thier Keynote Presentation
Guy Thier Keynote PresentationGuy Thier Keynote Presentation
Guy Thier Keynote Presentation
 
Mobile March Olson presentation 2012
Mobile March Olson presentation 2012Mobile March Olson presentation 2012
Mobile March Olson presentation 2012
 
Bannin mobile march_2012_public
Bannin mobile march_2012_publicBannin mobile march_2012_public
Bannin mobile march_2012_public
 
Beginningi os part1-bobmccune
Beginningi os part1-bobmccuneBeginningi os part1-bobmccune
Beginningi os part1-bobmccune
 
Mobile march2012 android101-pt2
Mobile march2012 android101-pt2Mobile march2012 android101-pt2
Mobile march2012 android101-pt2
 
Mobile march2012 android101-pt1
Mobile march2012 android101-pt1Mobile march2012 android101-pt1
Mobile march2012 android101-pt1
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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 future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 

Using Chipmunk Physics to create a iOS Game - Scott Lembcke

  • 1. Chipmunk Physics and Cocos2D Scott Lembcke, Howling Moon Software 1 Saturday, March 23, 13
  • 2. What is Chipmunk? 2 Saturday, March 23, 13
  • 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) 3 Saturday, March 23, 13
  • 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. 4 Saturday, March 23, 13
  • 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 5 Saturday, March 23, 13
  • 6. Shapes Body Joint Body 6 Space Saturday, March 23, 13
  • 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) 7 Saturday, March 23, 13
  • 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 8 Saturday, March 23, 13
  • 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) 9 Saturday, March 23, 13
  • 10. Simple Matching Game • Ignore scoring logic • Basic mechanics: • Match groups of 4 - collision callbacks • Tap a ball to remove it - queries • Horses! 10 Saturday, March 23, 13
  • 11. Code Time! 11 Saturday, March 23, 13
  • 12. Fixed Time Steps • Not required, but a really good idea • “Fix your timestep” - gafferongames.com 12 Saturday, March 23, 13
  • 13. Get the Source Code github.com/slembcke/ChipmunkColorMatch 13 Saturday, March 23, 13