Пример #1
0
  private void renderTextOverlay() {
    fsb.begin();

    String curStr;

    curStr = "Score " + player.score;
    TextBounds txtBounds = bigFont.getBounds(curStr);

    bigFont.setColor(Color.WHITE);
    bigFont.draw(fsb, curStr, 40, Globals.PSCR_H - txtBounds.height);

    curStr = "Shield " + player.shield;
    txtBounds = bigFont.getBounds(curStr);
    bigFont.draw(fsb, curStr, Globals.PSCR_W - 600, Globals.PSCR_H - txtBounds.height);

    curStr = "Health " + player.hp;
    txtBounds = bigFont.getBounds(curStr);
    bigFont.draw(
        fsb, curStr, Globals.PSCR_W - txtBounds.width - 100, Globals.PSCR_H - txtBounds.height);

    curStr = player.alive ? "ALIVE" : "DEAD";
    txtBounds = bigFont.getBounds(curStr);

    bigFont.setColor(player.alive ? Color.GREEN : Color.RED);
    bigFont.draw(fsb, curStr, Globals.PSCR_W - txtBounds.width, txtBounds.height + 40);

    if (player.gameover) {
      txtBounds = hugeFont.getBounds("GAME OVER!");
      float gx = (Globals.PSCR_W - txtBounds.width) / 2.0f;
      float gy = (Globals.PSCR_H - txtBounds.height) / 2.0f;
      hugeFont.draw(fsb, "GAME OVER!", gx, gy);
    }

    fsb.end();
  }
Пример #2
0
  @Override
  public void onDraw() {
    super.onDraw();

    J2hGame game = Game.getGame();

    Color color = Color.WHITE;

    topFont.setColor(color);
    botFont.setColor(color);

    String text = "Developer Menu";
    TextBounds bounds = topFont.getBounds(text);

    topFont.setColor(Color.BLACK);
    topFont.draw(game.batch, text, Game.getGame().getWidth() / 2 - bounds.width / 2, 900);

    topFont.setColor(Color.WHITE);
    topFont.draw(game.batch, text, Game.getGame().getWidth() / 2 - bounds.width / 2 - 3, 903);

    text = "-----";
    bounds = botFont.getBounds(text);

    botFont.setColor(Color.BLACK);
    botFont.draw(game.batch, text, Game.getGame().getWidth() / 2 - bounds.width / 2, 820);

    botFont.setColor(Color.WHITE);
    botFont.draw(game.batch, text, Game.getGame().getWidth() / 2 - bounds.width / 2 - 3, 823);
  }
Пример #3
0
  protected void setUp(String text, float x, float y) {
    alive = true;
    this.text = text;

    float sbWidth = font.getBounds(text).width + padX * 2,
        sbHeight = font.getBounds(text).height + padY * 2;

    if (sbWidth < 50) sbWidth = 50;

    yStretch =
        (float) Math.ceil(0.5f + (sbWidth / ((float) Gdx.app.getGraphics().getWidth() / 2f)));

    if (sbWidth > Gdx.app.getGraphics().getWidth() / 2) {
      sbWidth = Gdx.app.getGraphics().getWidth() / 2 + padX * 2;
      sbHeight = font.getBounds(text).height * yStretch + padY * yStretch;
    }

    setWidth(sbWidth);
    setHeight(sbHeight);

    wrapWidth = getWidth() - padX * 2;

    setOrigin(getWidth() / 2, getHeight() / 2);

    setX(x - getWidth() / 2);
    setY(y);

    setLife(0.6f + (float) text.length() * readSpeed);
  }
Пример #4
0
  // *** Methods for drawing text ***\\
  public static void drawString(
      SpriteBatch batch,
      String string,
      float x,
      float y,
      boolean centered,
      float scale,
      Color color) {
    // Check if the new scale is the same as the current one.
    if (font_.getScaleX() != scale || font_.getScaleY() != scale) font_.setScale(scale);

    // No need to check the colour, as that is done in the BitmapCache in the BitmapFont.
    font_.setColor(color);

    if (centered) {
      TextBounds bounds = font_.getBounds(string);
      float width = bounds.width;
      float height = bounds.height - font_.getAscent();

      x -= (width / 2);
      y -= (height / 2);
    }

    font_.draw(batch, string, x, y);
  }
