Add README
parent
98087e3642
commit
6c0673febe
|
|
@ -9,11 +9,11 @@ cd cs381
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
```
|
```
|
||||||
|
|
||||||
Navigate to the `as3` directory, create a build directory, and run CMake to
|
Navigate to the `as4` directory, create a build directory, and run CMake to
|
||||||
generate the build files:
|
generate the build files:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd as3
|
cd as4
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
|
|
@ -25,34 +25,47 @@ Compile the code using `make`:
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
This should create an executable named `as3` in the `build` directory. You can
|
This should create an executable named `as4` in the `build` directory. You can
|
||||||
run the executable with the following command:
|
run the executable with the following command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./as3
|
./as4
|
||||||
```
|
```
|
||||||
|
|
||||||
# Instructions on how to use the program
|
# Instructions on how to use the program
|
||||||
|
|
||||||
Hold W and S to accelerate the penguin forward and backward. Use A and D to
|
Hold W and S to accelerate the selected entity forward and backward. Use A and
|
||||||
change heading direction. This allows you to steer the penguin around the
|
D to change heading direction. This allows you to steer the entity around the
|
||||||
environment.
|
environment.
|
||||||
|
|
||||||
Use the arrow keys to change the camera's rotation (pitch and yaw) with respect
|
Use TAB to switch between entities. The currently selected entity will
|
||||||
to the penguin, allowing you to look around while the penguin moves.
|
be drawn with a bounding box.
|
||||||
|
|
||||||
|
When the eagle is selected, press Q and Z to change the pitch.
|
||||||
|
|
||||||
# Readme Question
|
# Readme Question
|
||||||
|
|
||||||
`dt` is delta time, which is the time elapsed between each frame, which can be
|
The entity selection system works by when TAB is pressed (key down only on one
|
||||||
found by taking the current time and subtracting the time from the previous
|
frame), the program increments the index of the currently selected entity.
|
||||||
frame. Raylib provides a function `GetFrameTime()` that returns the time
|
Selection wraps around to the first entity when it exceeds the number of
|
||||||
elapsed since the last frame, which can be used to calculate `dt`. By using
|
entities in the game. Movement keys only apply to the selected entity, which is
|
||||||
`dt`, it ensures that physics calculations are independent of frame rate, since
|
determined by the selected index. When drawing, the selected index is compared
|
||||||
otherwise the velocity would be in terms of units per frame rather than units
|
to the index of each entity, and if they match, a bounding box is drawn around
|
||||||
per second. By multiplying the velocity by `dt`, it converts the velocity to
|
the entity to indicate that it is selected.
|
||||||
units per second, allowing for consistent movement regardless of the frame
|
|
||||||
rate.
|
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
|
# Extra Credit
|
||||||
|
|
||||||
The camera moves with the penguin and can be rotated around the penguin using the arrow keys.
|
The eagle can move in 3D space with an additional DOF compared to the penguins.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue