コード例 #1
0
ファイル: GameScreen.java プロジェクト: willsun888/flykite
  @Override
  public void present(float deltaTime) {
    GLCommon gl = Gdx.gl;
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    camera.update();

    worldRender.render(deltaTime);
    if (isTreasure) {
      batcher.begin();
      renderTreasure(treasureType);
      if (isTreasureSound) {
        Assets.playSound(Assets.treasureSound, game.soundState);
        isTreasureSound = false;
      }
      batcher.end();
    } else if (isFinal) {
      batcher.begin();
      renderFinal();
      batcher.end();
    } else {
      if (isPause && !isDialog) {
        batcher.begin();
        renderGamePause();
        batcher.end();
      }
    }
    if ((isPause || !game.soundState) && bgMusic.isPlaying()) {
      bgMusic.pause();
    } else if (!isPause && !bgMusic.isPlaying() && game.soundState) {
      Assets.playMusic(bgMusic, game.soundState);
    }
  }
コード例 #2
0
ファイル: RenderingSystem.java プロジェクト: vladsvs/sioncore
  protected void renderParticles() {
    particleFrameBuffer.begin();
    batch.begin();

    Color initialColor = batch.getColor();

    Values<Entity> values = particleEntities.values();

    while (values.hasNext()) {
      Entity entity = values.next();
      ParticleComponent particle = entity.getComponent(ParticleComponent.class);
      ColorComponent color = entity.getComponent(ColorComponent.class);

      if (color != null) {
        batch.setColor(color.color);
      }

      particle.effect.draw(batch);

      batch.setColor(initialColor);
    }

    batch.end();
    particleFrameBuffer.end();

    batch.begin();
    batch.draw(particleRegion, 0.0f, 0.0f);
    batch.end();
  }
コード例 #3
0
  @Override
  public void render() {
    // Update
    //		Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    world.step(1 / 60f, 10, 10);
    for (int i = 0; i < MAX_BALL_COUNT; i++) {
      Vector2 pos =
          ballModels[i]
              .getPosition()
              .sub(ballSprites[i].getWidth() / 2, ballSprites[i].getHeight() / 2);
      float angleDeg = ballModels[i].getAngle() * MathUtils.radiansToDegrees;

      ballSprites[i].setPosition(pos.x, pos.y);
      ballSprites[i].setRotation(angleDeg);
    }

    // Render
    //		GL10 gl = Gdx.gl10;
    //		gl.glClearColor(1, 1, 1, 1);
    //		gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    spriteBatch.setProjectionMatrix(camera.combined);
    spriteBatch.begin();
    vialSprite.draw(spriteBatch);
    for (int i = 0; i < MAX_BALL_COUNT; i++) ballSprites[i].draw(spriteBatch);
    spriteBatch.end();

    spriteBatch
        .getProjectionMatrix()
        .setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    spriteBatch.begin();
    font.draw(spriteBatch, "Touch the screen to restart", 5, 25);
    spriteBatch.end();
  }
コード例 #4
0
  @Override
  public void render(SpriteBatch sb) {

    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    sb.setProjectionMatrix(cam.combined);
    sb.begin();

    // Determine what to render based on score
    {
      if (score <= 3) {
        sb.draw(bg2, cam.position.x - (cam.viewportWidth / 2), 0);
        sb.draw(bird.getTexture(score), bird.getPosition().x, bird.getPosition().y);

      } else if (score <= 6) {
        sb.draw(bg, cam.position.x - (cam.viewportWidth / 2), 0);
        sb.draw(bird.getTexture(score), bird.getPosition().x, bird.getPosition().y);

      } else if (score <= 9) {
        sb.draw(android_bg, cam.position.x - (cam.viewportWidth / 2), 0);
        sb.draw(bird.getTexture(score), bird.getPosition().x, bird.getPosition().y);

      } else if (score > 9) {
        sb.draw(cob_bg, cam.position.x - (cam.viewportWidth / 2), 0);
        sb.draw(bird.getTexture(score), bird.getPosition().x, bird.getPosition().y);
      }

      // pass score to tube to determine what to render
      for (Tube tube : tubes) {

        sb.draw(tube.getTopTube(score), tube.getPosTopTube().x, tube.getPosTopTube().y);
        sb.draw(tube.getBottomTube(score), tube.getPosBotTube().x, tube.getPosBotTube().y);
      }

      // determine what ground to render based on current score
      if (score <= 3) {
        sb.draw(ground, groundPos1.x, groundPos1.y);
        sb.draw(ground, groundPos2.x, groundPos2.y);
      } else if (score <= 6) {
        sb.draw(ground2, groundPos1.x, groundPos1.y);
        sb.draw(ground2, groundPos2.x, groundPos2.y);
      } else if (score <= 9) {
        sb.draw(ground3, groundPos1.x, groundPos1.y);
        sb.draw(ground3, groundPos2.x, groundPos2.y);
      } else if (score > 9) {
        sb.draw(ground4, groundPos1.x, groundPos1.y);
        sb.draw(ground4, groundPos2.x, groundPos2.y);
      }
    }

    sb.end();

    sb.begin();

    // Write score to screen
    font.setColor(Color.WHITE);
    font.draw(sb, String.format("%.0f", score), scoreX, scoreY);

    sb.end();
  }
コード例 #5
0
ファイル: PlayScreen2.java プロジェクト: Clairehuei/rockman
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0.39f, 0.58f, 0.92f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Update deltaTime & animationTime
    deltaTime = Gdx.graphics.getDeltaTime();
    animationTime += Gdx.graphics.getDeltaTime();

    // Store Spritesheet to sprite
    sprite = new Sprite(animation.getKeyFrame(animationTime, true));
    sprite.setPosition(xPosition, 0);
    sprite.setScale(1.8f);

    // Set camera to batch and undate camera
    batch.setProjectionMatrix(camera.combined);
    camera.update();

    tiledMapRenderer.setView(camera);
    tiledMapRenderer.render(background);
    tiledMapRenderer.render(foreground);

    // Display on Screen
    batch.begin();
    sprite.draw(batch);
    batch.end();

    // update xPosition
    xPosition = xPosition + (speed * deltaTime);

    HUDBatch.begin();
    font1.draw(HUDBatch, "SCORE:100", 100, 450);
    HUDBatch.end();
  }
コード例 #6
0
  @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();
  }
コード例 #7
0
  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();
  }
コード例 #8
0
ファイル: Gamescreen.java プロジェクト: piotrekuczy/jwt2015
  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();
  }
コード例 #9
0
  @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();
    }
  }
コード例 #10
0
ファイル: NewGameOpening.java プロジェクト: Brusi/VolcanoDrop
  private void renderShrine(ShapeRenderer shapes, SpriteBatch batch) {
    batch.end();

    // 2. clear our depth buffer with 1.0
    Gdx.gl.glClearDepthf(1f);
    Gdx.gl.glClear(GL20.GL_DEPTH_BUFFER_BIT);

    // 3. set the function to LESS
    Gdx.gl.glDepthFunc(GL20.GL_LESS);

    // 4. enable depth writing
    Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);

    // 5. Enable depth writing, disable RGBA color writing
    Gdx.gl.glDepthMask(true);
    Gdx.gl.glColorMask(false, false, false, false);

    // 6. render your primitive shapes
    shapes.begin(ShapeType.Filled);

    // TODO: remove setColor if not needed.
    shapes.setColor(1f, 0f, 0f, 0.5f);
    // shapes.circle(200, 200, 100);
    shapes.setColor(0f, 1f, 0f, 0.5f);
    // shapes.rect(200, 200, 100, 100);
    shapes.rect(-300, 0, 600, 500);

    shapes.rect(100, 100, 100, 100);

    shapes.end();

    batch.begin();
    // 8. Enable RGBA color writing
    //   (SpriteBatch.begin() will disable depth mask)
    Gdx.gl.glColorMask(true, true, true, true);

    // 9. Make sure testing is enabled.
    Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);

    // 10. Now depth discards pixels outside our masked shapes
    Gdx.gl.glDepthFunc(GL20.GL_EQUAL);

    shrineOff.render(batch);
    shrineOn.setAlpha(shrineGlowAlpha);
    shrineOn.render(batch);

    batch.end();
    Gdx.gl.glDepthFunc(GL20.GL_ALWAYS);
    batch.begin();
  }
コード例 #11
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();
  }
コード例 #12
0
ファイル: Button.java プロジェクト: vik-goel/waterwater
  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;
  }
コード例 #13
0
ファイル: PlayState.java プロジェクト: SamHindson/Ultranaut
  @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();
  }
コード例 #14
0
ファイル: OptionsScreen.java プロジェクト: agmcleod/ld25
  @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();
  }
コード例 #15
0
ファイル: physics.java プロジェクト: weihanli101/FlickyBall
  public void render() { // the artistic drawing function that draws everything out (such talent)
    // make the frame ticker thing that actually makes pretty pictures move
    // in this case you are updating the world you just made
    // apparently you aren't suppose to update this in the render loop but w/e
    // also have no idea what 6 & 2 mean so again w/e (sensai plssss)
    world.step(Gdx.graphics.getDeltaTime(), 6, 2);

    // move the sprite with the body!
    sprite.setPosition(body.getPosition().x, body.getPosition().y);

    // just a limit for when it falls off the screen since there is no ground LOL
    System.out.println(body.getPosition().y);
    if (body.getPosition().y < (10)) {
      body.setAwake(false);
    } else {
      body.setAwake(true);
    }

    // Again not box2dStuff just cool things I added
    HandleTouch();

    // the Background color
    // This doesn't look like it does anything?    Gdx.gl.glClearColor(1, 1, 1, 1);

    // clears the background after each fram update
    // Same with this?    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // this is where the sprite img is rendered and updated etc.
    batch.begin();
    batch.draw(sprite, sprite.getX(), sprite.getY());
    batch.end();
  }
コード例 #16
0
  public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0.2f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // tell the camera to update its matrices.
    camera.update(
        car.body.getPosition().x * PIXELS_PER_METER, car.body.getPosition().y * PIXELS_PER_METER);

    spriteBatch.setProjectionMatrix(camera.getCombined());

    if (Gdx.input.isKeyPressed(Input.Keys.UP) || Gdx.input.isTouched()) {
      car.setAccelerate(Car.ACC_ACCELERATE);
    } else if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
      car.setAccelerate(Car.ACC_BRAKE);
    } else {
      car.setAccelerate(Car.ACC_NONE);
    }

    if (Gdx.input.isKeyPressed(Input.Keys.LEFT) || Gdx.input.getAccelerometerY() < -2.5) {
      car.setSteer(Car.STEER_HARD_LEFT);
    } else if (Gdx.input.getAccelerometerY() < -1) {
      car.setSteer(Car.STEER_LEFT);
    } else if (Gdx.input.isKeyPressed(Input.Keys.RIGHT) || Gdx.input.getAccelerometerY() > 2.5) {
      car.setSteer(Car.STEER_HARD_RIGHT);
    } else if (Gdx.input.getAccelerometerY() > 1) {
      car.setSteer(Car.STEER_RIGHT);
    } else {
      car.setSteer(Car.STEER_NONE);
    }

    car.update(Gdx.app.getGraphics().getDeltaTime());

    /**
     * Have box2d update the positions and velocities (and etc) of all tracked objects. The second
     * and third argument specify the number of iterations of velocity and position tests to perform
     * -- higher is more accurate but is also slower.
     */
    world.step(Gdx.app.getGraphics().getDeltaTime(), 3, 3);

    world.clearForces();

    // draw the sprites
    spriteBatch.begin();

    playerSprite.setPosition(
        PIXELS_PER_METER * car.body.getPosition().x - playerTexture.getRegionWidth() / 2,
        PIXELS_PER_METER * car.body.getPosition().y - playerTexture.getRegionHeight() / 2);
    playerSprite.setRotation((MathUtils.radiansToDegrees * car.body.getAngle()));

    playerSprite.setFlip(false, true);
    playerSprite.setScale(0.3f);

    playerSprite.draw(spriteBatch);

    spriteBatch.end();

    /** Draw this last, so we can see the collision boundaries on top of the sprites and map. */
    debugRenderer.render(
        world, camera.getCombined().scale(PIXELS_PER_METER, PIXELS_PER_METER, PIXELS_PER_METER));
  }
コード例 #17
0
 @Override
 public void render() {
   if (selectedOption != -1) {
     RectangleRenderer.begin();
     RectangleRenderer.setColor(StripesMatrix.darkCell);
     RectangleRenderer.setAlpha(0.8f);
     RectangleRenderer.setBounds(
         selectionBounds.getX(),
         selectionBounds.getY() + lineH * (selectedOption),
         selectionBounds.getWidth(),
         selectionBounds.getHeight());
     RectangleRenderer.renderRect();
     RectangleRenderer.end();
   }
   StaticBitmapFont.begin();
   titleText.render();
   pricesText.render();
   currencyText.render();
   ammountsText.render();
   StaticBitmapFont.end();
   arrowsColumn.render();
   goldBatch.begin();
   goldSprite.draw(goldBatch);
   goldBatch.end();
   if (buttonChangeCurrency.checkButton()) {}
 }
コード例 #18
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();
    levelBuilder.update(delta);
    levelBuilder.render(batch);
    batch.end();

    stage.act();
    stage.draw();
    if (addHelp) helpFreezAnimation(delta);

    if (gameState == GameState.WINNER && !winnerUi.isVisible) {
      winnerUi.showWindow(true);
      winnerUi.setTime(time);
    }
    if (gameState == GameState.PLAY || gameState == GameState.MOVING) {
      updateGameTime(delta);
    }
    if (freezers != LevelData.freezers) {
      updateFreeze();
    }
  }
コード例 #19
0
ファイル: GameScreenMulti.java プロジェクト: h4a/SuperJumper
 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();
 }
コード例 #20
0
ファイル: RenderingSystem.java プロジェクト: vladsvs/sioncore
  @Override
  public void update(float deltaTime) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    int width = Gdx.graphics.getWidth();
    int height = Gdx.graphics.getHeight();

    viewport.update(width, height);

    renderMap();

    batch.begin();
    renderWorldEntities();
    batch.end();

    renderParticles();

    uiViewport.update(width, height);
    uiCamera.position.set(
        uiViewport.getWorldWidth() * 0.5f, uiViewport.getWorldHeight() * 0.5f, 0.0f);
    Env.game.getStage().draw();

    viewport.update(width, height);
    debugDrawWorld();

    uiViewport.update(width, height);
    debugDrawUI();

    if (previousWidth != width || previousHeight != height) {
      Env.game.resize(width, height);
      previousWidth = width;
      previousHeight = height;
    }
  }
コード例 #21
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();
  }
コード例 #22
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(Color.BLUE.r, Color.BLUE.g, Color.BLUE.b, Color.BLUE.a);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    camera.update();
    game.batch.setProjectionMatrix(camera.combined);

    batch.begin();
    font.draw(batch, "Loading Game", 32, 32);
    background.draw(batch);
    batch.end();

    if (licenseVerified) {
      if (Gdx.input.isTouched()) {
        Logger.logMsg("transitioning to main menu screen");
        game.setGameScreen(this, game.mainMenuScreen);
        dispose();
      }
    } else {
      Dialog dialog =
          new Dialog("license key invalid", game.uiSkin) {
            protected void result(Object object) {
              Logger.logMsg("exiting");
              Gdx.app.exit();
            }
          };
      dialog.text("Your license key is invalid, exiting...");
      dialog.button("OK", true);
      dialog.show(stage);
    }
  }
コード例 #23
0
ファイル: MatrixTest.java プロジェクト: avgtivihd/bings-game
 @Override
 public void render() {
   Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
   batch.begin();
   font.drawMultiLine(batch, results, 20, 300);
   batch.end();
 }
コード例 #24
0
  /*
   * (non-Javadoc)
   * @see com.badlogic.gdx.Screen#render(float)
   */
  @Override
  public void render(float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.gl.glClearColor(1, 1, 1, 1);

    batch.setProjectionMatrix(ownCamera.combined);
    batch.begin();
    batch.draw(
        texture,
        ((BattleColorConfig.WIDTH - texture.getWidth()) / 2),
        (BattleColorConfig.HEIGHT - texture.getHeight()) / 2);
    batch.end();

    if (System.currentTimeMillis() - oldTime > 1000) { // Eine Sekunde
      // vergangen
      if (countdown == 1) {
        gameRef.setScreen(gameRef.gameScreen);
      } else {
        oldTime = System.currentTimeMillis();
        countdown--;
        setTexture();
      }
    }
    if (gameRef.toast != null) {
      gameRef.toast.toaster();
    }
  }
コード例 #25
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();
  }
コード例 #26
0
  @Override
  public void render() {
    frameBuffer.begin();
    Gdx.graphics.getGL20().glViewport(0, 0, frameBuffer.getWidth(), frameBuffer.getHeight());
    Gdx.graphics.getGL20().glClearColor(0f, 1f, 0f, 1);
    Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.graphics.getGL20().glEnable(GL20.GL_TEXTURE_2D);
    texture.bind();
    meshShader.begin();
    meshShader.setUniformi("u_texture", 0);
    mesh.render(meshShader, GL20.GL_TRIANGLES);
    meshShader.end();
    frameBuffer.end();

    Gdx.graphics.getGL20().glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    Gdx.graphics.getGL20().glClearColor(0.2f, 0.2f, 0.2f, 1);
    Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);

    spriteBatch.begin();
    spriteBatch.draw(
        frameBuffer.getColorBufferTexture(),
        0,
        0,
        256,
        256,
        0,
        0,
        frameBuffer.getColorBufferTexture().getWidth(),
        frameBuffer.getColorBufferTexture().getHeight(),
        false,
        true);
    spriteBatch.end();
  }
コード例 #27
0
ファイル: LoadingScreen.java プロジェクト: rabus/ProjectOne
 @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();
   }
 }
コード例 #28
0
ファイル: SSGame.java プロジェクト: AdamAwan/SpaceShooter
  @Override
  public void render() {
    delta = Gdx.graphics.getDeltaTime() * 60;
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    camera.update();
    player.update(delta);
    if (player.atLimit()) backgroundPos -= 20 * delta;
    else backgroundPos -= 10 * delta;

    if (backgroundPos <= -background.getHeight()) backgroundPos = 0;

    spriteBatch.setProjectionMatrix(camera.combined);
    spriteBatch.begin();
    spriteBatch.draw(background, -1080 / 2, +background.getHeight() / 2 + backgroundPos);
    spriteBatch.draw(background, -1080 / 2, -background.getHeight() / 2 + backgroundPos);
    player.draw(spriteBatch);
    enemies.update(spriteBatch, delta);
    tweenManager.update(delta / 60);
    spriteBatch.end();

    rayHandler.setCombinedMatrix(camera.combined);
    rayHandler.updateAndRender();

    controls.handleInput(camera);
  }
コード例 #29
0
ファイル: PayTest.java プロジェクト: Suslik73/gdx-pay
 @Override
 public void render() {
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   batch.begin();
   font.drawMultiLine(batch, message, 20, Gdx.graphics.getHeight() - 20);
   batch.end();
 }
コード例 #30
0
ファイル: DeathGame.java プロジェクト: 0x17/DeathJam
  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();
  }