@Override
  public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 0);
    Gdx.gl.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    lote.setProjectionMatrix(camara.combined);

    stateTime += Gdx.graphics.getDeltaTime();

    Sprite ciano = animadoCiano.getKeyFrame(stateTime, true);
    // ciano.setPosition(-ciano.getWidth() / 2,
    //		-ciano.getHeight() / 2);
    // ciano.setRotation(stateTime * 10);

    // inanimadoVerde.setSize(0.5f, 0.5f);
    // inanimadoVerde.setPosition(-inanimadoVerde.getWidth() / 2,
    //		-inanimadoVerde.getHeight() / 2);

    lote.setProjectionMatrix(camara.combined);
    lote.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE);

    lote.begin();
    ciano.draw(lote);
    // inanimadoCastanho.draw(lote);
    lote.end();
  }
예제 #2
0
  /**
   * @param simulation
   * @param gl
   */
  private void renderHud(GL10 gl) {
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    int width = Gdx.app.getGraphics().getWidth();
    int height = Gdx.app.getGraphics().getHeight();
    // spriteBatch.setProjectionMatrix(viewMatrix);
    // spriteBatch.setTransformMatrix(transformMatrix);

    spriteBatch.begin();
    spriteBatch.enableBlending();
    spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

    /*A minimum of dataset
    B maximum of dataset
    a is from where you would like normalised data set to start
    b is where you would like normalised data set to end
    x is the value you are trying to normalise
    a + (x-A)*(b-a)/(B-A)

    */

    float length = 0 + (progress - 0) * ((Gdx.graphics.getWidth() / 10) * 8 - 0) / (1 - 0);
    spriteBatch.setColor(0, 0, 1, 1);
    spriteBatch.draw(
        progressBarTexture,
        Gdx.graphics.getWidth() / 10,
        110,
        (Gdx.graphics.getWidth() / 10) * 8,
        30);
    spriteBatch.setColor(0, 1, 1, 1);
    spriteBatch.draw(progressBarTexture, (Gdx.graphics.getWidth() / 10) + 2, 112, length, 26);
    spriteBatch.setColor(1, 1, 1, 1);
    font.draw(spriteBatch, "Version:" + BattleBeasties3d.version, 10, 10);
    font.draw(spriteBatch, "Loading " + String.format("%.0f", progress * 100) + "%", 100, 100);
    if (Splash.fadeIn) {
      spriteBatch.setColor(0, 0, 0, Splash.fadeTimer);
      spriteBatch.draw(xfadeTexture, 0, 0, width, height);
    }
    if (Splash.fadeOut) {
      spriteBatch.setColor(1, 1, 1, Splash.fadeTimer);
      spriteBatch.draw(xfadeTexture, 0, 0, width, height);
    }
    spriteBatch.setColor(1, 1, 1, 1);
    if (BattleBeasties3d.Error == BattleBeasties3d.NETWORK_DOWN && netErrorShown == false) {
      stage.addActor(
          Actors.bottomToast(
              "Connection to internet failed, Please check your network is working.", 5, skin));

      netErrorShown = true;
    }

    spriteBatch.end();
  }
예제 #3
0
  public void draw(SpriteBatch spriteBatch) {

    if (background != null) {
      spriteBatch.disableBlending();

      float x = 0;

      for (AtlasRegion tile : background) {
        spriteBatch.draw(tile, x, 0f);
        x += tile.getRegionWidth();
      }

      spriteBatch.enableBlending();
    }

    // draw layers from bottom to top
    for (int i = layers.size() - 1; i >= 0; i--) {
      SceneLayer layer = layers.get(i);
      layer.draw(spriteBatch);
    }

    // Draw the light map
    if (lightMap != null) {
      // Multiplicative blending for light maps
      spriteBatch.setBlendFunction(GL20.GL_DST_COLOR, GL20.GL_ZERO);

      float x = 0;

      for (AtlasRegion tile : lightMap) {
        spriteBatch.draw(tile, x, 0f);
        x += tile.getRegionWidth();
      }

      spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
  }
예제 #4
0
  @Override
  public void draw(float delta) {
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    viewMatrix.setToOrtho2D(0, 0, 480, 320);
    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();
    spriteBatch.disableBlending();
    spriteBatch.setColor(Color.WHITE);
    spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
    spriteBatch.enableBlending();
    spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 256, 512, 256, false, false);
    String text = "It is the end my friend.\nTouch to continue!";
    TextBounds bounds = font.getMultiLineBounds(text);
    spriteBatch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
    font.drawMultiLine(spriteBatch, text, 0, 160 + bounds.height / 2, 480, HAlignment.CENTER);
    spriteBatch.end();
  }
