2016-01-13 2 views
3

J'ai un problème de scintillement avec les vignettes de rendu. Méthode de rendu.SLICK && LWJGL Scintillement Problème

int tileSize = TileManager.tileSize; 

    for(int y = 0 ; y < mapHeight ; y++){ 
     for(int x = 0 ; x < mapWidth ; x++){ 
      TileManager.tiles[tileIDs[y][x]].render(x * tileSize + xOffset, y * tileSize + yOffset, g); 
     } 
    } 

TileManager

public static Tile[] tiles = new Tile[256]; 

public static final int tileSize = 32; 

public static void loadTiles(String path){ 

    Image tileSet = GeneralUtils.getImage(path); 

    int row = (int)Math.floor(tileSet.getWidth()/tileSize); 
    int col = (int)Math.floor(tileSet.getHeight()/tileSize); 

    for(int y = 0 ; y < col ; y++){ 
     for(int x = 0 ; x < row ; x++){ 
      tiles[x + y * row] = new Tile(tileSet.getSubImage(x * tileSize, y * tileSize, tileSize, tileSize)); 
     } 
    } 

} 

Enfin carreaux

private Image tileImage; 

public Tile(Image tileImage){ 
    this.tileImage = tileImage; 
} 

public void render(int xPix, int yPix, Graphics g){ 
    g.drawImage(tileImage, xPix, yPix); 
} 

Si je rends comme ça il n'y a pas vacillante. Je ne pouvais pas comprendre pourquoi?

img = new Image("Res/blabla.png"); 
---------------------------------------------------- 
int tileSize = TileManager.tileSize; 

    for(int y = 0 ; y < mapHeight ; y++){ 
     for(int x = 0 ; x < mapWidth ; x++){ 
      g.drawImage(img, x * tileSize + xOffset, y * tileSize + yOffset); 
     } 
    } 

Quelle est la différence?

Répondre

1

Résolu en utilisant vsync.

private static AppGameContainer gameApp; 
gameApp.setVSync(true);