Using Chipmunk Physics to create a iOS Game - Scott Lembcke
-
Upload
mobile-march -
Category
Technology
-
view
768 -
download
3
description
Transcript of Using Chipmunk Physics to create a iOS Game - Scott Lembcke
![Page 1: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/1.jpg)
Chipmunk Physicsand Cocos2D
Scott Lembcke, Howling Moon Software
1
Saturday, March 23, 13
![Page 2: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/2.jpg)
What is Chipmunk?
2
Saturday, March 23, 13
![Page 3: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/3.jpg)
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
![Page 4: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/4.jpg)
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
![Page 5: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/5.jpg)
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
![Page 6: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/6.jpg)
Space
Shapes
BodyJoint
6
Body
Saturday, March 23, 13
![Page 7: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/7.jpg)
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
![Page 8: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/8.jpg)
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
![Page 9: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/9.jpg)
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
![Page 10: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/10.jpg)
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
![Page 11: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/11.jpg)
Code Time!
11
Saturday, March 23, 13
![Page 12: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/12.jpg)
Fixed Time Steps
12
• Not required, but a really good idea
• “Fix your timestep” - gafferongames.com
Saturday, March 23, 13
![Page 13: Using Chipmunk Physics to create a iOS Game - Scott Lembcke](https://reader033.fdocuments.in/reader033/viewer/2022060108/554dc7e2b4c905c7488b51ef/html5/thumbnails/13.jpg)
Get the Source Codegithub.com/slembcke/ChipmunkColorMatch
13
Saturday, March 23, 13