Add README

master
John Montagu, the 4th Earl of Sandvich 2026-03-08 23:47:59 -07:00
parent 76b4223fea
commit 8f9d446f4b
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
1 changed files with 27 additions and 30 deletions

View File

@ -9,11 +9,11 @@ cd cs381
git submodule update --init --recursive git submodule update --init --recursive
``` ```
Navigate to the `as4` directory, create a build directory, and run CMake to Navigate to the `as5` directory, create a build directory, and run CMake to
generate the build files: generate the build files:
```sh ```sh
cd as4 cd as5
mkdir -p build mkdir -p build
cd build cd build
cmake .. cmake ..
@ -25,47 +25,44 @@ Compile the code using `make`:
make make
``` ```
This should create an executable named `as4` in the `build` directory. You can This should create an executable named `as5` in the `build` directory. You can
run the executable with the following command: run the executable with the following command:
```sh ```sh
./as4 ./as5
``` ```
# Instructions on how to use the program # Instructions on how to use the program
Hold W and S to accelerate the selected entity forward and backward. Use A and If the selected entity is a penguin, hold W and S to accelerate it forward and
D to change heading direction. This allows you to steer the entity around the backward. Use A and D to change heading direction.
environment.
Use TAB to switch between entities. The currently selected entity will Use TAB to switch between entities. The currently selected entity will be drawn
be drawn with a bounding box. with a bounding box.
When the eagle is selected, press Q and Z to change the pitch.
# Readme Question # Readme Question
The entity selection system works by when TAB is pressed (key down only on one Having a bool stored per object to dictate whether or not to draw the bounding
frame), the program increments the index of the currently selected entity. box could be storage inefficient as it requires an additional byte per object.
Selection wraps around to the first entity when it exceeds the number of This is less apparent when using a component-based architecture (although might
entities in the game. Movement keys only apply to the selected entity, which is not be the best solution), as the visibility component is only added to
determined by the selected index. When drawing, the selected index is compared entities that need it (you can compose it down further by having a component
to the index of each entity, and if they match, a bounding box is drawn around specifically for bounding boxes). In the monolithic architecture, this would
the entity to indicate that it is selected. require every entity to have this. In the ad-hoc architecture, it is simply not
scalable as it requires tracking multiple booleans and requires a lot of
branching logic to determine which entities should have bounding boxes drawn.
Both monolithic and ad-hoc approaches to entity management are fast to setup Calculating whether or not to draw the bounding box in the rendering system can
since they require the least amount of code/boilerplate to get something be more efficient, especially in a monolithic architecture. This does not
working. However, monolithic entities are easier to scale, since in ad-hoc, you require additional storage per entity, and can be done by simply checking if
have to write the entire state and behavior of the entity (its variables, the entity is the currently selected entity. This can however cause a lot of
methods, etc) for each entity that exists. Ad-hoc is faster to work with only branching logic in the rendering system.
when managing few entities with very different behavior.
For this particular assignment, the monolithic approach is more suitable since Splitting bounding box drawing into a separate system can be more efficient in
most of the entities share similar behavior (change velocity) and state terms of computation and storage. However, it is harder to maintain, since if
(position, speed, heading). This however still became more difficult to manage you want to modify how a bounded model is drawn, you would have to modify the
when adding the eagle that had an additional pitch variable and flying draw calls in multiple places.
behavior.
# Extra Credit # Extra Credit
The eagle can move in 3D space with an additional DOF compared to the penguins. The camera follows the currently selected entity using similar.