I think I’ve found a bug.
I got this result, from some code:
Obviously, I’m drawing green rectangles, underneath the pictures.
Now, if I comment it out (and that is the ONLY change made to the code):
and
Depending on where the X-coord for the camera is set.
…also, this doesn’t move smoothly, like normally, but in 10 pixel steps.
Boils down to just odd behavoir, because this shouldn’t work that way.
Code, for people interrested:
// World-rendering
int startingX = cameraX / 10;
g.setColor(Color.green);
for (int x = startingX; x < 50 + startingX; x++) {
for (int y = 0; y < 20; y++) {
if (level.getBrick(x, y) != null) {
int k = x * 10;
int startDrawX = k - cameraX;
int startDrawY = 200 - ((y + 1) * 10);
g.drawRect(startDrawX, startDrawY, 10, 10);
Brick brick = level.getBrick(x, y);
BRICK_TYPE type = brick.getType();
ResourceManager.TILE image = type.getImage();
g.drawImage(graphics.getSprite(image.getX(), image.getY()), startDrawX, startDrawY);
}
}
}
EDIT:
Can anyone explain this behavoir, or suggest a way to fix it? I got no ideas as to why this is happening. I just cleaned up my code, so it shouldn’t be spaggetthi-loops and oddness.