Skip to content

Commit

Permalink
Make bunnies run faster, print randomly selected map
Browse files Browse the repository at this point in the history
  • Loading branch information
Laguna1989 committed Jun 26, 2023
1 parent 3170ed5 commit 5542837
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions assets/critters/bunny.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
"sourceSize": { "w": 32, "h": 32 },
"duration": 400
"duration": 100
},
"bunny 5.aseprite": {
"frame": { "x": 160, "y": 0, "w": 32, "h": 32 },
Expand Down Expand Up @@ -129,8 +129,8 @@
}
},
"meta": {
"app": "https://www.aseprite.org/",
"version": "1.3-rc2-x64",
"app": "http://www.aseprite.org/",
"version": "1.3-rc4-x64",
"image": "bunny.png",
"format": "RGBA8888",
"size": { "w": 512, "h": 32 },
Expand Down
Binary file modified assets_src/bunny.aseprite
Binary file not shown.
13 changes: 9 additions & 4 deletions impl/game_server_lib/game_simulation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "game_simulation.hpp"
#include "system_helper.hpp"
#include <box2dwrapper/box2d_world_impl.hpp>
#include <game_properties.hpp>
#include <math_helper.hpp>
Expand All @@ -17,15 +18,14 @@ namespace {
std::string getRandomMapName()
{
// clang-format off
char const* mapList[] {
static std::vector<std::string> mapList {
"assets/maps/map_de_dust_2.json",
"assets/maps/map_over_the_hills.json",
"assets/maps/map_plains.json",
"assets/maps/map_valley_of_death.json"
};
// clang-format on
jt::Random::useTimeAsRandomSeed();
return mapList[jt::Random::getInt(0, (sizeof(mapList) / sizeof(char const*)) - 1)];
return *jt::SystemHelper::select_randomly(mapList.cbegin(), mapList.cend());
}

} // namespace
Expand All @@ -37,7 +37,12 @@ GameSimulation::GameSimulation(jt::LoggerInterface& logger, UnitInfoCollection&
{
}

void GameSimulation::rollNewMap() { m_world = std::make_shared<Terrain>(getRandomMapName()); }
void GameSimulation::rollNewMap()
{
const auto name = getRandomMapName();
m_logger.info("new map: " + name);
m_world = std::make_shared<Terrain>(name);
}

void GameSimulation::prepareSimulationForNewRound()
{
Expand Down

0 comments on commit 5542837

Please sign in to comment.