Пример #5
0
  public void setItems(Object[] objects) {
    if (objects == null) throw new IllegalArgumentException("items cannot be null.");

    if (!(objects instanceof String[])) {
      String[] strings = new String[objects.length];
      for (int i = 0, n = objects.length; i < n; i++) strings[i] = String.valueOf(objects[i]);
      objects = strings;
    }

    this.items = (String[]) objects;
    selectedIndex = 0;

    Drawable bg = style.background;
    BitmapFont font = style.font;

    prefHeight =
        Math.max(
            bg.getTopHeight() + bg.getBottomHeight() + font.getCapHeight() - font.getDescent() * 2,
            bg.getMinHeight());

    float max = 0;
    for (int i = 0; i < items.length; i++) max = Math.max(font.getBounds(items[i]).width, max);
    prefWidth = bg.getLeftWidth() + bg.getRightWidth() + max;
    prefWidth =
        Math.max(
            prefWidth,
            max
                + style.listBackground.getLeftWidth()
                + style.listBackground.getRightWidth()
                + 2 * style.itemSpacing);

    invalidateHierarchy();
  }
Пример #6
0
  @Override
  public void draw(SpriteBatch batch, float parentAlpha) {
    Drawable background;
    if (list != null && list.getParent() != null && style.backgroundOpen != null)
      background = style.backgroundOpen;
    else if (clickListener.isOver() && style.backgroundOver != null)
      background = style.backgroundOver;
    else background = style.background;
    final BitmapFont font = style.font;
    final Color fontColor = style.fontColor;

    Color color = getColor();
    float x = getX();
    float y = getY();
    float width = getWidth();
    float height = getHeight();

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    background.draw(batch, x, y, width, height);
    if (items.length > 0) {
      float availableWidth = width - background.getLeftWidth() - background.getRightWidth();
      int numGlyphs =
          font.computeVisibleGlyphs(
              items[selectedIndex], 0, items[selectedIndex].length(), availableWidth);
      bounds.set(font.getBounds(items[selectedIndex]));
      height -= background.getBottomHeight() + background.getTopHeight();
      float textY = (int) (height / 2 + background.getBottomHeight() + bounds.height / 2);
      font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);
      font.draw(
          batch, items[selectedIndex], x + background.getLeftWidth(), y + textY, 0, numGlyphs);
    }

    // calculate screen coords where list should be displayed
    getStage().toScreenCoordinates(screenCoords.set(x, y), batch.getTransformMatrix());
  }
Пример #7
0
 @Override
 public boolean touchDown(int x, int y, int arg2, int arg3) {
   camera.unproject(mousePos.set(x, y, 0));
   if (backButton.contains(mousePos.x, mousePos.y)) {
     goBack();
   }
   ObjectMap.Entries<String, Rectangle> entries = bindingButtons.entries();
   boolean focusedAnOption = false;
   while (entries.hasNext()) {
     ObjectMap.Entry<String, Rectangle> entry = entries.next();
     Rectangle bounds = entry.value;
     camera.unproject(mousePos.set(x, y, 0));
     if (bounds.contains(mousePos.x, mousePos.y)) {
       this.focused = true;
       focusedAnOption = true;
       this.focusedBox.setY(bounds.y);
       this.focusedBox.setX(bounds.x);
       BitmapFont.TextBounds b = font.getBounds(entry.key);
       this.focusedBox.setHeight(b.height);
       this.focusedBox.setWidth(b.width);
       this.focusedAction = entry.key;
     }
   }
   if (!focusedAnOption) {
     this.focused = false;
   }
   return false;
 }
Пример #8
0
  public void writeLine(String text, BitmapFont font, float x, float y) {
    TextBounds bounds = font.getBounds(text);

    font.setColor(Color.BLACK);
    font.draw(Game.getGame().batch, text, x - bounds.width / 2 + 3, y);

    font.setColor(Color.WHITE);
    font.draw(Game.getGame().batch, text, x - bounds.width / 2, y + 3);
  }
Пример #9
0
  @Override
  public void draw() {
    // Draw actors
    super.draw();

    // Write title
    getBatch().begin();
    font.setScale(1f);
    font.draw(
        getBatch(),
        Game.TITLE,
        getWidth() / 2f - font.getBounds(Game.TITLE).width / 2f,
        getHeight() - 10f);
    font.setScale(0.5f);
    TextBounds bounds = font.getBounds("Highscore : " + Game.Save().highScore);
    font.draw(
        getBatch(), "Highscore : " + Game.Save().highScore, getWidth() - bounds.width, getHeight());
    getBatch().end();
  }
