1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.applet.*;
import java.awt.*;
import java.awt.image.*;

public class TestApplet extends Applet implements Runnable
{
    BufferedImage buffer;
    Graphics2D g2d;
    Thread gameloop1;
    fpscounter FPS = new fpscounter();

    public void init()
    {
        setSize(1200,800);
        buffer = new BufferedImage(1200,800,BufferedImage.TYPE_INT_ARGB);
        g2d = buffer.createGraphics();

    }

       public void start()
    {
        gameloop1 = new Thread(this);
        gameloop1.start();
    }

       public void run()
    {
        Thread t = Thread.currentThread();
        while (t == gameloop1)
        {


           System.out.println(""+FPS.getFPS());
            repaint();
        }
   }



       public void update(Graphics g)
       {
           FPS.tick();
           g2d.setColor(Color.BLACK);
           g2d.fillRect(0,0,1200,800);
           g2d.setColor(Color.WHITE);
           g2d.drawString("FPS:" +FPS.getFPS(),20,30);
           g.drawImage(buffer,0,0,this);
           //paint(g);
       }
}