<commit_before>﻿using System.Drawing;
using ISGPAI.Game.Maths;

namespace ISGPAI.Game.Artwork
{
	internal class AnimatedSpriteSet
	{
		private Image _spriteSet;
		private int _spriteWidth;
		private int _spriteHeight;
		private int _columns;

		private int _currentColumn;
		private int _currentRow;

		private Rectangle _srcRectangle;

		public AnimatedSpriteSet(string fileName,
			int spriteWidth, int spriteHeight)
		{
			this._spriteWidth = spriteWidth;
			this._spriteHeight = spriteHeight;

			_spriteSet = Image.FromFile(fileName);
			this._columns = _spriteSet.Width / _spriteWidth;
			AdvanceAnimation();
		}

		public void AdvanceAnimation()
		{
			_currentColumn = (_currentColumn + 1) % _columns;
		}

		public void ChangeRow(int row)
		{
			this._currentRow = row;
		}

		public void ChangeColumn(int column)
		{
			this._currentColumn = column;
		}

		public void PaintAt(Graphics g, Vector2 position)
		{
			_srcRectangle = new Rectangle(
				_currentColumn * _spriteWidth,
				_currentRow * _spriteHeight,
				_spriteWidth,
				_spriteHeight
			);
			Rectangle destRectangle = new Rectangle((int)position.X, (int)position.Y,
				_spriteWidth, _spriteHeight);
			g.DrawImage(_spriteSet, destRectangle, _srcRectangle, GraphicsUnit.Pixel);
		}
	}
}<commit_msg>AnimatedSpriteSet is now drawn centered.<commit_after>﻿using System.Drawing;
using ISGPAI.Game.Maths;

namespace ISGPAI.Game.Artwork
{
	internal class AnimatedSpriteSet
	{
		private Image _spriteSet;
		private int _spriteWidth;
		private int _spriteHeight;
		private int _columns;

		private int _currentColumn;
		private int _currentRow;

		private Rectangle _srcRectangle;

		public AnimatedSpriteSet(string fileName,
			int spriteWidth, int spriteHeight)
		{
			this._spriteWidth = spriteWidth;
			this._spriteHeight = spriteHeight;

			_spriteSet = Image.FromFile(fileName);
			this._columns = _spriteSet.Width / _spriteWidth;
			AdvanceAnimation();
		}

		public void AdvanceAnimation()
		{
			_currentColumn = (_currentColumn + 1) % _columns;
		}

		public void ChangeRow(int row)
		{
			this._currentRow = row;
		}

		public void ChangeColumn(int column)
		{
			this._currentColumn = column;
		}

		public void PaintAt(Graphics g, Vector2 position)
		{
			_srcRectangle = new Rectangle(
				_currentColumn * _spriteWidth,
				_currentRow * _spriteHeight,
				_spriteWidth,
				_spriteHeight
			);
			Rectangle destRectangle = new Rectangle(
				(int)position.X - _spriteWidth / 2,
				(int)position.Y - _spriteHeight / 2,
				_spriteWidth, _spriteHeight);
			g.DrawImage(_spriteSet, destRectangle, _srcRectangle, GraphicsUnit.Pixel);
		}
	}
}
{'fraction_non_alphanumeric': 0.08272969881814717, 'fraction_numerical': 0.002287457110179184, 'mean_word_length': 3.9416195856873824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4917238', 'n_tokens_mistral': 1019, 'n_tokens_neox': 860, 'n_words': 193}