Exemplo n.º 1
0
  public void update(float deltaTime) {
    if (Gdx.input.justTouched()) {
      guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

      if (OverlapTester.pointInRectangle(playBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new GameScreen(game));
        return;
      }
      if (OverlapTester.pointInRectangle(highscoresBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new HighscoresScreen(game));
        return;
      }
      if (OverlapTester.pointInRectangle(helpBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new HelpScreen(game));
        return;
      }
      if (OverlapTester.pointInRectangle(soundBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        Settings.soundEnabled = !Settings.soundEnabled;
        if (Settings.soundEnabled) Assets.music.play();
        else Assets.music.pause();
      }
    }
  }
Exemplo n.º 2
0
 @Override
 public void dispose() {
   stage.dispose();
   game.dispose();
   skin.dispose();
   batch.dispose();
 }
Exemplo n.º 3
0
 @Override
 public void render() {
   Gdx.gl.glClearColor(0.06f, 0.06f, 0.06f, 1f);
   Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
   // this.logger.log();
   super.render();
 }
  @Override
  public void render() {
    super.render();

    // output the current FPS
    fpsLogger.log();
  }
Exemplo n.º 5
0
  @Override
  public void render() {

    super.render();

    this.update();
    this.getScreen().render(Gdx.graphics.getDeltaTime());
  }
  public void update() {
    if (Gdx.input.justTouched()) {
      guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

      if (nextBounds.contains(touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new MainMenuScreen(game));
      }
    }
  }
Exemplo n.º 7
0
  public void update(float deltaTime) {
    if (Gdx.input.justTouched()) {
      guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

      if (OverlapTester.pointInRectangle(nextBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new MainMenuScreen(game));
        return;
      }
    }
  }
Exemplo n.º 8
0
  @Override
  protected void onChangeState() {
    try {
      // If we switched state and it is a screen, update the game screen
      State state = getCurrentState();

      if (state instanceof Screen) {
        game.setScreen((Screen) state);
        setChanged();
        notifyObservers();
      }
    } catch (IllegalStateException e) {
      // No state
    }
  }
Exemplo n.º 9
0
 @Override
 /** Dispose all the resources. */
 public void dispose() {
   super.dispose();
   for (Texture t : textureMap.values()) {
     t.dispose();
   }
   textureMap.clear();
   regionMap.clear();
   for (BitmapFont f : fontMap.values()) {
     f.dispose();
   }
   for (Sound s : soundMap.values()) {
     s.dispose();
   }
 }
Exemplo n.º 10
0
  private void updatePaused() {
    if (Gdx.input.justTouched()) {
      guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

      if (OverlapTester.pointInRectangle(resumeBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        state = GAME_RUNNING;
        return;
      }

      if (OverlapTester.pointInRectangle(quitBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new MainMenuScreen(game));
        return;
      }
    }
  }
 @Override
 public boolean touchUp(int screenX, int screenY, int pointer, int button) {
   if (!wasTouchDown) {
     return false;
   }
   wasTouchDown = false;
   for (EventButton evBtn : _buttons) {
     evBtn.btn.setNormalMode();
     if (this.isButtonUnderPoint(evBtn.btn)) {
       if (evBtn.type == -1) {
         GooglePlayData.showAchievements();
       } else {
         _game.setScreen(ScreenControl.getScreen(evBtn.type));
       }
     }
   }
   return super.touchUp(screenX, screenY, pointer, button);
 }
Exemplo n.º 12
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.begin();
    textFont.setColor(Color.YELLOW);
    textFont.draw(
        batch,
        String.format("%4s%9s%9s", "RANK", "SCORE", "NAME"),
        (int) (1200 * .12),
        (int) (1824 * .875));
    for (int i = 0; i < 10; i++) {
      textFont.setColor(scoreColors[i]);
      drawScore(i);
    }
    batch.draw(backButton.getTexture(), backButton.getX(), backButton.getY());
    batch.end();

    if (Gdx.input.isKeyPressed(Input.Keys.BACK)) MainGame.setScreen(new MenuScreen(MainGame));
  }
Exemplo n.º 13
0
  // ---------------------------------------------------
  // 画像移動
  // 画面端にいったらステート移行
  // ---------------------------------------------------
  public void moveSprite() {
    // クリックされたらメニューの文字が移動
    if (scrollFlag) {
      // 加速して画面外へ
      spritePositionX += MOVE_SPEED;

      // スプライト移動
      modeContinue.setPosition(spritePositionX, 0);
      modeNewGame.setPosition(spritePositionX, -4);
      modeLoadGame.setPosition(spritePositionX, -8);
      modeNetwork.setPosition(spritePositionX, -12);
      modeOption.setPosition(spritePositionX, -16);
      modeExit.setPosition(spritePositionX, -20);
    }

    // メニューの文字が画面外まで移動したらゲームメイン移行
    if (spritePositionX >= FADE_MENU) {
      scrollNinja.setScreen(new GameMain(scrollNinja, nextStageNum));
    }
  }
Exemplo n.º 14
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();
    backGroundSprite.draw(batch);
    batch.draw(
        backGroundSprite,
        backGroundSprite.getX(),
        backGroundSprite.getY(),
        backGroundSprite.getWidth(),
        backGroundSprite.getHeight());
    batch.end();

    stage.act(Gdx.graphics.getDeltaTime());
    stage.draw();
    if (Gdx.input.isKeyPressed(Input.Keys.BACK)) {
      game.setScreen(new LoginScreen(game));
    }
  }
