Esempio n. 1
0
  public void Game_Finished(int level) {
    game_finished = true;
    this.level = level;
    if (simulation.game_won()) {
      prefs.putInteger("Level_26_Game", 2);
      if (prefs.getInteger("Level_10_Game", 0) == 2) {

      } else {
        prefs.putInteger("Level_10_Game", 1);
      }
      if (prefs.getInteger("Level_21_Game", 0) == 2) {

      } else {
        prefs.putInteger("Level_21_Game", 1);
      }
      if (prefs.getInteger("Level_27_Game", 0) == 2) {

      } else {
        prefs.putInteger("Level_27_Game", 1);
      }
      if (prefs.getInteger("Level_31_Game", 0) == 2) {

      } else {
        prefs.putInteger("Level_31_Game", 1);
      }
      prefs.flush();
    }
  }
  /**
   * Will load font from file. If that fails, font will be generated and saved to file.
   *
   * @param fontFile the actual font (.otf, .ttf)
   * @param fontName the name of the font, i.e. "arial-small", "arial-large", "monospace-10" This
   *     will be used for creating the font file names
   * @param fontSize fontSize of font when screen width equals referenceScreenWidth
   */
  public AnimvsBitmapFont createFont(
      FileHandle fontFile,
      String fontName,
      int fontSize,
      String characters,
      String language,
      int pageSize) {
    if (pageSize < 50)
      throw new RuntimeException("Page fontSize too small during font generation: " + pageSize);

    AnimvsBitmapFont font = null;
    // if fonts are already generated, just load from file
    Preferences fontPrefs = Gdx.app.getPreferences(propertyName);
    String lastVersionTag = fontPrefs.getString("tag");
    int displayWidth = fontPrefs.getInteger("display-width", 0);
    int displayHeight = fontPrefs.getInteger("display-height", 0);
    String lastUsedLanguage = fontPrefs.getString("lang");
    boolean loaded = false;
    if (displayWidth != Gdx.graphics.getWidth() || displayHeight != Gdx.graphics.getHeight())
      Gdx.app.debug(TAG, "Screen fontSize change detected, regenerating fonts");
    else if (!lastUsedLanguage.equals(language))
      Gdx.app.debug(TAG, "Language change detected, regenerating fonts");
    else if (!lastVersionTag.equals(versionTag))
      Gdx.app.debug(TAG, "Version change detected, regenerating fonts");
    else if (!forceGeneration) {
      try {
        // try to load from file
        Gdx.app.debug(TAG, "Loading generated font from file cache");
        font = new AnimvsBitmapFont(getFontFile(fontName + ".fnt"));
        setDefaultFilter(font);

        loaded = true;

        // arquivosFonte.add(fontFile.path());
      } catch (GdxRuntimeException e) {
        Gdx.app.error(TAG, e.getMessage());
        Gdx.app.debug(TAG, "Couldn't load pre-generated fonts. Will generate fonts.");
      }
    }
    if (!loaded || forceGeneration) {
      forceGeneration = false;
      // float width = Gdx.graphics.getWidth();
      // float ratio = width / referenceScreenWidth; // use 1920x1280 as
      // float baseSize = 28f; // for 28 sized fonts at baseline width
      // above

      Gdx.app.log(
          TAG,
          "Generating Font - Name: "
              + fontName
              + " Size: "
              + fontSize
              + " characters: "
              + characters);
      font = generateFontWriteFiles(fontName, fontFile, fontSize, pageSize, pageSize, characters);
      // arquivosFonte.add(fontFile.path());
    }
    return font;
  }
Esempio n. 3
0
  @Override
  public void preDraw(float delta) {
    super.preDraw(delta);

    if (!isInitialised) {
      Gdx.app.log(TAG, "Loading Prefs");
      isInitialised = true;
      ArtTag.gameSettings = new GameSettings();
      final Preferences prefs = Gdx.app.getPreferences("ArtTreacheryPrefs");
      ArtTag.gameSettings.screenWidth = prefs.getInteger("screenWidth", 1280);
      ArtTag.gameSettings.screenHeight = prefs.getInteger("screenHeight", 1024);
      ArtTag.gameSettings.fullscreen = prefs.getBoolean("fullscreen", false);
      ArtTag.gameSettings.blur = prefs.getInteger("blur", 1);
      ArtTag.gameSettings.rays = prefs.getInteger("rays", 64);
      ArtTag.gameSettings.handleResAuto = prefs.getBoolean("handleResAuto", true);

      Gdx.app.log(TAG, "Saving Prefs");
      prefs.putInteger("screenWidth", ArtTag.gameSettings.screenWidth);
      prefs.putInteger("screenHeight", ArtTag.gameSettings.screenHeight);
      prefs.putBoolean("fullscreen", ArtTag.gameSettings.fullscreen);
      prefs.putInteger("blur", ArtTag.gameSettings.blur);
      prefs.putInteger("rays", ArtTag.gameSettings.rays);
      prefs.putBoolean("handleResAuto", ArtTag.gameSettings.handleResAuto);
      prefs.flush();

      if (Gdx.graphics.supportsDisplayModeChange() && ArtTag.gameSettings.handleResAuto == false) {
        Gdx.app.log(TAG, "Trying to set Displaymode");
        Gdx.graphics.setDisplayMode(
            ArtTag.gameSettings.screenWidth,
            ArtTag.gameSettings.screenHeight,
            ArtTag.gameSettings.fullscreen);

        // Gdx.gl.glViewport(0, 0, ArtTag.gameSettings.screenWidth,
        // ArtTag.gameSettings.screenHeight);
      }
    }

    Assets.assetsManager.update();
    if (!isStarted && MathUtils.isEqual(1f, Assets.assetsManager.getProgress())) {
      // done loading eh
      Assets.instance.onFinishLoading();

      startGame();
      isStarted = true;

      // final TextButton startButton = new TextButton("Start", Assets.instance.skin);
      // startButton.addListener(new InputListener() {
      //
      // @Override
      // public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
      // startGame();
      // return super.touchDown(event, x, y, pointer, button);
      // }
      // });
    }
  }
  /** Ladataan nykyinen kieli. * */
  public void load(Preferences preferences) {
    if (preferences.contains("Locale")) currentLocaleIndex = preferences.getInteger("Locale");
    else currentLocaleIndex = 0;

    languageBundle =
        I18NBundle.createBundle(Gdx.files.internal("Resources\\strings"), getCurrentLocale());
  }
Esempio n. 5
0
 public void load() {
   sound = prefs.getBoolean("sound", true);
   music = prefs.getBoolean("music", true);
   // если нет записи в "volSound" берем значение 0.5 и проверяем на границы от 0.0 до 1.0
   volSound = MathUtils.clamp(prefs.getFloat("volSound", 0.5f), 0.0f, 1.0f);
   volMusic = MathUtils.clamp(prefs.getFloat("volMusic", 0.5f), 0.0f, 1.0f);
   charSkin = MathUtils.clamp(prefs.getInteger("charSkin", 0), 0, 2);
   showFpsCounter = prefs.getBoolean("showFpsCounter", false);
   useMonochromeShader = prefs.getBoolean("useMonochromeShader", false);
 }
Esempio n. 6
0
 public ScoresScreen(VeryAngryRobotsGame game) {
   super(game);
   scoreCam =
       CameraHelper.createCamera2(
           ViewportMode.PIXEL_PERFECT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, Assets.pixelDensity);
   spriteBatch = new SpriteBatch();
   spriteBatch.setProjectionMatrix(scoreCam.combined);
   scoreString = new ScoreString();
   topScoreString = new ScoreString();
   preferences = Gdx.app.getPreferences(VERY_ANGRY_ROBOTS);
   topScore = preferences.getInteger(TOP_SCORE_PREF, 1000);
   topScoreString.setScore(topScore);
   stateTime = 0.0f;
 }
  private void initLabels() {
    Label.LabelStyle estilo = new Label.LabelStyle();
    estilo.font = fonteTitulo;

    lbTitulo = new Label("SPACE INVADERS", estilo);
    palco.addActor(lbTitulo);

    Preferences preferencias = Gdx.app.getPreferences("SpaceInvaders");
    int pontuacaoMaxima = preferencias.getInteger("pontuacao_maxima", 0);

    estilo = new Label.LabelStyle();
    estilo.font = foneBotoes;

    lbPontuacao = new Label("Pontuação Máxima: " + pontuacaoMaxima + " Pontos", estilo);
    palco.addActor(lbPontuacao);
  }
