- 35 hours on-demand video content
- Lifetime access
- Live meetup
- Downloadable resources and exercises
- Certificate on completion
- Access on mobile and desktop
- Secure checkout via Credit Card or PayPal
- 14-day money back guarantee
- Last updated February 2024

$69.99

ENROLL NOW FREE PREVIEW14-day money back guarantee

This course is a gentle introduction into the world of **2D game physics**! We'll review all the beautiful **math** that provides the foundation for most physics engines, starting with a strong review of vectors, matrices, basic trigonometry, rigid-body collision, and touching a little bit of calculus as well.

The lectures are designed to teach all concepts **from first principles**. In our journey, we'll review several topics from physics, like velocity, acceleration, integration, mass, forces, gravity, drag, friction, rigid body dynamics, collision detection, constraints, etc.

We'll also put theory into practice by **coding a very simple 2D physics engine** from scratch using the C++ programming language.

We'll start by writing a simulation of **particle physics**, which is a good start for us to address concepts like movement, forces, displacement, and integration.

We'll then proceed to work with **rigid bodies** by adding shapes to our objects, like circles, rectangles, and polygons. We'll also learn how to code the *collision detection* and *collision resolution* between these rigid bodies.

We'll conclude our C++ implementation by adding **constraints** to our physics engine, which will help us add different types of objects to our engine, like joints and ragdolls. Ultimately, *constraints* will help us improve the stability of our engine, and they are a great opportunity for us to discuss some interesting ideas from calculus.

All you really need is a simple code editor and a C++ compiler. We'll use a cross-platform library called SDL to display our graphics, and since we can find a C++ compiler for virtually any operating system, you can follow along on either **Windows**, **macOS**, or **Linux**!

Also, make sure you have **pen** and **paper** ready for the lectures. This course will probably be a little bit different than other programming courses you took before. We will take our sweet time and make sure we understand *every* formula we find along the way!

This is a self-contained course with **no** formal prerequisites. However, you will probably get the most out of it if you already know the basics of coding (if-else, loops, functions).

We will explore some very interesting math along the way, but all you really need is to know some simple algebra. If you know how to solve the equation below for **x**, then you should be able to follow along and have fun like everyone else!

\(22-4x=2(3x+1)\)

view solution...
And finally, if you never programmed in C++ before... don't worry! Many successful students come from different languages like Java, Python, JavaScript, Swift, and others. We'll go over the ugly parts of C++ together.

**Gustavo Pezzi** is a university lecturer in London, UK. He has won multiple education awards as a teacher and is also the founder of pikuma.com.

Gustavo teaches fundamentals of computer science and mathematics; his academic path includes institutions such as Pittsburg State University, City University of London, and University of Oxford.

35 hours total length • 32 Chapters • Last updated February 2024

- Introduction and Motivations
- How to Take this Course?
- What is Game Physics?
- A Quick Review of Vector Math

- Scalar and Vector Quantities
- Intro to the P5js Web Editor
- Coding the Vec2 Class
- Quiz: Scalars and Vectors

- Vector Magnitude
- Vector Addition
- Vector Subtraction
- Examples of Vector Addition and Subtraction
- Vector Equality
- Scaling Vectors
- Quiz: Vector Arithmetic

- Dot Product
- Is the Dot Product Commutative?
- Quiz: Dot Product
- Cross Product
- Coding the Cross Product Method
- Exercise: Perpendicular 2D Vectors
- Exercise: Vec3 Class
- Examples of Dot Product and Cross Product
- Quiz: Cross Product

- Vector Normalization
- Coding the Vec2.Normalize Method

- Scaling, Translating, and Rotating Vectors
- Review of Sine, Cosine, and Tangent
- Vector Rotation Proof (x)
- Vector Rotation Proof (y)
- Coding the Vec2 Rotate Method
- Quiz: Vector Transformations
- Concluding our JavaScript Vec2 Class

- Vec2 C++ Header File
- A Review of the C++ Syntax for Vec2
- Vec2 Operator Overloading

- Libraries and Dependencies
- Project Folder Structure
- Initial Project Files
- Compiling our Project on Linux
- Compiling our Project on macOS
- Makefiles
- Configuring Visual Studio on Windows

