added draw time and debug mode
This commit is contained in:
@@ -6,6 +6,8 @@ import de.miaurizius.jgame2d.tile.TileManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class GamePanel extends JPanel implements Runnable {
|
||||
|
||||
@@ -96,11 +98,28 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
super.paintComponent(graphics);
|
||||
Graphics2D graphics2d = (Graphics2D) graphics;
|
||||
|
||||
// DEBUG
|
||||
long drawStart = 0;
|
||||
drawStart = System.nanoTime();
|
||||
|
||||
//Draw all components
|
||||
tileM.draw(graphics2d);
|
||||
for (SuperObject superObject : obj) if (superObject != null) superObject.draw(graphics2d, this);
|
||||
player.draw(graphics2d);
|
||||
ui.draw(graphics2d);
|
||||
|
||||
long drawEnd = System.nanoTime();
|
||||
long passed = drawEnd - drawStart;
|
||||
|
||||
// DEBUG
|
||||
if(keyH.checkDrawTime) {
|
||||
graphics2d.setColor(Color.white);
|
||||
graphics2d.drawString("Draw Time: " + passed, 10, 400);
|
||||
System.out.println("Draw Time: " + passed);
|
||||
Logger.getLogger("DEBUG").log(Level.FINE, "Draw Time: " + passed);
|
||||
}
|
||||
|
||||
// END
|
||||
graphics.dispose();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user