fixed static or global variables

use of strip.now instead of millis()
use float instead of double
respond to changes in segment size
make effect usable with multible segments
This commit is contained in:
muebau
2024-05-23 18:51:55 +02:00
parent 78089107b7
commit 5f0c6fce74
6 changed files with 75 additions and 36 deletions

View File

@@ -25,6 +25,7 @@ private:
public:
uint8_t nPieces;
uint8_t nBagLength;
uint8_t queueLength;
uint8_t bagIdx;
std::vector<uint8_t> bag;
std::vector<Piece> piecesQueue;
@@ -32,6 +33,7 @@ public:
TetrisBag(uint8_t nPieces, uint8_t nBagLength, uint8_t queueLength):
nPieces(nPieces),
nBagLength(nBagLength),
queueLength(queueLength),
bag(nPieces * nBagLength),
piecesQueue(queueLength)
{
@@ -95,6 +97,15 @@ public:
std::rotate(piecesQueue.begin(), piecesQueue.begin() + 1, piecesQueue.end());
piecesQueue[piecesQueue.size() - 1] = Piece(idx % nPieces);
}
void reset()
{
bag.clear();
bag.resize(nPieces * nBagLength);
piecesQueue.clear();
piecesQueue.resize(queueLength);
init();
}
};
#endif /* __TETRISBAG_H__ */