<commit_before>package com.mpu.spinv;

import java.awt.Graphics;

import javax.swing.JPanel;

import com.mpu.spinv.engine.StateMachine;
import com.mpu.spinv.engine.model.Animation;
import com.mpu.spinv.engine.model.Sprite;
import com.mpu.spinv.engine.model.SpriteSheet;
import com.mpu.spinv.utils.Constants;

@SuppressWarnings("serial")
public class Core extends JPanel implements Runnable {

	// Engine wise objects
	private StateMachine stateMachine;
	
	private Thread thread;
	private boolean running = false;
	
	// Game Elements
	SpriteSheet spriteSheet = new SpriteSheet(Core.class.getResource("/resources/img/player.png"));
	private Animation animation;
	private Sprite[] sprites = {
			new Sprite(spriteSheet.getSprite(0, 0, 32, 32)),
			new Sprite(spriteSheet.getSprite(32, 0, 32, 32)),
			new Sprite(spriteSheet.getSprite(64, 0, 32, 32))
	};

	public Core() {
		initUI();
		initGame();
	}

	private void initUI() {
		setFocusable(true);
		setDoubleBuffered(true);
	}

	private void initGame() {
		stateMachine = new StateMachine();
		
		
		animation = new Animation(sprites, 15, Animation.ALTERNATIVE_LOOP, true);
		animation.start();
		

		if (!running || thread == null) {
			running = true;
			thread = new Thread(this);
			thread.start();
		}
	}

	private void update() {
		stateMachine.update();
		animation.update();
	}

	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);

		// Clears the screen before drawing.
		g.clearRect(0, 0, Constants.WINDOW_WIDTH, Constants.WINDOW_HEIGHT);
		
		g.drawImage(animation.getSprite(), 0, 0, null);
		
		stateMachine.draw(g);
	}

	@Override
	public void run() {
		long beforeTime, diff, sleep;
		beforeTime = System.currentTimeMillis();
		while (running) {<commit_msg>[ Brendon ] Removed temporary code for animation test cases<commit_after>package com.mpu.spinv;

import java.awt.Graphics;

import javax.swing.JPanel;

import com.mpu.spinv.engine.StateMachine;
import com.mpu.spinv.utils.Constants;

@SuppressWarnings("serial")
public class Core extends JPanel implements Runnable {

	// Engine wise objects
	private StateMachine stateMachine;
	
	private Thread thread;
	private boolean running = false;

	public Core() {
		initUI();
		initGame();
	}

	private void initUI() {
		setFocusable(true);
		setDoubleBuffered(true);
	}

	private void initGame() {
		stateMachine = new StateMachine();

		if (!running || thread == null) {
			running = true;
			thread = new Thread(this);
			thread.start();
		}
	}

	private void update() {
		stateMachine.update();
	}

	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);

		// Clears the screen before drawing.
		g.clearRect(0, 0, Constants.WINDOW_WIDTH, Constants.WINDOW_HEIGHT);
		
		stateMachine.draw(g);
	}

	@Override
	public void run() {
		long beforeTime, diff, sleep;
		beforeTime = System.currentTimeMillis();
		while (running) {
{'fraction_non_alphanumeric': 0.12218760816891658, 'fraction_numerical': 0.009691934925579786, 'mean_word_length': 4.2355072463768115, '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': '2332559', 'n_tokens_mistral': 1046, 'n_tokens_neox': 935, 'n_words': 229}