void addFrames(thor::FrameAnimation& animation, int y, int xFirst, int xLast, float duration = 1.f) { const int step = (xFirst < xLast) ? +1 : -1; xLast += step; // so yLast is excluded in the range for (int x = xFirst; x != xLast; x += step) animation.addFrame(duration, sf::IntRect(CHARACTER_SIZE*x, CHARACTER_SIZE*y, CHARACTER_SIZE, CHARACTER_SIZE)); }
// Adds a range of frames, assuming they are aligned as rectangles in the texture. // animation: FrameAnimation to modify // x: Column index of the texture rectangle // [yFirst,yLast]: Bounds for row indices (if yLast < yFirst, add frames in reverse order) // duration: Relative duration of current frame (1 by default) void addFrames(thor::FrameAnimation& animation, int x, int yFirst, int yLast, float duration = 1.f) { const int step = (yFirst < yLast) ? +1 : -1; yLast += step; // so yLast is excluded in the range for (int y = yFirst; y != yLast; y += step) animation.addFrame(duration, sf::IntRect(36*x, 39*y, 36, 39)); }
void nasic::enemy::addFrames(thor::FrameAnimation& animation, int w, int h, int y, int xFirst, int xLast, float duration) { const int step = (xFirst < xLast) ? +1 : -1; xLast += step; // so xLast is excluded in the range for (int x = xFirst; x != xLast; x += step) animation.addFrame(duration, sf::IntRect(w*x, h*y, w, h)); }
void addFrames(thor::FrameAnimation& animation, int y, int xFirst, int xLast, int xSep, int ySep, float duration) { if (y == 0) y = 0; else if (y == 1) y = 94; else if (y == 2) y = 188; for (int x = xFirst; x != xLast; x += 1) animation.addFrame(duration, sf::IntRect(xSep * x, y, xSep, ySep)); }
void Player::addFrame(thor::FrameAnimation& animation, int x, int y, float duration) { animation.addFrame(duration, sf::IntRect(16 * x, 16 * y, 16, 16)); }
void Player::addFrameFlipped(thor::FrameAnimation& animation, int x, int y, float duration) { animation.addFrame(duration, sf::IntRect(16 * (x + 1), 16 * y, -16, 16)); }