Exemple #1
0
  @Override
  public void render(float delta) {
    if (this.handleInput(delta)) {
      myGame.setScreen(BaseGame.screens.get("main"));
      return;
    }

    // Make a black background
    if (Settings.getRetro()) {
      GL10 g1 = Gdx.graphics.getGL10();
      Gdx.gl.glClearColor(0, 0, 0, 1);
      g1.glClear(GL20.GL_COLOR_BUFFER_BIT);
    } else {
      GL10 g1 = Gdx.graphics.getGL10();
      Gdx.gl.glClearColor(.19f, .19f, .19f, 1f);
      g1.glClear(GL20.GL_COLOR_BUFFER_BIT);
    }

    float dpi = Gdx.graphics.getDensity() * 160f;
    float inchHeight = ((float) Gdx.graphics.getHeight()) / dpi;

    spriteBatch.begin();
    font.setScale(2 * dpi * (inchHeight / 22f) / 72f);
    font.draw(spriteBatch, "High Scores", xx * .40f, yy * .98f);
    font.setScale(dpi * (inchHeight / 22f) / 72f);
    for (int i = 0; i < 10; i++) {
      font.draw(spriteBatch, scores[i][0], xx * .05f, yy * (.85f - i * .08f));
      font.draw(spriteBatch, scores[i][1], xx * .20f, yy * (.85f - i * .08f));
      font.draw(spriteBatch, scores[i][2], xx * .70f, yy * (.85f - i * .08f));
    }
    spriteBatch.end();
  }
 @Override
 public void draw(Batch batch, float parentAlpha) {
   font.setScale(getScaleX());
   font.setColor(this.getColor());
   font.drawWrapped(batch, text, getX(), getY(), getWidth());
   font.setColor(Color.WHITE);
   font.setScale(1);
 }
  @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();
  }
Exemple #4
0
  // *** Methods for drawing text ***\\
  public static void drawString(
      SpriteBatch batch,
      String string,
      float x,
      float y,
      boolean centered,
      float scale,
      Color color) {
    // Check if the new scale is the same as the current one.
    if (font_.getScaleX() != scale || font_.getScaleY() != scale) font_.setScale(scale);

    // No need to check the colour, as that is done in the BitmapCache in the BitmapFont.
    font_.setColor(color);

    if (centered) {
      TextBounds bounds = font_.getBounds(string);
      float width = bounds.width;
      float height = bounds.height - font_.getAscent();

      x -= (width / 2);
      y -= (height / 2);
    }

    font_.draw(batch, string, x, y);
  }
Exemple #5
0
  @Override
  public void create() {
    font = new BitmapFont();
    font.setColor(1f, 0f, 0.05f, 1f);
    font.setScale(1.2f);

    project = ProjectManager.getInstance().getCurrentProject();
    pathForScreenshot = Utils.buildProjectPath(project.getName()) + "/";

    virtualWidth = project.getXmlHeader().virtualScreenWidth;
    virtualHeight = project.getXmlHeader().virtualScreenHeight;

    virtualWidthHalf = virtualWidth / 2;
    virtualHeightHalf = virtualHeight / 2;

    stage = new Stage(virtualWidth, virtualHeight, true);
    batch = stage.getSpriteBatch();

    Gdx.gl.glViewport(0, 0, ScreenValues.SCREEN_WIDTH, ScreenValues.SCREEN_HEIGHT);
    initScreenMode();

    sprites = project.getSpriteList();
    for (Sprite sprite : sprites) {
      sprite.resetSprite();
      sprite.look.createBrightnessContrastShader();
      stage.addActor(sprite.look);
      sprite.resume();
    }

    passepartout =
        new Passepartout(
            ScreenValues.SCREEN_WIDTH,
            ScreenValues.SCREEN_HEIGHT,
            maximizeViewPortWidth,
            maximizeViewPortHeight,
            virtualWidth,
            virtualHeight);
    stage.addActor(passepartout);

    if (DEBUG) {
      OrthoCamController camController = new OrthoCamController(camera);
      InputMultiplexer multiplexer = new InputMultiplexer();
      multiplexer.addProcessor(camController);
      multiplexer.addProcessor(stage);
      Gdx.input.setInputProcessor(multiplexer);
      fpsLogger = new FPSLogger();
    } else {
      Gdx.input.setInputProcessor(stage);
    }

    axes = new Texture(Gdx.files.internal("stage/red_pixel.bmp"));
    skipFirstFrameForAutomaticScreenshot = true;
    if (checkIfAutomaticScreenshotShouldBeTaken) {
      makeAutomaticScreenshot = project.manualScreenshotExists(SCREENSHOT_MANUAL_FILE_NAME);
    }
  }
  @Override
  public void draw() {
    // Draw actors
    super.draw();

    // Write title
    getBatch().begin();
    font.setScale(1f);
    font.draw(
        getBatch(),
        Game.TITLE,
        getWidth() / 2f - font.getBounds(Game.TITLE).width / 2f,
        getHeight() - 10f);
    font.setScale(0.5f);
    TextBounds bounds = font.getBounds("Highscore : " + Game.Save().highScore);
    font.draw(
        getBatch(), "Highscore : " + Game.Save().highScore, getWidth() - bounds.width, getHeight());
    getBatch().end();
  }
