// set to full screen public void init() { s = new ScreenManager(); DisplayMode dm = s.findFirstCompatibleMode(modes); s.setFullScreen(dm); Window w = s.getFullScreenWindow(); w.setFont(new Font("Arial", Font.PLAIN, 20)); w.setBackground(Color.BLUE); w.setForeground(Color.WHITE); running = true; }
public void run() { try { init(); gameLoop(); } finally { s.restoreScreen(); } }
// main grameloop public void gameLoop() { long startingTime = System.currentTimeMillis(); long cumTime = startingTime; while (running) { long timePassed = System.currentTimeMillis() - cumTime; cumTime += timePassed; // a.update(timePassed); update(timePassed); // draw graphics Graphics2D g = s.getGraphics(); draw(g); g.dispose(); s.update(); try { Thread.sleep(20); } catch (Exception ex) { } } }