package graficos;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class Game extends Canvas implements Runnable{
private Thread thread;
private boolean isRunning;
public static JFrame frame;
private final int WIDTH = 160;
private final int HEIGHT = 120;
private final int SCALE = 4;
private BufferedImage image;
public Game() {
[Link](new Dimension(WIDTH*SCALE,HEIGHT*SCALE));
initiFrame();
image = new BufferedImage(WIDTH, HEIGHT,BufferedImage.TYPE_INT_RGB);
}
public void initiFrame() {
frame = new JFrame("TELINHA DO GAME #1");
[Link](this);
[Link](false);
[Link]();
[Link](null);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](true);
}
public synchronized void start() {
thread = new Thread(this);
isRunning = true;
[Link]();
}
public synchronized void stop() {
public void tick() {
public void render() {
BufferStrategy bs = [Link]();
if(bs == null) {
[Link](3);
return;
}
Graphics g = [Link]();
[Link]([Link]);
[Link](0, 0, WIDTH, HEIGHT);
[Link]([Link]);
[Link](0, 0, 30, 30);
[Link]([Link]);
[Link](0, 80, 165, 70);
[Link]([Link]);
[Link](120, 10, 30, 15);
[Link]([Link]);
[Link](80, 10, 30, 15);
[Link]([Link]);
[Link](40, 10, 30, 15);
g = [Link]();
[Link](image,0,0,WIDTH*SCALE,HEIGHT*SCALE,null);
[Link]();
}
public static void main(String args []) {
Game game = new Game();
[Link]();
}
public void run() {
long lastTime = [Link]();
double amountTicks = 60.0;
double ns = 1000000000 / amountTicks;
double delta = 0;
int frame = 0;
double timer = [Link]();
while(isRunning) {
long now = [Link]();
delta+=( now - lastTime) / ns;
lastTime = now;
if(delta >= 1) {
tick();
render();
frame++;
delta--;
}
if([Link]() - timer >= 1000) {
[Link]("FPS: "+frame);
frame = 0;
timer+=1000;
}
}
}