class Myszka extends Phaser.State {
    preload() {
        this.game.load.image('tlo', 'IMAGEE/TLO.bmp');
        this.game.load.image('tak', 'IMAGEE/TAK.bmp');
        this.game.load.image('nie', 'IMAGEE/NIE.bmp');
        this.game.load.image('nie_chcesz', 'IMAGEE/NIE_CHCESZ.bmp');
    }
   
    create() {
        
        var tablicaSprite = [];
        var parzystosc10 = 0;
        var tlo = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, 'tlo');
        tlo.anchor.setTo(0.5, 0.5);
        tablicaSprite[0] = this.game.add.sprite(100, 400, 'tak');
        tablicaSprite[0].anchor.setTo(0.5, 0.5);
        tablicaSprite[0].visible = true;
        tablicaSprite[1] = this.game.add.sprite(700, 400, 'nie');
        tablicaSprite[1].anchor.setTo(0.5, 0.5);
        tablicaSprite[1].visible = true;
        tablicaSprite[2] = this.game.add.sprite(700, 400, 'tak');
        tablicaSprite[2].anchor.setTo(0.5, 0.5);
        tablicaSprite[2].visible = false;
        tablicaSprite[3] = this.game.add.sprite(100, 400, 'nie');
        tablicaSprite[3].anchor.setTo(0.5, 0.5);
        tablicaSprite[3].visible = false;
        tablicaSprite[4] = this.game.add.sprite(400, 500, 'nie_chcesz');
        tablicaSprite[4].anchor.setTo(0.5, 0.5);
        tablicaSprite[4].visible = false;

        var mysz = new Phaser.Mouse(this.game);
        this.game.canvas.addEventListener('mousemove', onMouseMove, true);
        this.game.canvas.addEventListener('mouseup', onMouseDown, true);
        mysz.callbackContext = this.game;
        mysz.mouseMoveCallback = null;
        mysz.mouseDownCallback = null;
        mysz.disabled = false;
        mysz.event = null;

        function onMouseDown(event) {
            if (event.capture) {
                event.preventDefault();
            }
            if (event.mouseMoveCallback) {
                event.mouseMoveCallback.call(event.callbackContext, event);
            }

            if (event.disabled) {
                return;
            }
            if (event.x > 50 && event.x < 150 && event.y > 350 && event.y < 450 && parzystosc10 == 1) {
                tablicaSprite[4].visible = true;
            }
            if (event.x > 650 && event.x < 750 && event.y > 350 && event.y < 450 && parzystosc10 == 0) {
                tablicaSprite[4].visible = true;
            }
        }
        function onMouseMove(event) {

            if (event.capture) {
                event.preventDefault();
            }
            if (event.mouseMoveCallback) {
                event.mouseMoveCallback.call(event.callbackContext, event);
            }

            if (event.disabled) {
                return;
            }
            if (event.x > 50 && event.x < 150 && event.y > 350 && event.y < 450 && parzystosc10==0) {
                tablicaSprite[0].visible = false;
                tablicaSprite[1].visible = false;
                tablicaSprite[2].visible = true;
                tablicaSprite[3].visible = true;
                parzystosc10 = 1;
            }
            if (event.x > 650 && event.x < 750 && event.y > 350 && event.y < 450 && parzystosc10 == 1) {
                tablicaSprite[0].visible = true;
                tablicaSprite[1].visible = true;
                tablicaSprite[2].visible = false;
                tablicaSprite[3].visible = false;
                parzystosc10 = 0;
            }
        }
    }
}