Esempio n. 8
0
  public GameState(TitleState title) {
    this.title = title;
    this.title.reset();
    prefs = Gdx.app.getPreferences("highscore");
    adsController = MainGame.adsController;
    restartButton = new RestartButton(MainGame.WIDTH / 2 - 78, MainGame.HEIGHT / 2 - 100);
    menuButton = new MenuButton(MainGame.WIDTH / 2 - 125, MainGame.HEIGHT / 2);
    unpauseButton = new UnpauseButton(MainGame.WIDTH / 2 - 78, MainGame.HEIGHT / 2 + 100);
    highScore = prefs.getInteger("highscore", 0);

    gameOverOverlay = new Sprite(new Texture(Gdx.files.internal("gui/gameoverlay.png")));
    gameOverOverlay.setPosition(0, MainGame.HEIGHT / 2 - (gameOverOverlay.getHeight() / 2));

    backGroundFade = new Sprite(new Texture(Gdx.files.internal("gui/bgfade.png")));
    backGroundFade.setPosition(0, 0);
    backGroundFade.setSize(MainGame.WIDTH, MainGame.HEIGHT);
    backGroundFade.setAlpha(0.6f);

    grid = new Grid(15, 15, 390, 390, prefs);

    parameter.size = 20;
    parameter.shadowColor = new Color(0, 0, 0, 1f);
    parameter.shadowOffsetX = 1;
    parameter.shadowOffsetY = 1;
    score = grid.getScore();
    scoreFont = generator.generateFont(parameter);
    highscoreFont = generator.generateFont(parameter);
    redCounter = new Sprite(new Texture(Gdx.files.internal("gui/score/scorecounter.png")));
    redCounter.setSize(144, 26.4f);
    redCounter.setPosition(18, MainGame.HEIGHT - redCounter.getHeight() - 260);

    blueCounter = new Sprite(new Texture(Gdx.files.internal("gui/score/highscorecounter.png")));
    blueCounter.setSize(144, 26.4f);
    blueCounter.setPosition(
        MainGame.WIDTH - blueCounter.getWidth() - 18,
        MainGame.HEIGHT - blueCounter.getHeight() - 260);

    scoreFont.setColor(Color.WHITE);
    scoreFont.setFixedWidthGlyphs("0123456789");
    highscoreFont.setFixedWidthGlyphs("0123456789");
    grid.setPaused(false);
  }
Esempio n. 9
0
  public void saveState() {
    System.out.println("SAVE");
    hasFlushed = false;
    int currentHighScore = prefs.getInteger("highscore");
    prefs.clear();
    for (int i = 0; i < grid.getBlocks().size; i++) {
      prefs.putFloat("x" + i, grid.getBlocks().get(i).getX());
      prefs.putFloat("y" + i, grid.getBlocks().get(i).getY());
      prefs.putFloat("val" + i, grid.getBlocks().get(i).getValue());
    }

    prefs.putInteger("score", grid.getScore());

    if (highScore >= currentHighScore) {
      prefs.putInteger("highscore", highScore);
    } else {
      prefs.putInteger("highscore", currentHighScore);
    }
    prefs.flush();
    hasFlushed = true;
  }
Esempio n. 10
0
  private Settings() {

    loadTables();

    // NOTES: on desktop, file is store in /Users/[username]/.prefs/[name]
    Preferences p = Gdx.app.getPreferences(PREFS_NAME);
    if (p.contains("soundOn")) {
      this.soundOn = p.getBoolean("soundOn");
    }
    if (p.contains("musicOn")) {
      this.musicOn = p.getBoolean("musicOn");
    }
    if (p.contains("rulesEverSeen")) {
      this.rulesEverSeen = p.getBoolean("rulesEverSeen");
    }

    // look for best scores on all of the tables
    // best score is stored as a key matching the map file
    for (TableInfo ti : this.tables) {
      if (p.contains(ti.getName())) {
        ti.setHighScore(p.getInteger(ti.getName()));
      }
    }
  }
