Compare commits
2 Commits
d350044cb2
...
9c631d3d9a
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c631d3d9a | |||
| 2eead14b8e |
@@ -9,8 +9,8 @@ std::unordered_map<char, char> Fish::color_map;
|
||||
Fish::Fish() : Fish(getRandomAssetIndex()) {}
|
||||
|
||||
Fish::Fish(int asset_index)
|
||||
: Entity(asset_index % 2 == 0), image(fishAssetPairs[asset_index].image),
|
||||
mask(fishAssetPairs[asset_index].mask),
|
||||
: Entity(asset_index % 2 == 0), image(getFishAssetPairs()[asset_index].image),
|
||||
mask(getFishAssetPairs()[asset_index].mask),
|
||||
speed(Random::floatInRange(0.25f, 2.25f)) {
|
||||
|
||||
const auto &aquarium = Aquarium::getInstance();
|
||||
@@ -45,7 +45,7 @@ void Fish::randomizeMask() {
|
||||
}
|
||||
|
||||
int Fish::getRandomAssetIndex() {
|
||||
return Random::intInRange(0, static_cast<int>(fishAssetPairs.size()) - 1);
|
||||
return Random::intInRange(0, static_cast<int>(getFishAssetPairs().size()) - 1);
|
||||
}
|
||||
|
||||
void Fish::update() noexcept { x += moving_right ? speed : -speed; }
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include "../SpriteUtils.h"
|
||||
#include <vector>
|
||||
|
||||
const std::vector<AssetPair> fishAssets = {
|
||||
inline const std::vector<AssetPair>& getFishAssets() {
|
||||
static const std::vector<AssetPair> fishAssets = {
|
||||
{
|
||||
{
|
||||
R"(???\??)",
|
||||
@@ -100,6 +101,11 @@ const std::vector<AssetPair> fishAssets = {
|
||||
R"( 6 3 77 4 1)",
|
||||
R"(6661111111311311111 )",
|
||||
}}};
|
||||
return fishAssets;
|
||||
}
|
||||
|
||||
inline const std::vector<AssetPair> fishAssetPairs =
|
||||
createBidirectionalAssets(fishAssets);
|
||||
inline const std::vector<AssetPair>& getFishAssetPairs() {
|
||||
static const std::vector<AssetPair> fishAssetPairs =
|
||||
createBidirectionalAssets(getFishAssets());
|
||||
return fishAssetPairs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user