예제 #5
0
파일: Bdx.java 프로젝트: colepram/bdx
  public static void init() {
    time = 0;
    profiler = new Profiler();
    display = new Display();
    scenes = new ArrayListScenes();
    sounds = new Sounds();
    music = new Music();
    mouse = new Mouse();
    gamepads = new ArrayListNamed<Gamepad>();

    for (int i = 0; i < Controllers.getControllers().size; i++) {
      gamepads.add(new Gamepad(i));
    }

    imaps = new InputMaps();
    keyboard = new Keyboard();
    fingers = new ArrayList<Finger>();
    components = new ArrayList<Component>();
    matShaders = new HashMap<String, ShaderProgram>();

    allocatedFingers = new ArrayList<Finger>();
    for (int i = 0; i < 10; ++i) {
      allocatedFingers.add(new Finger(i));
    }

    Gdx.input.setInputProcessor(new GdxProcessor(keyboard, mouse, allocatedFingers, gamepads));

    com.badlogic.gdx.graphics.glutils.ShaderProgram.pedantic = false;

    shaderProvider = new BDXShaderProvider();
    modelBatch = new ModelBatch(shaderProvider);
    spriteBatch = new SpriteBatch();
    spriteBatch.setBlendFunction(Gdx.gl.GL_SRC_ALPHA, Gdx.gl.GL_ONE_MINUS_SRC_ALPHA);
    frameBuffer = new RenderBuffer(spriteBatch);
    tempBuffer = new RenderBuffer(spriteBatch);
    advancedLightingOn = true;
  }
    public void render() {
      int viewWidth = Gdx.graphics.getWidth();
      int viewHeight = Gdx.graphics.getHeight();

      float delta = Gdx.graphics.getDeltaTime();

      Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

      if ((pixelsPerMeter.getValue() != pixelsPerMeterPrev)
          || (zoomLevel.getValue() != zoomLevelPrev)) {
        if (pixelsPerMeter.getValue() <= 0) {
          pixelsPerMeter.setValue(1);
        }

        worldCamera.setToOrtho(
            false, viewWidth / pixelsPerMeter.getValue(), viewHeight / pixelsPerMeter.getValue());
        worldCamera.zoom = zoomLevel.getValue();
        worldCamera.update();
        effect.setPosition(worldCamera.viewportWidth / 2, worldCamera.viewportHeight / 2);
        zoomLevelPrev = zoomLevel.getValue();
        pixelsPerMeterPrev = pixelsPerMeter.getValue();
      }

      spriteBatch.setProjectionMatrix(worldCamera.combined);

      spriteBatch.begin();
      spriteBatch.enableBlending();
      spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

      if (bgImage != null) {
        bgImage.setPosition(
            viewWidth / 2 - bgImage.getWidth() / 2, viewHeight / 2 - bgImage.getHeight() / 2);
        bgImage.draw(spriteBatch);
      }

      activeCount = 0;
      boolean complete = true;
      for (ParticleEmitter emitter : effect.getEmitters()) {
        if (emitter.getSprite() == null && emitter.getImagePath() != null) loadImage(emitter);
        boolean enabled = isEnabled(emitter);
        if (enabled) {
          if (emitter.getSprite() != null) emitter.draw(spriteBatch, delta);
          activeCount += emitter.getActiveCount();
          if (!emitter.isComplete()) complete = false;
        }
      }
      if (complete) effect.start();

      maxActive = Math.max(maxActive, activeCount);
      maxActiveTimer += delta;
      if (maxActiveTimer > 3) {
        maxActiveTimer = 0;
        lastMaxActive = maxActive;
        maxActive = 0;
      }

      if (mouseDown) {
        // gl.drawLine(mouseX - 6, mouseY, mouseX + 5, mouseY);
        // gl.drawLine(mouseX, mouseY - 5, mouseX, mouseY + 6);
      }

      spriteBatch.setProjectionMatrix(textCamera.combined);

      font.draw(spriteBatch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 5, 15);
      font.draw(spriteBatch, "Count: " + activeCount, 5, 35);
      font.draw(spriteBatch, "Max: " + lastMaxActive, 5, 55);
      font.draw(spriteBatch, (int) (getEmitter().getPercentComplete() * 100) + "%", 5, 75);

      spriteBatch.end();

      // gl.drawLine((int)(viewWidth * getCurrentParticles().getPercentComplete()), viewHeight - 1,
      // viewWidth, viewHeight -
      // 1);
    }
예제 #7
0
 public void setAdditive(boolean additive) {
   int dstFunc = additive ? GL20.GL_ONE : GL20.GL_ONE_MINUS_SRC_ALPHA;
   mySpriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, dstFunc);
 }