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();
  }
    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;
    }
  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;
  }
Exemple #4
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);
  }
  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();
  }
Exemple #6
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);
  }
  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));
  }
  /**
   * 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;
  }
Exemple #9
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;
  }
  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);
  }