public synchronized void update() {
        
        //Check the collision of the between the robot and the walls.
        checkTileMapCollision();
        updatePosition();

        //Animation
        if (currentAnimation == SCRATCH) {
            if (animation.hasPlayedOnce()) {
                isScratching = false;
                notifyAll();
            }
        }

        if (isScratching == true) {
            if (currentAnimation != SCRATCH) {
                currentAnimation = SCRATCH;
                animation.setFrames(sprites.get(SCRATCH));
                animation.setDelay(50);
                width = 60;
            }
        } else if (currentAnimation != IDLE) {
            currentAnimation = IDLE;
            animation.setFrames(sprites.get(IDLE));
            animation.setDelay(400);
            width = 30;
        }

        animation.update();
    }