Пример #1
0
  public Model() {
    if (created) {
      JOptionPane.showMessageDialog(
          null,
          "Only one mazinator game may be running at any given time",
          "",
          JOptionPane.ERROR_MESSAGE);
      System.exit(1);
    }

    created = true;
    screens[Screens.HOME] =
        new Menu(
            this,
            Preferences.getColor(),
            new DrawableString(
                80, 80, "mazinator", Preferences.getWallsColor(), Preferences.getLargeFont()),
            new MenuOption[] {
              new MenuOption(
                  this,
                  Preferences.getColor(),
                  Preferences.getWallsColor(),
                  new Rectangle(0, 100, Preferences.getWindowWidth(), 100),
                  new DrawableString(
                      90,
                      155,
                      "play game",
                      Preferences.getWallsColor(),
                      Preferences.getMediumFont()),
                  new DrawableString(
                      90, 155, "play game", Preferences.getColor(), Preferences.getMediumFont())) {
                @Override
                protected void onClick() {
                  getModel().setScreen(Screens.GAME);
                }
              },
              new MenuOption(
                  this,
                  Preferences.getColor(),
                  Preferences.getWallsColor(),
                  new Rectangle(0, 200, Preferences.getWindowWidth(), 100),
                  new DrawableString(
                      90,
                      255,
                      "instructions",
                      Preferences.getWallsColor(),
                      Preferences.getMediumFont()),
                  new DrawableString(
                      90,
                      255,
                      "instructions",
                      Preferences.getColor(),
                      Preferences.getMediumFont())) {
                @Override
                protected void onClick() {
                  getModel().setScreen(Screens.INSTRUCTIONS);
                }
              },
              new MenuOption(
                  this,
                  Preferences.getColor(),
                  Preferences.getWallsColor(),
                  new Rectangle(0, 300, Preferences.getWindowWidth(), 100),
                  new DrawableString(
                      90,
                      355,
                      "preferences",
                      Preferences.getWallsColor(),
                      Preferences.getMediumFont()),
                  new DrawableString(
                      90,
                      355,
                      "preferences",
                      Preferences.getColor(),
                      Preferences.getMediumFont())) {
                @Override
                protected void onClick() {
                  getModel().setScreen(Screens.PREFERENCES);
                }
              }
            });
    screens[Screens.GAME] = game;
    screens[Screens.INSTRUCTIONS] = new Instructions(this);
    screens[Screens.PREFERENCES] = new Preferences(this);
    currentScreen = screens[Screens.HOME];

    start();
  }