Skip to content

Commit

Permalink
add chest
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Lentz committed Jun 7, 2024
1 parent 595d874 commit 18f5141
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 36 deletions.
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"server": {
"lobby_name": "Hope you're doing well!",
"lobby_broadcast": true,
"max_players": 2,
"disable_dm": false,
"max_players": 1,
"disable_dm": true,
"skip_intro": true
},
"client": {
Expand All @@ -25,6 +25,6 @@
"draw_bboxes": false,
"fps_counter": true,
"presentation": false,
"render": 75
"render": 50
}
}
1 change: 1 addition & 0 deletions include/client/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class Client {
std::unique_ptr<Model> lava_vertical_model;
std::unique_ptr<Model> lava_horizontal_model;
std::unique_ptr<Model> lightning_model;
std::unique_ptr<Model> chest_model;

GLFWwindow *window;

Expand Down
3 changes: 2 additions & 1 deletion include/shared/game/sharedmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ enum class ModelType {
SunGod,
Mirror,
LightCut,
TorchPost
TorchPost,
Chest
};
47 changes: 17 additions & 30 deletions src/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ bool Client::init() {
auto lava_cross_model_path = env_models_dir / "lava" / "lava_cross.obj";
this->lava_cross_model = std::make_unique<Model>(lava_cross_model_path.string(), false);

auto chest_model_path = item_models_dir / "Chest1" / "Chest1 1.obj";
this->chest_model = std::make_unique<Model>(chest_model_path.string(), false);

auto lava_row_model_path = env_models_dir / "lava" / "lava_row.obj";
this->lava_horizontal_model = std::make_unique<Model>(lava_row_model_path.string(), false);
// thank you openai!
Expand Down Expand Up @@ -838,7 +841,8 @@ void Client::geometryPass() {
sharedObject->type == ObjectType::ArrowTrap ||
sharedObject->type == ObjectType::SpikeTrap ||
sharedObject->type == ObjectType::TeleporterTrap ||
sharedObject->type == ObjectType::Projectile)
sharedObject->type == ObjectType::Projectile ||
sharedObject->modelType == ModelType::Chest)
&& dist > this->config.client.render / 2) {
continue;
}
Expand All @@ -853,7 +857,8 @@ void Client::geometryPass() {
sharedObject->type == ObjectType::ArrowTrap ||
sharedObject->type == ObjectType::SpikeTrap ||
sharedObject->type == ObjectType::Projectile ||
sharedObject->type == ObjectType::Torchlight) // dont render post from far away
sharedObject->type == ObjectType::Torchlight || // light post
sharedObject->modelType == ModelType::Chest)
&& dist > this->config.client.render) {
continue;
}
Expand Down Expand Up @@ -1162,14 +1167,7 @@ void Client::geometryPass() {
}
case ObjectType::Potion: {
if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) {
Model* model = this->item_model.get();
if (sharedObject->modelType == ModelType::HealthPotion) {
model = this->item_model.get();
} else if (sharedObject->modelType == ModelType::NauseaPotion || sharedObject->modelType == ModelType::InvincibilityPotion) {
model = this->item_model.get();
} else if (sharedObject->modelType == ModelType::InvisibilityPotion) {
model = this->item_model.get();
}
Model* model = this->chest_model.get();

model->setDimensions(sharedObject->physics.dimensions);
model->translateAbsolute(sharedObject->physics.getCenterPosition());
Expand All @@ -1181,20 +1179,9 @@ void Client::geometryPass() {
}
case ObjectType::Spell: {
if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) {
glm::vec3 color;
if (sharedObject->modelType == ModelType::FireSpell) {
color = glm::vec3(0.9f, 0.1f, 0.0f);
}
else if (sharedObject->modelType == ModelType::HealSpell) {
color = glm::vec3(1.0f, 1.0f, 0.0f);
}
else {
color = glm::vec3(0.8f, 0.7f, 0.6f);
}

this->item_model->setDimensions(sharedObject->physics.dimensions);
this->item_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->item_model->draw(this->deferred_geometry_shader.get(),
this->chest_model->setDimensions(sharedObject->physics.dimensions);
this->chest_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->chest_model->draw(this->deferred_geometry_shader.get(),
this->cam->getPos(),
true);
}
Expand Down Expand Up @@ -1222,9 +1209,9 @@ void Client::geometryPass() {
}
case ObjectType::Weapon: {
if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) {
this->item_model->setDimensions(sharedObject->physics.dimensions);
this->item_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->item_model->draw(this->deferred_geometry_shader.get(),
this->chest_model->setDimensions(sharedObject->physics.dimensions);
this->chest_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->chest_model->draw(this->deferred_geometry_shader.get(),
this->cam->getPos(),
true);
}
Expand Down Expand Up @@ -1257,9 +1244,9 @@ void Client::geometryPass() {
}
case ObjectType::Mirror: {
if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) {
this->item_model->setDimensions(sharedObject->physics.dimensions);
this->item_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->item_model->draw(this->deferred_geometry_shader.get(),
this->chest_model->setDimensions(sharedObject->physics.dimensions);
this->chest_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->chest_model->draw(this->deferred_geometry_shader.get(),
this->cam->getPos(),
true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/* Constructors and Destructors */
Item::Item(ObjectType type, bool movable, glm::vec3 corner, ModelType model, glm::vec3 dimensions):
Object(type, Physics(movable, Collider::Box, corner, dimensions), ModelType::Cube),
Object(type, Physics(movable, Collider::Box, corner, dimensions), ModelType::Chest),
iteminfo(SharedItemInfo{ .held = false, .used = false })
{}

Expand Down
3 changes: 2 additions & 1 deletion src/server/game/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ std::unordered_map<ModelType, glm::vec3> Object::models ({
{ModelType::FloorSpikeHorizontal, FLOOR_SPIKE_DIMENSIONS},
{ModelType::FloorSpikeVertical, FLOOR_SPIKE_DIMENSIONS},
{ModelType::Lightning, glm::vec3(3.0f, 100.0f, 3.0f)},
{ModelType::Orb, glm::vec3(0.887116, 0.941508, 0.950092)}
{ModelType::Orb, glm::vec3(0.887116, 0.941508, 0.950092)},
{ModelType::Chest, glm::vec3(1.377020, 1.355794, 1.092905)}
});

/* SharedGameState generation */
Expand Down

0 comments on commit 18f5141

Please sign in to comment.