public void render() {
        try {
            lastTime = curTime;
            curTime = System.currentTimeMillis();
            totalTime += curTime - lastTime;
            if (totalTime > 1000) {
                totalTime -= 1000;
                fps = frames;
                frames = 0;
            }
            frames++;

            g2d = buffImg.createGraphics();
            g2d.setColor(background);
            g2d.fillRect(0, 0, p.getWidth(), p.getHeight());


            if (p.getFirstRound()) {
                drawStartingScreen();
            } else if (!p.getShip().getAlive()) {
                drawEndScreen();
            } else {
                drawLasers();
                drawAsteroids();
                drawShip();

                g2d.setFont(new Font("Courier New", Font.PLAIN, 12));
                g2d.setColor(Color.CYAN);
                g2d.setTransform(identity);
                g2d.drawString(String.format("FPS: %s", fps), 20, 20);
                g2d.drawString(String.format("Score:") + Integer.toString(p.calculateScore()), 20, 35);
                g2d.drawString(String.format("Highscore  ") + highscore.getHighscore(), 20, 50);

                if (p.getLevelup()) {
                    levelupScreen();
                }
            }
            graphics = buffer.getDrawGraphics();
            graphics.drawImage(buffImg, 0, 0, null);

            if (!buffer.contentsLost()) {
                buffer.show();
            }
            Thread.yield();


        } finally {

            if (graphics != null) {
                graphics.dispose();
            }
            if (g2d != null) {
                g2d.dispose();
            }
        }
    }