add warp view, clear screen to background color, set arcade score on completion of final level, remove UI from arcade-only mode
This commit is contained in:
parent
f637c86529
commit
ae0ce70b3d
|
@ -52,7 +52,6 @@
|
|||
"qr translation": [1.49, -0.7],
|
||||
"qr scale": [0.205, 0.225],
|
||||
"end screen timeout": 40.0,
|
||||
"end screen timeout": 10040.0,
|
||||
"enemy sprite scale": 0.024691358,
|
||||
"quest best text": "★ ",
|
||||
"quest best scale": [0.25, 0.04],
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
[594.000000, 285.333333], [681.000000, 284.666667], [682.000000, 212.000000], [695.333333, 188.000000], [734.666667, 194.000000],
|
||||
[733.000000, 115.000000], [737.000000, 12.333333], [675.000000, 23.666667], [717.000000, 174.000000], [788.666667, 342.666667],
|
||||
[830.333333, 205.333333], [674.000000, 169.000000], [756.333333, 184.000000], [782.666667, 175.000000], [800.000000, 155.000000]
|
||||
]
|
||||
],
|
||||
"warp": [1.32732, 6.35162e-07]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -27,7 +28,8 @@
|
|||
["slicer", 0.25, 5.00, 80],
|
||||
["slicer", 0.5, 5.00, 80],
|
||||
["slicer", 0.75, 5.00, 80, 0.1, 0]
|
||||
]
|
||||
],
|
||||
"warp": [1.84569, -0.0471237]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -73,7 +75,8 @@
|
|||
"position": 0.5,
|
||||
"angle": 4.71
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [0.0157079, 0.895354]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -84,7 +87,8 @@
|
|||
["fish", 0.5, 0.16, 40.000000, 0.0],
|
||||
["fish", 0.16, 0.1, 70.000000, 0.0],
|
||||
["projector", [432, 400, 0.0], 10.00000, 2.0, 0.6, 3]
|
||||
]
|
||||
],
|
||||
"warp": [-0.00785417, 2.20697]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -119,7 +123,8 @@
|
|||
"position": 0.57,
|
||||
"angle": 1.57
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-6.36173, -0.887501]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -132,7 +137,8 @@
|
|||
["slicer", 0.5, 10, 300],
|
||||
["fish", 0.75, 0.15, 40.000000, 0.0],
|
||||
["fish", 0.95, 0.15, 40.000000, 0.0, 3.14]
|
||||
]
|
||||
],
|
||||
"warp": [-7.54768, 0.141371]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -153,7 +159,8 @@
|
|||
["flame", [0.59, -0.75, 0], 0.25, 1.5707963267948966, -1],
|
||||
["flame", [1.18, -0.75, 0], 0.25, 1.5707963267948966, -1],
|
||||
["slicer", 0.97, 6, 75, 0.09, 4.712]
|
||||
]
|
||||
],
|
||||
"warp": [-7.37491, 3.98197]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -179,7 +186,8 @@
|
|||
"position": 0.62,
|
||||
"angle": 2.35
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-11.6631, 10.108]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -208,7 +216,8 @@
|
|||
"position": 0.62,
|
||||
"angle": 2.65
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-20.0667, 10.053]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -255,7 +264,8 @@
|
|||
"position": 0.72,
|
||||
"angle": 1.8
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-18.8179, 8.10529]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -270,7 +280,8 @@
|
|||
["projector", [660.000000, 386.000000, 0.0], 5.00000, 2.0, 0.6],
|
||||
["projector", [671.000000, 106.000000, 0.0], 5.00000, 1.0, 0.6],
|
||||
["projector", [668.000000, 239.000000, 0.0], 5.00000, 2.0, 0.6]
|
||||
]
|
||||
],
|
||||
"warp": [-3.16516, 2.54469]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -307,7 +318,8 @@
|
|||
"position": 0.57,
|
||||
"angle": 4.71
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-6.401, -1.06814]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -337,7 +349,8 @@
|
|||
"position": 0.4,
|
||||
"angle": 1.9
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-9.42476, 3.14945]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -371,7 +384,8 @@
|
|||
"position": 0.215,
|
||||
"angle": 4.1
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-12.7704, 5.06582]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -435,7 +449,8 @@
|
|||
"position": 0.34,
|
||||
"angle": 5.2
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-12.527, 7.28064]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -472,7 +487,8 @@
|
|||
"position": 0.387,
|
||||
"angle": 5.2
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-14.8595, 7.24922]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -531,7 +547,8 @@
|
|||
"position": 0.44,
|
||||
"angle": 1.8
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-18.818, 8.71792]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -592,7 +609,8 @@
|
|||
"position": 0.6661,
|
||||
"angle": 0.0
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-34.7536, 18.881]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -655,7 +673,8 @@
|
|||
["fish", 0.91, 0.1, 50.00000, 0.0],
|
||||
["fish", 0.91, 0.1, 70.00000, 0.0],
|
||||
["wave", 0.45, 3.5, 0.26, 0.7, -0.15]
|
||||
]
|
||||
],
|
||||
"warp": [-34.5652, 19.5722]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -702,7 +721,8 @@
|
|||
"position": 0.59,
|
||||
"angle": 3.34
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-38.0916, 25.0072]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -836,7 +856,9 @@
|
|||
"position": 0.636,
|
||||
"angle": 4.0
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
"warp": [-40.8485, 25.9654]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -859,7 +881,8 @@
|
|||
["slicer", 0.95000, 5.00000, 72.50000],
|
||||
["slicer", 0.90000, 3.00000, 42.50000],
|
||||
["slicer", 0.85000, 1.25000, 32.50000]
|
||||
]
|
||||
],
|
||||
"warp": [-41.6338, 24.7874]
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -951,13 +974,15 @@
|
|||
"position": 0.62,
|
||||
"angle": 3.14
|
||||
}
|
||||
]
|
||||
],
|
||||
"warp": [-40.8406, 27.5206]
|
||||
},
|
||||
|
||||
{
|
||||
"curve": [
|
||||
[280, 244], [280, 244], [584, 244], [584, 244]
|
||||
]
|
||||
],
|
||||
"warp": [-45.1289, 25.0702]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
128
src/Cakefoot.cpp
128
src/Cakefoot.cpp
|
@ -1484,14 +1484,12 @@ void Cakefoot::collect_coin(bool add_to_bank)
|
|||
configuration()["progress"]["arcade bank"].get_ref<nlohmann::json::number_integer_t&>()++;
|
||||
configuration()["progress"]["arcade coin"] = true;
|
||||
write_progress();
|
||||
std::cout << "Bank increase! " << configuration()("progress", "arcade bank") << std::endl;
|
||||
}
|
||||
else if (quest())
|
||||
{
|
||||
configuration()["progress"]["quest bank"].get_ref<nlohmann::json::number_integer_t&>()++;
|
||||
configuration()["progress"]["quest coin"] = true;
|
||||
write_progress();
|
||||
std::cout << "Bank increase! " << configuration()("progress", "quest bank") << std::endl;
|
||||
} } } } }
|
||||
}
|
||||
|
||||
|
@ -1514,6 +1512,33 @@ void Cakefoot::submit_score()
|
|||
load_level(0);
|
||||
}
|
||||
|
||||
void Cakefoot::set_arcade_score(float extended_limit, int maximum_distance)
|
||||
{
|
||||
arcade_score = ArcadeScores::Score {arcade_time_remaining(extended_limit), maximum_distance};
|
||||
int rank = std::min(9999, arcade_scores.rank(arcade_score));
|
||||
std::ostringstream rank_str, distance_str;
|
||||
rank_str << rank;
|
||||
if (rank == 1)
|
||||
{
|
||||
rank_str << "st";
|
||||
}
|
||||
else if (rank == 2)
|
||||
{
|
||||
rank_str << "nd";
|
||||
}
|
||||
else if (rank == 3)
|
||||
{
|
||||
rank_str << "rd";
|
||||
}
|
||||
else
|
||||
{
|
||||
rank_str << "th";
|
||||
}
|
||||
label.at("arcade rank").content(rank_str.str());
|
||||
distance_str << arcade_score.distance << "m";
|
||||
label.at("arcade distance").content(distance_str.str());
|
||||
}
|
||||
|
||||
void Cakefoot::shift_hue()
|
||||
{
|
||||
rotating_hue.shift_hue(configuration()("display", "hue shift").get<float>());
|
||||
|
@ -1889,15 +1914,33 @@ void Cakefoot::update(float timestamp)
|
|||
|
||||
/* Rotate X 180 if mirror mode is active */
|
||||
float rotation_x = rotation.x;
|
||||
float rotation_y = rotation.y;
|
||||
if (view_index == 1)
|
||||
{
|
||||
rotation_x += glm::pi<float>();
|
||||
}
|
||||
else if (view_index == 2)
|
||||
{
|
||||
glm::vec2 warp = configuration()("levels", level_index, "warp");
|
||||
rotation_x += warp.x;
|
||||
rotation_y += warp.y;
|
||||
}
|
||||
|
||||
/* Transformation that applies the rotation state of the entire scene */
|
||||
glm::mat4 rotation_matrix = glm::rotate(glm::mat4(1), rotation_x, {0.0f, 1.0f, 0.0f}) * glm::rotate(glm::mat4(1), rotation.y, {1.0f, 0.0f, 0.0f});
|
||||
glm::mat4 rotation_matrix = glm::rotate(glm::mat4(1), rotation_x, {0.0f, 1.0f, 0.0f}) * glm::rotate(glm::mat4(1), rotation_y, {1.0f, 0.0f, 0.0f});
|
||||
|
||||
/* Clear screen to configured color */
|
||||
/* Clear screen to world color */
|
||||
if (flash_animation.playing())
|
||||
{
|
||||
sb::Color extra_shift = rotating_hue;
|
||||
extra_shift.shift_hue(180.0f);
|
||||
glm::vec4 clear = extra_shift.normal() / configuration()("display", "flash darken factor").get<float>() + world_color;
|
||||
glClearColor(clear.r, clear.g, clear.b, clear.a);
|
||||
}
|
||||
else
|
||||
{
|
||||
glClearColor(world_color.r, world_color.g, world_color.b, world_color.a);
|
||||
}
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
/* Ignore most of the update and draw loop if the play button is enabled and hasn't been pressed */
|
||||
|
@ -1936,29 +1979,7 @@ void Cakefoot::update(float timestamp)
|
|||
game_over_animation.play_once(configuration()("display", "game over display time"));
|
||||
|
||||
/* Create arcade score */
|
||||
arcade_score = ArcadeScores::Score(arcade_time_remaining(extended_limit), maximum_distance);
|
||||
int rank = std::min(9999, arcade_scores.rank(arcade_score));
|
||||
std::ostringstream rank_str, distance_str;
|
||||
rank_str << rank;
|
||||
if (rank == 1)
|
||||
{
|
||||
rank_str << "st";
|
||||
}
|
||||
else if (rank == 2)
|
||||
{
|
||||
rank_str << "nd";
|
||||
}
|
||||
else if (rank == 3)
|
||||
{
|
||||
rank_str << "rd";
|
||||
}
|
||||
else
|
||||
{
|
||||
rank_str << "th";
|
||||
}
|
||||
label.at("arcade rank").content(rank_str.str());
|
||||
distance_str << arcade_score.distance << "m";
|
||||
label.at("arcade distance").content(distance_str.str());
|
||||
set_arcade_score(extended_limit, maximum_distance);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1971,13 +1992,19 @@ void Cakefoot::update(float timestamp)
|
|||
level_index ? std::nullopt : std::optional<float>(configuration()("character", "idle speed").get<float>()));
|
||||
if (character.at_end(curve()))
|
||||
{
|
||||
/* On the end level, save the score and name entry. */
|
||||
/* On the ending screen, submit the score and name entry. */
|
||||
if (arcade() && static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1)
|
||||
{
|
||||
submit_score();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* On the final arcade level, create a score since game is over */
|
||||
if (arcade() && static_cast<std::size_t>(level_index) == configuration()("levels").size() - 2)
|
||||
{
|
||||
set_arcade_score(extended_limit, maximum_distance);
|
||||
}
|
||||
|
||||
/* Collect any previously taken coins */
|
||||
collect_coin();
|
||||
|
||||
|
@ -2071,22 +2098,8 @@ void Cakefoot::update(float timestamp)
|
|||
/* Plane position vertices will be used for everything before the curve */
|
||||
sb::Plane::position->bind("vertex_position", shader_program);
|
||||
|
||||
/* Disable texture, set background color for the current world using the color addition uniform, and draw playing field (background) */
|
||||
/* Disable texture */
|
||||
glUniform1i(uniform["texture enabled"], false);
|
||||
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. */
|
||||
if (flash_animation.playing())
|
||||
|
@ -2182,7 +2195,10 @@ void Cakefoot::update(float timestamp)
|
|||
if (level_index == 0)
|
||||
{
|
||||
/* Flash play button */
|
||||
glUniform4fv(uniform.at("color addition"), 1, &rotating_hue.normal()[0]);
|
||||
if (!configuration()("display", "arcade only"))
|
||||
{
|
||||
glUniform4fv(uniform.at("color addition"), 1, &rotating_hue.normal()[0]);
|
||||
}
|
||||
button.at("start").draw(uniform["mvp"], view, projection, uniform["texture enabled"]);
|
||||
if (!flash_animation.playing())
|
||||
{
|
||||
|
@ -2216,7 +2232,10 @@ void Cakefoot::update(float timestamp)
|
|||
{
|
||||
if (unpaused_timer)
|
||||
{
|
||||
button.at("pause").draw(uniform["mvp"], view, projection, uniform["texture enabled"]);
|
||||
if (!configuration()("display", "arcade only"))
|
||||
{
|
||||
button.at("pause").draw(uniform["mvp"], view, projection, uniform["texture enabled"]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2322,7 +2341,7 @@ void Cakefoot::update(float timestamp)
|
|||
}
|
||||
|
||||
/* Draw end screen messages */
|
||||
if (static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1)
|
||||
if (static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1 && !configuration()("display", "arcade only"))
|
||||
{
|
||||
float y = configuration()("ending", "messages y").get<float>();
|
||||
for (std::size_t message_ii = 0; message_ii < ending_messages.size(); message_ii++)
|
||||
|
@ -2371,16 +2390,17 @@ void Cakefoot::update(float timestamp)
|
|||
button.at("play").draw(uniform["mvp"], view, projection, uniform["texture enabled"]);
|
||||
}
|
||||
|
||||
/* Always draw the volume and fullscreen buttons if enabled */
|
||||
for (const std::string& name : {"volume", "fullscreen"})
|
||||
/* Always draw the volume and fullscreen buttons if enabled unless it's arcade only mode */
|
||||
if (!configuration()("display", "arcade only"))
|
||||
{
|
||||
if (name != "fullscreen" || configuration()("display", "fullscreen enabled"))
|
||||
for (const std::string& name : {"volume", "fullscreen"})
|
||||
{
|
||||
sb::Plane::position->bind("vertex_position", shader_program);
|
||||
sb::Plane::color->bind("vertex_color", shader_program);
|
||||
button.at(name).draw(uniform["mvp"], view, projection, uniform["texture enabled"]);
|
||||
}
|
||||
}
|
||||
if (name != "fullscreen" || configuration()("display", "fullscreen enabled"))
|
||||
{
|
||||
sb::Plane::position->bind("vertex_position", shader_program);
|
||||
sb::Plane::color->bind("vertex_color", shader_program);
|
||||
button.at(name).draw(uniform["mvp"], view, projection, uniform["texture enabled"]);
|
||||
} } }
|
||||
|
||||
/* Update display */
|
||||
SDL_GL_SwapWindow(window());
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
Score(float time, int distance, const std::string& name = "") : time(time), distance(distance), name(name), date(std::time(nullptr)) {};
|
||||
Score() : Score(0.0f, 0) {};
|
||||
|
||||
bool operator >(const Score& other) const
|
||||
bool operator>(const Score& other) const
|
||||
{
|
||||
return time > other.time || (time == other.time && distance > other.distance);
|
||||
}
|
||||
|
@ -427,6 +427,10 @@ private:
|
|||
/* Can be used to time out the name entry screen */
|
||||
Animation submit_score_animation {sb::Animation(std::bind(&Cakefoot::submit_score, this))};
|
||||
|
||||
/*!
|
||||
*/
|
||||
void set_arcade_score(float extended_limit, int maximum_distance);
|
||||
|
||||
/*!
|
||||
* Shift the hue of the global sb::Color object that tracks the hue shift by the given amount in the configuration.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue