Esempio n. 1
0
  @Override
  public void render(SpriteBatch batch, float runTime) {
    if (shouldntFlap()) {
      batch.draw(
          AssetLoader.bird,
          getX(),
          getY(),
          getWidth() / 2.0f,
          getHeight() / 2.0f,
          getWidth(),
          getHeight(),
          1,
          1,
          getRotation());

    } else {
      batch.draw(
          AssetLoader.birdAnimation.getKeyFrame(runTime),
          getX(),
          getY(),
          getWidth() / 2.0f,
          getHeight() / 2.0f,
          getWidth(),
          getHeight(),
          1,
          1,
          getRotation());
    }
  }
 public void drawVictory(int x, int y, int pid, float xoff, float yoff) {
   if (numRed == 0) {
     if (pid == BLUE_TEAM)
       spriteBatch.draw(
           victoryB,
           (x / 2 - victoryB.getWidth() / 2 + xoff),
           y / 2 - victoryB.getHeight() / 2 + yoff);
     else
       spriteBatch.draw(
           defeatR,
           (x / 2 - defeatR.getWidth() / 2 + xoff),
           y / 2 - defeatR.getHeight() / 2 + yoff);
   } else if (numBlue == 0) {
     if (pid == RED_TEAM)
       spriteBatch.draw(
           victoryR,
           (x / 2 - victoryR.getWidth() / 2 + xoff),
           y / 2 - victoryR.getHeight() / 2 + yoff);
     else
       spriteBatch.draw(
           defeatB,
           (x / 2 - defeatB.getWidth() / 2 + xoff),
           y / 2 - defeatB.getHeight() / 2 + yoff);
   }
 }
Esempio n. 3
0
 private void renderGuiExtraLives(SpriteBatch batch) {
   float x = cameraGUI.viewportWidth - 50 - Constants.LIVES_START * 50;
   float y = -15;
   for (int i = 0; i < Constants.LIVES_START; ++i) {
     if (worldController.lives <= i) batch.setColor(0.5f, 0.5f, 0.5f, 0.5f);
     batch.draw(Assets.instance.bunny.head, x + i * 50, y, 50, 50, 120, 100, 0.35f, -0.35f, 0);
     batch.setColor(1, 1, 1, 1);
   }
   if (worldController.lives >= 0 && worldController.livesVisual > worldController.lives) {
     int i = worldController.lives;
     float alphaColor = Math.max(0, worldController.livesVisual - worldController.lives - 0.5f);
     float alphaScale = 0.35f * (2 + worldController.livesVisual - worldController.lives) * 2;
     float alphaRotate = -45 * alphaColor;
     batch.setColor(1.0f, 0.7f, 0.7f, alphaColor);
     batch.draw(
         Assets.instance.bunny.head,
         x + i * 50,
         y,
         50,
         50,
         120,
         100,
         alphaScale,
         -alphaScale,
         alphaRotate);
     batch.setColor(1, 1, 1, 1);
   }
 }
  @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();
  }
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(1f, 1f, 1f, 0f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    batch.setProjectionMatrix(camera.combined);
    // menu goes here
    batch.begin();
    batch.setColor(Color.GREEN);
    batch.draw(continueButton, 0, MyGdxGame.hR * 3 / 4, MyGdxGame.wR, MyGdxGame.hR / 4);
    batch.draw(newGameButton, 0, MyGdxGame.hR / 2, MyGdxGame.wR, MyGdxGame.hR / 4);
    batch.draw(optionsButton, 0, MyGdxGame.hR / 4, MyGdxGame.wR, MyGdxGame.hR / 4);
    batch.draw(exitButton, 0, 0, MyGdxGame.wR, MyGdxGame.hR / 4);

    batch.end();

    if (Gdx.input.justTouched()) {
      Vector3 touchPos = new Vector3();
      touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
      //			camera.unproject(touchPos);
      if (touchPos.y < MyGdxGame.hR / 4) {
        game.setScreen(MyGdxGame.gameScreen);
      }
      if (touchPos.y > MyGdxGame.hR / 4 && touchPos.y < MyGdxGame.hR / 2) {
        MyGdxGame.gameScreen = new GameScreen(game, MyGdxGame.getLandscapeGenerator());
        game.setScreen(MyGdxGame.gameScreen);
      }
      if (touchPos.y < MyGdxGame.hR * 3 / 4 && touchPos.y > MyGdxGame.hR / 2) {
        game.setScreen(MyGdxGame.optionsScreen);
      }
      if (touchPos.y > MyGdxGame.hR * 3 / 4) {
        Gdx.app.exit();
      }
    }
  }
