Example #1
0
 public void addBird() {
   TextureRegion[] birdRegions =
       new TextureRegion[] {
         Atlas.findRegion("bird1"), Atlas.findRegion("bird2"), Atlas.findRegion("bird3")
       };
   bird = new Chim(birdRegions);
   bird.setPosition(Flappybird.VIEWPORT.x / 2 - bird.getWidth(), Flappybird.VIEWPORT.y / 2);
   stage.addActor(bird);
 }
Example #2
0
 public void addPipe() {
   int r = config.random(0, 7);
   float dy = r * 10;
   r = config.random(0, 1);
   if (r == 0) {
     dy = -dy;
   }
   Pipe pipe1 = new Pipe(Atlas.findRegion("pipe1"), bird, true);
   pipe1.setZIndex(1);
   float x = Flappybird.VIEWPORT.x;
   float y =
       (Flappybird.VIEWPORT.y - config.KlandHeight) / 2
           + config.KlandHeight
           + config.KholeBetwenPipe / 2;
   pipe1.setPosition(x, y + dy);
   Pipe pipe2 = new Pipe(Atlas.findRegion("pipe2"), bird, false);
   pipe2.setZIndex(1);
   y =
       (Flappybird.VIEWPORT.y - config.KlandHeight) / 2
           + config.KlandHeight
           - pipe2.getHeight()
           - config.KholeBetwenPipe / 2;
   pipe2.setPosition(x, y + dy);
   stage.addActor(pipe1);
   stage.addActor(pipe2);
   labelScore.setZIndex(pipe1.getZIndex());
   land.setZIndex(pipe2.getZIndex());
   bird.setZIndex(pipe2.getZIndex());
 }
Example #3
0
 @Override
 public void render(float delta) {
   Gdx.gl.glClearColor(0, 0, 0, 1);
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   if (Gdx.input.justTouched()) {
     if (bird.isDie) {
       resetGame();
     } else {
       bird.Tapme();
       Flappybird.Sounds.get(config.SoundsJump).play();
     }
   }
   duraTimepipe += delta;
   if (duraTimepipe > config.KtimeAddPipe) {
     if (bird.isTapPipe()) {
       duraTimepipe = 0;
       addPipe();
     }
   }
   stage.act();
   stage.draw();
 }