Ejemplo n.º 1
0
  public void Inicializar(com.juegospichurria.modelo.Mapa mapa, int filaActivo, int columnaActivo) {

    this.mapa = mapa;

    fuente = new BitmapFont();
    fuente.setColor(new Color(1, 1, 1, 1));
    fuente.scale(.1f);

    estado = new Stage(new FitViewport(qbox.Pantalla.ANCHO, qbox.Pantalla.ALTO));

    this.filaActivo = filaActivo;
    this.columnaActivo = columnaActivo;

    cuadrosActores = new Array<com.juegospichurria.actores.Cuadro>();

    int index = 0;
    for (com.juegospichurria.modelo.Cuadro cuadro : this.mapa.getCuadros()) {

      com.juegospichurria.actores.Cuadro cuadrillo =
          new com.juegospichurria.actores.Cuadro(cuadro, this);
      cuadrosActores.add(cuadrillo);
      estado.addActor(cuadrosActores.get(index));
      index++;
    }

    com.juegospichurria.actores.Cuadro.cuadroActivo = obtenerActivo();

    estado.addActor(reset);
  }
Ejemplo n.º 2
0
 public int drawText(AnimationState as, int x, int y, CharSequence str, int start, int end) {
   FontState fontState = evalFontState(as);
   x += fontState.offsetX;
   y += fontState.offsetY + yOffset;
   bitmapFont.setColor(renderer.getColor(fontState.color));
   return bitmapFont.draw(renderer.batch, str, x, y, start, end).width;
 }
Ejemplo n.º 3
0
    @Override
    public void draw(SpriteBatch batch, float parentAlpha) {
      final Drawable listBackground = style.listBackground;
      final Drawable listSelection = style.listSelection;
      final BitmapFont font = style.font;
      final Color fontColor = style.fontColor;

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

      Color color = getColor();
      batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
      listBackground.draw(batch, x, y, width, height);

      width -= listBackground.getLeftWidth() + listBackground.getRightWidth();
      x += listBackground.getLeftWidth();
      float posY = height - listBackground.getTopHeight();
      for (int i = 0; i < items.length; i++) {
        if (listSelectedIndex == i) {
          listSelection.draw(batch, x, y + posY - itemHeight, width, itemHeight);
        }
        font.setColor(fontColor.r, fontColor.g, fontColor.b, color.a * fontColor.a * parentAlpha);
        font.draw(batch, items[i], x + textOffsetX, y + posY - textOffsetY);
        posY -= itemHeight;
      }
    }
Ejemplo n.º 4
0
  public void draw(SpriteBatch batch) {
    batch.draw(
        /*Texture*/ sprite, /*x*/
        x - originX + dOffX, /*y*/
        y - originY + dOffY, /*originX*/
        originX, /*originY*/
        originY, /*width*/
        dWidth, /*height*/
        dHeight, /*scaleX*/
        1, /*scaleY*/
        1, /*rotation*/
        angle, /*uselss shit to the right*/
        0,
        0,
        sprite.getWidth(),
        sprite.getHeight(),
        flipX,
        flipY);

    font.draw(
        batch,
        Integer.toString(effect.getNum()),
        (float) (x + 32 - font.getScaleX() * (Math.floor(Math.log10(effect.getNum())) + 1) * 7) - 4,
        y + font.getScaleY() * 12 + 1);
  }
Ejemplo n.º 5
0
  @Override
  public void render(float delta) {
    update(delta);

    Gdx.gl20.glClear(
        GL20.GL_COLOR_BUFFER_BIT
            | (Gdx.graphics.getBufferFormat().coverageSampling
                ? GL20.GL_COVERAGE_BUFFER_BIT_NV
                : 0));
    Gdx.gl20.glClearColor(0.0f, 0.0f, 0.1f, 1.0f);

    universe.render();

    pauseMenuBatch.begin();
    if (paused) {
      pauseMenuBatch.draw(
          pauseBackground, 0, UltranautGame.HEIGHT / 2 - 200, UltranautGame.WIDTH, 400);
      pauseFont.draw(
          pauseMenuBatch,
          "Stasis",
          UltranautGame.WIDTH / 2 - new GlyphLayout(pauseFont, "Stasis").width / 2,
          UltranautGame.HEIGHT / 2 + 150);
      resume.draw(pauseMenuBatch);
      mainMenu.draw(pauseMenuBatch);
      exit.draw(pauseMenuBatch);
    }

    if (UltranautGame.debug) {
      pauseFont.draw(
          pauseMenuBatch, Gdx.graphics.getFramesPerSecond() + "fps", 5, Gdx.graphics.getHeight());
    }
    pauseMenuBatch.end();
  }
