Skip to content

Commit

Permalink
Merge pull request #203 from ucsd-cse125-sp24/feat/warren-bear
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Lentz authored Jun 5, 2024
2 parents 7049864 + e63a9c1 commit 6d28296
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 14 deletions.
Binary file added assets/sounds/server_sfx/minotaur_death.wav
Binary file not shown.
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"game": {
"maze": {
"directory": "maps",
"procedural": true,
"procedural": false,
"maze_file": "test/itemRoom.maze"
}
},
Expand All @@ -14,8 +14,8 @@
"lobby_name": "Hope you're doing well!1",
"lobby_broadcast": true,
"max_players": 1,
"disable_dm": false,
"skip_intro": false
"disable_dm": true,
"skip_intro": false
},
"client": {
"default_name": "Conan O'Brien",
Expand Down
1 change: 0 additions & 1 deletion include/client/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ class Client {
std::unique_ptr<Model> pillar_model;
std::unique_ptr<Model> sungod_model;
std::unique_ptr<Model> slime_model;
std::unique_ptr<Model> minotaur_model;
std::unique_ptr<Model> python_model;
std::unique_ptr<Model> item_model;
std::unique_ptr<Model> spike_trap_model;
Expand Down
3 changes: 2 additions & 1 deletion include/client/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ Bbox aiBboxToGLM(const aiAABB& bbox);
*/
Bbox combineBboxes(const Bbox& bbox1, const Bbox& bbox2);

glm::quat getGLMQuat(const aiQuaternion& pOrientation);

glm::quat getGLMQuat(const aiQuaternion& pOrientation);
glm::vec3 rotate90DegreesAroundYAxis(const glm::vec3& direction);
4 changes: 3 additions & 1 deletion include/shared/audio/soundtype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ enum class ServerSFX {
ElectricHum,
IntroGateOpen,
Wind,
MinotaurDeath
// make sure to add to server sfx len map!
// make sure to add to macro below!
};
Expand Down Expand Up @@ -111,6 +112,7 @@ const std::unordered_map<ServerSFX, std::chrono::milliseconds> SERVER_SFX_LENS =
{ServerSFX::ItemPickUp, 500ms},
{ServerSFX::ItemDrop, 500ms},
{ServerSFX::MirrorShatter, 2000ms},
{ServerSFX::MinotaurDeath, 3100ms},
// dont forget macro below!
};

Expand All @@ -123,7 +125,7 @@ const std::unordered_map<ServerSFX, std::chrono::milliseconds> SERVER_SFX_LENS =
ServerSFX::PlayersStartTheme, ServerSFX::ElectricHum, ServerSFX::IntroGateOpen, ServerSFX::ZeusStartTheme, \
ServerSFX::Wind, \
ServerSFX::Teleport, ServerSFX::Potion, ServerSFX::Spell, ServerSFX::ItemPickUp, ServerSFX::ItemDrop, \
ServerSFX::MirrorShatter \
ServerSFX::MirrorShatter, ServerSFX::MinotaurDeath \
}

// const std::unordered_map<ServerSound, size_t> serverSoundTickLengths = {
Expand Down
15 changes: 9 additions & 6 deletions src/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ bool Client::init() {
auto sungod_model_path = entity_models_dir / "sungod.obj";
this->sungod_model = std::make_unique<Model>(sungod_model_path.string(), true);

auto minotaur_model_path = entity_models_dir / "minotaur.obj";
this->minotaur_model = std::make_unique<Model>(minotaur_model_path.string(), true);

auto python_model_path = entity_models_dir / "python.obj";
this->python_model = std::make_unique<Model>(python_model_path.string(), true);

Expand Down Expand Up @@ -824,6 +821,10 @@ void Client::geometryPass() {
}
break;
}
if (!sharedObject->playerInfo->is_alive) {
break; // don't render dead players
}

animManager->setAnimation(sharedObject->globalID, sharedObject->type, sharedObject->animState);

/* Update model animation */
Expand Down Expand Up @@ -892,9 +893,11 @@ void Client::geometryPass() {
break;
}
case ObjectType::Minotaur: {
this->minotaur_model->setDimensions(sharedObject->physics.dimensions);
this->minotaur_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->minotaur_model->draw(this->deferred_geometry_shader.get(),
this->bear_model->setDimensions(sharedObject->physics.dimensions);
this->bear_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->bear_model->translateRelative(glm::vec3(0, -8.5f, 0));
this->bear_model->rotateAbsolute(rotate90DegreesAroundYAxis(sharedObject->physics.facing));
this->bear_model->draw(this->deferred_geometry_shader.get(),
this->cam->getPos(),
true);
break;
Expand Down
11 changes: 11 additions & 0 deletions src/client/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,14 @@ Bbox combineBboxes(const Bbox& bbox1, const Bbox& bbox2) {
)
};
}

glm::vec3 rotate90DegreesAroundYAxis(const glm::vec3& direction) {
// Create a 90-degree rotation matrix around the Y-axis
glm::mat4 rotationMatrix = glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f));

// Apply the rotation to the direction vector
glm::vec4 rotatedDirection = rotationMatrix * glm::vec4(direction, 1.0f);

// Return the rotated vector as a vec3
return glm::vec3(rotatedDirection);
}
3 changes: 1 addition & 2 deletions src/server/game/minotaur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "shared/utilities/rng.hpp"

Minotaur::Minotaur(glm::vec3 corner, glm::vec3 facing) :
Enemy(corner, facing, ObjectType::Minotaur, ModelType::Cube, SharedStats(
Enemy(corner, facing, ObjectType::Minotaur, ModelType::WarrenBear, SharedStats(
Stat(0, 50, 50),
Stat(0, 7, 3)
))
Expand All @@ -19,7 +19,6 @@ Minotaur::Minotaur(glm::vec3 corner, glm::vec3 facing) :
this->physics.velocityMultiplier.y = 0.2;
this->physics.velocityMultiplier.x = 0.3;
this->physics.velocityMultiplier.z = 0.3;
this->physics.shared.dimensions = glm::vec3(3.0f, 7.0f, 3.0f);
}

bool Minotaur::doBehavior(ServerGameState& state) {
Expand Down
9 changes: 9 additions & 0 deletions src/server/game/servergamestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,15 @@ void ServerGameState::handleDeaths() {
if (enemy->doDeath(*this)) {
this->entities_to_delete.insert(enemy->globalID);
}
if (enemy->type == ObjectType::Minotaur) {
this->soundTable().addNewSoundSource(SoundSource(
ServerSFX::MinotaurDeath,
enemy->physics.shared.getCenterPosition(),
DEFAULT_VOLUME,
MEDIUM_DIST,
MEDIUM_ATTEN
));
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/shared/audio/soundtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ std::string getAudioPath(ServerSFX sfx) {
return (dir / "itemdrop.wav").string();
case ServerSFX::MirrorShatter:
return (dir / "mirror_shatter.mp3").string();
case ServerSFX::MinotaurDeath:
return (dir / "minotaur_death.wav").string();

default:
std::cerr << "FATAL: no known path for ServerSFX " << static_cast<int>(sfx) << std::endl;
Expand Down

0 comments on commit 6d28296

Please sign in to comment.