- Introduction to Particle Physics
- Particle Class
- Particle Velocity
- Exercise: Operator + to Add Vectors
- Controlling our Framerate
- Framerate Independent Movement
- Variable Delta Time
- A Discussion About Determinism
- Quiz: Framerate and Delta Time
- Moving in a Constant Velocity
- What About Mass?
- Changing Particle's Velocity
- Keeping Particles Inside the Window

- Constant Acceleration
- Discrete vs. Continuous
- Integration & Simulation of Movement
- Different Notations for Differentation
- Integrals as Continuous Sum
- Different Integration Techniques
- Particle Integrate Function
- Quiz: Integration

- Applying Forces to Particles
- Kinematics vs. Kinetics
- Function to Add Forces
- Particles with Different Mass
- Weight Force
- Inverse of Mass
- Quiz: Forces and Mass
- Exercise: Applying Forces on Key Press

- Drag Force
- Function to Apply Drag
- Handling Mouse Clicks with SDL
- Friction Force
- Function to Apply Friction
- Examples of Forces in Games
- Quiz: Drag and Friction

- Gravitational Attraction Force
- Coding the Gravitational Attraction Force
- Quiz: Gravitational Attraction Force

- Spring Force
- Spring Force Function
- Exercise: Spring Forces
- Chain of Objects with Springs
- Soft Body with Springs
- A Discussion on Verlet Integration

- Rigid Bodies
- Different Rigid Body Shapes
- Shape Parent Class
- Circle Shape
- Angular Velocity
- Angular Acceleration
- Torque and Moment of Inertia
- Angular Motion for the Circle Shape
- Exercise: Coding Torque and Moment of Inertia
- Direction of the Angular Velocity
- Quiz: Angular Motion

- Box Vertices
- Local Space vs. World Space
- Body Update Function
- Quiz: Local Space and World Space

- Circle-Circle Collision Detection
- Collision Detection Class
- Collision Contact Information
- Coding the Circle-Circle Collision Information
- Broad Phase and Narrow Phase
- The Projection Method
- Objects with Infinite Mass
- Floating-Point Comparison
- Quiz: Circle-Circle Collision Detection

- Impulse Method and Momentum
- Impulse
- Deriving the Linear Impulse Formula
- Coding the Linear Impulse Function
- Is Linear Collision Resolution Good Enough?
- Quiz: Linear Collision Resolution

- AABB Collision
- SAT: Separating Axis Theorem
- Different SAT Approaches
- Finding the Minimum Separation with SAT
- Polygon-Polygon Collision Code
- What are Support Points?
- Finding Collision Information with SAT
- Quiz: SAT

- Linear and Angular Velocity at a Point
- Post-Collision Velocity at a Point
- Computing the Linear & Angular Velocity at a Point
- Collision Distance Vectors
*ra*and*rb* - 2D Cross Product Simplification
- Impulse Along the Normal Vector
- Exercise: Impulse Along the Tangent Vector
- Friction Along the Tangent Vector
- Discussing Collision Resolution in 3D

- Circle-Polygon Collision Detection
- Finding Polygon's Nearest Edge with Circle
- Exercise: Computing Circle-Polygon Edge Regions
- Exercise: Polygons with More than 4 Vertices
- Quiz: Circle-Polygon Collision

- Loading SDL Textures
- Rendering Circle Texture
- Rigid Body Textures

- Creating a World Class
- Coding the World Functions

- Refactoring Function to Update Vertices
- Local Solvers vs. Global Solvers
- A Naive Iterative Solution to Positional Correction
- Quiz: Local Solvers vs. Global Solvers

- Constrained Rigid Body Physics
- Position Constraint vs. Velocity Constraint
- Example of Velocity Constraint and Bias Factor
- Force Constraint & Constrained Movement
- Force-Based vs. Impulse-Based Constraints
- Coding the Constraint Parent Class
- Quiz: Constraints

- VecN Class
- VecN Functions
- Coding VecN Operator Overloading
- Matrices
- MatMN Class
- MatMN Functions
- Matrix Transpose
- Matrix Multiplication Function
- Exercise: Seeing Beyond the Matrix

