CS 3 (Spring 2024) Project 02: Gravity (Engine)

In this project, you will create a generic list data structure in C!

Code Correctness

Deliverable

Generic List

This week, you will apply the concepts you’ve learned in lecture about void * abstraction to create a generic list that can store any type of object. In addition, you will need slightly better abstractions (in particular, you will need some kind of resizing for your list) than you did last week, and we expect you to spend a significant amount of the project time on improving them.

Note that since the generic list builds off your team’s implementation of vector list in week 1, you should read and understand your team’s implementation of vec_list_t and repurpose the code for list_t. In other words, do NOT write your code for the generic list from scratch; use the code for vec_list_t as a starting point and modify it to fit the new list_t interface.

You may not remove or edit signatures of functions in the interfaces in list.h!!!! You may add functionality if you deem it necessary.

If you find yourself spending very little time on implementing list_t, something about your architecture probably needs to be modified.

Polygon

Instead of just representing polygons as vec_list_t’s, we’ll want to create a struct for them in an effort to make our code more encapsulated. Among other benefits, we’ll then be able to access values like its velocity, center, rotation, etc. more easily without having to recalculate them each time.

Again, use your team’s current implementation of polygons as a foundation for your code and modify it so that it fits the new polygon_t interface.

Color and Vector

We have provided a color implementation for you that should be helpful for completing your task for this week.

You do not need to rewrite vector and should instead copy over your vector implementation from last week.

Testing

We have given you tests for the generic list and polygon that must be passed in order to receive full credit. The vector and color tests have been provided as sanity checks.

As a reminder, to run all the tests, all you need to type is make test. To run compile and run an individual test suite, run the following commands (replacing vector with the test suite you want to run) :

make bin/test_suite_vector
./bin/test_suite_vector