Esempio n. 6
0
  public void drawUi(SpriteBatch batch) {
    float x = GameScreen.playerPos.x;
    float y = GameScreen.playerPos.y;

    // Hardcoded UI:
    batch.setColor(1, 0, 0, 1);
    if (hp > 0) batch.draw(Inventory.tex, x + 300, y + 290, 9, 26, 380, 236, 9, 26, false, false);

    batch.draw(
        Inventory.tex,
        x + 309,
        y + 290,
        100 - ((500 - hp) / 5),
        26,
        399,
        262,
        16,
        26,
        false,
        false);

    if (hp >= 500)
      batch.draw(Inventory.tex, x + 409, y + 290, 9, 26, 390, 236, 9, 26, false, false);
    batch.setColor(1, 1, 1, 1);
  }
Esempio n. 7
0
  @Override
  public void draw(Player p) {
    cam.setToOrtho(true, HawkthorneGame.WIDTH, HawkthorneGame.HEIGHT);
    cam.zoom = 1f;
    cam.update(true);
    batch.setProjectionMatrix(cam.combined);
    batch.begin();
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    batch.draw(
        this.background,
        cam.viewportWidth / 2 - this.background.getRegionWidth() / 2,
        cam.viewportHeight / 2 - this.background.getRegionHeight() / 2);

    batch.setColor(0, 0, 0, 1);
    BitmapFont font = Assets.getFont();
    font.setScale(0.8f, -0.8f);
    font.draw(batch, "SERVER", 278, 151);
    font.draw(batch, "CLIENT", 278, 181);
    batch.setColor(1, 1, 1, 1);
    batch.draw(this.arrow, 236, 139 + 30 * this.option);
    String back = Keys.toString(KeyMapping.gameKeyToInt(GameKeys.START)) + ": EXIT GAME";
    String howto =
        "<JUMP> OR " + Keys.toString(KeyMapping.gameKeyToInt(GameKeys.JUMP)) + ": SELECT ITEM";
    font.draw(batch, back, 25, 25);
    font.draw(batch, howto, 25, 55);

    font.setColor(Color.RED);
    font.draw(batch, warning, 60, 305);

    font.setColor(Color.WHITE);
    batch.end();
  }
Esempio n. 8
0
  @Override
  public void render() {
    // clear the screen with a dark blue color. The
    // arguments to glClearColor are the red, green
    // blue and alpha component in the range [0,1]
    // of the color to be used to clear the screen.
    Gdx.gl.glClearColor(0, 0, 0.2f, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    // tell the camera to update its matrices.
    camera.update();

    // tell the SpriteBatch to render in the
    // coordinate system specified by the camera.
    batch.setProjectionMatrix(camera.combined);

    // begin a new batch and draw the bucket and
    // all drops
    batch.begin();
    batch.draw(bucketImage, bucket.x, bucket.y);
    for (Rectangle raindrop : raindrops) {
      batch.draw(dropImage, raindrop.x, raindrop.y);
    }
    batch.end();
    //

    // process user input
    if (Gdx.input.isTouched()) {
      Vector3 touchPos = new Vector3();
      touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
      camera.unproject(touchPos);
      bucket.x = touchPos.x - 48 / 2;
    }
    if (Gdx.input.isKeyPressed(Keys.LEFT)) bucket.x -= 200 * Gdx.graphics.getDeltaTime();
    if (Gdx.input.isKeyPressed(Keys.RIGHT)) bucket.x += 200 * Gdx.graphics.getDeltaTime();

    // make sure the bucket stays within the screen bounds
    if (bucket.x < 0) bucket.x = 0;
    if (bucket.x > 800 - 48) bucket.x = 800 - 48;

    // commit

    // check if we need to create a new raindrop
    if (TimeUtils.nanoTime() - lastDropTime > 1000000000) spawnRaindrop();

    // move the raindrops, remove any that are beneath the bottom edge of
    // the screen or that hit the bucket. In the later case we play back
    // a sound effect as well.
    Iterator<Rectangle> iter = raindrops.iterator();
    while (iter.hasNext()) {
      Rectangle raindrop = iter.next();
      raindrop.y -= 200 * Gdx.graphics.getDeltaTime();
      if (raindrop.y + 48 < 0) iter.remove();
      if (raindrop.overlaps(bucket)) {
        dropSound.play();
        iter.remove();
      }
    }
  }
Esempio n. 9
0
 public void render(SpriteBatch sb) {
   if (bg != null) {
     sb.setColor(Res.PRIMARY_COLOR);
     sb.draw(bg, x - bwidth / 2, y - bheight / 2);
   }
   sb.setColor(Color.WHITE);
   sb.draw(image, x - width / 2, y - height / 2);
 }
Esempio n. 10
0
  private void drawRunning() {
    batch.begin();
    Color gray = new Color(102 / 255f, 102 / 255f, 102 / 255f, 1);
    Color darkGreen = new Color(64 / 255f, 141 / 255f, 52 / 255f, 1);

    if (gameState != GameState.GameOver) {
      // draw elapse time
      batch.draw(
          dot,
          0,
          0,
          game.screenWidth - (game.screenWidth * (caseTotalTime - elapseTime)) / caseTotalTime,
          game.screenHeight);

      batch.draw(line, lineStart, game.screenHeight - 110);

      DrawTextUtils.DrawAlignLeft(
          Assets.instance.fonts.defaultSmall,
          batch,
          "Score",
          gray,
          scorePosition.x,
          scorePosition.y);
      DrawTextUtils.DrawAlignLeft(
          Assets.instance.fonts.defaultNormal,
          batch,
          score + "",
          Color.BLACK,
          scorePosition.x + 150,
          scorePosition.y + 12);
      DrawTextUtils.DrawAlignCenter(
          Assets.instance.fonts.defaultBig,
          batch,
          "+",
          darkGreen,
          crossSignPosition.x,
          crossSignPosition.y);
      DrawTextUtils.DrawAlignLeft(
          Assets.instance.fonts.defaultBig,
          batch,
          "= " + answer,
          darkGreen,
          answerPosition.x,
          answerPosition.y);

      for (int i = 0; i < 4; i++) {
        batch.draw(selected[i] ? colorRings[i] : colorPads[i], blockBounds[i].x, blockBounds[i].y);
        DrawTextUtils.DrawAlignCenter(
            Assets.instance.fonts.defaultSmall,
            batch,
            number[i] + "",
            selected[i] ? Color.BLACK : Color.WHITE,
            blockBounds[i].x + 60,
            blockBounds[i].y + 75);
      }
    }
    batch.end();
  }
Esempio n. 11
0
  public void renderizar(SpriteBatch pincel) {
    float x = (corpoCima.getPosition().x - largura / 2) * Util.PIXEL_METRO;
    float y = (corpoCima.getPosition().y - altura / 2) * Util.PIXEL_METRO;
    pincel.draw(texturaCima, x, y, largura * Util.PIXEL_METRO, altura * Util.PIXEL_METRO);

    x = (corpoBaixo.getPosition().x - largura / 2) * Util.PIXEL_METRO;
    y = (corpoBaixo.getPosition().y - altura / 2) * Util.PIXEL_METRO;
    pincel.draw(textureBaixo, x, y, largura * Util.PIXEL_METRO, altura * Util.PIXEL_METRO);
  }
Esempio n. 12
0
  private void presentRunning() {
    batcher.draw(Assets.pause, 320 - 54, 480 - 54, 54, 44);
    Assets.font.draw(batcher, scoreString, 16, 480 - 20);

    String scoret;
    scoret = world.shot + "x ";
    Assets.font.draw(batcher, scoret, 4, 480 - 410);
    batcher.draw(Assets.portaproj, 320 - 315, 480 - 410, 35, 35);
  }
Esempio n. 13
0
 /**
  * Show achieved badges.
  *
  * @param lvl badge level.
  */
 private void drawBadges(SpriteBatch batch) {
   switch (badgeLevel) {
     case 3:
       batch.draw(badges[2], (float) badges[2].getRegionWidth(), 0.0f);
     case 2:
       batch.draw(badges[1], -(float) badges[1].getRegionWidth() / 2.0f, 0.0f);
     case 1:
       batch.draw(badges[0], -2f * (float) badges[0].getRegionWidth(), 0.0f);
   }
 }
Esempio n. 14
0
  private void renderBG(SpriteBatch sb) {
    for (int y = 0; y < scrollH; y++) {
      for (int x = 0; x < scrollW; x++) {
        tiles[x + y * scrollW].render(sb, (x * 32) - scrollX, y * 32, 32, 32);
      }
    }

    int w = 256 + 128;
    int h = 256 + 128;

    int wa = w / 64;
    int ha = h / 64;

    for (int y = 0; y < ha; y++) {
      for (int x = 0; x < wa; x++) {
        sb.draw(guiFill, xo + (x * 64) + 64, yo + (y * 64) + 32, 64, 64);
      }
    }

    for (int x = 1; x < wa; x++) {
      sb.draw(guiEdge3, xo + x * 64, yo + h, 64, 64);
      sb.draw(guiEdge4, xo + x * 64, yo, 64, 64);
    }

    for (int y = 1; y < ha; y++) {
      sb.draw(guiEdge1, xo, yo + y * 64, 64, 64);
      sb.draw(guiEdge2, xo + w, yo + y * 64, 64, 64);
    }
    sb.draw(guiCorner1, xo, yo + h, 64, 64);
    sb.draw(guiCorner2, xo + w, yo + h, 64, 64);
    sb.draw(guiCorner3, xo, yo, 64, 64);
    sb.draw(guiCorner4, xo + w, yo, 64, 64);
  }
  private void drawWorld() {
    camera.update();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    batch.draw(background, camera.position.x - background.getWidth() / 2, 0);
    for (Rock rock : rocks) {
      batch.draw(rock.image, rock.position.x, rock.position.y);
    }
    batch.draw(ground, groundOffsetX, 0);
    batch.draw(ground, groundOffsetX + ground.getRegionWidth(), 0);
    batch.draw(ceiling, groundOffsetX, 480 - ceiling.getRegionHeight());
    batch.draw(ceiling, groundOffsetX + ceiling.getRegionWidth(), 480 - ceiling.getRegionHeight());
    batch.draw(plane.getKeyFrame(planeStateTime), planePosition.x, planePosition.y);
    batch.end();

    batch.setProjectionMatrix(uiCamera.combined);
    batch.begin();
    if (gameState == GameState.Start) {
      batch.draw(
          ready,
          Gdx.graphics.getWidth() / 2 - ready.getRegionWidth() / 2,
          Gdx.graphics.getHeight() / 2 - ready.getRegionHeight() / 2);
    }
    if (gameState == GameState.GameOver) {
      batch.draw(
          gameOver,
          Gdx.graphics.getWidth() / 2 - gameOver.getRegionWidth() / 2,
          Gdx.graphics.getHeight() / 2 - gameOver.getRegionHeight() / 2);
    }
    if (gameState == GameState.GameOver || gameState == GameState.Running) {
      font.draw(batch, "" + score, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() - 60);
    }
    batch.end();
  }
Esempio n. 16
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();
  }
Esempio n. 17
0
  public void updateTitle(float delta) {
    // System.out.println("update title");
    batch.begin();
    switch (level) {
      case 0:
        batch.draw(swiat00tlo, 0, 0);
        break;
      case 1:
        batch.draw(swiat01tlo, 0, 0);
        break;
      case 2:
        batch.draw(swiat02tlo, 0, 0);
        break;
      case 3:
        batch.draw(swiat03tlo, 0, 0);
        break;
    }
    // total power numbers
    font.draw(batch, "total: ", 35, 100);
    font.draw(batch, pulaGracza + "", 50, 70, 50, Align.center, false);
    font.draw(batch, "total: ", 1160, 100);
    font.draw(batch, pulaPrzeciwnika + "", 1175, 70, 50, Align.center, false);

    // actual hp
    font.draw(
        batch,
        game.player.playerHp + "",
        playerIcon.getX() - 25,
        playerIcon.getY() + 260,
        50,
        Align.center,
        false);

    if (enemys.size > 0) {
      font.draw(
          batch, enemys.peek().getHp() + "", enemys.peek().getX() - 15, enemys.peek().getY() + 260);
    }

    batch.end();
    // draw kotara
    batch.begin();
    kotaraState.update(Gdx.graphics.getDeltaTime());
    kotaraState.apply(kotaraSkeleton);
    kotaraSkeleton.updateWorldTransform();
    sr.draw(batch, kotaraSkeleton);
    batch.end();
    // sprawdz czy kotara sie odslonila
    if (kotaraState.getCurrent(0) == null) {
      currentState = GameState.MAP;
    }
    stage.act(delta);
    stage.draw();
  }
Esempio n. 18
0
  public void startMenu() {
    Texture background = new Texture(Gdx.files.internal("menu/mainMenu_background.png"));
    TextureRegion[][] temp = TextureRegion.split(background, 1024, 640);
    temp[0][0].flip(false, true);

    Texture newGame = new Texture(Gdx.files.internal("menu/newGame_button.png"));
    TextureRegion[][] temp1 = TextureRegion.split(newGame, 200, 100);
    temp1[0][0].flip(false, true);

    batch.draw(temp[0][0], 200, 0);
    batch.draw(temp1[0][0], 50, 150);
  }
  @Override
  public void render() {
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Update animationTime
    animationTime += Gdx.graphics.getDeltaTime();
    camera.update();
    batch.setProjectionMatrix(camera.combined);

    // Render background image
    batch.begin();
    batch.draw(background, 0, 0);
    batch.end();

    // Check if async load is done
    if (!loaded) {
      // Render Logo and Loading Bar
      batch.begin();
      batch.draw(logo, logoPos.x, logoPos.y);
      batch.draw(progressBarBaseImg, pbPos.x, pbPos.y);
      batch.draw(
          progressBarImg,
          pbPos.x,
          pbPos.y,
          progressBarImg.getWidth() * manager.getProgress(),
          progressBarImg.getHeight());
      batch.end();

      if (manager.update()) {
        // Initialize params for caveman
        loaded = true;
        cavemanAnims = manager.get("data/caveman-sheet.json");
        cavemanWalk = cavemanAnims.getAnimation("walk");
        currentFrame = cavemanWalk.getKeyFrames()[0];
        cavemanX = 0;
        cavemanSpeed = 180;
        goingRight = true;

        Gdx.app.log(TAG, "Instructions");
        Gdx.app.log(TAG, "- Press Left key to move left");
        Gdx.app.log(TAG, "- Press Right key to move right");
      }
    } else {
      // Caveman resources are loaded... let's have some fun
      updateCaveman();

      batch.begin();
      batch.draw(currentFrame, cavemanX, .0f);
      batch.end();
    }
  }
  @Override
  public void draw(SpriteBatch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);

    batch.setColor(Colors.ICS_BLUE_SEMI_TRANSPARENT);
    batch.draw(whiteSwatch, getX(), getY() - LINE_WIDTH, getWidth(), LINE_WIDTH);
    batch.draw(
        whiteSwatch,
        getX() + getWidth(),
        getY() - LINE_WIDTH,
        LINE_WIDTH,
        getHeight() + LINE_WIDTH * 2);
  }
Esempio n. 21
0
 @Override
 public void render(SpriteBatch batch) {
   batch.draw(texture, x, y, width, height);
   Assets.getFont().getData().setScale(0.7f);
   Assets.getFont().setColor(Color.BLACK);
   Assets.getFont().draw(batch, "Generator", x - 20, y - 4);
   Assets.getFont().draw(batch, "" + cost, x + 4, y - 24);
   Assets.getFont().setColor(1.0f, 1.0f, 0.0f, 1.0f);
   Assets.getFont().getData().setScale(0.5f);
   Assets.getFont().draw(batch, "+  /" + (int) GeneratorTile.TIMEINTERVAL + "s", x + 2, y + 54);
   batch.draw(Assets.getRegion("resourceIcon"), x + 44, y - 38, 16, 16);
   batch.draw(Assets.getRegion("energyIcon"), x + 14, y + 40, 16, 16);
 }
Esempio n. 22
0
  /**
   * *********************************************************************************** This
   * renders stuff on the screen
   * ***********************************************************************************
   */
  @Override
  public void draw(SpriteBatch batch, float parentAlpha) {
    final Color c = getColor();
    batch.setColor(c.r, c.g, c.b, c.a * parentAlpha);

    if (texture != null) {
      batch.draw(texture, getX(), getY(), getWidth(), getHeight());
    } else if (region != null) {
      batch.draw(region, getX(), getY(), getWidth(), getHeight());
    }

    super.draw(batch, parentAlpha);
  }
