Cleaned ImageRenderer.java

This commit is contained in:
Norbi Peti 2016-04-07 09:48:04 +02:00
parent 6dff07844f
commit 11351dd953

View file

@ -13,32 +13,21 @@ public class ImageRenderer extends MapRenderer
private BufferedImage image; private BufferedImage image;
//private Boolean imageRendered;
public ImageRenderer(BufferedImage image) public ImageRenderer(BufferedImage image)
{ {
this.image = image; this.image = image;
//this.imageRendered = false;
} }
private int progress = 0; private int progress = 0;
//private final int updatepixels = 20;
public static int updatepixels = 15; public static int updatepixels = 15;
@Override @Override
public void render(MapView view, MapCanvas canvas, Player player) public void render(MapView view, MapCanvas canvas, Player player)
{ {
/*
* if(imageRendered) {
* return;
* }
*/
long time = System.nanoTime(); long time = System.nanoTime();
try try
{ {
//if (progress != 128 / updatepixels) //<-- Never had an issue with this before 2016.02.20. because I wasn't using 16 as updatepixels
canvas.drawImage(0, progress * updatepixels, image.getSubimage(0, canvas.drawImage(0, progress * updatepixels, image.getSubimage(0,
progress * updatepixels, 128, (progress * updatepixels progress * updatepixels, 128, (progress * updatepixels
+ updatepixels >= 128 ? 128 - progress + updatepixels >= 128 ? 128 - progress
@ -47,26 +36,13 @@ public class ImageRenderer extends MapRenderer
progress++; progress++;
else else
progress = 0; progress = 0;
//this.imageRendered = true;
long diff = System.nanoTime() - time; long diff = System.nanoTime() - time;
if (TimeUnit.NANOSECONDS.toMillis(diff) > 40) if (TimeUnit.NANOSECONDS.toMillis(diff) > 40)
{ {
System.out.println("Map rendering took " System.out.println("Map rendering took "
+ TimeUnit.NANOSECONDS.toMillis(diff) + " ms"); + TimeUnit.NANOSECONDS.toMillis(diff) + " ms");
/* }
* if (progress == 0 && updatepixels > 5)
* updatepixels--;
*/
} /*
* else if (TimeUnit.NANOSECONDS.toMillis(diff) < 25)
* if (progress == 0 && updatepixels < 50)
* updatepixels++;
*/
/*
* if (progress >= 128 / updatepixels)
* progress = 0;
*/
} catch (Exception e) } catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();