flash screen whenever load_level is called

This commit is contained in:
ohsqueezy 2023-12-04 23:15:08 -05:00
parent d11cffc210
commit 2e0b571f19
5 changed files with 37 additions and 6 deletions

View File

@ -61,7 +61,9 @@
"quest best foreground": [255.0, 255.0, 255.0, 255.0],
"quest best background": [0.0, 0.0, 0.0, 60.0],
"hue shift": 10.0,
"hue shift frequency": 0.025
"hue shift frequency": 0.025,
"flash length": 1.1,
"flash darken factor": 2.0
},
"configuration":

2
lib/sb

@ -1 +1 @@
Subproject commit a5f55be257eee0886c4fdd9287c9d91c9de22d8d
Subproject commit 5750997d5c7ef0a4fd9b41e0e4ba566d3a3907d2

View File

@ -1217,6 +1217,9 @@ void Cakefoot::load_level(int index)
world_color = world[ii].at("color").get<glm::fvec4>();
break;
} } }
/* Flash the screen at the start of a level */
flash_animation.play_once(configuration()("display", "flash length"));
}
void Cakefoot::write_progress() const
@ -1815,6 +1818,7 @@ void Cakefoot::update(float timestamp)
game_over_animation.update(timestamp);
submit_score_animation.update(timestamp);
shift_hue_animation.update(timestamp);
flash_animation.update(timestamp);
/* Transformation for looking at the center of the field of play from the camera position. */
view = glm::lookAt(camera_position, {0.0f, 0.0f, 0.0f}, glm::vec3{0.0f, 1.0f, 0.0f});
@ -2009,14 +2013,30 @@ void Cakefoot::update(float timestamp)
/* Disable texture, set background color for the current world using the color addition uniform, and draw playing field (background) */
glUniform1i(uniform["texture enabled"], false);
glUniform4fv(uniform["color addition"], 1, &world_color[0]);
if (flash_animation.playing())
{
sb::Color extra_shift = rotating_hue;
extra_shift.shift_hue(180.0f);
glUniform4fv(uniform.at("color addition"), 1, &(extra_shift.normal() / configuration()("display", "flash darken factor").get<float>() + world_color)[0]);
}
else
{
glUniform4fv(uniform.at("color addition"), 1, &world_color[0]);
}
playing_field.attributes("color")->bind("vertex_color", shader_program);
playing_field.attributes("color")->enable();
playing_field.draw(uniform["mvp"], view * rotation_matrix, projection, uniform["texture enabled"]);
playing_field.attributes("color")->disable();
/* Reset color addition, and draw curve. */
glUniform4fv(uniform["color addition"], 1, &glm::vec4(0)[0]);
if (flash_animation.playing())
{
glUniform4fv(uniform.at("color addition"), 1, &rotating_hue.normal()[0]);
}
else
{
glUniform4fv(uniform.at("color addition"), 1, &glm::vec4(0)[0]);
}
glm::mat4 vp = projection * view * rotation_matrix;
glUniformMatrix4fv(uniform["mvp"], 1, GL_FALSE, &vp[0][0]);
curve().color.bind("vertex_color", shader_program);
@ -2058,6 +2078,10 @@ void Cakefoot::update(float timestamp)
for (auto& enemy : enemies)
{
enemy->draw(uniform.at("mvp"), view * rotation_matrix, projection, uniform.at("texture enabled"), rotating_hue, uniform.at("color addition"));
if (!flash_animation.playing())
{
glUniform4fv(uniform.at("color addition"), 1, &glm::vec4(0)[0]);
}
}
/* Draw cake */
@ -2069,6 +2093,10 @@ void Cakefoot::update(float timestamp)
for (Flame& coin : ending_coins)
{
coin.draw(uniform.at("mvp"), view * rotation_matrix, projection, uniform.at("texture enabled"), rotating_hue, uniform.at("color addition"));
if (!flash_animation.playing())
{
glUniform4fv(uniform.at("color addition"), 1, &glm::vec4(0)[0]);
}
}
}

View File

@ -429,6 +429,9 @@ private:
/* Shift the hue by the configured amount once per configured amount of seconds */
Animation shift_hue_animation {sb::Animation(std::bind(&Cakefoot::shift_hue, this))};
/* Flash the screen */
Animation flash_animation;
/*!
* Get the arcade time as the amount of time remaining before the limit is reached.
*

View File

@ -60,7 +60,6 @@ void Enemy::draw(GLuint transformation_uniform, const glm::mat4& view, const glm
{
glUniform4fv(color_addition_uniform, 1, &rotating_hue.normal()[0]);
_coin->draw(transformation_uniform, view, projection, texture_flag_uniform);
glUniform4fv(color_addition_uniform, 1, &glm::vec4(0)[0]);
}
}
@ -306,7 +305,6 @@ void Projectile::draw(GLuint transformation_uniform, const glm::mat4& view, cons
{
glUniform4fv(color_addition_uniform, 1, &rotating_hue.normal()[0]);
_coin->draw(transformation_uniform, view, projection, texture_flag_uniform);
glUniform4fv(color_addition_uniform, 1, &glm::vec4(0)[0]);
}
}
else