Ejemplo n.º 6
0
  @Override
  public void render(float delta) {
    if (this.handleInput(delta)) {
      myGame.setScreen(BaseGame.screens.get("main"));
      return;
    }

    // Make a black background
    if (Settings.getRetro()) {
      GL10 g1 = Gdx.graphics.getGL10();
      Gdx.gl.glClearColor(0, 0, 0, 1);
      g1.glClear(GL20.GL_COLOR_BUFFER_BIT);
    } else {
      GL10 g1 = Gdx.graphics.getGL10();
      Gdx.gl.glClearColor(.19f, .19f, .19f, 1f);
      g1.glClear(GL20.GL_COLOR_BUFFER_BIT);
    }

    float dpi = Gdx.graphics.getDensity() * 160f;
    float inchHeight = ((float) Gdx.graphics.getHeight()) / dpi;

    spriteBatch.begin();
    font.setScale(2 * dpi * (inchHeight / 22f) / 72f);
    font.draw(spriteBatch, "High Scores", xx * .40f, yy * .98f);
    font.setScale(dpi * (inchHeight / 22f) / 72f);
    for (int i = 0; i < 10; i++) {
      font.draw(spriteBatch, scores[i][0], xx * .05f, yy * (.85f - i * .08f));
      font.draw(spriteBatch, scores[i][1], xx * .20f, yy * (.85f - i * .08f));
      font.draw(spriteBatch, scores[i][2], xx * .70f, yy * (.85f - i * .08f));
    }
    spriteBatch.end();
  }
Ejemplo n.º 7
0
 @Override
 public void dispose() {
   stage.dispose();
   font60.dispose();
   white36nonoFont.dispose();
   font100orange.dispose();
 }
Ejemplo n.º 8
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();
  }
Ejemplo n.º 9
0
  public static void dispose() {
    texture.dispose();
    bgTexture.dispose();
    bgBackTexture.dispose();

    robotoLt.dispose();
    robotoBlk.dispose();
    panel.dispose();
    fontFilter.dispose();
    fontFilter2.dispose();
    menuBack.dispose();
    smoke.dispose();
    fbShare.dispose();

    collision.dispose();
    jump.dispose();
    jumpSound.dispose();
    dblJump.dispose();
    milestone50.dispose();
    run.dispose();
    hit.dispose();
    milestone.dispose();
    milestone50.dispose();
    select.dispose();
    highScore.dispose();

    smokeParticle.dispose();
    starParticle.dispose();
    platform.dispose();
    nanoRun.dispose();
    //		gpgsAtlas.dispose();

  }
Ejemplo n.º 10
0
  public GameRenderer(Viewport viewport, Camera camera, GameEngine engine) {
    this.viewport = viewport;
    this.camera = camera;
    this.engine = engine;

    shapeRenderer = new MyShapeRenderer();
    shapeRenderer.setAutoShapeType(true);

    spriteBatch = new SpriteBatch();
    font = new BitmapFont();
    font.setColor(Color.WHITE);
    font.setUseIntegerPositions(false);
    font.getData().setScale(0.01f);
    shadowBatch = new ModelBatch(new DepthShaderProvider());

    ShaderProgram.pedantic = false;
    final String vertUber = Gdx.files.internal("shaders/uber.vert").readString();
    final String fragUber = Gdx.files.internal("shaders/uber.frag").readString();
    modelBatch =
        new ModelBatch(
            new DefaultShaderProvider(vertUber, fragUber) {
              @Override
              protected Shader createShader(final Renderable renderable) {
                return new UberShader(renderable, config);
              }
            });
  }
Ejemplo n.º 11
0
 @Override
 public void render(float delta) {
   if (assets.update()) // Updates assets loading and returns true is finished
   {
     Gdx.app.log("ProjectOne", "All assets loaded successfully ...");
     // game.setScreen(new MainMenu(game, assets)); // Loads main menu screen after loading assets
     game.setScreen(
         new GameScreen(
             game, assets,
             0)); // If anything pressed or touched (android) moves on and it's playtime :) (loads
     // 0 level)
   } else {
     float progress = assets.getProgress() * 100;
     Gdx.gl.glClearColor(0f, 0f, 0f, 1);
     Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
     batch.begin();
     font.draw(
         batch, Float.toString(progress) + " %", 400, 240); // Progress "bar" (percentage for now)
     font.draw(
         batch,
         Integer.toString(assets.getLoadedAssets())
             + " loaded / "
             + Integer.toString(assets.getQueuedAssets())
             + " to go ...",
         360,
         220);
     batch.end();
   }
 }
