package dothack;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;

import sillysagiri.Sagiri;

public class DotHack extends MIDlet implements Runnable {
  public DotHackC game;
  public Sagiri sagiri;
  private Display _display;
  public Thread thread;
    
  public void startApp() {
    Global.app = this;
    sagiri = new Sagiri();
    game = new DotHackC(this);

    _display = Display.getDisplay(this);
    _display.setCurrent(game);

    thread = new Thread(this);
    thread.setPriority(Thread.MAX_PRIORITY);
    thread.start();
  }
  
  public void pauseApp() {}
  
  public void destroyApp(boolean paramBoolean) {}

  public void run() {
    while (true) {
      try 
      {
        sagiri.time_begin = System.currentTimeMillis();

        game.repaint();
        game.serviceRepaints();
        Thread.sleep(1000/sagiri.fps);

        sagiri.time_delta = System.currentTimeMillis() - sagiri.time_begin;
      } 
      catch (Exception e) 
      {
        // TODO: catch any unhandled exception here
      }
    } 
  }
}