Пример #10
0
  public void addButton(String name, final Runnable stageRunner) {
    TextBounds bound = botFont.getBounds(name);
    final DeveloperMenu screen = this;

    getButtonManager()
        .addButton(
            new ShadowedTextButton(
                Game.getGame().getWidth() / 2 - bound.width / 2,
                START_Y - Y_ADD * index,
                botFont,
                name,
                new Runnable() {
                  @Override
                  public void run() {
                    TouhouSounds.Hud.OK.play();
                    Game.getGame().delete(screen);

                    for (StageObject obj : Game.getGame().getStageObjects()) {
                      obj.onDelete();
                    }

                    Game.getGame().getSpellcards().clear();
                    Game.getGame().getStageObjects().clear();
                    Game.getGame().clearObjects();

                    ((AllStarGame) Game.getGame()).score = 0;
                    ((AllStarGame) Game.getGame()).deaths = 0;

                    Game.getGame()
                        .spawn(
                            Marisa.newInstance(
                                Game.getGame().getWidth() / 2, Game.getGame().getHeight() / 2));

                    Game.getGame().setOutOfGame(false);
                    Game.getGame().setPaused(false);

                    stageRunner.run();

                    TouhouSounds.Hud.OK.play();

                    Menu parent = screen.getParent();

                    while (parent != null) {
                      Game.getGame().delete(parent);
                      parent = parent.getParent();
                    }
                  }
                }) {
              {
                setFont(botFont);
              }
            });

    index++;
  }
Пример #11
0
  public void render(float delta) {
    Gdx.gl.glClearColor(0.9f, 0.9f, 0.9f, 1);
    Gdx.gl.glClear(Gdx.gl.GL_COLOR_BUFFER_BIT);

    float font = text.getBounds(message).width;

    batch.begin();
    {
      text.draw(batch, message, (width / 2F) - (font / 2F), height - text.getCapHeight());
      replay.render(batch);
      menu.render(batch);
    }
    batch.end();
  }
Пример #12
0
  /**
   * Draws a String at the given coordinates. If <code>font == null</code> the Render's instance of
   * <code>BitmapFont</code> is used.
   *
   * @param batch
   * @param font
   * @param string
   * @param x
   * @param y
   * @param centered
   */
  public static void drawString(
      SpriteBatch batch, BitmapFont font, String string, float x, float y, boolean centered) {
    if (font == null) font = font_;

    if (centered) {
      TextBounds bounds = font.getBounds(string);
      float width = bounds.width;
      float height = bounds.height - font.getAscent();

      x -= (width / 2);
      y -= (height / 2);
    }

    font.draw(batch, string, x, y);
  }
Пример #13
0
 public void render() {
   //		System.out.println(font.getBounds(" ").width);
   float textWidth = font.getBounds(text).width;
   // float textHeight = font.getBounds(text).height;
   //		TextureRegion background = allocTextureRegion("grid");
   //		spriteBatch.setColor(0.0f, 0.0f, 0.0f, color.a * 0.7f);
   //		spriteBatch.draw(background,
   //				oringinX - textWidth * 0.5f - PAD, oringinY - PAD,
   //				textWidth + PAD * 2.0f, textHeight + PAD * 2.0f);
   //		spriteBatch.setColor(Color.WHITE);
   // font.get
   font.setColor(color);
   font.draw(spriteBatch, text, oringinX - textWidth * 0.5f, oringinY + font.getCapHeight());
   font.setColor(Color.WHITE);
 }
Пример #14
0
  protected void debugDrawUI() {
    if (Env.debug) {
      if (Env.drawFPS) {
        String fpsText = String.format("%d FPS", Gdx.graphics.getFramesPerSecond());
        TextBounds bounds = debugFont.getBounds(fpsText);
        batch.setProjectionMatrix(uiCamera.combined);
        batch.begin();
        debugFont.setColor(1.0f, 1.0f, 1.0f, 1.0f);
        debugFont.draw(batch, fpsText, uiViewport.getWorldWidth() - bounds.width - 20.0f, 20.0f);
        batch.end();
      }

      Table.drawDebug(Env.game.getStage());
    }
  }