Ejemplo n.º 12
0
  @Override
  public void render(float arg0) {
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    camera.update();
    if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) {
      if (focused) {
        focused = false;
      } else {
        goBack();
      }
    }

    if (focused) {
      shapeRenderer.begin(ShapeType.FilledRectangle);
      Color c = new Color(0.15f, 0.4f, 0.15f, 1f);
      shapeRenderer.setColor(c);
      shapeRenderer.filledRect(focusedBox.x, focusedBox.y, focusedBox.width, focusedBox.height);
      shapeRenderer.end();
    }

    batch.begin();
    ObjectMap.Entries<String, Rectangle> it = bindingButtons.entries();
    // draw back button text
    font.draw(batch, "Back", backButton.x, backButton.y + backButton.height);
    // draw option texts
    while (it.hasNext()) {
      ObjectMap.Entry<String, Rectangle> entry = it.next();
      Rectangle bounds = entry.value;
      font.draw(batch, entry.key, bounds.x, bounds.y + bounds.height);
      Binding binding = game.getBindings().get(entry.key);
      font.draw(batch, binding.character, bounds.x + 200.0f, bounds.y + bounds.height);
    }
    batch.end();
  }
Ejemplo n.º 13
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);
  }
 public BitmapFont getFont(String id, String fileFNT, String filePNG, Color color, float scale) {
   BitmapFont font =
       new BitmapFont(Gdx.files.internal(fileFNT), Gdx.files.internal(filePNG), false);
   font.setColor(color);
   // font.setScale(scale);
   return font;
 }
Ejemplo n.º 15
0
  @Override
  public void render() {
    red.a = (red.a + Gdx.graphics.getDeltaTime() * 0.1f) % 1;

    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    spriteBatch.begin();
    logoSprite.draw(spriteBatch);
    switch (renderMode) {
      case 0:
        font.getData().setScale(1);
        renderNormal("normal");
        break;
      case 1:
        font.getData().setScale(1);
        renderCached();
        break;
      case 2:
        font.getData().setScale(red.a + 0.5f);
        renderNormal("normal scaled");
        break;
      case 3:
        font.getData().setScale(1);
        renderCachedScaled();
        break;
    }
    spriteBatch.end();
  }
Ejemplo n.º 16
0
    public void draw(SpriteBatch batch, float parentAlpha) {
      super.draw(batch, parentAlpha);

      (selected ? checked : active)
          .draw(batch, getX(), getY(), checked.getMinWidth(), checked.getMinHeight());
      font.draw(batch, text, getX() + checked.getMinWidth() + pad, getY() + font.getCapHeight());
    }
Ejemplo n.º 17
0
 public void render(SpriteBatch batch) {
   font.draw(
       batch,
       text,
       bounds.getX(),
       bounds.getY() + ((bounds.getHeight() / 2F) + (font.getLineHeight() / 4F)));
 }
Ejemplo n.º 18
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());
  }
Ejemplo n.º 19
0
 @Override
 public void dispose() {
   palco.dispose();
   foneBotoes.dispose();
   fonteTitulo.dispose();
   texturaBotao.dispose();
   texturaBotaoPressionado.dispose();
 }
Ejemplo n.º 20
0
 public void drawFont(String text, int x, int y, boolean center) {
   layout.setText(font, text);
   float w = layout.width;
   float h = layout.height;
   if (center) {
     font.draw(batch, text, x - w / 2, y - h / 2);
   } else font.draw(batch, text, x, y);
 }
Ejemplo n.º 21
0
 public AssetFonts() {
   // create three fonts using Libgdx's 15px bitmap font
   defaultSmall = new BitmapFont(Gdx.files.internal("font/arial-15.fnt"), false);
   // set font sizes
   defaultSmall.getData().setScale(2.5f);
   // enable linear texture filtering for smooth fonts
   defaultSmall.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
 }
 @Override
 public void draw(Batch batch, float parentAlpha) {
   font.setScale(getScaleX());
   font.setColor(this.getColor());
   font.drawWrapped(batch, text, getX(), getY(), getWidth());
   font.setColor(Color.WHITE);
   font.setScale(1);
 }
