import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class WorldInputHandler implements KeyListener
{
    private World w;

    public WorldInputHandler(World w_)
    {
        w = w_;
    }
    
    @Override
    public void keyTyped(KeyEvent e)
    {}

    @Override
    public void keyReleased(KeyEvent e)
    {
        if (e.getKeyCode() == KeyEvent.VK_LEFT)
            w.moveX(0);
        else if (e.getKeyCode() == KeyEvent.VK_RIGHT)
            w.moveX(0);
    }

    @Override
    public void keyPressed(KeyEvent e)
    {
        if (e.getKeyCode() == KeyEvent.VK_LEFT)
            w.moveX(-3);
        else if (e.getKeyCode() == KeyEvent.VK_RIGHT)
            w.moveX(3);
        else if (e.getKeyCode() == KeyEvent.VK_SPACE)
            w.jump();
        // else if (e.getKeyCode() == KeyEvent.VK_UP)
        //     w.setYdir(-1);
        // else if (e.getKeyCode() == KeyEvent.VK_DOWN)
        //     w.setYdir(1);
        else if (e.getKeyCode() == KeyEvent.VK_Q)
            System.exit(0);
    }
}
