Ejemplo n.º 1
0
  // test de methode d'affichage avec google.lanterna
  public void affichageGraphique(Terminal terminal) {

    terminal.enterPrivateMode(); // mode d'edition du terminal
    terminal.clearScreen(); // on efface l'ecran

    for (Integer i = 1; i <= 8; i++) {
      // affichage des coordonnees au bord de l'ecran
      terminal.applyBackgroundColor(Terminal.Color.DEFAULT);
      terminal.applyForegroundColor(Terminal.Color.DEFAULT);
      terminal.moveCursor(i, 10);
      terminal.putCharacter(i.toString().charAt(0));
      terminal.moveCursor(10, i);
      terminal.putCharacter(i.toString().charAt(0));

      // changement de la couleur de fond de maniere alternative
      for (int j = 1; j <= 8; j++) {
        terminal.moveCursor(i, j);
        terminal.applyBackgroundColor(Terminal.Color.BLUE);
        if ((i + j) % 2 == 0) terminal.applyBackgroundColor(Terminal.Color.YELLOW);

        terminal.putCharacter(' ');
      }
    }
    Iterator<Piece> it = this.get_pieces().iterator();

    // affichage de chacune des pieces
    while (it.hasNext()) {
      Piece p = it.next();
      if (!p
          .get_estMange()) { // on n'affiche que les pièces qui ne sont pas mangées (i.e encore sur
                             // le plateau)
        terminal.moveCursor(p.get_coordonnees().get_x(), p.get_coordonnees().get_y());

        terminal.applyBackgroundColor(Terminal.Color.BLUE);
        if ((p.get_coordonnees().get_x() + p.get_coordonnees().get_y()) % 2 == 0)
          terminal.applyBackgroundColor(Terminal.Color.YELLOW);

        terminal.applyForegroundColor(Terminal.Color.BLACK);
        if (p.get_couleur().get_couleur() == "blanc")
          terminal.applyForegroundColor(Terminal.Color.WHITE);

        terminal.putCharacter(p.get_symbole().charAt(0));
      }
    }

    terminal.moveCursor(0, 0);
  }
Ejemplo n.º 2
0
  public static void main(String[] args) throws InterruptedException {
    Terminal terminal = TerminalFacade.createSwingTerminal();
    terminal.enterPrivateMode();
    terminal.clearScreen();
    terminal.moveCursor(10, 5);
    terminal.putCharacter('H');
    terminal.putCharacter('e');
    terminal.putCharacter('l');
    terminal.putCharacter('l');
    terminal.putCharacter('o');
    terminal.putCharacter('!');
    terminal.putCharacter(' ');
    terminal.putCharacter(ACS.HEART);
    terminal.putCharacter(ACS.SPADES);
    terminal.putCharacter(ACS.CLUB);
    terminal.putCharacter(ACS.DIAMOND);
    terminal.putCharacter(ACS.DOUBLE_LINE_CROSS);
    terminal.putCharacter(ACS.SINGLE_LINE_CROSS);
    terminal.putCharacter(ACS.DOUBLE_LINE_T_DOWN);
    terminal.putCharacter(ACS.SINGLE_LINE_VERTICAL);
    terminal.putCharacter(ACS.SINGLE_LINE_HORIZONTAL);
    terminal.moveCursor(10, 7);
    terminal.applySGR(Terminal.SGR.ENTER_BOLD);
    terminal.putCharacter('H');
    terminal.putCharacter('e');
    terminal.putCharacter('l');
    terminal.putCharacter('l');
    terminal.putCharacter('o');
    terminal.putCharacter('!');
    terminal.putCharacter(' ');
    terminal.putCharacter(ACS.HEART);
    terminal.putCharacter(ACS.SPADES);
    terminal.putCharacter(ACS.CLUB);
    terminal.putCharacter(ACS.DIAMOND);
    terminal.putCharacter(ACS.DOUBLE_LINE_CROSS);
    terminal.putCharacter(ACS.SINGLE_LINE_CROSS);
    terminal.putCharacter(ACS.DOUBLE_LINE_T_DOWN);
    terminal.putCharacter(ACS.SINGLE_LINE_VERTICAL);
    terminal.putCharacter(ACS.SINGLE_LINE_HORIZONTAL);
    terminal.moveCursor(10, 9);
    terminal.applySGR(Terminal.SGR.ENTER_UNDERLINE);
    terminal.putCharacter('H');
    terminal.putCharacter('e');
    terminal.applySGR(Terminal.SGR.EXIT_BOLD);
    terminal.putCharacter('l');
    terminal.applySGR(Terminal.SGR.EXIT_UNDERLINE);
    terminal.putCharacter('l');
    terminal.putCharacter('o');
    terminal.applySGR(Terminal.SGR.ENTER_UNDERLINE);
    terminal.putCharacter('!');
    terminal.putCharacter(' ');
    terminal.putCharacter(ACS.HEART);
    terminal.putCharacter(ACS.SPADES);
    terminal.putCharacter(ACS.CLUB);
    terminal.putCharacter(ACS.DIAMOND);
    terminal.putCharacter(ACS.DOUBLE_LINE_CROSS);
    terminal.putCharacter(ACS.SINGLE_LINE_CROSS);
    terminal.putCharacter(ACS.DOUBLE_LINE_T_DOWN);
    terminal.putCharacter(ACS.SINGLE_LINE_VERTICAL);
    terminal.putCharacter(ACS.SINGLE_LINE_HORIZONTAL);
    terminal.applySGR(Terminal.SGR.RESET_ALL);
    terminal.moveCursor(0, 0);

    Thread.sleep(5000);
    terminal.exitPrivateMode();
  }
Ejemplo n.º 3
0
 private static void putString(Terminal rawTerminal, String string) {
   for (int i = 0; i < string.length(); i++) rawTerminal.putCharacter(string.charAt(i));
 }
Ejemplo n.º 4
0
 // TODO add checkIntersection method,
 public void draw(Terminal terminal) {
   terminal.moveCursor(this.x, this.y);
   terminal.putCharacter(this.symbol);
   terminal.moveCursor(0, 0);
 }