Example #1
0
  @Override
  public void show() {
    super.show();

    table = new Table();
    table.setFillParent(true);

    TextButtonStyle bStyle = new TextButtonStyle();
    bStyle.font = Cache.getFont(48);
    bStyle.fontColor = Color.LIGHT_GRAY;
    final TextButton buttonPlay = new TextButton("PLAY", bStyle);

    buttonPlay.pad(20);
    table.add(buttonPlay);

    table.row();
    final TextButton buttonCredits = new TextButton("CREDITS", bStyle);

    buttonCredits.pad(20);
    table.add(buttonCredits);
    table.row();
    final TextButton buttonExit = new TextButton("EXIT", bStyle);

    buttonExit.pad(20);
    table.add(buttonExit);
    table.pad(150, 0, 0, 0);
    getStage().addActor(table);

    buttonPlay.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            onExit(new LevelSelect(getGame()), buttonPlay, buttonCredits, buttonExit);
          }
        });
    buttonCredits.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            onExit(new Credits(getGame()), buttonPlay, buttonCredits, buttonExit);
          }
        });
    buttonExit.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });
    Tween.set(buttonPlay, ActorAccessor.ALPHA).target(0).start(getTweenManager());
    Tween.to(buttonPlay, ActorAccessor.ALPHA, 1).target(1).start(getTweenManager());
    Tween.set(buttonCredits, ActorAccessor.ALPHA).target(0).start(getTweenManager());
    Tween.to(buttonCredits, ActorAccessor.ALPHA, 1).target(1).delay(0.1f).start(getTweenManager());
    Tween.set(buttonExit, ActorAccessor.ALPHA).target(0).start(getTweenManager());
    Tween.to(buttonExit, ActorAccessor.ALPHA, 1).target(1).delay(0.2f).start(getTweenManager());

    Gdx.input.setInputProcessor(new InputMultiplexer(getStage(), new TouchDetector(this)));
  }
Example #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();
  }
Example #3
0
  // this is the actual game thread start
  // it loops for each complete game played
  public void run() {
    while (true) {

      Screen ss = new Screen(this);
      ss.setBackground(new Color(0, 0, 0));
      ss.setLayout(new BorderLayout());
      {
        TitleScreen ts = new TitleScreen(this);
        ts.setBackground(new Color(0, 0, 0));
        ss.add("Center", ts);
      }
      MessagePanel mp = new MessagePanel(this);
      Game.messagepanel = mp;
      ss.add("South", mp);

      switchScreen(ss);

      repaint();

      if (!isapplet && gameFileFromCommandLine != null) {
        Game.message("Loading " + gameFileFromCommandLine + " game file...");
        final String ret = Game.tryToRestore(gameFileFromCommandLine);
        if (ret == null) {
          setupScreen();
          getScreen().mainLoop();
          continue;
        }

        Game.message("Load game failed: " + ret);
        Game.message("Press any key (except Tab) to continue");
        Game.getInput(false); // !!! not very good - this does not
        // recognize Tab key, for instance

      }

      Game.message("");
      Game.message(
          "Welcome to Tyrant. You are playing version " + Game.VERSION + ". Would you like to:");
      Game.message(" [a] Create a new character");
      Game.message(" [b] Load a previously saved game");
      Game.message(" [c] Play in debug mode");
      Game.message(" [d] QuickStart debug mode");
      Game.message(" [e] Edit a map");
      mp.repaint();

      // create lib in background
      Game.asynchronousCreateLib();

      char c = Game.getOption("abcdeQ");

      Game.setDebug(false);
      Game.visuals = true;

      if (c == 'b') {
        if (Game.restore()) {
          setupScreen();
          getScreen().mainLoop();
        }

      } else if (c == 'c') {
        // do hero creation
        Game.create();
        Thing h = createHero(true);
        if (h == null) continue;

        Game.setDebug(true);
        setupScreen();
        gameStart();

      } else if (c == 'e') {
        // Designer
        Game.message("");
        Game.message("Launching Designer...");
        mikera.tyrant.author.Designer.main(new String[] {"embedded"});
        continue;

      } else {

        Game.create();
        Thing h = createHero(true);

        if (h == null) continue;

        // first display starting info....
        InfoScreen l =
            new InfoScreen(
                this,
                "                                 Introduction\n"
                    + "\n"
                    + "Times are hard for the humble adventurer. Lawlessness has ravaged the land, and few can afford to pay for your services.\n"
                    + "\n"
                    + "After many weeks of travel, you find yourself in the valley of North Karrain. This region has suffered less badly from the incursions of evil, and you hear that some small towns are still prosperous. Perhaps here you can find a way to make your fortune.\n"
                    + "\n"
                    + "After a long day of travel, you see a small inn to the west. Perhaps this would be a good place to meet some and learn some more about these strange lands.\n"
                    + "\n"
                    + "                           [ Press a key to continue ]\n"
                    + "\n"
                    + "\n"
                    + "\n"
                    + "\n"
                    + "\n");

        l.setForeground(new Color(192, 160, 64));
        l.setBackground(new Color(0, 0, 0));
        switchScreen(l);
        Game.getInput();
        setupScreen();
        gameStart();

        // Debug mode should not start when pressing Enter!!
        // Game.create();
        // Game.setDebug(true);
        // createHero(false);
        // setupScreen();
        // gameStart();
      }
    }
  }
Example #4
0
 @Override
 public void dispose() {
   super.dispose();
 }
Example #5
0
 @Override
 public void resize(int width, int height) {
   super.resize(width, height);
   table.invalidateHierarchy();
 }