- Generalized Velocity Constraint
- Solving Violated Velocity Constraint
- Constraint Class Inheritance
- Distance Constraint
- Joint Constraint Class
- Joint Constraint vs. Distance Constraint
- Exercise: Converting from World Space to Local Space
- Inverse Rotation Matrix
- Deriving the Distance Jacobian
- Solving the System of Equations (Ax=b)
- The Gauss-Seidel Method
- Constrained Pendulum
- Quiz: Distance Constraints

- Solving System of Constraints Iteratively
- Warm Starting
- Adding a Bias Term
- Exercise: Ragdoll
- Quiz: System of Constraints

- Penetration Constraint
- Deriving the Penetration Jacobian
- Coding the Penetration Constraint Class
- Solving Penetration Constraints
- Linear Complementary Problem
- Penetration Warm Starting
- Quiz: Penetration Constraint
- Penetration Constraint Friction
- Clamping Friction Values

- Unstable Stack of Boxes
- Allowing for Multiple Contact Points
- Reference Edge and Incident Edge
- Finding the Incident Edge
- Clipping
- Coding the Clipping Function
- Testing Multiple Objects and Multiple Constraints
- Quiz: Stack of Boxes

- Contact Caching
- Continuous Collision Detection
- Computing the Moment of Inertia of Polygons
- Split Between Broad Phase and Narrow Phase

- Conclusion
- Moving Forward

This course is **not** just a simple tutorial on how to use a physics engine like Box2D or Bullet. This course focus on the **foundation** of what makes physics engines *tick*, including a comprehensive review of the beautiful math that comes with it.

While you can find other resources on game physics out there, most of them are either too theoretical or overwhelmingly complex. This course is a **beginner-friendly** introduction to the world of game physics, providing a mix between the theory we'll see in the lectures with the practical examples we'll write using C++.

So, if you ever wanted to understand what happens under the hood of a physics engine, then get ready and buckle up! This is going to be a 35-hour journey of pure nerd fun.

73% of our students **come back** for another course

We **don't** offer discounts on our courses. Ever.

Robert Pashov

"Great for learning fundamentals and how to think about physics/math within the context of a computer program. Lectures are well-thought-out, concepts are explained thoroughly and extra resources are included where needed. Material is very dense, there is no filler. The course is very much self-contained, which is a very nice touch. Definitely enough to build up a solid practical foundation and spark your interest in game development. If all teachers were like Gustavo, the world would be a much better place!"

13 Jun 2024

"This course was one of the best I have ever taken.

It provides a gentle introduction for anyone who wants to create a physics engine for games. I learned so many concepts and techniques, such as collision detection, impulse resolution, rigid body dynamics, constraint systems, and more. I also got to implement my own 2D physics engine from scratch using C++, SDL and CMake.

Not only that, but I also managed to port my engine to the web using Emscripten, and added some cool optimization techniques such as QuadTree, Contact Caching, Continuous Collision Detection and Broad & Narrow phases split, as explained by Gustavo.

The course was very well-structured, engaging, and challenging. Gustavo is an amazing instructor who explains everything clearly and provides helpful insights and feedback. I highly recommend this course to anyone who is interested in game physics programming. This course was also very helpful for me to understand what goes on under the hood of game and physics engines, and how they enable fun and engaging experiences.

Thank you so much, Pikuma and Gustavo Pezzi for this wonderful learning experience!"

18 Apr 2024

Alexandre Canova

"Great course! Approaching a topic as difficult as a physics engine in a beginner-friendly way is no small feat. This course opened my eyes to many possibilities and concepts. Thank you very much Gustavo, I hope one day we have the 3D version too!"

13 Apr 2024

Fahmi Ahmad

"I love this course, gustavo made complex physics and math easy to understand."

19 Feb 2024

Mohnish Sharma

"Amazing Course! The only course I know that goes into constraints and impulse solvers. Gustavo breaks it down very simple so that it is easy to understand. Learnt a lot about game physics. Thanks so much!"

08 Feb 2024

30 hours

- Learn to make a simple 2D game engine using modern C++, SDL, ECS, and Lua.

35 hours

- Create a 3D software renderer from scratch using the C programming language.

18 hours

- Write a raycasting engine with textures and sprites using the C programming language.