Пример #15
0
  @Override
  public void render() {
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    BitmapFont.TextBounds textSize = font.getBounds(message);
    float x = screenWidth / 2 - textSize.width / 2;
    float y = screenHeight / 2 + textSize.height / 2;

    batch.begin();

    font.draw(batch, message, x, y);

    batch.end();
  }
Пример #16
0
 public ToggleBox(String text, Skin skin) {
   this.text = text;
   this.skin = skin;
   font = skin.getFont("default-font");
   checked = skin.getDrawable("check-on");
   active = skin.getDrawable("check-off");
   setTouchable(Touchable.enabled);
   addListener(
       new ClickListener() {
         public void clicked(InputEvent ev, float x, float y) {
           setSelected(!isSelected());
         }
       });
   TextBounds fb = font.getBounds(text);
   setSize(
       checked.getMinWidth() + pad + fb.width,
       Math.max(checked.getMinHeight(), font.getCapHeight()));
 }
Пример #17
0
  public void render(SpriteBatch sb, ShapeRenderer sr, Point location) {
    Color color;
    if (!enabled) color = new Color(0.533f, 0.533f, 0.533f, 1f);
    else if (selected) color = new Color(0.533f, 0.533f, 0.8f, 1f);
    else color = new Color(0.133f, 0.133f, 0.8f, 1f);

    float border = 5f, height = 20f;

    Rectangle size = parent.getDefaultSize();

    sr.begin(ShapeType.Filled);

    // Draw track
    sr.setColor(Color.BLACK);
    sr.rect(location.x - 2.5f, location.y - 2.5f, size.width + 5, 25);
    sr.setColor(color);
    sr.rect(location.x, location.y, size.width, 20);

    // Draw slider
    float cx =
        location.x + size.width * Math.min(1f * step * val, maxVal - minVal) / (maxVal - minVal);
    float width_ptr = 20f, height_ptr = 30f;
    sr.setColor(Color.BLACK);
    sr.rect(
        cx - (border + width_ptr) / 2f,
        location.y - (height_ptr - height + border) / 2f,
        width_ptr + border,
        height_ptr + border);
    sr.setColor(0.133f, 0.133f, 0.8f, 1f);
    sr.rect(cx - width_ptr / 2f, location.y - (height_ptr - height) / 2f, width_ptr, height_ptr);
    sr.end();

    // Label
    String label = "" + Math.min(val * step + minVal, maxVal);
    BitmapFont font = Root.getFont(24);
    TextBounds lBound = font.getBounds(label);
    float width_t = lBound.width;

    sb.begin();
    if (!label.isEmpty()) {
      font.draw(sb, label, location.x - width_t - 20, location.y + height);
    }
    sb.end();
  }
Пример #18
0
  public void setText(String text) {
    if (text == null) throw new IllegalArgumentException("text cannot be null.");

    BitmapFont font = style.font;

    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < text.length(); i++) {
      if (maxLength > 0 && buffer.length() + 1 > maxLength) {
        break;
      }
      char c = text.charAt(i);
      if (font.containsCharacter(c) && (filter == null || filter.acceptChar(this, c)))
        buffer.append(c);
    }

    this.text = buffer.toString();
    updateDisplayText();
    cursor = 0;
    clearSelection();

    textBounds.set(font.getBounds(displayText));
    textBounds.height -= font.getDescent() * 2;
    font.computeGlyphAdvancesAndPositions(displayText, glyphAdvances, glyphPositions);
  }
Пример #19
0
  private void drawAxes() {
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    batch.draw(axes, -virtualWidthHalf, -AXIS_WIDTH / 2, virtualWidth, AXIS_WIDTH);
    batch.draw(axes, -AXIS_WIDTH / 2, -virtualHeightHalf, AXIS_WIDTH, virtualHeight);

    TextBounds bounds = font.getBounds(String.valueOf((int) virtualHeightHalf));
    font.draw(batch, "-" + (int) virtualWidthHalf, -virtualWidthHalf + 3, -bounds.height / 2);
    font.draw(
        batch,
        String.valueOf((int) virtualWidthHalf),
        virtualWidthHalf - bounds.width,
        -bounds.height / 2);

    font.draw(
        batch,
        "-" + (int) virtualHeightHalf,
        bounds.height / 2,
        -virtualHeightHalf + bounds.height + 3);
    font.draw(
        batch, String.valueOf((int) virtualHeightHalf), bounds.height / 2, virtualHeightHalf - 3);
    font.draw(batch, "0", bounds.height / 2, -bounds.height / 2);
    batch.end();
  }
