Skip to content

Commit

Permalink
change cut light range / update lobby gui again
Browse files Browse the repository at this point in the history
  • Loading branch information
tedpark217 committed Jun 7, 2024
1 parent c73c347 commit 595d874
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
8 changes: 4 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"game": {
"maze": {
"directory": "maps",
"procedural": false,
"procedural": true,
"maze_file": "test/itemRoom.maze"
},
"disable_enemies": true
Expand All @@ -14,17 +14,17 @@
"server": {
"lobby_name": "Hope you're doing well!",
"lobby_broadcast": true,
"max_players": 1,
"max_players": 2,
"disable_dm": false,
"skip_intro": true
},
"client": {
"default_name": "Conan O'Brien",
"lobby_discovery": true,
"fullscreen": false,
"fullscreen": true,
"draw_bboxes": false,
"fps_counter": true,
"presentation": false,
"render": 50
"render": 75
}
}
3 changes: 2 additions & 1 deletion include/server/game/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@
#define ITEM_SPAWN_BOUND 3
#define LIGHTNING_LIGHT_CUT_TICKS 100
#define LIGHT_CUT_TICKS 200
#define LIGHT_CUT_RANGE 25.0
#define LIGHT_CUT_RANGE 60.0
#define LIGHT_CUT_RANGE_LIGHTNING 20.0
2 changes: 1 addition & 1 deletion include/server/game/torchlight.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Torchlight : public Object {
* @param the position the lightning hit (if exists)
* @param the position of the light cut action (if exists)
*/
void doTick(ServerGameState& state, std::optional<glm::vec3> lightning_light_cut_pos, std::optional<glm::vec3> action_light_cut_pos);
bool doTick(ServerGameState& state, std::optional<glm::vec3> lightning_light_cut_pos, std::optional<glm::vec3> action_light_cut_pos);

/**
* @brief manually set torchlight intensity, for use in intro cutscene
Expand Down
4 changes: 2 additions & 2 deletions src/client/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ gui::widget::Flexbox::Ptr GUI::_createPlayerStatusRow(
if (lobbyPlayer.get().desired_role == PlayerRole::DungeonMaster) {
// Subcase 3
playerRoleString = "Player " + std::to_string(playerIndex)
+ " wants to play as the Zeus.";
+ " wants to play as Zeus.";
color = font::Color::YELLOW;
}
else if (lobbyPlayer.get().desired_role == PlayerRole::Player) {
Expand Down Expand Up @@ -877,7 +877,7 @@ gui::widget::Flexbox::Ptr GUI::_createPlayerStatusRow(
color = font::Color::YELLOW;
}
else if (lobbyPlayer.get().desired_role == PlayerRole::Player) {
playerRoleString = "You want to play as the Player.";
playerRoleString = "You want to play as a Player.";
color = font::Color::WHITE;
}

Expand Down
4 changes: 3 additions & 1 deletion src/server/game/servergamestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,9 @@ void ServerGameState::doTorchlightTicks() {
if (torchlight == nullptr)
continue;

torchlight->doTick(*this, this->dmLightningCutLights, this->dmActionCutLights);
if (torchlight->doTick(*this, this->dmLightningCutLights, this->dmActionCutLights)) {
this->updated_entities.insert(torchlight->globalID);
}
}
}

Expand Down
22 changes: 12 additions & 10 deletions src/server/game/torchlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@

SharedObject Torchlight::toShared() {
auto so = Object::toShared();
so.pointLightInfo = SharedPointLightInfo {
so.pointLightInfo = SharedPointLightInfo{
.intensity = this->curr_intensity,
.ambient_color = this->properties.ambient_color,
.diffuse_color = this->properties.diffuse_color,
.specular_color = this->properties.specular_color,
.attenuation_linear = this->properties.attenuation_linear,
.attenuation_quadratic = this->properties.attenuation_quadratic
.attenuation_quadratic = this->properties.attenuation_quadratic,
.is_cut = this->is_cut
};
return so;
}
Expand Down Expand Up @@ -131,30 +132,30 @@ void Torchlight::init() {

Torchlight::~Torchlight() {}

void Torchlight::doTick(ServerGameState& state, std::optional<glm::vec3> lightning_light_cut_pos, std::optional<glm::vec3> action_light_cut_pos) {
bool Torchlight::doTick(ServerGameState& state, std::optional<glm::vec3> lightning_light_cut_pos, std::optional<glm::vec3> action_light_cut_pos) {
if(!this->properties.flickering) {
return;
return false;
}

// cut this light if within position of light cut
if (lightning_light_cut_pos.has_value()) {
glm::vec3 pos = lightning_light_cut_pos.value();

// if within threshold, get out
if (glm::distance(pos, this->physics.shared.getCenterPosition()) <= LIGHT_CUT_RANGE) {
this->curr_intensity = 0.0f;
return;
if (glm::distance(pos, this->physics.shared.getCenterPosition()) <= LIGHT_CUT_RANGE_LIGHTNING) {
this->curr_intensity = 0.2f;
return false;
}
}

if (action_light_cut_pos.has_value()) {
glm::vec3 pos = action_light_cut_pos.value();

// if within threshold, black out (slightly expand the light cut action range)
if (glm::distance(pos, this->physics.shared.getCenterPosition()) <= (1.5 * LIGHT_CUT_RANGE)) {
this->curr_intensity = 0.0f;
if (glm::distance(pos, this->physics.shared.getCenterPosition()) <= (LIGHT_CUT_RANGE)) {
this->curr_intensity = 0.2f;
this->is_cut = true;
return;
return true;
}
}

Expand Down Expand Up @@ -187,6 +188,7 @@ void Torchlight::doTick(ServerGameState& state, std::optional<glm::vec3> lightni
} else if (this->curr_intensity < this->properties.min_intensity) {
this->curr_intensity = this->properties.min_intensity;
}
return false;
}

float Torchlight::getIntensity() const {
Expand Down

0 comments on commit 595d874

Please sign in to comment.