Esempio n. 1
0
 public static void reloadFonts() {
   if (fontGen == null || fonts == null) return;
   fontGen.dispose();
   fontGen = new FreeTypeFontGenerator(Gdx.files.internal("data/arial_bold.ttf"));
   for (int size : fonts.keySet()) {
     fonts.put(size, fontGen.generateFont(size));
   }
 }
Esempio n. 2
0
  @Override
  public void create() {

    w = Gdx.graphics.getWidth();
    h = Gdx.graphics.getHeight();
    margin = 10;
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf"));
    BitmapFont font15 = generator.generateFont(15);
    generator.dispose();

    LabelStyle lblStyle = new LabelStyle(skin.get(LabelStyle.class));
    lblStyle.font = font15;
    lblStyle.fontColor = Color.BLACK;
    lblStyle.background = null;

    LabelStyle lblOutStyle = new LabelStyle(skin.get(LabelStyle.class));
    lblOutStyle.font = font15;
    lblOutStyle.fontColor = Color.BLACK;
    lblOutStyle.background = new ColorDrawable(new HSV_Color(Color.WHITE));

    TextButtonStyle btnStyle = skin.get(TextButtonStyle.class);
    btnStyle.font = font15;
    btnStyle.fontColor = Color.BLACK;

    lblMsg = new Label(Msg, lblStyle);
    stage.addActor(lblMsg);

    lblOut = new Label("", lblOutStyle);
    // lblOut = new Label("", lblStyle);
    lblOut.setText(" ");
    stage.addActor(lblOut);

    btnRunLibGdx = new TextButton("", btnStyle);
    stage.addActor(btnRunLibGdx);

    btnRunTranslations = new TextButton("download and copy latest translations", btnStyle);
    btnRunTranslations.addListener(runListenerTranslations);
    stage.addActor(btnRunTranslations);

    btnRunTexturePacker = new TextButton("Pack and copy Texture Images", btnStyle);
    btnRunTexturePacker.addListener(runListenerTexture);
    stage.addActor(btnRunTexturePacker);

    TeePrintStream tee = new TeePrintStream(System.out);
    System.setOut(tee);

    chkSource();

    layout();
  }
Esempio n. 3
0
    public BitmapFont getLemonMilk(int size) {
      FreeTypeFontGenerator generator =
          new FreeTypeFontGenerator(Gdx.files.internal("fonts/LemonMilk.ttf"));
      FreeTypeFontParameter parameter = new FreeTypeFontParameter();
      parameter.size = size;
      BitmapFont lemonMilk = generator.generateFont(parameter);
      generator.dispose();

      return lemonMilk;
    }
Esempio n. 4
0
  public DebugGdx() {
    shapeRenderer = new ShapeRenderer();

    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("ARIBLK.TTF"));
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = 10;
    parameter.color = Color.BLACK;
    font = generator.generateFont(parameter);
    generator.dispose();
  }
Esempio n. 5
0
  @Override
  public void create() {
    FreeTypeFontGenerator fontGenerator =
        new FreeTypeFontGenerator(Gdx.files.internal("fonts/ProFont.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter fontParameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    fontParameter.size = (int) (48);
    gameFont = fontGenerator.generateFont(fontParameter);
    fontGenerator.dispose();

    setScreen(new MainMenuScreen(this));
  }
Esempio n. 6
0
  public TitleCard(int size, float x, float y) {
    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("assets/fonts/Fipps-Regular.ttf"));
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = size == 0 ? 36 : 72;
    titleFont = generator.generateFont(parameter);
    generator.dispose();

    this.x = x;
    this.y = y;
    this.size = size;
  }
Esempio n. 7
0
  public StartScreen(SpaceSim game) {
    this.game = game;
    background = new Texture(Gdx.files.internal("bg5.jpg"));
    batch = new SpriteBatch();
    stage = new Stage();
    heading = "Space Simulator";

    Gdx.input.setInputProcessor(stage);

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("fonts/Philosopher-Regular.ttf"));
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    buttonFont = generator.generateFont(parameter);
    buttonFont.setColor(1, 1, 1, 1);
    parameter.size = 72;
    headingFont = generator.generateFont(parameter);
    headingFont.setColor(1, 1, 1, 1);
    generator.dispose();

    GlyphLayout layout = new GlyphLayout(headingFont, heading);
    headingX = (int) ((Gdx.graphics.getWidth() / 2) - (layout.width / 2));
    headingY = 550;

    this.skin = new Skin();
    this.skin.add("default", buttonFont);

    Pixmap pixmap = new Pixmap(200, 50, Pixmap.Format.RGB888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    this.skin.add("background", new Texture(pixmap));

    TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
    textButtonStyle.up = this.skin.newDrawable("background", Color.GRAY);
    textButtonStyle.over = this.skin.newDrawable("background", Color.LIGHT_GRAY);
    textButtonStyle.font = this.skin.getFont("default");
    this.skin.add("default", textButtonStyle);

    TextButton startButton = new TextButton("Start", this.skin);
    startButton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            StartScreen.this.game.setScreen(new GalaxyMapScreen(StartScreen.this.game));
          };
        });
    startButton.setPosition((Gdx.graphics.getWidth() / 2) - (startButton.getWidth() / 2), 300);

    this.stage.addActor(startButton);
  }
  /**
   * Convenience method for generating a font, and then writing the fnt and png files. Writing a
   * generated font to files allows the possibility of only generating the fonts when they are
   * missing, otherwise loading from a previously generated file.
   *
   * @param fontFile
   * @param fontSize
   */
  private AnimvsBitmapFont generateFontWriteFiles(
      String fontName,
      FileHandle fontFile,
      int fontSize,
      int pageWidth,
      int pageHeight,
      String characters) {
    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);

    PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight, Pixmap.Format.RGBA8888, 1, false);

    FreeTypeFontParameter fontParameters = new FreeTypeFontParameter();
    fontParameters.characters = characters;
    fontParameters.size = fontSize;
    fontParameters.minFilter = TextureFilter.Nearest;
    fontParameters.magFilter = TextureFilter.Linear;
    fontParameters.packer = packer;

    // FreeTypeFontGenerator.FreeTypeBitmapFontData fontData =
    // generator.generateData(fontSize, characters, false, packer);

    FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(fontParameters);
    Array<PixmapPacker.Page> pages = packer.getPages();
    Array<TextureRegion> texRegions = new Array<TextureRegion>(pages.size);
    for (int i = 0; i < pages.size; i++) {
      PixmapPacker.Page p = pages.get(i);
      Texture tex =
          new Texture(
              new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false, true)) {
            @Override
            public void dispose() {
              super.dispose();
              getTextureData().consumePixmap().dispose();
            }
          };
      tex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
      texRegions.add(new TextureRegion(tex));
    }
    AnimvsBitmapFont font = new AnimvsBitmapFont(fontData, texRegions, true);
    setDefaultFilter(font);

    saveFontToFile(font, fontSize, fontName, packer);
    generator.dispose();
    packer.dispose();
    return font;
  }
