CS 18 (Spring 2026) Project 03: Space Invaders (Demo)

In this project, you will write a simple version of the game space invaders.

Code Correctness

Deliverables

This week’s demo uses destructive collision handling to create a version of the Space Invaders game.

Demo

The demo this week is a simple version of Space Invaders. Note that the last video has been sped up 2x.

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

Important Changes

Several important and relevant changes to the physics engine are highlighted below:

Collisions

This week, one of your teammates will implement collision detection. Take a look at collision.h to see what the find_collision method should do.

For your demo, you will also have to use some sort of destructive collision. We have defined two destructive collision methods for you in forces.h and implemented them in forces.c that you should use.

Body “info” field

Different applications will need to use different extra information about bodies. For example, for Space Invaders, you will need to be able to differentiate between the player and enemies. Thus, we will add auxilliary data to the body as a void *. Take a look at body.h to see how to use the new “info” field and your teammate’s implementation of it in body.c. Again, we encourage you to talk with your teammate who implemented the engine to get a better sense of how the code works! We’ve also given you an example of how to do so in make_bullet, but feel free to change your info to whatever makes the most sense for you.

emscripten_main

emscripten_main returns a bool now that tells the game loop if the game has ended. If it has, SDL quits. Look at emscripten.c to see how it’s being used. This will be relevant to your win/loss conditions this week.

color_compare

We’ve implemented a a new method color_compare for you to see if two colors are equal. Depending on how you implement the demo, it may or may not be used, but we wanted to let you know for future weeks as well.

sdl_wrapper

We’ve defined a new enum for arrow_key_t, called SPACE_BAR, in sdl_wrapper.h. Note that it is set to 6, not 5 (since esc is mapped to 5). You’ll have to make another change in order for the player to be able to use the space bar.

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