Hi there JGO,
I am experiencing a long time now a render glitch with is really been a pain in the “arssh”. I never knew why this happened nor I wanted to ask it on the forums… But since I implemented mouseListener the coords are not always right because of lines that are bad drawn.
Normally a pixel in the game is 3 pixels from the screen but sometimes this 3 changes to 4 at several points (if you look at the grass/sand texture you will see bigger pixels that arent really 3x pixels but 4x (as in the ratio game:screen). I dont know what I am doing really wrong can’t see something that is wrong… Maybe it is just java and need to put more RAM into the game?
Screenshots:
http://img27.imageshack.us/img27/2621/bvo.png
information:
If you look at the inventoryGrid you see that some lines are 4 pixels wide and have the same draw code as others that are 3 pixels wide (what the normal ratio is). If you see at the left of the screen(top screenshot), then you see that the eyes of the MobPlayerMP are 4 wide aswell So I think I made a small error on how to draw the first coords or something.
Code:
public void render(int xPos, int yPos, int tile, int colour, int mirrorDir, int scale) {
xPos -= xOffset;
yPos -= yOffset;
boolean mirrorX = (mirrorDir & BIT_MIRROR_X) > 0;
boolean mirrorY = (mirrorDir & BIT_MIRROR_Y) > 0;
int scaleMap = scale - 1;
int xTile = tile % 32;
int yTile = tile / 32;
int tileOffset = (xTile << 3) + (yTile << 3) * sheet.width;
for(int y = 0; y < 8; y++) {
int ySheet = y;
if(mirrorY)
ySheet = 7 - y;
int yPixel = y + yPos + (y * scaleMap) - ((scaleMap << 3) / 2);
for(int x = 0; x < 8; x++) {
int xSheet = x;
if(mirrorX)
xSheet = 7 - x;
int xPixel = x + xPos + (x * scaleMap) - ((scaleMap << 3) /2);
int col = (colour >> (sheet.pixels[xSheet + ySheet * sheet.width + tileOffset] * 8)) & 255;
if(col < 255){
for(int yScale = 0; yScale < scale; yScale++) {
if(yPixel + yScale < 0 || yPixel + yScale >= height)
continue;
for (int xScale = 0; xScale < scale; xScale++) {
if(xPixel + xScale < 0 || xPixel + xScale >= width)
continue;
pixels[(xPixel + xScale) + (yPixel + yScale) * width] = col;
}
}
}
}
}
}
If you can help just say something It will always be great!
-RoseSlayer