Пример #20
0
 public int computeTextWidth(CharSequence str) {
   return bitmapFont.getBounds(str).width;
 }
Пример #21
0
 public int computeTextWidth(CharSequence str, int start, int end) {
   return bitmapFont.getBounds(str, start, end).width;
 }
Пример #22
0
  @Override
  public void update(float dt) {
    if (!paused) {
      handleInput();
      if (!readyToFadeWhite) player.update(dt); // So player can be controlled upward from Sky
      else {
        // Lift player
        whiteOverlay += .3f * dt;
        player.getVelocity().add(0, -player.gravity / 2);
        player.getVelocity().scl(dt);
        player.getPosition().add(player.movement * dt, player.getVelocity().y);
        player.getVelocity().scl(1 / dt);
        float temp =
            player.normalize(
                -450, 200, (float) -Math.PI / 4f, (float) Math.PI / 4f, player.getVelocity().y);
        player.rotation = 25 * (float) Math.sin(temp);
        if (whiteOverlay > 1f) {
          dispose();
          Preferences p = Gdx.app.getPreferences(OwlCityTribute.GAME_PREFS);
          p.putInteger("level", 5);
          if (p.getInteger("maxlevel") < 5) {
            p.putInteger("maxlevel", 5);
          }
          p.flush();
          gsm.currentState = GameStateManager.SKY;
          this.gsm.setState(new Sky(this.gsm));
        }
      }
      fallen = player.getPosition().y == -OwlCityTribute.HEIGHT * .1f;

      if (!loss && fallen) {
        loss = true;
        gsm.push(new UponLoss(gsm));
      }

      note.update(dt);
      noteAnim.update(dt);
      noteRotation += 100f * dt;
      if (noteRotation > 360) noteRotation = 0;

      balloonFluctuation.update(dt);

      cam.position.x = player.getPosition().x + player.xOffset;
      float leftEdge = player.getPosition().x - (cam.viewportWidth / 2) + player.xOffset;

      // Check if note is hit
      if (!shrinking
          && Math.sqrt(
                  Math.pow(
                          (player.getPosition().x + player.getPlane().getWidth() * .75f)
                              - note.getPosition().x,
                          2)
                      + Math.pow(
                          (player.getPosition().y + (player.getPlane().getHeight() * .75f) / 2)
                              - (note.getPosition().y + noteAnim.getFrame().getRegionHeight() / 2),
                          2))
              < 40) {
        // Open textbox
        textCount++;
        textBox.prepare(
            sceneText.get(textCount).get(0),
            (sceneText.get(textCount).size() == 1) ? "" : sceneText.get(textCount).get(1),
            .1f);
        boxInitialized = true;

        // Set bounds
        int w = (int) font.getBounds(sceneText.get(textCount).get(0)).width;
        // int h = (int)(font.getBounds(sceneText.get(textCount).get(0)).height*2.5);
        int h =
            (int)
                (font.getBounds(sceneText.get(textCount).get(0)).height
                    * sceneText.get(textCount).size()
                    * 1.5);
        textBox.setBounds(
            w,
            h,
            (int) (OwlCityTribute.WIDTH * .65) - w / 2,
            (int) (OwlCityTribute.HEIGHT * .875) - h / 2);
        waiting = true;
        shrinking = true;
      } else if (note.getPosition().x < leftEdge - noteAnim.getFrame().getRegionWidth()
          && !waiting
          && textCount < sceneText.size() - 1
          && player.movement > player.maxMovement * .75) {
        note.getPosition().x = player.getPosition().x + cam.viewportWidth;
        note.setyOffset((int) (Math.random() * 100) + 200);
      }

      if (shrinking) {
        noteScale -= 2.5 * dt;
        if (noteScale < 0) {
          shrinking = false;
          noteScale = 1f;
          note.getPosition().x -= cam.viewportWidth;
        }
      }

      if (textBox.readyToUpdate) {
        if (!textBox.update(dt)) waiting = true;
        else {
          waiting = false;
          if (textCount < sceneText.size() - 1 && player.movement > player.maxMovement * .75) {
            note.getPosition().x = player.getPosition().x + cam.viewportWidth;
            note.setyOffset((int) (Math.random() * 100) + 200);
          }
        }
      }

      if (!fallen && boxInitialized && textCount == sceneText.size() - 1 && textBox.finished) {
        readyToFadeWhite = true;
      }

      // clouds
      for (int i = 0; i < clouds.size; i++) {
        clouds.get(i).update(dt);
        if (clouds.get(i).getPosition().x < leftEdge - cloud.getWidth()) {
          int index = (i == 0) ? clouds.size - 1 : i - 1;
          clouds.get(i).getPosition().x =
              (float) (clouds.get(index).getPosition().x + cam.viewportWidth * .8);
          clouds.get(i).yOffset =
              random.nextInt((int) (OwlCityTribute.HEIGHT * .1f))
                  + (int) (OwlCityTribute.HEIGHT * .75f);
        }
      }

      //        if(readyToFadeBlack){
      //            whiteValue  = (whiteValue > 0) ? whiteValue - .2f*dt : 0f;
      //            if(whiteValue == 0f){
      //                if(player.getPosition().y == -OwlCityTribute.HEIGHT*.1f){
      //                    dispose();
      //                    this.gsm.setState(new Sky(this.gsm));
      //                }
      //            }
      //        }
      // else{
      whiteValue = (whiteValue < 1f) ? whiteValue + .4f * dt : 1f;
      // }

      // Shimmer update
      for (int i = 0; i < NUM_SHIMMERS; i++) {
        shimmers.get(i).update(dt);
      }

      // Check brush
      for (int i = 0; i < brushmoving.size; i++) {
        brushmoving.get(i).MOVEMENT = -(player.movement / 5);
        brushmoving.get(i).update(dt);
        if (brushmoving.get(i).getPosition().x < leftEdge - brush.getWidth() * 1.5) {
          int index = (i == 0) ? brushmoving.size - 1 : i - 1;
          brushmoving.get(i).getPosition().x =
              brushmoving.get(index).getPosition().x + brush.getWidth();
          break;
        }
      }

      cam.update();
    }
  }