Esempio n. 9
0
 public static synchronized BitmapFont getFont(int fontSize) {
   if (fonts == null) fonts = new HashMap<Integer, BitmapFont>();
   if (!fonts.containsKey(fontSize)) {
     if (fontGen == null)
       fontGen = new FreeTypeFontGenerator(Gdx.files.internal("data/arial_bold.ttf"));
     fonts.put(fontSize, fontGen.generateFont(fontSize));
   }
   return fonts.get(fontSize);
 }
Esempio n. 10
0
  public void updateFont(String newChars) {
    parameter.characters = parameter.characters + newChars;
    font = generator.generateFont(parameter);
    //		generator.generateData(parameter);

    BitmapFont oldFont = this.getStyle().font;
    this.getStyle().font = this.getStyle().messageFont = font;
    oldFont.dispose();
    updateDisplayText();
  }
Esempio n. 11
0
  private void generateTextComponents() {

    genericTextBoxMap = new HashMap<Float, BitmapFont>();
    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("font/androidnation.ttf"));
    for (Float fontSize : Helper.TEXTBOX_SIZE) {
      genericTextBoxMap.put(fontSize, generator.generateFont((int) (fontSize * ppuy)));
    }
    generator.dispose();
    generator = new FreeTypeFontGenerator(Gdx.files.internal("font/androidnation.ttf"));
    miscTextFont = generator.generateFont((int) (Sizes.FONT_SIZE_MISC * ppux));
    generator.dispose();

    pauseBounds = createBounds(Helper.TEXTBOX_INDEX_PAUSE);
    levelFinishedBounds = createBounds(Helper.TEXTBOX_INDEX_LEVEL);
    tapBounds = createBounds(Helper.TEXTBOX_INDEX_TAP);
    gameFinishedBounds = createBounds(Helper.TEXTBOX_INDEX_GRATULATION);
    gameOverBounds = createBounds(Helper.TEXTBOX_INDEX_GAME_OVER);
  }
Esempio n. 12
0
  public void prepareEmbeddingFont(String fontfamily, int fontSize) {
    flushAllUnusedFonts();

    if (isFontLoaded(fontfamily, fontSize)) {
      return;
    }

    FontManager fontManager = facade.retrieveProxy(FontManager.NAME);

    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = fontSize;

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(fontManager.getTTFByName(fontfamily));
    BitmapFont font = generator.generateFont(parameter);

    addBitmapFont(fontfamily, parameter.size, font);
  }
