Exemplo n.º 1
0
  public static void main(String[] args) {

    Background bg = new Background();

    Player player = new Player(100, 100, 200, 1);

    LinkedList<GameObject> gameObjects = new LinkedList<>();

    gameObjects.sort(
        new Comparator<GameObject>() {
          @Override
          public int compare(GameObject t, GameObject t1) {
            if (t.getY() > t.getY()) {
              return 1;
            }
            if (t.getY() < t.getY()) {
              return -1;
            }
            return 0;
          }
        });

    gameObjects.add(player);

    GUI f = new GUI(bg, gameObjects);
    f.setVisible(true);
    f.setResizable(false);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(800, 600);
    f.setLocationRelativeTo(null);
    f.setTitle("EatGetRekt");
    f.makeStrat();

    long lastFrame = System.currentTimeMillis();
    while (true) {
      long thisFrame = System.currentTimeMillis();
      float tslf = (float) (thisFrame - lastFrame) / 1000;
      lastFrame = thisFrame;

      f.repaintScreen();

      bg.update(tslf);
      for (GameObject gameObject : gameObjects) {
        gameObject.update(tslf);
      }
      try {
        Thread.sleep(15);
      } catch (InterruptedException ex) {
        JOptionPane.showMessageDialog(
            null,
            "You can not travel backwards in time. " + "Error: " + ex.getMessage(),
            "ERROR",
            JOptionPane.ERROR_MESSAGE);
      }
      if (KL.keys[KeyEvent.VK_ESCAPE]) {
        System.exit(0);
      }
    }
  }
Exemplo n.º 2
0
  public void readFile() throws IOException {
    try {

      FileInputStream fstream = new FileInputStream("dataIn.txt");
      DataInputStream in = new DataInputStream(fstream);
      BufferedReader br = new BufferedReader(new InputStreamReader(in));

      String strLine;
      int memi = -1;
      int strLineMemory = 59;

      while ((strLine = br.readLine()) != null) {

        t.data[strLineMemory++][1] = String.valueOf(strLine);
        memi++;

        size++;
        while ((strLine = br.readLine()) != null && !strLine.startsWith("*")) {

          String[] arr = strLine.split(" ");
          String command = arr[0];
          String operand = arr[1];

          toMemory(command, operand, memarray[memi]);
          memarray[memi] = memarray[memi] + 2;
          System.out.printf("%s %s ", command, operand);
        }
      }

      in.close();
    } catch (Exception e) { // Catch exception if any
      System.err.println("Error: " + e.getMessage());
    }

    MOSMain mos = new MOSMain();
    mos.planner();

    t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    t.setSize(830, 800);
    t.setVisible(true);
    t.setTitle("Printer");
    sortTime();
  }
Exemplo n.º 3
0
 public static void main(String args[]) {
   GUI go = new GUI();
   go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   go.setSize(300, 200);
   go.setVisible(true);
 }