0

So I created an isometric world and I made that it scrolls the world when you use the W A S D keys. Now what I did is actually move all the world according to the player's movement and not the player. Is this a good way of doing it? I have some weird graphics glitches that at the top left of the world (ONLY TOP LEFT) the tiles start glitching and flashing... I am using Graphics2D..

Here is how I am doing it: The shifter it self:

public void checkForShift(Player p, World world, GameWindow win) {
    //X MOVING

    if (p.getEnty().getX()>win.getWidth()/2) {
        if (p.getEnty().getX()<world.getWidth()-win.getWidth()/2) {
            temp = (p.getEnty().getX()-win.getWidth()/2);
            world.subSWidth(temp);
            world.subWidth(temp);
            world.updateShift(1, temp);
        }
    }
    if (p.getEnty().getX()<win.getWidth()/2) {
        if (p.getEnty().getX()>world.getSwidth()+win.getWidth()/2) {
            temp = (p.getEnty().getX()-(world.getSwidth()+win.getWidth()/2));
            world.addSWidth(temp);
            world.addWidth(temp);
            world.updateShift(2, temp);
        }
    }
    //Y MOVING
    if (p.getEnty().getY()>win.getHeight()/2) {
        if (p.getEnty().getY()<world.getHeight()-win.getHeight()/2) {
            temp = (p.getEnty().getY()-win.getHeight()/2);
            world.subSHeight(temp);
            world.subHeight(temp);
            world.updateShift(3, temp);
        }
    }
    if (p.getEnty().getY()<win.getHeight()/2) {
        if (p.getEnty().getY()>world.getSheight()+win.getHeight()/2) {
            temp = (p.getEnty().getY()-(world.getSheight()+win.getHeight()/2));
            world.addSHeight(temp);
            world.addHeight(temp);
            world.updateShift(4, temp);
        }
    }
}

world:

public void updateShift(int operation, int amount) {
    for(Entity e:ListManager.entityList) {
        e.updateShift(operation, amount);
    }
    for (Chunk c : this.getChunkList()) {
        for (Tile t : c.getTileList()) {
            t.updateShift(operation, amount);
        }
    }
}

entity:

public void updateShift(int operation, int amount) {
    if (operation == 1) {
        SubX(amount);
    } else if (operation == 2) {
        AddX(amount);
    } else if (operation == 3) {
        SubY(amount);
    } else {
        AddY(amount);
    }

}

tiles:

public void updateShift(int operation, int amount) {
    if (operation == 1) {
        SubX(amount);
    } else if (operation == 2) {
        AddX(amount);
    } else if (operation == 3) {
        SubY(amount);
    } else {
        AddY(amount);
    }
}

So i have 2 questions, Is this a good and performance efficient way of doing this? and how do I fix the weird glitches? Here is a video:

http://youtu.be/YUn5xCeBInM

Bart
  • 19,692
  • 7
  • 68
  • 77
Trixmix
  • 81
  • 9

1 Answers1

0

Maybe my response would be a bit off, but you may be interested in libgdx and its IsometricMap sample.

tsug303
  • 59
  • 2