protected void move(double xm, double ym) {
        if (xm == 0 && ym == 0) {
            moving = false;
            return;
        }
        if (slowed()) {
            xm *= 0.5;
            ym *= 0.5;
        }
        moving = true;
        if (ym > 0) dir = dirDown;
        else if (ym < 0) dir = dirUp;
        else if (xm > 0) dir = dirRight;
        else if (xm < 0) dir = dirLeft;
        if (!collides(xm, 0)) {
            pos.add(xm, 0);
        }
        if (!collides(0, ym)) {
            pos.add(0, ym);
        }
    }