Ejemplo n.º 23
0
  /**
   * Helper function to actually render the text.
   *
   * @param batch the spritebatch to use.
   * @param message The string to add.
   * @param x The x location.
   * @param y The y location.
   * @param color The colour to render the text as.
   * @param font The font to use.
   */
  private void renderText(
      SpriteBatch batch, String message, float x, float y, Color color, BitmapFont font) {
    GlyphLayout layout =
        new GlyphLayout(font, message, Color.BLACK, width - paddingX * 2, Align.left, false);

    font.draw(batch, layout, x + paddingX, y + height + paddingY - 2);
    layout.setText(font, message, color, width - paddingX * 2, Align.left, false);
    font.draw(batch, layout, x + paddingX, y + height + paddingY);
  }
Ejemplo n.º 24
0
 @Override
 public void dispose() {
   bigFont.dispose();
   hugeFont.dispose();
   sb.dispose();
   world.dispose();
   player.dispose();
   Globals.atlas.dispose();
 }
Ejemplo n.º 25
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);
  }
Ejemplo n.º 26
0
  public static void dispose() {
    texture.dispose();
    dead.dispose();
    flap.dispose();
    coin.dispose();

    font.dispose();
    shadow.dispose();
  }
Ejemplo n.º 27
0
  @Override
  public void create() {
    font = new BitmapFont();
    font.setColor(1f, 0f, 0.05f, 1f);
    font.setScale(1.2f);

    project = ProjectManager.getInstance().getCurrentProject();
    pathForScreenshot = Utils.buildProjectPath(project.getName()) + "/";

    virtualWidth = project.getXmlHeader().virtualScreenWidth;
    virtualHeight = project.getXmlHeader().virtualScreenHeight;

    virtualWidthHalf = virtualWidth / 2;
    virtualHeightHalf = virtualHeight / 2;

    stage = new Stage(virtualWidth, virtualHeight, true);
    batch = stage.getSpriteBatch();

    Gdx.gl.glViewport(0, 0, ScreenValues.SCREEN_WIDTH, ScreenValues.SCREEN_HEIGHT);
    initScreenMode();

    sprites = project.getSpriteList();
    for (Sprite sprite : sprites) {
      sprite.resetSprite();
      sprite.look.createBrightnessContrastShader();
      stage.addActor(sprite.look);
      sprite.resume();
    }

    passepartout =
        new Passepartout(
            ScreenValues.SCREEN_WIDTH,
            ScreenValues.SCREEN_HEIGHT,
            maximizeViewPortWidth,
            maximizeViewPortHeight,
            virtualWidth,
            virtualHeight);
    stage.addActor(passepartout);

    if (DEBUG) {
      OrthoCamController camController = new OrthoCamController(camera);
      InputMultiplexer multiplexer = new InputMultiplexer();
      multiplexer.addProcessor(camController);
      multiplexer.addProcessor(stage);
      Gdx.input.setInputProcessor(multiplexer);
      fpsLogger = new FPSLogger();
    } else {
      Gdx.input.setInputProcessor(stage);
    }

    axes = new Texture(Gdx.files.internal("stage/red_pixel.bmp"));
    skipFirstFrameForAutomaticScreenshot = true;
    if (checkIfAutomaticScreenshotShouldBeTaken) {
      makeAutomaticScreenshot = project.manualScreenshotExists(SCREENSHOT_MANUAL_FILE_NAME);
    }
  }
Ejemplo n.º 28
0
  public void updateFont(String newChars) {
    parameter.characters = parameter.characters + newChars;
    font = generator.generateFont(parameter);
    //		generator.generateData(parameter);

    BitmapFont oldFont = this.getStyle().font;
    this.getStyle().font = this.getStyle().messageFont = font;
    oldFont.dispose();
    updateDisplayText();
  }
Ejemplo n.º 29
0
 private void renderGuiGameOverMessage(SpriteBatch batch) {
   float x = cameraGUI.viewportWidth / 2;
   float y = cameraGUI.viewportHeight / 2;
   if (worldController.isGameOver()) {
     BitmapFont fontGameOver = Assets.instance.fonts.defaultBig;
     fontGameOver.setColor(1, 0.75f, 0.25f, 1);
     fontGameOver.draw(batch, "GAME OVER", x, y, 0, 5, true);
     fontGameOver.setColor(1, 1, 1, 1);
   }
 }
Ejemplo n.º 30
0
 @Override
 public void render() {
   Gdx.gl.glClearColor(0, 0, 0, 0);
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   gsm.render();
   batch.begin();
   font.draw(batch, Game.allByte + ":" + Game.waitTime + ":" + Game.countPlayer, 10, 25);
   font.draw(batch, "Time remain: " + Game.timeRemain, 10, 45);
   batch.end();
 }