Isometric scrolling woes

Hey everybody, got an isometric routine here that doesn’t quite work perfectly. It seems to work fine scrolling horizontally, but when scrolling vertically, at some locations the tiles “jump” around to incorrect map coordinates.

Here is the suspect code:


//map coords
int mapX;
int mapY;
//offsets for smooth scrolling
int offsetX;
int offsetY;

//determine tiles to draw
//(drawX and drawY are arguments used to tell the routine 
//which part of the map to draw.)
mapX = (int)(drawX / 64);
mapY = (int)(drawY / 32);

//figure offsets
offsetX = drawX & 63;
offsetY = drawY & 31;

for (i=0; i<SCREEN_WIDTH_TILES; i++) {
    for (j=0; j<SCREEN_HEIGHT_TILES; j++) {
        drawTile(mapX + j + ((mapY & 1) & (i & 1)), mapY + i, 
                 j*64 - offsetX + ((i & 1)*32), i*16 - offsetY);
    }
}

I’ve always had trouble with isometric, but I’m hoping this time I’ll finally get it running properly. Thanks for any and all help on this.

Did you get this working?

If not can you post your code for drawTile()? I’m not sure whats going on in there but you shouldn’t have to be using a modulus more than once to make the calculation.

I just made a similar reply to another isometric topic and gave this code:

plotx = i * TILE_WIDTH + (j & 1) * (TILE_WIDTH/2);
ploty = j * (TILE_HEIGHT/2);

This is the fundamental code to stagger your iso tiles correctly without taking into consideration scrolling or odd sized tiles.

Seeing all these threads on isometric tiles, i decided to give it a go myself. since your tiles seem to be jumping around, maybe the odd lines are becoming the even (for the purposes of rendering) and vice versa when your offset changes, and the line that is getting shifted halfway is alternating.

if you haven’t found the problem yet, i would be happy to look at your full code if i can compile and test it.

here’s a little test application i made that does what i think you are trying to do. it’s an executable JAR. the source is included inside. the main class is BufferedFrame.java

You can scroll by dragging the mouse over the tiles.

http://www.adam.com.au/kellyjones/javagaming/isostuff.jar

(for some reason, it may want to download as a .zip file… it’s actually a JAR file though)

-Judd

Nice tech demo …

why does black squares appears on the left, right and bottom of the screen (like flickering)?

Sounds like he was just testing out the idea of drawing an iso map. Don’t think he was concerned with clipping.

it was to make sure the clipping was actually working cause the fps is lower than i expected. and it still is. dont know why.