public void renderSprite(double x, double y, double z, double yOff, int[] pix) {
        int spriteSize = h / 2;
        double upco = -0.125;
        double rightco = 0.125;
        double forwardco = 0.125;
        double walkco = 0.0625;
        double xc = ((x / 2) - (right * rightco)) * 2 + 0.5;
        double yc = ((y / 2) - (up * upco)) + (walking * walkco) * 2 + yOff;
        double zc = ((z / 2) - (forward * forwardco)) * 2;
        double rotX = xc * cosine - zc * sine;
        double rotY = yc;
        double rotZ = zc * cosine + xc * sine;
        double xcenter = 400.0;
        double ycenter = 300.0;
        double xpixel = (rotX / rotZ * h + xcenter);
        double ypixel = (rotY / rotZ * h + ycenter);
        double xpixelL = xpixel - spriteSize / rotZ;
        double xpixelR = xpixel + spriteSize / rotZ;
        double ypixelL = ypixel - spriteSize / rotZ;
        double ypixelR = ypixel + spriteSize / rotZ;
        int xpl = (int) xpixelL;
        int xpr = (int) xpixelR;
        int ypl = (int) ypixelL;
        int ypr = (int) ypixelR;
        if (xpl < 0) {
            xpl = 0;
        }
        if (xpr > w) {
            xpr = w;
        }
        if (ypl < 0) {
            ypl = 0;
        }
        if (ypr > h) {
            ypr = h;
        }
        rotZ *= 8;
        for (int yp = ypl; yp < ypr; yp++) {
            double pixelrotY = (yp - ypixelR) / (ypixelL - ypixelR);
            int ytexture = (int) (8 * pixelrotY);
            for (int xp = xpl; xp < xpr; xp++) {
                double pixelrotX = (xp - xpixelR) / (xpixelL - xpixelR);
                int xtexture = (int) (8 * pixelrotX);
                if (zbuffer[xp + yp * w] > rotZ) {
                    int col = pix[(xtexture & 7) + (ytexture & 7) * 8];
                    if (col != 0xffff0000) {
                        pixels[xp + yp * w] = col;
                        zbuffer[xp + yp * w] = rotZ;
                    }
                }
            }
        }
    }