CS 18 (Spring 2026) Project 04: Breakout (Demo)

In this project, you will use collision resolution to create a breakout game.

Demos

The main demo this week is a simple version of Breakout.

Your game demo must have the following features (but feel free to play around and implement anything you want otherwise):

We have give you starter code along with some in-line comments for the demo.

Note that you should only need to replace the parts in demo.c marked with TODO.

Before you start, however, here are a few things we want to go over:

Collisions

We have added new collision functions for you in forces.h and forces.c. Like forces, collisions are “registered” in the scene using the create_x() and x_collision_handler() pattern. Take a look at them for more detail, and note the following things:

collision_aux_t

We’ve added a new collision_aux_t struct in forces.c that the new collision functions reference. Note that its structure is similar to that of body_aux_t with the exception of three additional fields:

Take a look at collision_aux_free and note how aux is owned and freed by the collision_aux_t. Like before, you can pass in NULL as the freer if the aux shouldn’t be freed.

create_physics_collision and create_destructive_collision

We’ve defined a generic create_collision function, which is referenced in create_physics_collision and create_destructive_collision (both will be implemented by the engine student). The key takeaway here is that abstraction can make our code much simpler and also more flexible! Note how create_physics_collision passes in a constant (the elasticity) through the aux.

Look over these functions and their documentation carefully! You will be referencing these functions and have to write the implementations for the breakout collision functions in forces.c as well. Note that the collision handler between the ball and the brick should also be a physics collision, with the additional requirement of removing the brick. Thus, the new collision functions in forces.c that you have to write should be very short if written correctly.

Once all your group members have finished, work with them to complete the extension (more information in the main project page).