CS 3 (Spring 2024) Project 05: Collision Detection (Demo)

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

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.

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:

sdl_wrapper Changes

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 *. The new body struct has been provided for you in body.c. Take a look at body.h to see how to use the new “info” field.

emscripten_main

emscripten_main returns a bool now and 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.

sdl_render_scene

We’ve added a new aux argument to sdl_render_scene. Currently, sdl_render_scene is implemented so that it assumes that aux is a body_t type and renders it on the screen. This may be helpful if you want to separate a body from the scene (like the pacman and the pellets).

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.