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