Пример #23
0
  {
    final DeveloperMenu screen = this;

    final J2hGame game = Game.getGame();

    final float startX = game.getMinX() + (game.getMaxX() - game.getMinX()) / 2;
    final float startY = Game.getGame().getHeight() - 150;

    addButton(
        "3D Background tester",
        new Runnable() {
          @Override
          public void run() {
            final Runnable run =
                new Runnable() {
                  @Override
                  public void run() {
                    Game.getGame().spawn(new MoonBG());
                  }
                };

            Getter getter =
                new Getter<TestScheme>() {
                  @Override
                  public TestScheme get() {
                    return new TestScheme() {
                      @Override
                      public GameFlowScheme getRestartInstance() {
                        return get();
                      }

                      @Override
                      public void startSpellcard() {
                        run.run();
                      }
                    };
                  }
                };

            Game.getGame().setScheme((GameFlowScheme) getter.get());

            Game.getGame().getScheme().start();
          }
        });

    final Getter<SpecialFlowScheme> getter =
        new Getter<SpecialFlowScheme>() {
          @Override
          public SpecialFlowScheme get() {
            DialogueFlowScheme holder =
                new DialogueFlowScheme(
                    new Getter<FaceToFaceDialogue>() {
                      @Override
                      public FaceToFaceDialogue get() {
                        final DDCDialogueTextBalloon balloon = new DDCDialogueTextBalloon();

                        final DialogueParticipant left = new MarisaDP();
                        final DialogueParticipant right = new MarisaDP();

                        final FaceToFaceDialogue d = new FaceToFaceDialogue(balloon, left, right);

                        String ipsum =
                            "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a luctus risus, vel fringilla metus. Nunc commodo dui sed lectus viverra, in tincidunt felis tincidunt. Mauris metus ex, bibendum et nulla eu, pharetra iaculis arcu. Curabitur at malesuada libero, non bibendum tellus. Maecenas non luctus est. Suspendisse id lectus nisi. Donec pharetra orci ultrices, aliquam magna quis, iaculis lorem. Sed imperdiet feugiat pretium. In fringilla diam magna, vulputate dignissim lectus hendrerit eget. Suspendisse potenti. Nulla sit amet nisi vitae mi pharetra volutpat. Sed erat quam, rhoncus id elit id, sollicitudin laoreet purus. Donec sodales eleifend ex, a interdum elit consequat non. Maecenas nibh tellus, commodo sed risus eu, imperdiet commodo dui. Nam id mollis leo, vitae congue eros. Phasellus eget libero at eros laoreet commodo nec in eros.";

                        String[] array = ipsum.split("\\. ");

                        DialogueMaker m = new DialogueMaker(left);

                        m.text("Hey, I'm about to say something really long and boring")
                            .enterStage()
                            .nextDialogue(right);
                        m.text("k, ignored you anyways.")
                            .face(MarisaDPFace.SIGH)
                            .enterStage()
                            .nextDialogue(left);

                        for (int i = 0; i < array.length - 2; i += 2) {
                          String str = array[i] + "\n" + array[i + 1];

                          m.text(str).face(MarisaDPFace.CONFUSED).nextDialogue(right);

                          String[] replies = {
                            "Very nice...",
                            "Alright.",
                            "Interesting...",
                            "Good for you.",
                            "Uhu",
                            "Sooooo innnnteerreeessstttinnggg... -ZZZZ-"
                          };

                          m.text(replies[(int) (Math.random() * replies.length)])
                              .face(MarisaDPFace.SIGH)
                              .nextDialogue(left);
                        }

                        m.text("Remember to take it easy!")
                            .face(MarisaDPFace.YUKKURI)
                            .speechBubbleType(DDCBalloonType.SCREAM)
                            .nextDialogue(right);
                        m.text("What was that!?").face(MarisaDPFace.IDIOCY);

                        d.addDialogue(m.getDialogue());

                        return d;
                      }
                    });

            return holder;
          }
        };

    addButton(
        "Simple Dialogue between 2xMarisa",
        new Runnable() {
          @Override
          public void run() {
            Getter<GameFlowScheme> schemeGetter =
                new Getter<GameFlowScheme>() {
                  @Override
                  public GameFlowScheme get() {
                    return new GameFlowScheme() {
                      @Override
                      public GameFlowScheme getRestartInstance() {
                        return get();
                      }

                      @Override
                      public void runScheme() {
                        getter.get().executeFight(this);
                      }
                    };
                  }
                };

            Game.getGame().setScheme(schemeGetter.get());

            Game.getGame().getScheme().start();
          }
        });

    TextBounds bound = botFont.getBounds("Exit");
    getButtonManager()
        .addButton(
            new ShadowedTextButton(
                Game.getGame().getWidth() / 2 - bound.width / 2,
                100,
                botFont,
                "Exit",
                new Runnable() {
                  @Override
                  public void run() {
                    TouhouSounds.Hud.OK.play();

                    Game.getGame().delete(screen);
                  }
                }) {
              {
                setFont(botFont);
              }
            });

    setZIndex(J2hGame.GUI_Z_ORDER + 2);
  }
