public void setBGImage (String bgimg, int depth, boolean wrapx,
                            boolean wrapy) {
        while (bg_images.size() < depth + 1)
            bg_images.addElement(null);
        if (bgimg != null) {
            if (!images.containsKey(bgimg)
                && !images_orig.containsKey(bgimg))
                throw new JGameError("unknown BG image " + bgimg);
            BGImage newimg = new BGImage(bgimg, wrapx, wrapy);
            bg_images.setElementAt(newimg, depth);
            if (depth == 0) {
                newimg.xofs = xofs;
                newimg.yofs = yofs;
            }
        }
        else {
            bg_images.setElementAt(null, depth);
        }
        invalidateBGTiles();
    }