cs381/as4
John Montagu, the 4th Earl of Sandvich 6c0673febe
Add README
2026-03-01 23:39:47 -08:00
..
generated Add AS4 2026-03-01 10:55:19 -08:00
CMakeLists.txt Add monolithic entities 2026-03-01 11:54:41 -08:00
CO.cpp Add AS4 2026-03-01 10:55:19 -08:00
README.md Add README 2026-03-01 23:39:47 -08:00
as4.cpp Add 3D eagle movement 2026-03-01 23:39:40 -08:00
skybox.cpp Add AS4 2026-03-01 10:55:19 -08:00
skybox.hpp Add AS4 2026-03-01 10:55:19 -08:00

README.md

Building and Running

Clone the repository, navigate to the root of the project, and initialize the submodules:

git clone https://github.com/humanoidsandvichdispenser/cs381.git
cd cs381
git submodule update --init --recursive

Navigate to the as4 directory, create a build directory, and run CMake to generate the build files:

cd as4
mkdir -p build
cd build
cmake ..

Compile the code using make:

make

This should create an executable named as4 in the build directory. You can run the executable with the following command:

./as4

Instructions on how to use the program

Hold W and S to accelerate the selected entity forward and backward. Use A and D to change heading direction. This allows you to steer the entity around the environment.

Use TAB to switch between entities. The currently selected entity will be drawn with a bounding box.

When the eagle is selected, press Q and Z to change the pitch.

Readme Question

The entity selection system works by when TAB is pressed (key down only on one frame), the program increments the index of the currently selected entity. Selection wraps around to the first entity when it exceeds the number of entities in the game. Movement keys only apply to the selected entity, which is determined by the selected index. When drawing, the selected index is compared to the index of each entity, and if they match, a bounding box is drawn around the entity to indicate that it is selected.

Both monolithic and ad-hoc approaches to entity management are fast to setup since they require the least amount of code/boilerplate to get something working. However, monolithic entities are easier to scale, since in ad-hoc, you have to write the entire state and behavior of the entity (its variables, methods, etc) for each entity that exists. Ad-hoc is faster to work with only when managing few entities with very different behavior.

For this particular assignment, the monolithic approach is more suitable since most of the entities share similar behavior (change velocity) and state (position, speed, heading). This however still became more difficult to manage when adding the eagle that had an additional pitch variable and flying behavior.

Extra Credit

The eagle can move in 3D space with an additional DOF compared to the penguins.