Esempio n. 13
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. 14
0
  public void loadCurrentProjectBitmapFonts(String path, String curResolution) {
    bitmapFonts.clear();

    ArrayList<FontSizePair> requiredFonts = getProjectRequiredFontsList();
    for (int i = 0; i < requiredFonts.size(); i++) {
      FontSizePair pair = requiredFonts.get(i);
      FileHandle fontFile;
      try {
        fontFile = getTTFSafely(pair.fontName);
        FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
        FreeTypeFontGenerator.FreeTypeFontParameter parameter =
            new FreeTypeFontGenerator.FreeTypeFontParameter();
        parameter.size = Math.round(pair.fontSize * resolutionManager.getCurrentMul());
        BitmapFont font = generator.generateFont(parameter);
        bitmapFonts.put(pair, font);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
Esempio n. 15
0
  private void initFontes() {
    FreeTypeFontGenerator gerador =
        new FreeTypeFontGenerator(Gdx.files.internal("fonts/roboto.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter param =
        new FreeTypeFontGenerator.FreeTypeFontParameter();

    param.size = 48;
    param.color = new Color(.25f, .25f, .85f, 1);
    param.shadowOffsetX = 2;
    param.shadowOffsetY = 2;
    param.shadowColor = Color.BLACK;

    fonteTitulo = gerador.generateFont(param);
    param = new FreeTypeFontGenerator.FreeTypeFontParameter();
    param.size = 32;
    param.color = Color.BLACK;

    foneBotoes = gerador.generateFont(param);

    gerador.dispose();
  }
  public MainMenu(GameSoundController sound) {
    this.sound = sound;

    masterMech = new Texture("img/masterMechanic.png");

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("fonts/black.ttf"));
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = 20;
    font = generator.generateFont(parameter);
    generator.dispose();

    stage = new Stage();

    atlas = new TextureAtlas("ui/buttons.pack");
    skin = new Skin(Gdx.files.internal("ui/menuButtonSettings.json"), atlas);

    table = new Table(skin);

    heading = new Label("Mech Infiltration", new LabelStyle(font, Color.WHITE));
  }
Esempio n. 17
0
  @Override
  public void show() {
    batch = new SpriteBatch();
    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("SharedAssets/Fonts/textFont.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = 42;
    textFont = generator.generateFont(parameter);
    generator.dispose();

    backButton =
        new Button(
            new Texture(Gdx.files.internal("SharedAssets/mainMenuText.png")),
            (int) (1200 * .12),
            (int) (1824 * .12));
    ScoreBuilder scoreBuilder = new ScoreBuilder();
    topScores = scoreBuilder.getTopScores();

    // If high score needs to be entered, receive that input, too.
  }
Esempio n. 18
0
  public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    // set asset manager error handler
    assetManager.setErrorListener(this);
    // load texture atlas
    assetManager.load(Constants.TEXTURE_ATLAS_OBJECTS, TextureAtlas.class);
    // start loading assets and wait until finished
    assetManager.finishLoading();
    // get texture atlas from asset manager
    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS_OBJECTS);

    player = new AssetPlayer(atlas);

    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(Constants.FONT));

    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = 18;

    font = generator.generateFont(parameter);
    generator.dispose();
  }
Esempio n. 19
0
  private void initFontes() {
    FreeTypeFontGenerator gerador =
        new FreeTypeFontGenerator(Gdx.files.internal("fonts/roboto.ttf"));

    // instancia a fonte utilizada no título
    FreeTypeFontGenerator.FreeTypeFontParameter params =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    params.size = 48;
    params.color = new Color(.25f, .25f, .85f, 1); // tom de azul
    params.shadowOffsetX = 2;
    params.shadowOffsetY = 2;
    params.shadowColor = Color.BLACK;

    fonteTitulo = gerador.generateFont(params);

    // instancia a fonte utilizada nos botões
    params = new FreeTypeFontGenerator.FreeTypeFontParameter();
    params.size = 32;
    params.color = Color.BLACK;

    fonteBotoes = gerador.generateFont(params);

    gerador.dispose();
  }
Esempio n. 20
0
  @Override
  public void create() {
    stop = win = false;

    debugRenderer = new Box2DDebugRenderer();
    Gdx.input.setInputProcessor(new PlayerInputProcessor(player));
    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cameraBak = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    batch = new SpriteBatch();
    atlas = new TextureAtlas("spacemangame.atlas");

    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(new FileHandle("font.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = 120;
    font = generator.generateFont(parameter); // font size 12 pixels
    generator.dispose();

    layout = new GlyphLayout();
    b2dWorld = new World(new Vector2(0, -0.8f), true);
    b2dWorld.setContactListener(new GameCollision());

    player = new Player(atlas, b2dWorld, -200, camera.viewportHeight / 2 - 30, 1, 10000);

    meter = new SimpleGameObject(atlas, "meter", -camera.viewportWidth / 2 + 45, -120);
    meter_fuel = new SimpleGameObject(atlas, "meter_fuel", -camera.viewportWidth / 2 + 52, -159);
    lives = new SimpleGameObject(atlas, "spaceman_jump1", -camera.viewportWidth / 2 + 20, 200);
    gameOver = new SimpleGameObject(atlas, "game_over", -80, -70);
    meter.sprite.scale(2);
    meter_fuel.sprite.scale(2);
    gameOver.sprite.scale(2);
    background = new Background(atlas, -120, -80);

    manager = new GameObjectManager(atlas, b2dWorld, player, camera);
    manager.loadGameFromFile("level.png");
  }
Esempio n. 21
0
  public Sky(GameStateManager gsm) {
    super(gsm);
    cam.setToOrtho(false, OwlCityTribute.WIDTH, OwlCityTribute.HEIGHT);
    player =
        new Player(
            OwlCityTribute.WIDTH,
            OwlCityTribute.HEIGHT,
            OwlCityTribute.HEIGHT,
            -OwlCityTribute.HEIGHT * .1f);
    player.getPosition().y = -OwlCityTribute.HEIGHT * .1f;
    background = new Texture("skybg.png");
    vignette = new Texture("vignette.png");
    cloud = new Texture("cloud.png");
    pauseButton = new Texture("pause.png");
    // playerXOffset = OwlCityTribute.WIDTH*.4f;
    textCount = 3;
    note =
        new FluctuatingObject(
            (int) (player.getPosition().x + cam.viewportWidth), 2f, 200, 50, -250);
    noteAnim = new Animation(new TextureRegion(new Texture("paper.png")), 9, .5f);
    planeRegion = new TextureRegion(player.getPlane());

    clouds = new Array<FluctuatingObject>();
    clouds.add(
        new FluctuatingObject(
            (int) (player.getPosition().x - cam.viewportWidth * .1),
            0f,
            -(int) (OwlCityTribute.HEIGHT * .1f),
            0,
            -1));
    clouds.add(
        new FluctuatingObject(
            (int) (player.getPosition().x + cam.viewportWidth * .7),
            0f,
            -(int) (OwlCityTribute.HEIGHT * .1f),
            0,
            -1));
    sr = new ShapeRenderer();
    noteRotation = 0f;
    for (int i = 0; i < 5; i++) this.sceneText.add(new ArrayList<String>());
    sceneText.get(0).add("I dreamt we were");
    sceneText.get(0).add("above the blue.");

    sceneText.get(1).add("and I was right beside you");
    sceneText.get(1).add("floating away.");

    sceneText.get(2).add("The Earth didn't care");
    sceneText.get(2).add("that we were up there.");

    sceneText.get(3).add("The world looked brighter");
    sceneText.get(3).add("from that high altitude.");

    sceneText.get(4).add("We could go anywhere.");

    parameter.size = 20;
    parameter.characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.";

    font = generator.generateFont(parameter);
    generator.dispose();
    textBox = new TextBox();
    sr = new ShapeRenderer();
    waiting = false;
    whiteValue = 1f;
    whiteOverlay = .99f;
    // readyToFadeBlack = false;
    boxInitialized = false;

    random = new Random(System.currentTimeMillis());
    // Shimmers
    shimmers = new Array<Shimmer>();
    for (int i = 0; i < NUM_SHIMMERS; i++) {
      shimmers.add(
          new Shimmer(
              random.nextInt(OwlCityTribute.WIDTH),
              random.nextInt((int) (OwlCityTribute.HEIGHT * .5f - OwlCityTribute.HEIGHT * .3f))
                  + OwlCityTribute.HEIGHT * .3f,
              random.nextInt((int) (OwlCityTribute.WIDTH * .0025f) + 1),
              random.nextInt(Shimmer.MAX_LIFE) + 50));
    }
    fallen = false;
    noteScale = 1f;
    shrinking = false;
    intro = true;
  }
Esempio n. 22
0
  public GameState(Specular game) {
    super(game);

    // Loading map texture from a internal directory
    Texture mapTexture = new Texture(Gdx.files.internal("graphics/game/packed/Level.png"));
    Texture shockLight = new Texture(Gdx.files.internal("graphics/game/packed/ShockLight.png"));
    Texture parallax = new Texture(Gdx.files.internal("graphics/game/packed/Parallax.png"));

    // Loading gameover textures
    gameOverTex = new Texture(Gdx.files.internal("graphics/game/packed/Background.png"));
    newHighscore = new Texture(Gdx.files.internal("graphics/menu/gameover/New Highscore.png"));

    // Loading pause menu textures
    pauseTex = new Texture(Gdx.files.internal("graphics/menu/pausemenu/Pause.png"));
    greyPixel = new Texture(Gdx.files.internal("graphics/menu/pausemenu/Grey Pixel.png"));

    textureAtlas = new TextureAtlas(Gdx.files.internal("graphics/game/packed/Specular.atlas"));

    // Loading HUD
    hud = new HUD(this);

    // Initializing map handler for handling many maps
    mapHandler = new MapHandler();
    mapHandler.addMap(
        "Map",
        mapTexture,
        shockLight,
        parallax,
        mapTexture.getWidth(),
        mapTexture.getHeight(),
        this);
    currentMap = mapHandler.getMap("Map");

    clipBounds = new Rectangle(0, 0, currentMap.getWidth(), currentMap.getHeight());

    // Initializing font
    FreeTypeFontGenerator fontGen =
        new FreeTypeFontGenerator(Gdx.files.internal("fonts/Battlev2l.ttf"));
    FreeTypeFontParameter ftfp = new FreeTypeFontParameter();
    ftfp.size = 96; // MAX SIZE
    ftfp.characters = "1234567890,";
    gameOverScoreFont = fontGen.generateFont(ftfp);
    gameOverScoreFont.setColor(Color.RED);

    ftfp.characters = "1234567890,tapocniue"; // Characters for "Tap to continue"
    ftfp.size = 64;
    scoreFont = fontGen.generateFont(ftfp);
    scoreFont.setColor(Color.RED);

    ftfp.characters = "1234567890,x";
    ftfp.size = 40;
    multiplierFont = fontGen.generateFont(ftfp);
    multiplierFont.setColor(Color.RED);

    // Tutorial (Must be initialized before fontGen.dispose())
    tutorial = new Tutorial(this, fontGen);

    fontGen.dispose();
    // Graphics Settings
    GfxSettings.init();

    // Tutorial
    Tutorial.init(textureAtlas);

    // Initializing entities and analogstick statically
    Player.init(textureAtlas);
    Bullet.init(this);
    Particle.init(textureAtlas);
    UpgradeOrb.init(textureAtlas);
    EnemyWanderer.init(textureAtlas);
    EnemyCircler.init(textureAtlas);
    EnemyStriver.init(textureAtlas);
    EnemyBooster.init(textureAtlas);
    EnemyWorm.init(textureAtlas);
    EnemyVirus.init(textureAtlas);
    EnemyShielder.init(textureAtlas);
    EnemyExploder.init(textureAtlas);
    EnemyDasher.init(textureAtlas);
    EnemyTanker.init(textureAtlas);
    AnalogStick.init(hud);

    // Initializing power-ups
    AddLife.init(textureAtlas);
    BulletBurst.init(textureAtlas);
    FireRateBoost.init(textureAtlas);
    ScoreMultiplier.init(textureAtlas);
    ShieldPowerUp.init(textureAtlas);
    SlowdownEnemies.init(textureAtlas);
    BoardshockPowerUp.init(textureAtlas);
    Ricochet.init(textureAtlas);
    Repulsor.init(textureAtlas);
    LaserPowerup.init(textureAtlas);
    ShockWaveRenderer.init(textureAtlas);
    Laser.init(this);
    Swarm.init(textureAtlas);
    PDSPowerUp.init(textureAtlas);

    pss = new PlayerSpawnSystem(this);
    puss = new PowerUpSpawnSystem(this);
    pass = new ParticleSpawnSystem(this);
    oss = new OrbSpawnSystem(this);
    cs = new ComboSystem();
    waveManager = new WaveManager(this);

    input = Gdx.input;
  }
Esempio n. 23
0
  @Override
  public void show() {
    openingtheme.play();
    openingtheme.setLooping(true);
    // openingtheme.setVolume(game.state.volume);
    batch = new SpriteBatch();

    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    // Straight up stolen from https://www.pinterest.comore
    //        img = new Texture("menubackground1.png");
    img = new Texture("menu_background_fix.png");
    titleimg = new Texture("SlashHeroesTitle.png");
    img.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    // change these numbers around so it looks good on the presentation phone
    TextureRegion region = new TextureRegion(img, 0, 0, 600, 400);
    sprite = new Sprite(region);
    sprite.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    sprite.setOrigin(0, 0);

    skin = new Skin();
    // Generate a 1x1 white texture and store it in the skin named "white".
    Pixmap pixmap = new Pixmap(320, 75, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.GREEN);
    pixmap.fill();
    skin.add("white", new Texture(pixmap));

    // create the custom font
    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("fonts/slkscre.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = 80;
    BitmapFont OurFont = generator.generateFont(parameter);
    generator.dispose(); // don't forget to dispose to avoid memory leaks!

    // add ourfont to the skin for our buttons.
    skin.add("default", OurFont);

    // textbuttonstyle wont overwrite the font
    TextButtonStyle textButtonStyle = new TextButtonStyle();
    textButtonStyle.up = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.down = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.checked = skin.newDrawable("white", Color.BLUE);
    textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY);
    textButtonStyle.font = skin.getFont("default");

    skin.add("default", textButtonStyle);

    // Create a button with the "default" TextButtonStyle.
    final TextButton PlayButton = new TextButton("PLAY", textButtonStyle);
    // final TextButton ContinueButton = new TextButton("Continue",textButtonStyle);
    final TextButton SettingsButton = new TextButton("Mute", textButtonStyle);
    final TextButton QuitButton = new TextButton("Quit", textButtonStyle);
    PlayButton.setPosition(Gdx.graphics.getWidth() / 2 - 160, Gdx.graphics.getHeight() / 2 - 150);
    // ContinueButton.setPosition(Gdx.graphics.getWidth()/2 - 160, Gdx.graphics.getHeight()/2 - 85);
    //        SettingsButton.setPosition(Gdx.graphics.getWidth()/2 - 160, Gdx.graphics.getHeight()/2
    // - 165);
    SettingsButton.setPosition(
        Gdx.graphics.getWidth() / 2 - 160, Gdx.graphics.getHeight() / 2 - 300);
    //        QuitButton.setPosition(Gdx.graphics.getWidth()/2 - 160, Gdx.graphics.getHeight()/2 -
    // 245);
    QuitButton.setPosition(Gdx.graphics.getWidth() / 2 - 160, Gdx.graphics.getHeight() / 2 - 450);
    stage.addActor(PlayButton);
    // stage.addActor(ContinueButton);
    stage.addActor(SettingsButton);
    stage.addActor(QuitButton);

    PlayButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            select.play();
            PlayButton.setText("Starting new game");
            openingtheme.stop();
            game.setScreen(game.introscreen);
          }
        });
    SettingsButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            // System.out.println("Clicked! Is checked: " + button.isChecked());
            select.play();
            if (game.state.volume == 0f) {
              game.state.volume = .7f;
              openingtheme.play();
              openingtheme.setVolume(game.state.volume);
              SettingsButton.setText("Mute");
            } else {
              game.state.volume = 0f;
              openingtheme.stop();
              SettingsButton.setText("Unmute");
            }

            // TODO make this mute and unmute the non existant sound
            // mute and unmute;
          }
        });
    QuitButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            select.play();
            openingtheme.stop();
            QuitButton.setText("Quitting");
            // TODO make this quit the correct way
            System.exit(0);
          }
        });
  }