Пример #24
0
  @Override
  public void render(SpriteBatch sb) {
    float leftEdge = player.getPosition().x - cam.viewportWidth / 2 + player.xOffset;
    sb.setProjectionMatrix(cam.combined);
    sb.begin();
    sb.setColor(whiteValue, whiteValue, whiteValue, 1f);
    sb.draw(
        background,
        player.getPosition().x - cam.viewportWidth / 2 + player.xOffset,
        0,
        cam.viewportWidth,
        cam.viewportHeight);
    sb.end();

    Gdx.gl.glEnable(GL20.GL_BLEND);

    sr.setProjectionMatrix(cam.combined);
    sr.begin(ShapeRenderer.ShapeType.Filled);
    // Draw sparkles
    for (int i = 0; i < NUM_SHIMMERS; i++) {
      sr.setColor(
          whiteValue,
          whiteValue,
          whiteValue,
          Math.abs((float) Math.sin(Math.PI * shimmers.get(i).life / Shimmer.MAX_LIFE)));
      sr.circle(
          shimmers.get(i).x + player.getPosition().x - cam.viewportWidth / 2 + player.xOffset,
          shimmers.get(i).y,
          (float) Math.abs(Math.sin(Math.PI * shimmers.get(i).life / Shimmer.MAX_LIFE))
              * shimmers.get(i).size);
    }
    sr.end();
    sb.begin();
    // Draw pause
    sb.draw(
        pauseButton,
        cam.position.x - cam.viewportWidth / 2 + cam.viewportWidth * .05f,
        cam.viewportHeight * .95f - pauseButton.getHeight());

    // Draw balloon
    sb.draw(
        balloon,
        cam.position.x
            - cam.viewportWidth / 2
            + balloonFluctuation.getPosition().x
            - balloon.getWidth() / 2,
        balloonFluctuation.getPosition().y - balloon.getHeight() / 2);

    // Draw text
    if (!textBox.finished) {
      sb.end();
      Gdx.gl.glEnable(GL20.GL_BLEND);
      sr.setProjectionMatrix(cam.combined);
      sr.setAutoShapeType(true);
      sr.begin();
      sr.set(ShapeRenderer.ShapeType.Filled);
      sr.setColor(1f, 1f, 1f, (textBox.alpha > .4f) ? .4f : textBox.alpha);
      // Vert
      sr.rect(
          leftEdge + textBox.x - textBox.width / 2 - textBox.padding / 2,
          textBox.y - textBox.height / 2,
          textBox.width + textBox.padding,
          textBox.height);
      // Horiz
      sr.rect(
          leftEdge + textBox.x - textBox.width / 2,
          textBox.y + textBox.height / 2,
          textBox.width,
          textBox.padding / 2);
      sr.rect(
          leftEdge + textBox.x - textBox.width / 2,
          textBox.y - textBox.height / 2,
          textBox.width,
          -textBox.padding / 2);
      sr.end();
      sb.begin();
      if (textBox.boxOpened) {
        font.setColor(1f, 1f, 1f, textBox.alpha);
        // First line
        font.draw(
            sb,
            textBox.firstLineBuffer,
            (leftEdge + textBox.x - (textBox.width / 2)),
            textBox.y + textBox.height / 2);
        // Second line
        font.draw(
            sb,
            textBox.secondLineBuffer,
            (leftEdge + textBox.x - (textBox.width / 2)),
            textBox.y
                + textBox.height / 2
                - font.getBounds(sceneText.get(textCount).get(0)).height * 1.5f);
      }
    }

    // clouds
    sb.setColor(whiteValue, whiteValue, whiteValue, .75f);
    sb.draw(cloud, clouds.get(0).getPosition().x, clouds.get(0).getPosition().y);
    sb.draw(cloud, clouds.get(1).getPosition().x, clouds.get(1).getPosition().y);

    // draw note
    sb.setColor(whiteValue, whiteValue * (230f / 255f), whiteValue, 1f);
    sb.draw(
        noteAnim.getFrame(),
        note.getPosition().x,
        note.getPosition().y,
        noteAnim.getFrame().getRegionWidth() / 2,
        noteAnim.getFrame().getRegionHeight() / 2,
        noteAnim.getFrame().getRegionWidth(),
        noteAnim.getFrame().getRegionHeight(),
        noteScale,
        noteScale,
        noteRotation);

    sb.setColor(whiteValue, whiteValue, whiteValue, 1f);
    // Draw player
    sb.draw(
        planeRegion,
        player.getPosition().x,
        player.getPosition().y,
        planeRegion.getRegionWidth() / 2,
        planeRegion.getRegionHeight() / 2,
        player.getPlane().getWidth() * .75f,
        player.getPlane().getHeight() * .75f,
        1,
        1,
        player.rotation);

    sb.setColor(whiteValue, whiteValue, whiteValue, 1f);

    // draw brush
    for (FluctuatingObject f : brushmoving) {
      sb.draw(brush, f.getPosition().x, f.getPosition().y);
    }

    sb.end();
    // HUD
    Matrix4 uiMatrix = cam.combined.cpy();
    uiMatrix.setToOrtho2D(0, 0, OwlCityTribute.WIDTH, OwlCityTribute.HEIGHT);

    sb.setProjectionMatrix(uiMatrix);
    sb.begin();
    sb.draw(vignette, 0, 0, cam.viewportWidth, cam.viewportHeight);
    sb.end();
    sr.begin(ShapeRenderer.ShapeType.Filled);
    Gdx.gl.glEnable(GL20.GL_BLEND);

    sr.setColor(1f, 1f, 1f, whiteOverlay);
    sr.setProjectionMatrix(cam.combined);
    sr.rect(leftEdge, 0, cam.viewportWidth, cam.viewportHeight);
    sr.end();
  }