<commit_before>import Audio from './audio';
import Battle from './battle';
import Input from './input';
import Screen from './screen';
import Title from './title';

export default class Game {
    constructor() {
        this.screen = new Screen();
        this.input = new Input();
        Audio.play();

        this.tutorial = true;
        this.currentState = new Title();
    }

    start() {
        setInterval(this.update.bind(this), 1000 / 30);
    }

    update() {
        this.currentState.update(this);
        this.draw();
        if (this.input.hasKey(84)) {
            this.input.handleKey(84);
            Audio.isPlaying ? Audio.stop() : Audio.play();
        }
    }

    draw() {
        this.screen.reset();
        this.currentState.draw(this.screen);
    }

    startBattle() {
        this.currentState = new Battle(this, this.tutorial);
    }
}<commit_msg>use requestAnimationFrame<commit_after>import Audio from './audio';
import Battle from './battle';
import Input from './input';
import Screen from './screen';
import Title from './title';

export default class Game {
    constructor() {
        this.screen = new Screen();
        this.input = new Input();
        Audio.play();

        this.tutorial = true;
        this.currentState = new Title();
    }

    start() {
        setInterval(this.update.bind(this), 1000 / 30);
    }

    update() {
        this.currentState.update(this);
        requestAnimationFrame(() => this.draw());
        if (this.input.hasKey(84)) {
            this.input.handleKey(84);
            Audio.isPlaying ? Audio.stop() : Audio.play();
        }
    }

    draw() {
        this.screen.reset();
        this.currentState.draw(this.screen);
    }

    startBattle() {
        this.currentState = new Battle(this, this.tutorial);
    }
}
{'fraction_non_alphanumeric': 0.1484764542936288, 'fraction_numerical': 0.0110803324099723, 'mean_word_length': 2.113793103448276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '593658', 'n_tokens_mistral': 545, 'n_tokens_neox': 513, 'n_words': 118}