Esempio n. 24
0
  private static void loadResources(Skin skin) {
    FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal("graduate.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter param =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    param.size = 12;
    skin.add("x-small", gen.generateFont(param));
    param.size = 16;
    skin.add("small", gen.generateFont(param));
    param.size = 20;
    skin.add("default", gen.generateFont(param));
    param.size = 24;
    skin.add("medium", gen.generateFont(param));
    param.size = 32;
    skin.add("big", gen.generateFont(param));
    param.size = 48;
    skin.add("huge", gen.generateFont(param));
    param.size = 72;
    skin.add("x-huge", gen.generateFont(param));

    skin.add(
        "default.up",
        new NinePatch(new Texture(Gdx.files.internal("button.up.default.9.png")), 16, 16, 16, 16));
    skin.add(
        "default.over",
        new NinePatch(
            new Texture(Gdx.files.internal("button.over.default.9.png")), 16, 16, 16, 16));
    skin.add(
        "default.down",
        new NinePatch(
            new Texture(Gdx.files.internal("button.down.default.9.png")), 16, 16, 16, 16));

    skin.add(
        "success.up",
        new NinePatch(new Texture(Gdx.files.internal("button.up.success.9.png")), 16, 16, 16, 16));
    skin.add(
        "success.over",
        new NinePatch(
            new Texture(Gdx.files.internal("button.over.success.9.png")), 16, 16, 16, 16));
    skin.add(
        "success.down",
        new NinePatch(
            new Texture(Gdx.files.internal("button.down.success.9.png")), 16, 16, 16, 16));

    skin.add(
        "warning.up",
        new NinePatch(new Texture(Gdx.files.internal("button.up.warning.9.png")), 16, 16, 16, 16));
    skin.add(
        "warning.over",
        new NinePatch(
            new Texture(Gdx.files.internal("button.over.warning.9.png")), 16, 16, 16, 16));
    skin.add(
        "warning.down",
        new NinePatch(
            new Texture(Gdx.files.internal("button.down.warning.9.png")), 16, 16, 16, 16));

    skin.add(
        "error.up",
        new NinePatch(new Texture(Gdx.files.internal("button.up.error.9.png")), 16, 16, 16, 16));
    skin.add(
        "error.over",
        new NinePatch(new Texture(Gdx.files.internal("button.over.error.9.png")), 16, 16, 16, 16));
    skin.add(
        "error.down",
        new NinePatch(new Texture(Gdx.files.internal("button.down.error.9.png")), 16, 16, 16, 16));

    skin.add(
        "window", new NinePatch(new Texture(Gdx.files.internal("window.9.png")), 32, 32, 32, 32));

    skin.add("checkbox.on", new Texture(Gdx.files.internal("checkbox.on.default.png")));
    skin.add("checkbox.off", new Texture(Gdx.files.internal("checkbox.off.default.png")));
    skin.add("checkbox.on.disabled", new Texture(Gdx.files.internal("checkbox.on.disabled.png")));
    skin.add("checkbox.off.disabled", new Texture(Gdx.files.internal("checkbox.off.disabled.png")));

    skin.add(
        "checkbox.on.slider.horizontal",
        new Texture(Gdx.files.internal("checkbox.on.slider.horizontal.png")));
    skin.add(
        "checkbox.off.slider.horizontal",
        new Texture(Gdx.files.internal("checkbox.off.slider.horizontal.png")));

    skin.add("radiobutton.on", new Texture(Gdx.files.internal("radiobutton.on.default.png")));
    skin.add(
        "radiobutton.on.over", new Texture(Gdx.files.internal("radiobutton.on.over.default.png")));
    skin.add("radiobutton.off", new Texture(Gdx.files.internal("radiobutton.off.default.png")));
    skin.add(
        "radiobutton.off.over",
        new Texture(Gdx.files.internal("radiobutton.off.over.default.png")));
    skin.add(
        "radiobutton.disabled",
        new Texture(Gdx.files.internal("radiobutton.disabled.default.png")));

    skin.add("arrow.up", new Texture(Gdx.files.internal("arrow.up.default.png")));
    skin.add("arrow.up.disabled", new Texture(Gdx.files.internal("arrow.up.disabled.png")));
    skin.add("arrow.down", new Texture(Gdx.files.internal("arrow.down.default.png")));
    skin.add("arrow.down.disabled", new Texture(Gdx.files.internal("arrow.down.disabled.png")));
    skin.add("arrow.left", new Texture(Gdx.files.internal("arrow.left.default.png")));
    skin.add("arrow.left.disabled", new Texture(Gdx.files.internal("arrow.left.disabled.png")));
    skin.add("arrow.right", new Texture(Gdx.files.internal("arrow.right.default.png")));
    skin.add("arrow.right.disabled", new Texture(Gdx.files.internal("arrow.right.disabled.png")));

    for (ColorEnum color : ColorEnum.values()) {
      skin.add(color.colorName, color.getColor());
    }

    Pixmap pixmap;

    pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(skin.getColor("white"));
    pixmap.fill();
    skin.add("white", new Texture(pixmap));

    pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(skin.getColor("transparent"));
    pixmap.fill();
    skin.add("transparent", new Texture(pixmap));

    pixmap = new Pixmap(8, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    skin.add("white1x8", new Texture(pixmap));

    pixmap = new Pixmap(1, 8, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    skin.add("white8x1", new Texture(pixmap));

    pixmap = new Pixmap(32, 32, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    skin.add("white32s", new Texture(pixmap));
  }
Esempio n. 25
0
  @Override
  public void show() {
    imgNinja = new Texture(Gdx.files.internal("Ninja-Shadow.png"));
    imgNinja.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("lastninja.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.genMipMaps = true;
    parameter.minFilter = Texture.TextureFilter.Linear.MipMapLinearNearest;
    parameter.magFilter = Texture.TextureFilter.Linear;
    parameter.size = 26;
    final BitmapFont font = generator.generateFont(parameter);

    startLabel = new Label("Start Game", new Label.LabelStyle(font, Color.BLACK));
    startLabel.setPosition(500, 300);
    startLabel.setTouchable(Touchable.enabled);
    startLabel.setBounds(500, 300, startLabel.getWidth(), startLabel.getHeight());
    startLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new PlayScreen(game));
            dispose();
          }
        });

    instructionLabel = new Label("Instructions", new Label.LabelStyle(font, Color.BLACK));
    instructionLabel.setPosition(500, 250);
    instructionLabel.setTouchable(Touchable.enabled);
    instructionLabel.setBounds(500, 250, instructionLabel.getWidth(), instructionLabel.getHeight());
    instructionLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new InstructionScreen(game));
            dispose();
          }
        });

    aboutLabel = new Label("About", new Label.LabelStyle(font, Color.BLACK));
    aboutLabel.setPosition(500, 200);
    aboutLabel.setTouchable(Touchable.enabled);
    aboutLabel.setBounds(500, 200, aboutLabel.getWidth(), aboutLabel.getHeight());
    aboutLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new AboutScreen(game));
            dispose();
          }
        });
    quitLabel = new Label("Quit", new Label.LabelStyle(font, Color.BLACK));
    quitLabel.setPosition(500, 150);
    quitLabel.setTouchable(Touchable.enabled);
    quitLabel.setBounds(500, 150, quitLabel.getWidth(), quitLabel.getHeight());
    quitLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });
    stage.addActor(startLabel);
    stage.addActor(instructionLabel);
    stage.addActor(aboutLabel);
    stage.addActor(quitLabel);
  }