Exemplo n.º 15
0
 @Override
 public void resume() {
   super.resume();
 }
Exemplo n.º 16
0
 @Override
 public void pause() {
   super.pause();
 }
Exemplo n.º 17
0
 @Override
 public void resize(int width, int height) {
   super.resize(width, height);
 }
Exemplo n.º 18
0
 private void updateGameOver() {
   if (Gdx.input.justTouched()) {
     game.setScreen(new MainMenuScreen(game));
   }
 }
Exemplo n.º 19
0
 private void updateGameOver2(float deltaTime) {
   if (Gdx.input.justTouched()) game.setScreen(new MainMenuScreen(game));
 }
Exemplo n.º 20
0
 @Override
 public void dispose() {
   super.dispose();
   batch.dispose();
 }
Exemplo n.º 21
0
  @Override
  public void render(float delta) {
    super.render();

    totalGameTimer += delta;
    // if ((totalGameTimer >= 5) && (levelStarted == false)) {
    // startLevel("theme1.txt");
    // levelStarted = true;
    // return;
    // }

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

    batch.begin();
    {
      // batch.draw(rightFootprintTexture, WIDTH / 2 + footSpacing - 50,
      // 0);
      // batch.draw(leftFootprintTexture, WIDTH / 2 - footSpacing - 50,
      // 0);
      // batch.draw(rightWall, 0, 0, WIDTH, HEIGHT);
      // batch.draw(leftWall, 0, 0, WIDTH, HEIGHT);
      // batch.draw(perspectiveTexture, 0, 0, WIDTH, HEIGHT);

    }
    batch.end();

    batch.begin();
    // sprite.draw(batch);
    elapsedTime += Gdx.graphics.getDeltaTime();
    // batch.draw(), x, y, originX, originY, width, height, scaleX, scaleY,
    // rotation);
    batch.draw(smokeTexture, 0, 0, WIDTH, HEIGHT);

    // System.out.println(level.getSkipped());
    int damage = (level.getSkipped() + level.getMisses()) / 3;

    // System.out.println(damage);

    if (damage == 5) {
      leftWallAnimation = new Animation(1 / 45f, leftWallTextureAtlas.getRegions());
      rightWallAnimation = new Animation(1 / 45f, rightWallTextureAtlas.getRegions());
    }

    if (damage >= 6) {
      deathCounter++;
      ScreenManager.getInstance().show(ScreenManager.Screens.TITLE);
      endingLevel = true;
      music.stop();
      music.dispose();
    } else {
      batch.draw(
          pentagramAtlas.findRegion("000" + Integer.toString((damage % 7) + 1)),
          WIDTH / 2 - (72 / 2),
          HEIGHT - 72,
          72,
          72);
    }
    // batch.draw(stairTexture, 0, (float) -(level.getCurrPos() * 10),
    // WIDTH, HEIGHT);
    batch.draw(
        stairsAnimation.getKeyFrame(level.getFootstepsBetween(-level.getCurrPos(), 0).size(), true),
        (float) 0,
        0,
        WIDTH,
        HEIGHT / 2);
    batch.draw(leftWallAnimation.getKeyFrame(elapsedTime, true), 0, 0, 225, HEIGHT);
    batch.draw(rightWallAnimation.getKeyFrame(elapsedTime, true), WIDTH - 225, 0, 225, HEIGHT);
    batch.end();

    // Advance in level
    // level.addCurrPos(delta);
    // TODO:
    level.syncWithMusic(music);

    // // Announce next footstep, if one has been passed
    // if (level.getFootsteps().get(nextFootstep).getTime() <
    // level.getCurrPos()) {
    // // "Next" footstep is in the past
    // nextFootstep++;
    //
    // // Announce
    // System.out.println("Next footstep is now: " +
    // level.getFootsteps().get(nextFootstep).toString());
    // }

    // TODO: Look for input
    boolean leftPressed = Gdx.input.isKeyJustPressed(Input.Keys.SHIFT_LEFT);
    boolean rightPressed = Gdx.input.isKeyJustPressed(Input.Keys.SHIFT_RIGHT);
    if (leftPressed || rightPressed) {
      // TODO: If pressed BEFORE a footstep, miss the next footstep

      // If pressed DURING a footstep, mark footstep as hit if it is left.
      // Otherwise miss.
      for (Footstep f : level.getActiveFootsteps(HIT_THRESHOLD)) {
        if (f != null) {
          Footstep active = f;
          if ((!active.isDidHit()) && (!active.isDidMiss())) {
            if (((active.getType() == FootstepType.LEFT) && leftPressed)
                || ((active.getType() == FootstepType.RIGHT) && rightPressed)) {
              // HIT!
              active.setDidHit(true);
              // System.out.println("HIT FOOTSTEP: " +
              // active.toString());
            } else {
              // Miss.
              active.setDidMiss(true);
              // System.out.println("MISSED FOOTSTEP: " +
              // active.toString());
            }
          }
        }
      }
    }

    // Render visible footsteps
    batch.begin();
    {
      double startTime = -2;
      double farthestTime = 5.0f;
      for (Footstep f : level.getFootstepsBetween(startTime, farthestTime)) {
        float distanceOnRoad =
            (float) ((f.getTime() - level.getCurrPos()) / (farthestTime - startTime));
        distanceOnRoad -= 1;
        distanceOnRoad = -(-Math.abs(distanceOnRoad * distanceOnRoad * distanceOnRoad) - 1);
        distanceOnRoad = 2 - (distanceOnRoad);
        Sprite sprite = new Sprite(rightFootprintTexture);
        // Flip for left foot
        sprite.flip(f.getType() == FootstepType.LEFT, false);
        // Add alpha
        if (distanceOnRoad > 0) {
          sprite.setAlpha((1f - distanceOnRoad) * 0.9f + 0.1f);
        }
        // Add scaling
        sprite.setScale((1f - distanceOnRoad) * 0.6f);
        // Light footsteps that are "active"
        double distanceTo = f.getTime() - level.getCurrPos();
        if (Math.abs(distanceTo) < LIT_THRESHOLD) {
          sprite.setColor(Color.BLUE);
        }
        if (-distanceTo > LIT_THRESHOLD && (!(f.isDidHit() || f.isDidMiss()))) {
          sprite.setRotation((int) (level.getCurrPos() * 2000));
          sprite.setColor(Color.FIREBRICK);
        }

        // Mark hits or misses
        if (f.isDidHit()) {
          sprite.setColor(Color.GREEN);
        } else if (f.isDidMiss()) {
          sprite.setColor(Color.RED);
        }

        float leftFactor = 1;
        if (f.getType() == FootstepType.LEFT) {
          leftFactor = -1;
        }
        float x = WIDTH / 2 + (leftFactor * (WIDTH / 11) * (1 - distanceOnRoad));
        float y = (distanceOnRoad * (HEIGHT / 2 + 50 - FOOTSTEP_LINE)) + FOOTSTEP_LINE;

        // Celebrate hits!
        if (f.isDidHit()) {
          y += -distanceTo * 100;
        }

        sprite.setCenter(x, y);
        sprite.draw(batch);
      }
    }
    batch.end();
  }
Exemplo n.º 22
0
 @Override
 public void resume() {
   super.resume();
   Assets.manager.update();
 }
Exemplo n.º 23
0
 @Override
 public void dispose() {
   super.dispose();
   Assets.unload();
 }
 @Override
 public void setScreen(Screen screen) {
   super.setScreen(screen);
 }
Exemplo n.º 25
0
 @Override
 public void render() {
   super.render();
 }
Exemplo n.º 26
0
 @Override
 public void resize(int width, int height) {
   recalculateSize(width, height);
   super.resize(width, height);
 }
Exemplo n.º 27
0
 @Override
 public void dispose() {
   super.dispose();
   AssetLoader.dispose();
 }
Exemplo n.º 28
0
 @Override
 public void render() {
   super.render(); // DON'T FORGET!
 }
Exemplo n.º 29
0
 public void render() {
   super.render(); // important!
 }
Exemplo n.º 30
0
 public void dispose() {
   super.dispose();
   Assets.dispose();
 }