<commit_before>/*********************************
** Tsunagari Tile Engine        **
** animation.cpp                **
** Copyright 2011-2012 OmegaSDG **
*********************************/

#include <Gosu/Graphics.hpp>

#include "animation.h"

Animation::Animation()
	: frames(),
	  img(NULL),
	  animated(false),
	  frameLen(0),
	  animCycle(0),
	  frameShowing(0),
	  base(0)
{
}

void Animation::addFrame(ImageRef frame)
{
	frames.push_back(frame);
	animCycle = frameLen * (int)frames.size();
	if (frames.size() == 1)
		img = frame.get();
	if (frames.size() > 1)
		animated = true;
}

void Animation::setFrameLen(int milliseconds)
{
	frameLen = milliseconds;
	animCycle = frameLen * (int)frames.size();
}

void Animation::startOver(int ms_now)
{
	base = ms_now;
	frameShowing = 0;
	img = frames[0].get();
}

bool Animation::needsRedraw(int milliseconds) const
{
	if (animated) {
		int offset = milliseconds - base;
		int frame = (offset % animCycle) / frameLen;
		return frame != frameShowing;
	}
	return false;
}

void Animation::updateFrame(int milliseconds)
{
	if (animated) {
		int offset = milliseconds - base;
		int frameShowing = (offset % animCycle) / frameLen;
		img = frames[frameShowing].get();
	}
}

Gosu::Image* Animation::frame() const
{
	return img;<commit_msg>regression: tile animations cycle frames<commit_after>/*********************************
** Tsunagari Tile Engine        **
** animation.cpp                **
** Copyright 2011-2012 OmegaSDG **
*********************************/

#include <Gosu/Graphics.hpp>

#include "animation.h"

Animation::Animation()
	: frames(),
	  img(NULL),
	  animated(false),
	  frameLen(0),
	  animCycle(0),
	  frameShowing(0),
	  base(0)
{
}

void Animation::addFrame(ImageRef frame)
{
	frames.push_back(frame);
	animCycle = frameLen * (int)frames.size();
	if (frames.size() == 1)
		img = frame.get();
	if (frames.size() > 1)
		animated = true;
}

void Animation::setFrameLen(int milliseconds)
{
	frameLen = milliseconds;
	animCycle = frameLen * (int)frames.size();
}

void Animation::startOver(int ms_now)
{
	base = ms_now;
	frameShowing = 0;
	img = frames[0].get();
}

bool Animation::needsRedraw(int milliseconds) const
{
	if (animated) {
		int offset = milliseconds - base;
		int frame = (offset % animCycle) / frameLen;
		return frame != frameShowing;
	}
	return false;
}

void Animation::updateFrame(int milliseconds)
{
	if (animated) {
		int offset = milliseconds - base;
		frameShowing = (offset % animCycle) / frameLen;
		img = frames[frameShowing].get();
	}
}

Gosu::Image* Animation::frame() const
{
	return img;
{'fraction_non_alphanumeric': 0.19396051103368175, 'fraction_numerical': 0.012388695315524584, 'mean_word_length': 4.273469387755102, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2924414', 'n_tokens_mistral': 953, 'n_tokens_neox': 870, 'n_words': 192}