Exemple #1
0
  public static void main(String[] args) {
    int n = 20, maxval = 20;

    if (args.length == 0) {
      System.out.println("You must specify f or s as first argument");
      System.exit(0);
    }
    String choice = args[0];
    if (args.length > 1) {
      n = Integer.parseInt(args[1]);
    }
    if (args.length > 2) {
      maxval = Integer.parseInt(args[2]);
    }

    Mode m = new Mode(n, maxval);
    if (choice.equals("s")) {
      System.out.println("slow modecount = " + m.mode());
    } else {
      System.out.println("fast modecount = " + m.fastmode());
    }
  }
Exemple #2
0
  public void paint(Graphics g) {
    super.paint(g);
    if (screen.equalsIgnoreCase("title")) {
      MyPanel.score = 0;
      hs = new Highscore();
      c.removeAll();
      c.add(ts);
      panel = null;
      ts.revalidate();
    } else if (screen.equalsIgnoreCase("instructions")) {
      c.removeAll();
      c.add(instructions);
      instructions.revalidate();
    } else if (screen.equalsIgnoreCase("mode")) {
      c.removeAll();
      c.add(mode);
      mode.revalidate();
    } else if (screen.equalsIgnoreCase("difficulty")) {
      c.removeAll();
      c.add(dif);
      dif.revalidate();
    } else if (screen.equalsIgnoreCase("highscore")) {
      if (hs.returnCount() == 0) {
        c.removeAll();
        c.add(hs);
        c.validate();
      }
    } else if (screen.equalsIgnoreCase("gameover")) {
      if (!once) {
        c.removeAll();
        c.add(gg);
        once = true;
        c.validate();
      }

    } else {
      if (once) {
        c.removeAll();
        panel = new MyPanel(THA.WIDTH, THA.HEIGHT, ai, diff);
        c.setLayout(new BorderLayout());
        c.add(panel.returnNs(), BorderLayout.WEST);
        c.add(panel, BorderLayout.CENTER);
        c.add(btns, BorderLayout.SOUTH);
        c.add(panel.returnAmmo(), BorderLayout.EAST);
        c.validate();
        once = false;
      }
    }
    repaint();
  }