Exemplo n.º 1
0
 protected void scheduleKeyRepeatTask(int keycode) {
   if (!keyRepeatTask.isScheduled() || keyRepeatTask.keycode != keycode) {
     keyRepeatTask.keycode = keycode;
     keyRepeatTask.cancel();
     Timer.schedule(keyRepeatTask, keyRepeatInitialTime, keyRepeatTime);
   }
 }
Exemplo n.º 2
0
 public Retard(Object objecte, float temps) {
   Timer.schedule(
       new Timer.Task() {
         @Override
         public void run() {
           ((IRetard) objecte).canviEstat();
         }
       },
       temps);
 }
Exemplo n.º 3
0
  public void update(float delta) {
    if (isDead()) {
      if (hasInventory() && inventory.hasItems()) {
        inventory.clear();
      }

      if (!reset) {
        hidden = true;
        reset = true;
        Timer.schedule(run, 1F);
      }
    }

    if (!isHidden()) {
      updateEntity(delta);
    }
  }
Exemplo n.º 4
0
  public void hitright() {

    if (hit) {
    } else {
      body.setTransform(body.getPosition().x + 5, body.getPosition().y + 7, 1.5f);
      rotation = 90;

      Timer.schedule(
          new com.badlogic.gdx.utils.Timer.Task() {
            @Override
            public void run() {
              body.setTransform(body.getPosition().x - 5, body.getPosition().y - 7, 0f);
              rotation = 0;
              hit = false;
            }
          },
          0.2f //    (delay)
          //    (seconds)
          );
    }
    hit = true;
  }
 public SplashScreen() {
   if (GameConstants.currentMusic != null) {
     GameConstants.currentMusic.stop();
     GameConstants.currentMusic.dispose();
   }
   GameConstants.currentMusic = Gdx.audio.newSound(Gdx.files.internal("menu.mp3"));
   long id = GameConstants.currentMusic.play(GameConstants.MUSIC_VOLUME);
   GameConstants.currentMusic.setLooping(id, true);
   splashScreenTime = 5;
   spriteBatch = new SpriteBatch();
   background1 = new Texture("seems-legit-tunnel.jpg");
   background2 = new Texture("seemslegit2.jpg");
   background3 = new Texture("seemslegit3.jpg");
   choice = MathUtils.random(0, 2);
   Timer.schedule(
       new Timer.Task() {
         @Override
         public void run() {
           nextGameScreen = new MenuScreen();
           screenDone = true;
         }
       },
       splashScreenTime);
 }
Exemplo n.º 6
0
 void setVisible(boolean b) {
   this.isVisible = b;
   BLINK_TASK.cancel();
   TIMER.schedule(BLINK_TASK, getHoldDelay(), getBlinkDelay());
 }
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(1F, 1F, 1F, 1F);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();
    batch.draw(Assets.background, 0, 0, W, H);
    batch.end();

    switch (state) {
      case PAUSE:
        batch.begin();
        batch.draw(
            Assets.avoid,
            (W / 2) - (Assets.avoid.getWidth() / 2),
            H - (augH + Assets.avoid.getHeight()));
        batch.draw(Assets.touch, (W / 2) - (Assets.touch.getWidth() / 2), augH);
        batch.draw(Assets.player, player.getPosition().x, player.getPosition().y);
        batch.end();
        Timer.schedule(
            new Task() {
              @Override
              public void run() {
                touch();
              }
            },
            0.3f);

        break;
      case RUN:
        if (playing) {
          if (gameover == false) {
            time += Gdx.graphics.getDeltaTime();
            meteorIterator = meteor.iterator();
            while (meteorIterator.hasNext()) {
              Meteor cur = meteorIterator.next();
              cur.update();
              batch.begin();
              batch.draw(
                  Assets.meteor,
                  cur.getPosition().x,
                  cur.getPosition().y,
                  Assets.meteor.getWidth() / 2f,
                  Assets.meteor.getHeight() / 2f,
                  Assets.meteor.getWidth(),
                  Assets.meteor.getHeight(),
                  1,
                  1,
                  cur.getMetSp().getRotation(),
                  0,
                  0,
                  Assets.meteor.getWidth(),
                  Assets.meteor.getHeight(),
                  false,
                  false);
              batch.end();
              cur.getMetSp().rotate(8f);
              if (Intersector.overlaps(cur.getmBounds(), player.getpBounds())) {
                gameover = true;
              }
            }
            enemyIterator = enemy.iterator();
            enemyIterator = enemy.iterator();
            while (enemyIterator.hasNext()) {
              Enemy cur = enemyIterator.next();
              cur.update();
              batch.begin();
              batch.draw(
                  Assets.enemy1,
                  cur.getPosition().x,
                  cur.getPosition().y,
                  scX / 2f,
                  scY / 2f,
                  scX,
                  scY,
                  1,
                  1,
                  cur.getRotate().getRotation());
              batch.end();
              cur.getRotate().rotate(-5f);
              if (Intersector.overlaps(cur.getBounds(), player.getpBounds())) {
                gameover = true;
              }
            }
            batch.begin();
            if (time > 40) {
              e2.update();
              batch.draw(Assets.enemy2, e2.getPosition().x, e2.getPosition().y);
              if (Intersector.overlaps(player.getpBounds(), e2.getBounds())) {
                gameover = true;
              }
            }
            if (Assets.H && !Assets.N) {
              if (time > 80) {
                e4.update();
                batch.draw(Assets.enemy2, e4.getPosition().x, e4.getPosition().y);
                if (Intersector.overlaps(player.getpBounds(), e2.getBounds())) {
                  gameover = true;
                }
              }
            }
            batch.draw(Assets.player, player.getPosition().x, player.getPosition().y);
            batch.end();
          } else {
            if (Assets.N) {
              Assets.setBestTime(time, true);
            } else {
              Assets.setBestTime(time, false);
            }
            Assets.setCurrentTime(time);
            exp.currentFrame = exp.anime.getKeyFrame(delta, false);
            batch.begin();
            batch.draw(exp.currentFrame, player.getPosition().x, player.getPosition().y);
            batch.end();
            if (!Assets.boom.isPlaying()) {
              Assets.boom.play();
            }
            Timer.schedule(
                new Task() {
                  @Override
                  public void run() {
                    playing = false;
                  }
                },
                0.7f);
          }
        } else {
          game.setScreen(new Replay(game));
        }

        if (gameover == false) {
          player.movement();
          player.update();
        } else if (gameover) {
          Assets.bgm.stop();
        }
        break;
    }
  }
Exemplo n.º 8
0
  protected void decreaseTimeLeft() {
    if (timeLeft >= 1) timeLeft -= 1;

    Timer.schedule(dtlTask, 1);
  }