Exemple #7
0
  public void render(Treasure cost) {
    fontScale = font.getScaleX();
    font.setScale(Math.max(Math.round(fontScale * scale), 1));
    if (!cost.equals(this.cost) || !this.equals(bounds)) {
      this.bounds = new Rectangle(this);
      this.cost = new Treasure(cost);

      caches = new ArrayList<costValueCache>();
      if (showCost) {
        if (cost.getGold() > 0) {
          caches.add(new costValueCache(Color.WHITE, "Cost: "));
          caches.add(new costValueCache(Color.YELLOW, cost.getGold() + " "));
        }
      }
      for (Element element : Element.values()) {
        int element1 = cost.getElement(element);
        if (element1 > 0) {
          caches.add(new costValueCache(Color.WHITE, element1 + "x "));
          caches.add(new costValueCache(element.getColor(), element.toString() + " "));
        }
      }

      render();

    } else {
      render();
    }

    font.setScale(fontScale);

    if (App.DEBUG != null) {
      shapeRenderer.setColor(Color.RED);
      shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
      shapeRenderer.rect(x, y, width, height);
      shapeRenderer.end();
    }
  }
Exemple #8
0
  protected void renderGame() {

    Gdx.gl.glClearDepthf(1f);
    Gdx.gl.glClear(GL20.GL_DEPTH_BUFFER_BIT);

    // Clearing screen, positioning camera, rendering map and entities
    // Positioning camera to the player
    Specular.camera.zoom = 1;
    Camera.setPosition();
    Specular.camera.update();

    // Rendering map and entities
    game.batch.setProjectionMatrix(Specular.camera.combined);
    game.batch.begin();

    game.batch.setColor(1, 1, 1, 1);
    game.batch.draw(
        currentMap.getParallax(),
        -1024 + Camera.getCameraX() / 2,
        -1024 + Camera.getCameraY() / 2,
        4096,
        4096);
    game.batch.setColor(1, 1, 1, 1);

    Camera.setZoom();
    BoardShock.setZoom();

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

    currentMap.render(game.batch, true);

    ScissorStack.calculateScissors(
        Specular.camera, game.batch.getTransformMatrix(), clipBounds, scissors);
    ScissorStack.pushScissors(scissors);

    if (tutorialOnGoing && tutorial.getCurrentWave().getEvent() == TutorialEvent.POWER_UPS_SHOWN) {
      if (!tutorial.enemiesHasSpawned()) {
        Util.writeCentered(
            game.batch,
            tutorial.getFont(),
            "these are power-ups",
            tutorial.getTextX(),
            tutorial.getTextY() + 200);

        if (tutorial.allPowerUpsActivated())
          Util.writeCentered(
              game.batch,
              tutorial.getFont(),
              "some can be combined",
              tutorial.getTextX(),
              tutorial.getTextY());
      }
    }

    for (Entity ent : entities) {
      if (!(ent instanceof Enemy)) ent.render(game.batch);
    }

    game.batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE);

    for (UpgradeOrb orb : orbs) orb.render(game.batch);

    for (Particle p : particles) p.render(game.batch);

    game.batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    for (Entity ent : enemies) {
      ent.render(game.batch);
    }

    if (!gameMode.isGameOver()) player.render(game.batch);

    game.batch.flush();
    ScissorStack.popScissors();

    // Re-positioning camera for HUD
    Specular.camera.position.set(0, 0, 0);
    Specular.camera.zoom = 1;
    Specular.camera.update();
    game.batch.setProjectionMatrix(Specular.camera.combined);

    if (isPaused) { // Pause menu
      game.batch.draw(
          greyPixel,
          -Specular.camera.viewportWidth / 2,
          -Specular.camera.viewportHeight / 2,
          Specular.camera.viewportWidth,
          Specular.camera.viewportHeight);
      game.batch.draw(pauseTex, -pauseTex.getWidth() / 2, 100);
      pauseInputProcessor.getResumeButton().render();
      pauseInputProcessor.getToMenuButton().render();
    } else {
      if (!gameMode.isGameOver()) {
        // Drawing HUD
        hud.render(game.batch, scoreMultiplierTimer);
        gameInputProcessor.getShootStick().render(game.batch);
        gameInputProcessor.getMoveStick().render(game.batch);

        // Tutorial
        if (tutorialOnGoing && !showTutorialEnd) tutorial.render(game.batch);

        // Drawing SCORE in the middle top of the screen
        Util.writeCentered(
            game.batch,
            scoreFont,
            player.getFormattedScore(),
            0,
            Specular.camera.viewportHeight / 2 - 36);
        // Drawing MULTIPLIER on screen
        Util.writeCentered(
            game.batch,
            multiplierFont,
            "x" + Math.round(scoreMultiplier),
            0,
            Specular.camera.viewportHeight / 2 - 98);

        // Tutorial end
        if (showTutorialEnd) {
          tutorialTicks++;

          if (tutorialTicks > 120) {
            scoreFontAlpha = (tutorialTicks - 120) / 180f;
            scoreFontAlpha = scoreFontAlpha > 1 ? 1 : scoreFontAlpha;

            game.batch.setColor(1, 1, 1, scoreFontAlpha);
            game.batch.draw(
                greyPixel,
                -Specular.camera.viewportWidth / 2,
                -Specular.camera.viewportHeight / 2,
                Specular.camera.viewportWidth,
                Specular.camera.viewportHeight);
            game.batch.setColor(Color.WHITE);

            scoreFont.setColor(1, 0, 0, scoreFontAlpha);
            Util.writeCentered(game.batch, scoreFont, "tap to continue", 0, -100);
          }
        }

        gameMode.render(game.batch);
      } else if (gameMode.isGameOver()) { // Game over screen
        // Manual camera shake
        Specular.camera.position.set(0, 0, 0);
        Specular.camera.position.add(
            rand.nextFloat() * 100 * Camera.getShakeIntensity(),
            rand.nextFloat() * 100 * Camera.getShakeIntensity(),
            0);
        Specular.camera.update();
        game.batch.setProjectionMatrix(Specular.camera.combined);

        game.batch.draw(
            greyPixel,
            -Specular.camera.viewportWidth / 2,
            -Specular.camera.viewportHeight / 2,
            Specular.camera.viewportWidth,
            Specular.camera.viewportHeight);
        game.batch.draw(gameOverTex, -gameOverTex.getWidth() / 2, -gameOverTex.getHeight() / 2);

        // Game Over effects [fade in, camera shake]
        if (gameOverScoreFont.getScaleX() > 1f) {
          gameOverScoreFont.scale(-0.1f);
          gameOverScoreFont.setColor(
              1, 0, 0, Math.max((10 - gameOverScoreFont.getScaleX()) / 10f, 0));
        } else {
          gameOverScoreFont.setScale(1);
          if (!shaken) {
            Camera.shake(0.5f, 0.02f);
            shaken = true;
          }

          if (player.getScore() >= lastHighscore) {
            Util.drawCentered(game.batch, newHighscore, 0, 0, 0);
            lastHighscore = player.getScore();
          }
        }

        // Drawing final score and buttons
        if (music != null) music.setVolume(0.25f);
        if (gameOverTicks == GAMEOVERSOUND_TIMER && isSoundEnabled()) {
          gameOverSound.play(1f, 1, 0);
        }
        Util.writeCentered(game.batch, gameOverScoreFont, player.getFormattedScore(), 0, 100);

        game.batch.setColor(Color.WHITE);
        ggInputProcessor.getRetryBtn().render();
        ggInputProcessor.getMenuBtn().render();
        ggInputProcessor.getHighscoreBtn().render();

        if (player.getUpgradePoints() >= 1) {
          if (!ggInputProcessor.isTouchingUpgradeBtn()) {
            if (gameOverTicks % 90 < 40) {
              ggInputProcessor.getUpgradeBtn().setScale(1.00f);
              ggInputProcessor.getUpgradeBtn().setTouch(true);
            } else {
              ggInputProcessor.getUpgradeBtn().setScale(1.0f);
              ggInputProcessor.getUpgradeBtn().setTouch(false);
            }
          }
        }

        ggInputProcessor.getUpgradeBtn().render();
      }
    }

    game.batch.end();
  }