Esempio n. 26
0
 public void dispose() {
   generator.dispose();
   font.dispose();
 }
Esempio n. 27
0
 public static BitmapFont getFont(int fontSize, String path) {
   FreeTypeFontGenerator fontGen = new FreeTypeFontGenerator(Gdx.files.internal(path));
   BitmapFont font = fontGen.generateFont(fontSize);
   fontGen.dispose();
   return font;
 }
Esempio n. 28
0
 public void loadBitmapFont(String folder, String path, String key, int size, Color color) {
   FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal(folder + "/" + path));
   BitmapFont bmf = gen.generateFont(size);
   bmf.setColor(color);
   font.put(key, bmf);
 }
Esempio n. 29
0
  public OptionScreen(Anvil anvil) {
    super(anvil);

    Skin skin = new Skin(Gdx.files.internal(Systems.Skin));

    back = new Texture(Gdx.files.internal(Locale.SYSTEM_UI_PATH + "marble.png"));
    background = new Image(back);

    FreeTypeFontGenerator gen =
        new FreeTypeFontGenerator(Gdx.files.internal(Locale.FONT_BASE + "Canted Comic.ttf"));
    FreeTypeFontParameter par = new FreeTypeFontParameter();
    par.size = 20;
    par.borderColor = Color.BLACK;
    par.color = Color.WHITE;
    par.borderWidth = 2;
    BitmapFont font = gen.generateFont(par);

    LabelStyle ls = new LabelStyle();
    ls.font = font;

    CheckBox vsync = new CheckBox("VSync", skin);
    vsync.setChecked(getBool("Graphics", "useVsync"));
    vsync.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            bVsync = vsync.isChecked();
            vsync.setChecked(vsync.isChecked() ? false : true);
          }
        });

    Separator sep = new Separator();

    CheckBox controller = new CheckBox("Use Controller", skin);
    controller.setChecked(getBool("Controls", "useController"));
    controller.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {}
        });

    TextButton okay = new TextButton("Apply", skin);
    okay.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            save();
            anvil.setScreen(new MenuScreen(anvil));
          }
        });

    Table opt = new Table(skin);
    opt.setFillParent(true);
    opt.setBackground(background.getDrawable());

    opt.add(new Label("Graphics", ls)).row();
    opt.add(sep);
    opt.add(vsync).row();
    opt.add().row();
    opt.add().row();
    opt.add().row();

    opt.add(okay).align(Align.bottomLeft);

    stage.addActor(opt);
    Gdx.input.setInputProcessor(stage);
  }