Esempio n. 23
0
  private void drawAttacking(SpriteBatch batch) {
    Vector2 pos = character.getPosition();
    float stateTime = character.attackAnimationHandler.stateTime;

    switch ((int) character.rotation) {
      case 0:
        batch.draw(attackE.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 45:
        batch.draw(attackNe.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 90:
        batch.draw(attackN.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 135:
        batch.draw(attackNw.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 180:
        batch.draw(attackW.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 225:
        batch.draw(attackSw.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 270:
        batch.draw(attackS.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 315:
        batch.draw(attackSe.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
    }
  }
Esempio n. 24
0
 private void drawTippingOver(SpriteBatch batch) {
   Vector2 pos = character.getPosition();
   tipOverStateTime += Gdx.graphics.getDeltaTime();
   switch ((int) character.rotation) {
     case 0:
       batch.draw(tipOverE.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 45:
       batch.draw(tipOverNe.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 90:
       batch.draw(tipOverN.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 135:
       batch.draw(tipOverNw.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 180:
       batch.draw(tipOverW.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 225:
       batch.draw(tipOverSw.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 270:
       batch.draw(tipOverS.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 315:
       batch.draw(tipOverSe.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
   }
 }
  @Override
  public void render(float delta) {
    // TODO Auto-generated method stub
    GameUtils.clearScreen();
    mBatch.begin();
    mBatch.draw(background, 0, 0);
    txtTitle.Draw(mBatch, GameUtils.getInstance().systemFont, Color.WHITE);
    txtMusic.Draw(mBatch, GameUtils.getInstance().systemFont, Color.WHITE);
    txtSound.Draw(mBatch, GameUtils.getInstance().systemFont, Color.WHITE);
    txtBack.Draw(mBatch, GameUtils.getInstance().systemFont, Color.WHITE);
    mBatch.draw(selector, 25, selector_Y);
    mBatch.end();

    handleInput();
  }
Esempio n. 26
0
  @Override
  public void render() {

    Gdx.gl.glClearColor(0, 0, 0.2f, 1);

    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    camera.update();

    batch.setProjectionMatrix(camera.combined);

    batch.begin();
    batch.draw(bucketImage, bucket.x, bucket.y);

    for (Rectangle raindrop : raindrops) {
      batch.draw(dropImage, raindrop.x, raindrop.y);
    }

    batch.end();

    if (Gdx.input.isTouched()) {
      Vector3 touchPos = new Vector3();
      touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
      camera.unproject(touchPos);
      bucket.x = touchPos.x - 64 / 2;
    }
    if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) bucket.x -= 200 * Gdx.graphics.getDeltaTime();
    if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) bucket.x += 200 * Gdx.graphics.getDeltaTime();

    // make sure the bucket stays within the screen bounds
    if (bucket.x < 0) bucket.x = 0;
    if (bucket.x > 800 - 64) bucket.x = 800 - 64;

    if (TimeUtils.nanoTime() - lastDropTime > 1000000000) {
      spawnRaindrop();
    }

    Iterator<Rectangle> iter = raindrops.iterator();
    while (iter.hasNext()) {
      Rectangle raindrop = iter.next();
      raindrop.y -= 200 * Gdx.graphics.getDeltaTime();
      if (raindrop.y + 64 < 0) iter.remove();
      if (raindrop.overlaps(bucket)) {
        dropSound.play();
        iter.remove();
      }
    }
  }
  @Override
  public void render(SpriteBatch batch) {

    // Renders the flare after the planets
    renderFlare(batch);

    // Renders the background to the window
    batch.draw(
        reg.getTexture(),
        position.x - dimension.x / 2,
        position.y - dimension.y / 2,
        origin.x,
        origin.y,
        dimension.x,
        dimension.y,
        scale.x,
        scale.y,
        rotation,
        reg.getRegionX(),
        reg.getRegionY(),
        reg.getRegionWidth(),
        reg.getRegionHeight(),
        false,
        false);
  }
Esempio n. 28
0
  @Override
  public void render(SpriteBatch sb) {
    delta = (TimeUtils.millis() - startTime + 700) / 1000;
    tweenManager.update(delta);
    bgManager.render(sb);

    sb.setProjectionMatrix(camera.combined);
    sb.begin();
    backButton.render(sb);
    randomCardButton.draw(sb);
    rareCardButton.draw(sb);

    Fonts.MFont.draw(
        sb, "Cost: " + randomCardCost, randomCardButton.getX(), randomCardButton.getY() - 40);
    Fonts.MFont.draw(
        sb, "Cost: " + rareCardCost, rareCardButton.getX(), rareCardButton.getY() - 40);

    Fonts.MFont.draw(
        sb,
        currGold,
        MainGame.WIDTH - Fonts.MFont.getBounds(currGold).width - 40,
        MainGame.HEIGHT - 50);

    if (showingCard) {
      sb.draw(alpha, 0, 0, MainGame.WIDTH, MainGame.HEIGHT);
      purchasedCard.render(
          new Vector2(
              MainGame.WIDTH / 2 - (Card.WIDTH / 2 * cardAnimSprite.getScaleX()),
              MainGame.HEIGHT / 2 - (Card.HEIGHT / 2 * cardAnimSprite.getScaleX())),
          cardAnimSprite.getScaleX(),
          sb);
      unlockedText.draw(sb);
    }
    sb.end();
  }
Esempio n. 29
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();
  }
Esempio n. 30
0
  public boolean draw(float dt, SpriteBatch batch) {
    boolean result = false;

    if (Gdx.input.isTouched()) {
      if (inside()) {
        // scale = Math.max(minScale, scale - dt * 1.1f);
        down = true;
      } else {
        // scale = Math.min(1, scale + dt * 0.3f);
        down = false;
      }
    } else if (down) {
      result = true;
      down = false;
    } else {
      down = false;
    }

    batch.begin();

    TextureRegion tex = down ? pressed : regular;
    batch.draw(tex, x, y, width * 0.5f, height * 0.5f, width, height, 1, 1, 0);
    batch.end();

    return result;
  }