Exemple #9
0
  protected void update() {
    if (!isPaused) {

      if (tutorialOnGoing) tutorial.update();

      // Remove random particles if there are too many
      while (particles.size >= PARTICLE_LIMIT) particles.removeIndex(rand.nextInt(particles.size));

      // Remove random orbs if there are too many
      while (orbs.size >= ORB_LIMIT) orbs.removeIndex(rand.nextInt(orbs.size));

      // Adding played time
      if (!gameMode.isGameOver()) ticks++;

      // Updating combos
      cs.update();

      BoardShock.update();

      if (scoreMultiplier > 1) {
        if (scoreMultiplierTimer < MULTIPLIER_COOLDOWN_TIME) {
          float decreaseRate = (float) scoreMultiplier / 3;

          scoreMultiplierTimer += decreaseRate;
        } else {
          if (isSoundEnabled())
            multiplierDownSound.play(1f, (float) Math.sqrt(scoreMultiplier / 3), 0);

          scoreMultiplierTimer = 0;
          scoreMultiplier--;
        }
      }

      if (cs.getCombo() > 7) {
        if (isSoundEnabled()) multiplierUpSound.play(1f, (float) Math.sqrt(scoreMultiplier / 3), 0);

        setScoreMultiplier(scoreMultiplier + 1);
        if (getScoreMultiplier() % 10 == 0) {
          multiplierFont.scale(2);
        }

        cs.resetCombo();
      }

      if (multiplierFont.getScaleX() > 1) {
        multiplierFont.scale(-0.05f);
        if (multiplierFont.getScaleX() <= 1) {
          multiplierFont.setScale(1);
        }
      }

      boolean playerKilled = false; // A variable to keep track of player status
      if (!gameMode.isGameOver()) {
        // Update game mode, enemy spawning and player hit detection
        gameMode.update(TICK_LENGTH / 1000000);

        if (!tutorialOnGoing) {
          // Update power-ups
          powerUpSpawnTime--;
          if (powerUpSpawnTime < 0) {
            if (enablePowerUps) {
              puss.spawn();
              powerUpSpawnTime = 300;
            }
          }
        }

        updateHitDetections();

        // So that they don't spawn while death animation is playing
        if (!player.isDying() && !player.isSpawning()) {
          if (player.isDead() && !tutorialOnGoing) {
            pss.spawn(true);
            waveNumber++;
            currentWave = waveManager.getWave(waveNumber);
          } else {
            player.updateHitDetection();
            if (!tutorialOnGoing) {
              if (currentWave.update()) {
                waveNumber++;
                currentWave = waveManager.getWave(waveNumber);
              }
            }
          }
        }

        if (player.update() && !player.isDying()) {
          if (!tutorialOnGoing) {
            gameMode.playerKilled();
            playerKilled = true;
          }
        }
      } else {
        clearLists();
        gameOverTicks++;
      }

      // Removing destroyed entities
      for (Iterator<Entity> it = entities.iterator(); it.hasNext(); ) {
        Entity ent = it.next();
        if (ent.update()) {
          if (ent instanceof Particle) pass.getPool().free((Particle) ent);
          else if (ent instanceof UpgradeOrb) oss.getPool().free((UpgradeOrb) ent);
          else if (ent instanceof Enemy) enemies.removeIndex(enemies.indexOf((Enemy) ent, true));
          else if (ent instanceof PowerUp)
            powerups.removeIndex(powerups.indexOf((PowerUp) ent, true));
          else if (ent instanceof Bullet) {
            bullets.removeIndex(bullets.indexOf((Bullet) ent, true));
            Bullet.free((Bullet) ent);
          }

          it.remove();
        }
      }

      for (Iterator<UpgradeOrb> it = orbs.iterator(); it.hasNext(); ) {
        if (it.next().update()) it.remove();
      }

      for (Iterator<Particle> it = particles.iterator(); it.hasNext(); ) {
        if (it.next().update()) it.remove();
      }
      // Enemy Slowdown
      SlowdownEnemies.setUpdatedSlowdown(false);

      if (playerKilled && tutorialHasEnded()) {
        if (!gameMode.isGameOver()) {
          clearLists();
          resetGameTime();
          pss.spawn(false);
        } else {
          saveStats();
          input.setInputProcessor(ggInputProcessor);
          gameOverScoreFont.scale(14);

          if (Specular.nativeAndroid.isLoggedIn()) {
            Specular.nativeAndroid.postHighscore(player.getScore(), true);
          }
        }
      }

      Camera.update(this);
    }
  }
  public static void load(NanoCat nano) {

    pref = Gdx.app.getPreferences("NanoGameState");

    if (!pref.getBoolean("hdState")) {
      if (nano.getTime() < 15 && nano.getTime() >= 5) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_1_s.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_1_s.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

      } else if (nano.getTime() < 20 && nano.getTime() >= 15) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_2_s.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_2_s.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      } else if (nano.getTime() >= 20) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_3_s.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3_s.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      } else {
        bgTexture = new Texture(Gdx.files.internal("data/bg_3_s.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3_s.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      }
    } else if (pref.getBoolean("hdState")) {
      if (nano.getTime() < 15 && nano.getTime() >= 5) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_1.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_1.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      } else if (nano.getTime() < 20 && nano.getTime() >= 15) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_2.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_2.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      } else if (nano.getTime() >= 20) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_3.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      } else {
        bgTexture = new Texture(Gdx.files.internal("data/bg_3.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      }
    }

    bgBack = new TextureRegion(bgBackTexture, 0, 0, 4096, 580);

    // Particle Stuff

    smoke = new Texture(Gdx.files.internal("data/smoke_particle.png"));
    smokeSprite = new Sprite(smoke);
    smokeEmitter = new ParticleEmitter();
    smokeParticle = new ParticleEffect();
    smokeParticle.load(Gdx.files.internal("data/particlesmoke"), Gdx.files.internal("data"));
    smokeParticle.findEmitter("smoke").getScale().setHigh(50f);

    starEmitter = new ParticleEmitter();
    starParticle = new ParticleEffect();
    starParticle.load(Gdx.files.internal("data/particles"), Gdx.files.internal("data"));
    starParticle.findEmitter("star").getScale().setHigh(5f);
    starParticle.findEmitter("star2").getScale().setHigh(5f);

    //		smokeParticle.getScale().setHigh(5f);

    // End Particle Stuff

    texture = new Texture(Gdx.files.internal("data/nano_region.png"));
    texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);

    nanoRun = new TextureAtlas(Gdx.files.internal("data/nanorun.atlas"));
    platform = new TextureAtlas(Gdx.files.internal("data/platform.atlas"));

    catRun1 = nanoRun.findRegion("nanorun0001");
    catRun2 = nanoRun.findRegion("nanorun0005");
    catRun3 = nanoRun.findRegion("nanorun0009");
    catRun4 = nanoRun.findRegion("nanorun0013");
    catRun5 = nanoRun.findRegion("nanorun0017");
    catRun6 = nanoRun.findRegion("nanorun0021");
    catRun7 = nanoRun.findRegion("nanorun0025");
    catRun8 = nanoRun.findRegion("nanorun0029");
    catRun9 = nanoRun.findRegion("nanorun0033");
    catRun10 = nanoRun.findRegion("nanorun0037");
    catRun11 = nanoRun.findRegion("nanorun0041");
    catRun12 = nanoRun.findRegion("nanorun0045");
    catRun13 = nanoRun.findRegion("nanorun0049");
    catRun14 = nanoRun.findRegion("nanorun0053");
    catRun15 = nanoRun.findRegion("nanorun0057");

    catCollide1 = nanoRun.findRegion("nanocollide0080");
    catCollide2 = nanoRun.findRegion("nanocollide0084");
    catCollide3 = nanoRun.findRegion("nanocollide0088");
    catCollide4 = nanoRun.findRegion("nanocollide0092");
    catCollide5 = nanoRun.findRegion("nanocollide0096");
    catCollide6 = nanoRun.findRegion("nanocollide0100");
    catCollide7 = nanoRun.findRegion("nanocollide0104");
    catCollide8 = nanoRun.findRegion("nanocollide0108");

    case0 = platform.findRegion("case0");
    case1 = platform.findRegion("case1");
    case2 = platform.findRegion("case2");
    case3 = platform.findRegion("case3");
    case4 = platform.findRegion("case4");
    case5 = platform.findRegion("case5");
    case6 = platform.findRegion("case6");
    caseDefault = platform.findRegion("default");

    TextureRegion[] catRun = {
      catRun1, catRun2, catRun3, catRun4, catRun5, catRun6, catRun7, catRun8, catRun9, catRun10,
      catRun11, catRun12, catRun13, catRun14, catRun15
    };
    catRunAnim = new Animation(.015f, catRun);
    catRunAnim.setPlayMode(Animation.PlayMode.LOOP);

    TextureRegion[] catJump = {
      catRun1, catRun2, catRun3, catRun4, catRun5, catRun6, catRun7, catRun8, catRun9, catRun9,
      catRun9, catRun9, catRun9, catRun9, catRun9, catRun9
    };
    catJumpAnim = new Animation(.04f, catJump);
    catJumpAnim.setPlayMode(Animation.PlayMode.LOOP);

    TextureRegion[] catCollide = {
      catCollide1,
      catCollide2,
      catCollide3,
      catCollide4,
      catCollide5,
      catCollide6,
      catCollide7,
      catCollide8
    };
    catCollideAnim = new Animation(.02f, catCollide);
    catCollideAnim.setPlayMode(Animation.PlayMode.NORMAL);

    fontFilter = new Texture(Gdx.files.internal("data/roboto_lt.png"));
    fontFilter.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    robotoLt =
        new BitmapFont(
            Gdx.files.internal("data/roboto_lt.fnt"), new TextureRegion(fontFilter), false);
    robotoLt.setScale(.5f, .5f);

    fontFilter2 = new Texture(Gdx.files.internal("data/roboto_blk.png"));
    fontFilter2.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    robotoBlk =
        new BitmapFont(
            Gdx.files.internal("data/roboto_blk.fnt"), new TextureRegion(fontFilter2), false);
    robotoBlk.setScale(.5f, .5f);

    panel = new Texture(Gdx.files.internal("data/panelcolor.png"));
    panel.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    panelSprite = new Sprite(panel, 500, 300);

    fbShare = new Texture(Gdx.files.internal("data/fbshare.png"));
    fbShare.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    fbShareSprite = new Sprite(fbShare, 199, 57);

    menuBack = new Texture(Gdx.files.internal("data/menu_back.png"));
    menuBack.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    menuBackSprite = new Sprite(menuBack, 320, 50);

    collision = Gdx.audio.newSound(Gdx.files.internal("data/audio/collide.wav"));
    milestone = Gdx.audio.newSound(Gdx.files.internal("data/audio/milestone.wav"));
    milestone50 = Gdx.audio.newSound(Gdx.files.internal("data/audio/milestone50.wav"));
    jump = Gdx.audio.newSound(Gdx.files.internal("data/audio/nanojump.wav"));
    jumpSound = Gdx.audio.newSound(Gdx.files.internal("data/audio/jump_sound.wav"));
    dblJump = Gdx.audio.newSound(Gdx.files.internal("data/audio/nanojump2.wav"));
    hit = Gdx.audio.newSound(Gdx.files.internal("data/audio/hit.wav"));
    select = Gdx.audio.newSound(Gdx.files.internal("data/audio/select.wav"));
    run = Gdx.audio.newSound(Gdx.files.internal("data/audio/run.wav"));
    highScore = Gdx.audio.newSound(Gdx.files.internal("data/audio/highscore.wav"));

    // Scoring
    score = Gdx.app.getPreferences("NanoCat");

    if (!score.contains("distance")) {
      score.putFloat("distance", 0);
    }

    if (!score.contains("highScore")) {
      score.putFloat("highScore", 0);
    }

    if (!score.contains("totalFall")) {
      score.putInteger("totalFall", 0);
    }
  }
Exemple #11
0
 @Override
 public void show() {
   font.setScale(.40f);
   spriteBatch = new SpriteBatch();
 }
Exemple #12
0
  public static void load() {
    // TEXTURES has to be in Formtat: 2^x * 2^y
    loadNumbers();
    loadBlocks();
    loadPlayerTextures();

    logoTexture = new Texture(Gdx.files.internal("data/logo.png"));
    logoTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    logo = new TextureRegion(logoTexture, 0, 0, 512, 114);

    texture = new Texture(Gdx.files.internal("data/texture.png"));
    texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);

    FileHandle test = Gdx.files.internal("data/touchBackground.png");
    System.out.println(test.exists());
    touchKnob = new Texture(test);
    touchKnob.setFilter(TextureFilter.Linear, TextureFilter.Nearest);

    playButtonUp = new TextureRegion(texture, 0, 83, 29, 16);
    playButtonUp.flip(false, true);

    playButtonDown = new TextureRegion(texture, 29, 83, 29, 16);
    playButtonDown.flip(false, true);

    playerFace = new Texture(Gdx.files.internal("data/playerLogo.png"));
    playerLogo = new TextureRegion(playerFace, 0, 0, playerFace.getWidth(), playerFace.getHeight());
    playerLogo.flip(false, true);

    ready = new TextureRegion(texture, 59, 83, 34, 7);
    ready.flip(false, true);

    retry = new TextureRegion(texture, 59, 110, 33, 7);
    retry.flip(false, true);

    gameOver = new TextureRegion(texture, 59, 92, 46, 7);
    gameOver.flip(false, true);

    scoreboard = new TextureRegion(texture, 111, 83, 97, 37);
    scoreboard.flip(false, true);

    star = new TextureRegion(texture, 152, 70, 10, 10);
    noStar = new TextureRegion(texture, 165, 70, 10, 10);

    star.flip(false, true);
    noStar.flip(false, true);

    highScore = new TextureRegion(texture, 59, 101, 48, 7);
    highScore.flip(false, true);

    zbLogo = new TextureRegion(texture, 0, 55, 135, 24);
    zbLogo.flip(false, true);

    bg = new TextureRegion(texture, 0, 0, 136, 43);
    bg.flip(false, true);

    block = new TextureRegion(texture, 0, 100, 34, 25);
    block.flip(false, true);

    grass = new TextureRegion(texture, 0, 43, 143, 11);
    grass.flip(false, false);

    birdDown = new TextureRegion(texture, 136, 0, 17, 12);
    birdDown.flip(false, true);

    bird = new TextureRegion(texture, 153, 0, 17, 12);
    bird.flip(false, true);

    birdUp = new TextureRegion(texture, 170, 0, 17, 12);
    birdUp.flip(false, true);

    TextureRegion[] birds = {birdDown, bird, birdUp};
    birdAnimation = new Animation(0.06f, birds);
    birdAnimation.setPlayMode(Animation.LOOP_PINGPONG);

    skullUp = new TextureRegion(texture, 192, 0, 24, 14);
    // Create by flipping existing skullUp
    skullDown = new TextureRegion(skullUp);
    skullDown.flip(false, true);

    bar = new TextureRegion(texture, 136, 16, 22, 3);
    bar.flip(false, true);

    //		dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav"));
    //		flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav"));
    //		coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav"));
    //		fall = Gdx.audio.newSound(Gdx.files.internal("data/fall.wav"));

    font = new BitmapFont(Gdx.files.internal("data/text.fnt"));
    font.setScale(.25f, -.25f);

    whiteFont = new BitmapFont(Gdx.files.internal("data/whitetext.fnt"));
    whiteFont.setScale(.1f, -.1f);

    shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt"));
    shadow.setScale(.25f, -.25f);

    // Create (or retrieve existing) preferences file
    prefs = Gdx.app.getPreferences("ZombieBird");

    if (!prefs.contains("highScore")) {
      prefs.putInteger("highScore", 0);
    }
  }
Exemple #13
0
 /** Sets the font's scale relative to the current scale. */
 public void scale(float amount) {
   setScale(scaleX + amount, scaleY + amount);
 }
Exemple #14
0
 /**
  * Scales the font by the specified amount in both directions.<br>
  * <br>
  * Note that smoother scaling can be achieved if the texture backing the BitmapFont is using
  * {@link TextureFilter#Linear}. The default is Nearest, so use a BitmapFont constructor that
  * takes a {@link TextureRegion}.
  */
 public void setScale(float scaleXY) {
   setScale(scaleXY, scaleXY);
 }