Exemplo n.º 1
0
 public void draw(float deltaTime) {
   GLCommon gl = Gdx.gl;
   gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
   renderer.render();
   guiCam.update();
   batcher.setProjectionMatrix(guiCam.combined);
   batcher.enableBlending();
   batcher.begin();
   switch (state) {
     case GAME_READY:
       presentReady();
       break;
     case GAME_RUNNING:
       presentRunning();
       break;
     case GAME_PAUSED:
       presentPaused();
       break;
     case GAME_LEVEL_END:
       presentLevelEnd();
       break;
     case GAME_OVER:
       presentGameOver();
       break;
   }
   batcher.end();
 }
Exemplo n.º 2
0
  public void draw(float deltaTime) {
    renderer.render();

    guiCam.update();
    batcher.setProjectionMatrix(guiCam.combined);
    batcher.enableBlending();
    batcher.begin();

    drawUI(deltaTime);

    switch (state) {
      case GAME_READY:
        presentReady();
        break;
        // case ROUND_START
        // case COUNT_DUCKS
        // case NEXT_ROUND
      case GAME_RUNNING:
        presentRunning();
        break;
      case GAME_OVER_1:
      case GAME_OVER_2:
        presentGameOver();
        break;
    }

    batcher.end();
  }
  @Override
  public void render(float delta) {
    // TODO Auto-generated method stub

    if (Gdx.input.justTouched()) {
      guiCam.unproject(touch.set(Gdx.input.getX(), Gdx.input.getY(), 0));
      if (startbutton.contains(touch)) {
        maingame.setScreen(maingame.mainscene);
        return;
      }
    }

    GL10 gl = Gdx.graphics.getGL10();
    gl.glClearColor(0, 0, 0, 1);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    /*
     * Actualiza los parametros de la camara
     * y los enlaza al objeto de renderizado batcher
     * */
    guiCam.update();
    this.batcher.setProjectionMatrix(this.guiCam.combined);
    /*
     * Desactiva las trasnparencias
     * */
    batcher.disableBlending();
    batcher.begin();
    batcher.draw(Assets.background, 0, 0, 10, 15);
    batcher.end();
    batcher.enableBlending();
    batcher.begin();
    batcher.draw(Assets.title, 1, 6, 8, 8);
    batcher.draw(Assets.start, x, 3, 6, 3);
    x += c;
    batcher.end();
  }
Exemplo n.º 4
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();
  }
Exemplo n.º 5
0
  public void draw(float deltaTime) {
    GLCommon gl = Gdx.gl;
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    guiCam.update();

    batcher.disableBlending();
    batcher.begin();
    batcher.draw(helpRegion, 0, 0, 320, 480);
    batcher.end();

    batcher.enableBlending();
    batcher.begin();
    batcher.draw(Assets.arrow, 320, 0, -64, 64);
    batcher.end();

    gl.glDisable(GL10.GL_BLEND);
  }
  public void draw() {
    GLCommon gl = Gdx.gl;
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    guiCam.update();

    batcher.setProjectionMatrix(guiCam.combined);
    batcher.disableBlending();
    batcher.begin();
    batcher.draw(helpRegion, 0, 0, 320, 480);
    batcher.end();

    batcher.enableBlending();
    batcher.begin();
    batcher.draw(Assets.arrow, 320, 0, -64, 64);
    batcher.end();

    gl.glDisable(GL10.GL_BLEND);
  }
Exemplo n.º 7
0
  public void draw(float deltaTime) {
    GLCommon gl = Gdx.gl;
    gl.glClearColor(1, 0, 0, 1);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    guiCam.update();
    batcher.setProjectionMatrix(guiCam.combined);

    batcher.disableBlending();
    batcher.begin();
    batcher.draw(Assets.backgroundRegion, 0, 0, 320, 480);
    batcher.end();

    batcher.enableBlending();
    batcher.begin();
    batcher.draw(Assets.logo, 160 - 274 / 2, 480 - 10 - 142, 274, 142);
    batcher.draw(Assets.mainMenu, 10, 200 - 110 / 2, 300, 110);
    batcher.draw(Settings.soundEnabled ? Assets.soundOn : Assets.soundOff, 0, 0, 64, 64);
    batcher.end();
  }
Exemplo n.º 8
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();
  }
Exemplo n.º 9
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);
    }
  }
    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);
    }
Exemplo n.º 11
0
  private void draw(float delta) {

    GLCommon gl = Gdx.gl;
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    renderer.render();

    guiCam.update();
    batch.setProjectionMatrix(guiCam.combined);
    batch.enableBlending();
    batch.begin();

    if (state == GameScreen.GAME_PAUSED) batch.draw(Assets.play, 320 - 64, 480 - 64, 50, 50);
    else batch.draw(Assets.pause, 320 - 64, 480 - 64, 50, 50);
    batch.draw(Assets.left, 320 - 51, 0, 50, 50);
    batch.draw(Assets.right, 320 - 51, 70, 50, 50);
    batch.draw(Assets.up, 320 - 51, 120, 50, 50);
    // batch.draw(Assets.potEmpty, 20, 50);
    // batch.draw(new Texture(Gdx.files.internal("data/swordrangeattack.png")), 20, 50);
    Texture slot1Texture = Assets.skillSlotEmpty;
    Texture slot2Texture = Assets.skillSlotEmpty;
    Texture slot3Texture = Assets.skillSlotEmpty;
    boolean slot1cooldown = false;
    boolean slot2cooldown = false;
    boolean slot3cooldown = false;

    int count = 0;
    for (int key : world.skillsOnBar.keySet()) {

      Skill s = world.skillsOnBar.get(key);
      switch (count) {
        case 0:
          slot1Texture = new Texture(Gdx.files.internal("data/" + s.projectile_image));
          if (s.coolDown.isOnCooldown) slot1cooldown = true;
          break;

        case 1:
          slot2Texture = new Texture(Gdx.files.internal("data/" + s.projectile_image));
          if (s.coolDown.isOnCooldown) slot2cooldown = true;
          break;

        case 2:
          slot3Texture = new Texture(Gdx.files.internal("data/" + s.projectile_image));
          if (s.coolDown.isOnCooldown) slot3cooldown = true;
          break;
      }
      count++;
    }
    int x = 115;
    for (int i = 0; i < 3; i++) {

      batch.draw(Assets.skillSlotFrame, x, 5);
      x += 30;
    }
    batch.draw(slot1Texture, 113, 5);
    batch.draw(slot2Texture, 145, 5);
    batch.draw(slot3Texture, 175, 5);
    if (slot1cooldown) batch.draw(Assets.skillSlotOverlay, 115, 5);
    if (slot2cooldown) batch.draw(Assets.skillSlotOverlay, 145, 5);
    if (slot3cooldown) batch.draw(Assets.skillSlotOverlay, 175, 5);
    batch.end();
    renderHP();
  }