Esempio n. 11
0
  @Override
  public void update(float dt) {
    if (!paused) {
      handleInput();
      if (!readyToFadeWhite) player.update(dt); // So player can be controlled upward from Sky
      else {
        // Lift player
        whiteOverlay += .3f * dt;
        player.getVelocity().add(0, -player.gravity / 2);
        player.getVelocity().scl(dt);
        player.getPosition().add(player.movement * dt, player.getVelocity().y);
        player.getVelocity().scl(1 / dt);
        float temp =
            player.normalize(
                -450, 200, (float) -Math.PI / 4f, (float) Math.PI / 4f, player.getVelocity().y);
        player.rotation = 25 * (float) Math.sin(temp);
        if (whiteOverlay > 1f) {
          dispose();
          Preferences p = Gdx.app.getPreferences(OwlCityTribute.GAME_PREFS);
          p.putInteger("level", 5);
          if (p.getInteger("maxlevel") < 5) {
            p.putInteger("maxlevel", 5);
          }
          p.flush();
          gsm.currentState = GameStateManager.SKY;
          this.gsm.setState(new Sky(this.gsm));
        }
      }
      fallen = player.getPosition().y == -OwlCityTribute.HEIGHT * .1f;

      if (!loss && fallen) {
        loss = true;
        gsm.push(new UponLoss(gsm));
      }

      note.update(dt);
      noteAnim.update(dt);
      noteRotation += 100f * dt;
      if (noteRotation > 360) noteRotation = 0;

      balloonFluctuation.update(dt);

      cam.position.x = player.getPosition().x + player.xOffset;
      float leftEdge = player.getPosition().x - (cam.viewportWidth / 2) + player.xOffset;

      // Check if note is hit
      if (!shrinking
          && Math.sqrt(
                  Math.pow(
                          (player.getPosition().x + player.getPlane().getWidth() * .75f)
                              - note.getPosition().x,
                          2)
                      + Math.pow(
                          (player.getPosition().y + (player.getPlane().getHeight() * .75f) / 2)
                              - (note.getPosition().y + noteAnim.getFrame().getRegionHeight() / 2),
                          2))
              < 40) {
        // Open textbox
        textCount++;
        textBox.prepare(
            sceneText.get(textCount).get(0),
            (sceneText.get(textCount).size() == 1) ? "" : sceneText.get(textCount).get(1),
            .1f);
        boxInitialized = true;

        // Set bounds
        int w = (int) font.getBounds(sceneText.get(textCount).get(0)).width;
        // int h = (int)(font.getBounds(sceneText.get(textCount).get(0)).height*2.5);
        int h =
            (int)
                (font.getBounds(sceneText.get(textCount).get(0)).height
                    * sceneText.get(textCount).size()
                    * 1.5);
        textBox.setBounds(
            w,
            h,
            (int) (OwlCityTribute.WIDTH * .65) - w / 2,
            (int) (OwlCityTribute.HEIGHT * .875) - h / 2);
        waiting = true;
        shrinking = true;
      } else if (note.getPosition().x < leftEdge - noteAnim.getFrame().getRegionWidth()
          && !waiting
          && textCount < sceneText.size() - 1
          && player.movement > player.maxMovement * .75) {
        note.getPosition().x = player.getPosition().x + cam.viewportWidth;
        note.setyOffset((int) (Math.random() * 100) + 200);
      }

      if (shrinking) {
        noteScale -= 2.5 * dt;
        if (noteScale < 0) {
          shrinking = false;
          noteScale = 1f;
          note.getPosition().x -= cam.viewportWidth;
        }
      }

      if (textBox.readyToUpdate) {
        if (!textBox.update(dt)) waiting = true;
        else {
          waiting = false;
          if (textCount < sceneText.size() - 1 && player.movement > player.maxMovement * .75) {
            note.getPosition().x = player.getPosition().x + cam.viewportWidth;
            note.setyOffset((int) (Math.random() * 100) + 200);
          }
        }
      }

      if (!fallen && boxInitialized && textCount == sceneText.size() - 1 && textBox.finished) {
        readyToFadeWhite = true;
      }

      // clouds
      for (int i = 0; i < clouds.size; i++) {
        clouds.get(i).update(dt);
        if (clouds.get(i).getPosition().x < leftEdge - cloud.getWidth()) {
          int index = (i == 0) ? clouds.size - 1 : i - 1;
          clouds.get(i).getPosition().x =
              (float) (clouds.get(index).getPosition().x + cam.viewportWidth * .8);
          clouds.get(i).yOffset =
              random.nextInt((int) (OwlCityTribute.HEIGHT * .1f))
                  + (int) (OwlCityTribute.HEIGHT * .75f);
        }
      }

      //        if(readyToFadeBlack){
      //            whiteValue  = (whiteValue > 0) ? whiteValue - .2f*dt : 0f;
      //            if(whiteValue == 0f){
      //                if(player.getPosition().y == -OwlCityTribute.HEIGHT*.1f){
      //                    dispose();
      //                    this.gsm.setState(new Sky(this.gsm));
      //                }
      //            }
      //        }
      // else{
      whiteValue = (whiteValue < 1f) ? whiteValue + .4f * dt : 1f;
      // }

      // Shimmer update
      for (int i = 0; i < NUM_SHIMMERS; i++) {
        shimmers.get(i).update(dt);
      }

      // Check brush
      for (int i = 0; i < brushmoving.size; i++) {
        brushmoving.get(i).MOVEMENT = -(player.movement / 5);
        brushmoving.get(i).update(dt);
        if (brushmoving.get(i).getPosition().x < leftEdge - brush.getWidth() * 1.5) {
          int index = (i == 0) ? brushmoving.size - 1 : i - 1;
          brushmoving.get(i).getPosition().x =
              brushmoving.get(index).getPosition().x + brush.getWidth();
          break;
        }
      }

      cam.update();
    }
  }
Esempio n. 12
0
 // Retrieves the current high score
 public static int getHighScore() {
   return prefs.getInteger("highScore");
 }
Esempio n. 13
0
 public static int getLuckQuantity() {
   check();
   return prefs.getInteger(Consts.PREF_LUCK_QUANTITY, Consts.DEFAULT_LUCK_QUANTITY);
 }
Esempio n. 14
0
 public static int getScore() {
   check();
   return prefs.getInteger(Consts.PREF_SCORE, Consts.DEFAULT_SCORE);
 }
Esempio n. 15
0
 public static int getTotalFall() {
   return score.getInteger("totalFall");
 }
Esempio n. 16
0
 public static void setTotalFall() {
   fallTemp = score.getInteger("totalFall");
   fallTemp++;
   score.putInteger("totalFall", fallTemp);
 }