Esempio n. 30
0
  public Grassland(GameStateManager gsm) {
    super(gsm);
    cam.setToOrtho(false, OwlCityTribute.WIDTH, OwlCityTribute.HEIGHT);
    player =
        new Player(
            OwlCityTribute.WIDTH,
            OwlCityTribute.HEIGHT,
            OwlCityTribute.HEIGHT,
            -OwlCityTribute.HEIGHT * .1f);
    player.getPosition().y = OwlCityTribute.HEIGHT;
    background = new Texture("grass.png");
    vignette = new Texture("vignette.png");
    cloud = new Texture("cloud.png");
    pauseButton = new Texture("pause.png");
    balloon = new Texture("balloon.png");
    brush = new Texture("brush.png");

    textCount = -1;
    note =
        new FluctuatingObject(
            (int) (player.getPosition().x + cam.viewportWidth), 2f, 200, 50, -250);
    noteAnim = new Animation(new TextureRegion(new Texture("paper.png")), 9, .5f);
    planeRegion = new TextureRegion(player.getPlane());

    clouds = new Array<FluctuatingObject>();
    clouds.add(
        new FluctuatingObject(
            (int) (player.getPosition().x - cam.viewportWidth * .1),
            0f,
            (int) (OwlCityTribute.HEIGHT * .8f),
            0,
            -1));
    clouds.add(
        new FluctuatingObject(
            (int) (player.getPosition().x + cam.viewportWidth * .7),
            0f,
            (int) (OwlCityTribute.HEIGHT * .8f),
            0,
            -1));
    sr = new ShapeRenderer();
    noteRotation = 0f;
    for (int i = 0; i < 4; i++) this.sceneText.add(new ArrayList<String>());

    sceneText.get(0).add("The open summer breeze swept");
    sceneText.get(0).add("us through the hills.");

    sceneText.get(1).add("There was endless sky with");
    sceneText.get(1).add("the evening around us");

    sceneText.get(2).add("Everywhere we looked we saw");
    sceneText.get(2).add("green, scenic sublime");

    sceneText.get(3).add("And cold nostalgia chilled");
    sceneText.get(3).add("us in the warm air");

    parameter.size = 20;
    parameter.characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.,";

    font = generator.generateFont(parameter);
    generator.dispose();

    textBox = new TextBox();
    sr = new ShapeRenderer();
    waiting = false;
    whiteValue = 0f;
    // readyToFadeBlack = false;
    boxInitialized = false;

    random = new Random(System.currentTimeMillis());
    // Shimmers
    shimmers = new Array<Shimmer>();
    for (int i = 0; i < NUM_SHIMMERS; i++) {
      shimmers.add(
          new Shimmer(
              random.nextInt(OwlCityTribute.WIDTH),
              random.nextInt((int) (OwlCityTribute.HEIGHT * .5f - OwlCityTribute.HEIGHT * .3f))
                  + OwlCityTribute.HEIGHT * .3f,
              random.nextInt((int) (OwlCityTribute.WIDTH * .0025f) + 1),
              random.nextInt(Shimmer.MAX_LIFE) + 50));
    }
    fallen = false;
    noteScale = 1f;
    shrinking = false;

    balloonFluctuation =
        new FluctuatingObject(
            (int) (OwlCityTribute.WIDTH * .75),
            .75f,
            (int) (OwlCityTribute.HEIGHT * .8f),
            (int) (OwlCityTribute.HEIGHT * .025),
            0);

    brushmoving = new Array<FluctuatingObject>();
    for (int i = 0; i < 3; i++) {
      brushmoving.add(
          new FluctuatingObject(
              i * brush.getWidth()
                  + (int) (player.getPosition().x - cam.viewportWidth / 2 + player.xOffset),
              0,
              -(int) (OwlCityTribute.HEIGHT * .15),
              0,
              0));
    }
  }