With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Book Description

The casual game market continues to expand, and with the use of Flash growing and the increased popularity of the iPhone and other mobile gaming devices, developers have an exciting new route to market. But many of these budding game programmers find that they're missing the core math and physics skills they need to develop even simple games. MATHEMATICS AND PHYSICS FOR PROGRAMMERS, SECOND EDITION teaches beginning game programmers they skills they need to develop causal games. Beginning with the basic aspects of mathematics and physics that are relevant to games, and moving on to more complex topics, the book combines theory and practice and the reader develops a number of games throughout the course of the book. With the concepts and techniques presented in the book, readers should be able to program a number of standard casual game types, including Mario-style platformers, driving simulations, puzzle games, and a simple first-person shooter. They will also gain a basic understanding of 2D and 3D geometry.

2. Acknowledgments
4. Introduction
5. I. Essential Topics in Mathematics
1. 1. Numbers
1. In This Chapter
2. Overview
3. Numbers as Written
4. How Computers Represent Numbers
1. Representing Integers
2. Representing Rational and Irrational Numbers
3. Standards and Computed Numbers
4. Common Functions
5. Rounding Errors and Performance
6. Big Integers
5. Exercises
6. Summary
7. You Should Now Know
2. 2. Arithmetic
1. In This Chapter
2. Overview
3. Fractions
1. Calculating Fractions
2. Factors and Factorization
3. Modulo Arithmetic
4. Cycling Through Data
4. Proportions, Ratios, and Percentages
1. Mapping Between Ranges of Values
2. Making a Slider
3. Calculating Percentages
5. Exponentials
6. Logarithms
7. Exercises
8. Summary
9. You Should Now Know
3. 3. Algebra
1. In This Chapter
2. Overview
3. Basic Algebra
4. Working with Equations
5. Factoring and Solving Quadratic Equations
1. Examples of Factoring
3. The Quadratic Formula and the Difference of Two Squares
4. Solving Cubic Equations
5. Solving Simultaneous Equations
6. Functions and Graphs
1. What Is a Graph?
2. Plotting and Examining Functions on a Graph
3. What Graphs Tell You
4. Parametric Curves and Functions
7. Exercises
8. Summary
9. You Should Now Know
4. 4. Geometry and Trigonometry
1. In This Chapter
2. Overview
3. Angles
4. Triangles
1. The Types of Triangle
2. The Pythagorean Theorem
3. The Trigonometric Functions
4. Trigonometric Identities
5. The Inverse Trigonometric Functions
5. Calculations with Triangles
6. Rotations and Reflections
7. Exercises
8. Summary
9. You Should Now Know
5. 5. Vectors
1. In This Chapter
2. Overview
3. Getting from Here to There
1. The Vector as an Instruction
2. Vector Arithmetic
3. The Normal Vector
4. Vectors and Scalars in Real Life
4. Vector Motion
1. Describing Shapes with Vectors
2. Moving from P to Q
3. More Complicated Vector Paths
5. Vector Calculations
1. Separating Vectors into Components
2. The Scalar (Dot) Product
3. Vector Equations
6. Matrices
7. Exercises
8. Summary
9. You Should Now Know
6. 6. Calculus
1. In This Chapter
2. Overview
3. Differentiation and Integration
1. The Gradient of a Function
2. Differentiating
3. Differentiating Logarithms and Exponentials
4. Differentiating Trigonometric Functions
5. Parametric Equations and Partial Derivatives
6. Integration
4. Differential Equations
5. Approximation Methods
6. Exercises
7. Summary
8. You Should Now Know
6. II. Essential Topics in Physics
1. 7. Acceleration, Mass, and Energy
1. In This Chapter
2. Overview
3. Ballistics
4. Mass and Momentum
5. Energy
6. Exercises
7. Summary
8. You Should Now Know
2. 8. Detecting Collisions Between Simple Shapes
1. In This Chapter
2. Overview
3. Ground Rules
4. When Circles Collide
5. When Squares Collide
6. When Ellipses Collide
7. When Things Collide
8. Exercises
9. Summary
10. You Should Now Know
3. 9. Collision Resolution
1. In This Chapter
2. Overview
3. Resolving a Single Collision
4. Multiple Collisions
5. Exercises
6. Summary
7. You Should Now Know
4. 10. Detecting Collisions Between Complex Shapes
1. In This Chapter
2. Overview
3. Problems with Complex Shapes
1. Bitmaps and Vector Shapes
2. Defining a Complex Shape
3. Bezier Curves and Splines
4. Convex and Concave
5. Determining If a Point Is Inside a Shape
4. Some Reasonable Problems
5. Built-In Solutions
6. Exercises
7. Summary
8. You Should Now Know
5. 11. A Simple Pool Game
1. In This Chapter
2. Overview
3. Primary Elements of a Simulation
4. Taking a Shot
5. Exercises
6. Summary
7. You Should Now Know
7. III. Complex Motion
1. 12. Force and Newton’s Laws
1. In This Chapter
2. Overview
3. Force
4. Gravity
5. Rockets and Satellites
6. Exercise
7. Summary
8. You Should Now Know
2. 13. Angular Motion
1. In This Chapter
2. Overview
3. The Physics of a Lever
4. Spin
5. Spinning Collisions
6. Spin Applied to the Pool Game
7. Exercises
8. Summary
9. You Should Now Know
3. 14. Friction
1. In This Chapter
2. Overview
3. How Friction Works
4. Friction and Angular Motion
5. Exercise
6. Summary
7. You Should Now Know
4. 15. Strings, Pulleys, and Conveyor Belts
1. In This Chapter
2. Overview
3. Pulling Things Around
4. Continuous Momentum
5. Exercise
6. Summary
7. You Should Now Know
5. 16. Oscillations
1. In This Chapter
2. Overview
3. Springs
4. Simple Harmonic Motion
5. Damped Harmonic Motion
6. Complications of Springs
7. Calculating Spring Motion
8. Waves
9. Exercise
10. Summary
11. You Should Now Know
8. IV. 3-D Mathematics
1. 17. 3-D Geometry
1. In This Chapter
2. Overview
3. 3-D Vectors
4. Rendering
5. Casting a Ray
6. Exercise
7. Summary
8. You Should Now Know
2. 18. Transforms
1. In This Chapter
2. Overview
3. Describing Locations in Space
4. Applying Transforms
5. Exercise
6. Summary
7. You Should Now Know
3. 19. 3-D Collision Detection
1. In This Chapter
2. Overview
3. Colliding Worlds
4. Colliding Footballs
5. Colliding Boxes
6. Colliding Cans
7. Varieties of Collisions
8. Resolving Collisions in Three Dimensions
9. Exercise
10. Summary
11. You Should Now Know
4. 20. Lighting and Textures
1. In This Chapter
2. Overview
3. Light
4. Materials
6. Exercise
7. Summary
8. You Should Now Know
5. 21. Modeling Techniques
1. In This Chapter
2. Overview
3. Mathematical 3-D Modeling
1. Surfaces of Rotation
2. Splines in 3-D
3. Surfaces Generated with Sine and Cosine Functions
4. Tessellation
4. Animated Surfaces
5. Bone Animations
6. Exercises
7. Summary
8. You Should Now Know
9. V. Game Algorithms
1. 22. Speeding Things Up
1. In This Chapter
2. Overview
3. Cheap and Expensive Calculations
4. Pseudo-Physics
5. Culling
6. Exercises
7. Summary
8. You Should Now Know
2. 23. Tile-Based Games
1. In This Chapter
2. Overview
3. Generating a Game from Bits
5. Exercise
6. Summary
7. You Should Now Know
3. 24. Mazes
1. In This Chapter
2. Overview
3. Classifying Mazes
4. Creating Mazes
5. Navigating Within Mazes
6. Exercise
7. Summary
8. You Should Now Know
4. 25. Game Theory and Artificial Intelligence
1. In This Chapter
2. Overview
3. Introduction to Game Theory
4. Tactical AI
5. Top-Down AI
6. Bottom-Up AI
7. Exercises
8. Summary
9. You Should Now Know
5. 26. Search Techniques
1. In This Chapter
2. Overview
3. Problem Solving
4. Case Study
5. Genetic Algorithms
6. Exercise
7. Summary
8. You Should Now Know
10. A. Glossary of Mathematical Terms
11. B. Code References
12. C. The Greek Alphabet
13. D. Learning Resources
1. General Mathematics
2. Specialized Resources