Example #1
0
  private void createSprites() {

    // background
    backgroundTexture = new Texture(Gdx.files.internal("data/cr/map1bg.png"));
    backgroundTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    backgroundSprite = new Sprite(backgroundTexture);
    backgroundSprite.setSize(WIDTH_WORLD, HEIGHT_WORLD);
    backgroundSprite.setPosition(-WIDTH_WORLD / 2f, 0);

    // planet
    planetTexture = new Texture(Gdx.files.internal("data/cr/planet_terrain.png"));
    planetTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    planetSprite = new Sprite(planetTexture);
    planetSprite.setSize(
        PLANET_WIDTH, PLANET_WIDTH * planetSprite.getHeight() / planetSprite.getWidth());

    // planet core
    planetCoreTexture = new Texture(Gdx.files.internal("data/cr/planet_core.png"));
    planetCoreTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    planetCoreSprite = new Sprite(planetCoreTexture);
    planetCoreSprite.setSize(
        PLANET_CORE_WIDTH,
        PLANET_CORE_WIDTH * planetCoreSprite.getHeight() / planetCoreSprite.getWidth());

    // balls
    ballTexture = new Texture(Gdx.files.internal("data/gfx/ball.png"));
    ballTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    ballSprites = new Sprite[MAX_BALLS];
    for (int i = 0; i < MAX_BALLS; i++) {
      ballSprites[i] = new Sprite(ballTexture);
      ballSprites[i].setSize(BALL_RADIUS * 2, BALL_RADIUS * 2);
      ballSprites[i].setOrigin(BALL_RADIUS, BALL_RADIUS);
    }
  }
Example #2
0
  @Override
  public void create() {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    camera = new OrthographicCamera(1, h / w);
    batch = new SpriteBatch();

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

    texture_nave = new Texture(Gdx.files.internal("data/nave.png"));

    sprite_nave = new Sprite(texture_nave, 128, 64);
    sprite_nave.setPosition(-0.5f, -0.5f);
    sprite_nave.setSize(0.5f, 0.5f);

    TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275);

    sprite = new Sprite(region);
    sprite2 = new Sprite(region);

    sprite.setSize(0.9f, 0.9f * sprite.getHeight() / sprite.getWidth());
    sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);
    sprite.setPosition(-sprite.getWidth() / 2, -sprite.getHeight() / 2);
    sprite.setPosition(0, 0);
    sprite.setRotation(25);
  }
Example #3
0
  public Fly(float x, float y, int fly_type, int slot_number) { // set static data of fly(x, y, ect)
    xCoord = x;
    yCoord = y;
    fly_size = fly_type;
    slotNumber = slot_number;

    switch (fly_type) {
      case 1: // small fly
        texture = new Texture(Gdx.files.internal("data/medium_fly.png"));
        texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        TextureRegion region = new TextureRegion(texture, 0, 0, 212, 143);

        fly_sprite = new Sprite(region);
        fly_sprite.setSize(.0745f, .06155f);
        fly_sprite.setOrigin(fly_sprite.getWidth() / 2, fly_sprite.getHeight() / 2);
        fly_sprite.setPosition(x, y);
        break;
      case 2: // small fly
        texture = new Texture(Gdx.files.internal("data/medium_fly.png"));
        texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        region = new TextureRegion(texture, 0, 0, 212, 143);

        fly_sprite = new Sprite(region);
        fly_sprite.setSize(.0745f, .06155f);
        fly_sprite.setOrigin(fly_sprite.getWidth() / 2, fly_sprite.getHeight() / 2);
        fly_sprite.setPosition(x, y);
        break;
      case 3: // medium fly
        texture = new Texture(Gdx.files.internal("data/medium_fly.png"));
        texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        region = new TextureRegion(texture, 0, 0, 212, 143);

        fly_sprite = new Sprite(region);
        fly_sprite.setSize(.115f, .097f);
        fly_sprite.setOrigin(fly_sprite.getWidth() / 2, fly_sprite.getHeight() / 2);
        fly_sprite.setPosition(x, y);
        break;
      case 4: // large fly
        texture = new Texture(Gdx.files.internal("data/medium_fly.png"));
        texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        region = new TextureRegion(texture, 0, 0, 212, 143);

        fly_sprite = new Sprite(region);
        fly_sprite.setSize(.155f, .135f);
        fly_sprite.setOrigin(fly_sprite.getWidth() / 2, fly_sprite.getHeight() / 2);
        fly_sprite.setPosition(x, y);
        break;

      default:
        break;
    }
  }
Example #4
0
  private void initialize() {
    switch (scene) {
      case 5:
        enemySprite = new Sprite(assets.animationBigEnemy.getKeyFrame(0.1f));
        enemySprite.setSize(enemySprite.getWidth() / 2, enemySprite.getHeight() / 2);
        speed = 5f;
        type = enemyBIG;
        enemyRec =
            new Rectangle(
                startPos.x, startPos.y, enemySprite.getWidth() - 10, enemySprite.getHeight());
        // Range
        normalRange = 500;
        targetRange = 500;
        // Freeze
        freezeTime = 1;
        soundController = 0;
        break;

      default:
        enemySprite = new Sprite(assets.animationNormalEnemyRight.getKeyFrame(0.1f));
        enemySprite.setSize(enemySprite.getWidth() / 2, enemySprite.getHeight() / 2);
        speed = 8f;
        type = enemyNORMAL;
        enemyRec =
            new Rectangle(
                startPos.x, startPos.y, enemySprite.getWidth() - 5, enemySprite.getHeight());
        // Range
        normalRange = 50;
        targetRange = 80;
        freezeTime = 3;
        break;
    }

    stateTime = 0;

    isTarget = false;
    isFreeze = false;
    freezeController = 0;

    // Horizontal
    if (pol.getVertices()[0] != pol.getVertices()[2]) {
      isHorizontal = true;
      if (pol.getVertices()[2] < 0) {
        isLeft = true;
      }
    }
    // Vertical
    else if (pol.getVertices()[1] != pol.getVertices()[3]) {
      isHorizontal = false;
      // isUp = true;
      if (this.pol.getVertices()[3] < 0) {
        this.pol.getVertices()[3] *= -1;
      }
    }
  }
Example #5
0
 // TODO add Game g parameter
 public
 BoardDraw() // setting up the board. Probably should be called on every board update, since it
             // will eventually include the board state.
     {
   hx.setSize(LENGTH, HEIGHT);
   sel.setSize(LENGTH, HEIGHT);
   us = new Hex[5][3];
   them = new Hex[5][3];
   hexes.clear();
   hx.setSize(LENGTH, HEIGHT);
   //	master=g;
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   myBoard(5);
   theEnemy(5);
 }
Example #6
0
  private AudioDebugRenderer() {
    listenerTexture = new Texture(Gdx.files.classpath(listenerTextureLocation));
    listenerTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    listenerSprite = new Sprite(listenerTexture);
    listenerSprite.setSize(0.2f, 0.2f);
    listenerSprite.setOriginCenter();

    speakerTexture = new Texture(Gdx.files.classpath(speakerTextureLocation));
    speakerTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    speakerSprite = new Sprite(speakerTexture);
    speakerSprite.setSize(0.2f, 0.2f);
    speakerSprite.setOriginCenter();

    EventService.subscribe(this);
  }
Example #7
0
  @Override
  public void render(float delta) {
    begin1.setColor(color);
    begin2.setColor(rayColor);
    mid1.setColor(color);
    mid2.setColor(rayColor);
    end1.setColor(color);
    end2.setColor(rayColor);

    mid1.setSize(mid1.getWidth(), len);
    mid2.setSize(mid1.getWidth(), len);

    begin1.setPosition(positon.x, positon.y);
    begin2.setPosition(positon.x, positon.y);

    mid1.setPosition(begin1.getX(), begin1.getY() + begin1.getHeight());
    mid2.setPosition(begin1.getX(), begin1.getY() + begin1.getHeight());

    end1.setPosition(begin1.getX(), begin1.getY() + begin1.getHeight() + mid1.getHeight());
    end2.setPosition(begin1.getX(), begin1.getY() + begin1.getHeight() + mid1.getHeight());

    begin1.setOrigin(begin1.getWidth() / 2, 0);
    begin2.setOrigin(begin1.getWidth() / 2, 0);

    mid1.setOrigin(mid1.getWidth() / 2, -begin1.getHeight());
    mid2.setOrigin(mid2.getWidth() / 2, -begin1.getHeight());
    end1.setOrigin(mid1.getWidth() / 2, -begin1.getHeight() - mid1.getHeight());
    end2.setOrigin(mid2.getWidth() / 2, -begin1.getHeight() - mid2.getHeight());

    begin1.setRotation(degrees);
    begin2.setRotation(degrees);
    mid1.setRotation(degrees);
    mid2.setRotation(degrees);
    end1.setRotation(degrees);
    end2.setRotation(degrees);

    Engine.getSpriteBatch().setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
    begin1.draw(Engine.getSpriteBatch());
    begin2.draw(Engine.getSpriteBatch());

    mid1.draw(Engine.getSpriteBatch());

    mid2.draw(Engine.getSpriteBatch());

    end1.draw(Engine.getSpriteBatch());
    end2.draw(Engine.getSpriteBatch());
    Engine.getSpriteBatch().setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
  }
  public PopupDialog(Stage parentStage, ShooterGame g) {

    game = g;
    this.parentStage = parentStage;

    stage = new Stage();

    // FADED BACKGROUND
    fadedBGTexture = game.assetManager.getTexture("faded-black-bg.png");
    fadedBGTexture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
    fadedBG = new Sprite(fadedBGTexture);
    fadedBG.setSize(ShooterGame.GAME_WIDTH, ShooterGame.GAME_HEIGHT);

    initDialogBG();
    initCancelButton();

    // Button Listeners
    cancelButton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            hide();
          }
        });

    stage.addActor(cancelButton);
  }
  @Override
  public void create() {

    GeneralStorage.load();
    MenuStorage.load();
    SplashStorage.load();
    MenuStorage.load();
    PauseStorage.load();
    RunningStorage.load();
    GameOverStorage.load();

    GeneralStorage.estado = GeneralStorage.state.splash;
    MenuStorage.HelpTouched = false;
    // Init the particle effect
    particle1 = new ParticleEffect();
    particleLeft = new ParticleEffect();
    particleRight = new ParticleEffect();
    // load the particle, first parameter is path and name file when is the particle,
    // second one the fold when is the particle image.
    particle1.load(Gdx.files.internal("efectos/vuelo2"), Gdx.files.internal("efectos"));
    particleLeft.load(Gdx.files.internal("efectos/efLateral3"), Gdx.files.internal("efectos"));
    particleRight.load(Gdx.files.internal("efectos/efLateral3"), Gdx.files.internal("efectos"));
    // Sprites of button of the menu screen to music, sound and button help

    spHelp = new Sprite(GeneralStorage.imgBTHelp);
    spHelp.setSize(GeneralStorage.w / 10, GeneralStorage.w / 10);
    spHelp.setPosition(
        GeneralStorage.w - GeneralStorage.w / 4 - spHelp.getWidth() / 2, GeneralStorage.h / 4);

    // storage the background color
    colorFondo = MenuStorage.spBackGroundGame.getColor();
    // Time to splash screen.
    timer = 100;
  }
Example #10
0
  /**
   * An Entity with a square physics Body.
   *
   * @param sprite the sprite for this
   * @param friction the coefficient of friction for this
   * @param restitution the restitution for this
   * @param world the physics world that is in
   * @param mass the mass of this in grams
   * @param x the x ordinate of this in pixels
   * @param y the y ordinate of this in pixels
   * @param width the width of this in pixels
   * @param height the height of this in pixels
   * @param isStatic if this is capable of having motion
   * @param canRotate if this is capable of rotating
   */
  public SpriteEntity(
      float scale,
      Sprite sprite,
      float friction,
      float restitution,
      World world,
      float mass,
      float x,
      float y,
      float width,
      float height,
      boolean isStatic,
      boolean canRotate) {
    super(
        friction,
        restitution,
        world,
        mass,
        x,
        y,
        width * scale,
        height * scale,
        isStatic,
        canRotate);

    sprite.setSize(width * scale, height * scale);
    this.sprite = sprite;
  }
Example #11
0
  public void show() {
    game.showAds(true);

    batch = new SpriteBatch();
    bitmap = game.getText();
    title = game.getTitle();
    layout = new GlyphLayout();

    backgroundTexture = new Texture(Gdx.files.internal("images/background.png"));
    backgroundSprite = new Sprite(backgroundTexture);
    backgroundSprite.setSize(game.WIDTH, game.HEIGHT * 2);

    textureAtlas = new TextureAtlas(Gdx.files.internal("images/m.txt"));
    meteorAnimation = new Animation(1 / 12f, textureAtlas.getRegions());

    width = (float) meteorAnimation.getKeyFrame(0f, true).getRegionWidth() * game.scaleWidth;
    height = (float) meteorAnimation.getKeyFrame(0f, true).getRegionHeight() * game.scaleWidth;

    secondsElapsed = 0f;

    if (game.MAXSCORE <= 60) {
      maxLevel = game.getBundle().get("beginner");
    } else if (game.MAXSCORE <= 120) {
      maxLevel = game.getBundle().get("advanced");
    } else if (game.MAXSCORE <= 240) {
      maxLevel = game.getBundle().get("expert");
    } else {
      maxLevel = game.getBundle().get("master");
    }
    Gdx.input.setInputProcessor(this);
    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  }
Example #12
0
  public void setUp() {

    BodyDef bodyDef = new BodyDef();
    bodyDef.position.set(x + width / 2, y + height / 2);
    bodyDef.type = BodyDef.BodyType.KinematicBody;

    PolygonShape shape = new PolygonShape();
    shape.setAsBox(width / 2, height / 2);

    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.shape = shape;

    body = world.createBody(bodyDef);
    body.createFixture(fixtureDef);
    body.setUserData(Constants.robotNinjaID);

    body.setLinearVelocity(Constants.standardVelocity);

    sprite = new Sprite(texture);
    sprite.setSize(width, height);
    sprite.setOrigin(width / 2, height / 2);
    sprite.flip(false, flipy);
    sprite.setPosition(x, y);

    dead = false;
  }
  /** @param path */
  public LoadTexture(String path) {
    array_Texs.add(new Texture(path));
    array_Texs.get(BACKGROUND).setFilter(TextureFilter.Linear, TextureFilter.Linear);
    array_Texs.add(new Texture(Gdx.files.internal("data/arrow-down.png")));
    array_Texs.add(new Texture(Gdx.files.internal("data/arrow-up.png")));
    array_Texs.add(new Texture(Gdx.files.internal("data/menu.png")));

    for (int i = 0; i < array_Texs.size(); i++) {
      array_TexRegions.add(
          new TextureRegion(
              array_Texs.get(i),
              0,
              0,
              array_Texs.get(i).getWidth(),
              array_Texs.get(i).getHeight()));
      array_Sprites.add(new Sprite(array_TexRegions.get(i)));
    }

    // 背景画像設定
    Sprite sprite = array_Sprites.get(BACKGROUND);
    sprite.setSize(sprite.getRegionWidth(), sprite.getRegionHeight());
    sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);
    sprite.setPosition(-sprite.getWidth() / 2, -sprite.getHeight() / 2);
    array_Sprites.set(BACKGROUND, sprite);
  }
Example #14
0
 private void creatingRegisterButton() {
   Sprite spriteRegisterButton = new Sprite(Assets.registerButton);
   Assets.spriteDefaultColor(spriteRegisterButton);
   spriteRegisterButton.setSize(
       (Constant.CONSTANT_WIDTH_FIELD_AND_BUTTON), (Constant.CONSTANCE_HEIGHT_BUTTONS));
   SpriteDrawable registerSpriteDrawable = new SpriteDrawable(spriteRegisterButton);
   registerButton = new ImageButton(registerSpriteDrawable);
 }
 public InteractButton(float x, float y) {
   this.x = x;
   this.y = y;
   width = 64;
   height = 40;
   sprite = new Sprite(new Texture(Gdx.files.internal("sprites/placeables/usebutton.png")));
   sprite.setSize(64, 40);
   sprite.setPosition(x, y);
   hitBox = new Rectangle(x, y, width, height);
 }
Example #16
0
 private Touchpad getTouchPad(
     String backgroundTexturePath, String knobTexturePath, float xPos, float yPos) {
   Skin skin = new Skin();
   Texture padbgTex = new Texture(Gdx.files.internal(backgroundTexturePath));
   Texture knobTex = new Texture(Gdx.files.internal(knobTexturePath));
   padbgTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
   knobTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
   Sprite padSprite = new Sprite(padbgTex);
   padSprite.setSize(30, 30);
   Sprite knobSprite = new Sprite(knobTex);
   knobSprite.setSize(20, 20);
   skin.add("padbg", padSprite);
   skin.add("knob", knobSprite);
   TouchpadStyle touchpadStyle =
       new TouchpadStyle(skin.getDrawable("padbg"), skin.getDrawable("knob"));
   Touchpad touchpad = new Touchpad(3, touchpadStyle);
   touchpad.setPosition(xPos, yPos);
   return touchpad;
 }
Example #17
0
  public void update(float dt, OrthographicCamera cam) {
    stage.act(dt);
    if (Core.persistentAssets.update() && !assetsLoaded) {

      GameSave.save();

      assetsLoaded = true;

      layout = new Table(Core.persistentAssets.get("skins/uiskin.json", Skin.class));
      layout.setFillParent(true);
      layout.center().bottom();

      pressBtn =
          new Label(
              "Press any key to continue",
              Core.persistentAssets.get("skins/uiskin.json", Skin.class));

      layout.add(pressBtn).padBottom(40);

      layout.debug();

      stage.addActor(layout);

      stage.addListener(
          new InputListener() {
            public boolean keyUp(InputEvent event, int keycode) {
              gsm.setState(GameStateManager.MENU);
              return false;
            }

            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
              return true;
            }

            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
              gsm.setState(GameStateManager.MENU);
            }
          });
    }

    if (Core.persistentAssets.isLoaded("images/main-menu/background.jpg")) {
      if (!bgLoaded) {
        bgLoaded = true;
        bg =
            new Sprite(Core.persistentAssets.get("images/main-menu/background.jpg", Texture.class));
        float[] size =
            ImageUtils.minimalStretch(bg.getWidth(), bg.getHeight(), Core.WIDTH, Core.HEIGHT);

        bg.setSize(size[0], size[1]);
        bg.setPosition(size[2], size[3]);
      }
      bgOpacity += bgOpacityModifier * dt;
      bgOpacity = bgOpacity > 1 ? 1 : bgOpacity;
    }
  }
Example #18
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);
  }
Example #19
0
 public ClientFly(short id, float x, float y, WorldRenderer renderer) {
   super(id, x, y, renderer);
   markForDispose = false;
   Texture texture = AssetLoader.instance.getTexture("sprites/fly.png");
   sprite = new Sprite(texture);
   walk =
       new Animation(
           0.25f, TextureRegion.split(texture, texture.getWidth() / 2, texture.getHeight())[0]);
   walk.setPlayMode(Animation.PlayMode.LOOP);
   sprite.setSize(ServerBlob.WIDTH + 5f, ServerFly.HEIGHT);
 }
Example #20
0
 public Spike(float x, float y, float speed, float _size) {
   float rot = (float) (Math.random() * 360);
   _drot = (float) (Math.random() - 0.5) * 200;
   _x = x;
   _y = y;
   _dy = speed;
   _sprite = new Sprite(Resources.spike);
   _sprite.setSize(_size, _size);
   _sprite.setOrigin(_size / 2, _size / 2);
   _sprite.setPosition(_x - _size / 2, _y - _size / 2);
   // _sprite.rotate(rot);
 }
  public void initDialogBG() {

    dialogBGPath = "menu/save-score-popup/bg.png";

    // Dialog
    Texture dialogTexture = game.assetManager.getTexture(dialogBGPath);
    dialogSprite = new Sprite(dialogTexture);

    dialogSprite.setSize(536, 286);
    dialogSprite.setPosition(
        (stage.getWidth() / 2) - (dialogSprite.getWidth() / 2),
        (stage.getHeight() / 2) - (dialogSprite.getHeight() / 2));
  }
Example #22
0
  // singleton, Assets instance provides "global" access
  private Assets() {
    // this.assetManager = new AssetManager(); will be used for loading graphics
    this.uiElements = new UIElements();
    this.fonts = new Fonts();

    // Background
    textureBackground = new Texture(Gdx.files.internal("images/hedgemaze_alltiles.jpg"));
    spriteBackground = new Sprite(textureBackground);
    spriteBackground.setSize(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT);

    this.assetManager = new AssetManager();
    init();
  }
Example #23
0
  /**
   * Draws the objects
   *
   * @param batch
   * @param imageHandler
   */
  public void draw(SpriteBatch batch, ImageHandler imageHandler) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.begin();

    if (gameStatus.equalsIgnoreCase(GameConstants.GAME_STATUS_INTRO)) {
      player1.drawWithOffset(batch, 0, -intro_player_offset);

      for (Enemy badGuy : enemies) {
        badGuy.drawWithOffset(batch, 0, intro_enemy_offset);
      }
    } else {
      player1.draw(batch);

      for (Enemy badGuy : enemies) {
        badGuy.draw(batch);
      }

      for (Projectile proj : projectiles) {
        proj.draw(batch);
      }

      for (Explosion exp : explosions) {
        exp.draw(batch);
      }
    }

    scoreText.draw(batch, Integer.toString(score), 10, 750, 4);

    if (gameStatus.equalsIgnoreCase(GameConstants.GAME_STATUS_PAUSED)) {
      pauseMenu.draw(batch);
    }

    if (gameStatus.equalsIgnoreCase(GameConstants.GAME_STATUS_GAME_OVER)) {
      gameOverMenu.draw(batch);
    }

    if (gameStatus.equalsIgnoreCase(GameConstants.GAME_STATUS_INTRO_START)) {
      int draw_x = 450;
      int draw_y = 200;
      int size = 8;
      for (Sprite img : startText) {
        img.setPosition(draw_x, draw_y);
        img.setSize((int) (img.getRegionWidth() * size), (int) (img.getRegionHeight() * size));
        img.draw(batch);
        draw_x += img.getRegionWidth() * size;
      }
    }
  }
  @Override
  public void show() {
    sprite = new Sprite(AssetLoader.logo);
    sprite.setColor(1, 1, 1, 0);

    float width = Gdx.graphics.getWidth();
    float height = Gdx.graphics.getHeight();
    float desiredWidth = width * .7f;
    float scale = desiredWidth / sprite.getWidth();

    sprite.setSize(sprite.getWidth() * scale, sprite.getHeight() * scale);
    sprite.setPosition(
        (width / 2) - (sprite.getWidth() / 2), (height / 2) - (sprite.getHeight() / 2));
    setupTween();
    batcher = new SpriteBatch();
  }
Example #25
0
 // base code
 // http://www.gamefromscratch.com/post/2014/05/01/LibGDX-Tutorial-11-Tiled-Maps-Part-2-Adding-a-character-sprite.aspx
 // veiw port from here
 // http://www.gamefromscratch.com/post/2014/12/09/LibGDX-Tutorial-Part-17-Viewports.aspx
 // ______________________________________________________________________________________________
 @Override
 public void create() {
   // get screen size and set aspect
   dAspect = 1280 / 720;
   dViewH = (nViewW / dAspect);
   nViewH = (int) dViewH;
   // images
   batch = new SpriteBatch();
   spMenu = new Sprite(new Texture(Gdx.files.internal("mainmenu.png")));
   spMenu.setSize(320, 180);
   imgEnemy = new Texture("player.png");
   spMenu.setPosition(340, 510);
   imgPlayer = new Texture("player.png");
   for (int i = 0; i < 5; i++) {
     imgBaseKey[i] = new Texture("BaseKey.png");
     imgRedKey[i] = new Texture("RedKey.png");
     imgBaseWall[i] = new Texture("BaseFLW.png");
     imgRedwall[i] = new Texture("RedFLW.png");
     nKn[i] = 0;
   }
   for (int i = 0; i < 10; i++) {
     nKy[i] = nKx[i] = -100000;
     //  recKey[i].setSize(6,11);
     // recKey[i].setPosition(nKx[i],nKy[i]);
   }
   nWx[0] = 480;
   nWy[0] = 832;
   imgNum[0] = new Texture("Num 0.png");
   imgNum[1] = new Texture("Num 0.png");
   imgNum[2] = new Texture("Num 0.png");
   imgHud = new Texture("BASE HUD.png");
   // tiled map
   tiledMap = new TmxMapLoader().load("MyMap.tmx");
   tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap);
   // viewport
   camera = new OrthographicCamera();
   viewport = new FillViewport(320, 180, camera);
   nPx = (int) 500 + (int) (camera.viewportWidth) / 2;
   nPy = (int) 600 + (int) (camera.viewportHeight) / 2;
   viewport.apply();
   camera.position.set(500, 600, 0);
 }
Example #26
0
  public Player(PlayScreen playScreen, Body body, Sprite sprite, float width, float height) {
    super(body, sprite, width, height);
    this.playScreen = playScreen;
    TextureRegion textureRegion =
        GM.getAssetManager().get("images/actors.pack", TextureAtlas.class).findRegion("Flame");
    flame = new Sprite(textureRegion);
    flame.setSize(width / 2f, height);

    left_throttle = false;
    right_throttle = false;

    throttleSound = GM.getAssetManager().get("audio/Throttle.mp3", Sound.class);
    explosionSound = GM.getAssetManager().get("audio/Explosion1.ogg", Sound.class);

    rotation = 0;

    hp = maxHp;
    speed = 0;
    alive = true;
  }
Example #27
0
 GameGUI(HW4 game, SelectionManager manager) {
   this.game = game;
   gameEnd = new SpriteBatch();
   sm = manager;
   victory = game.atlas.createSprite("victory");
   victory.setSize(
       victory.getWidth() * (HW4.SCALE * 2 * HW4.SCALE + 1),
       victory.getHeight() * (HW4.SCALE * 2 * HW4.SCALE + 1));
   skin = new Skin(Gdx.files.internal("uiskin.json"));
   camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
   stage =
       new Stage(
           new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), camera), game.batch);
   Gdx.input.setInputProcessor(stage);
   gp = ghostPanel();
   bp = structurePanel();
   f = new TextField("Souls: " + GhostComponent.money, skin);
   cw = currencyScreen();
   rs = returnScreen();
 }
Example #28
0
  // draws a row.
  private void makeRow(
      int startY, int startX, Hex[][] arr, int row, boolean backwards) // length in hexes
      {
    ArrayList<Sprite> a1 = new ArrayList<Sprite>();
    for (int k = 0; k < 7; k++) {
      Sprite s = new Sprite(new Texture("GUI/selTile/selectedTile(" + k + ").png"));
      s.setSize(LENGTH, HEIGHT);
      a1.add(s);
    }

    for (int x = 0; x < arr[0].length; x++) {
      Hex h = new Hex(startX, startY + LENGTH * x, hx, new AnimatedSprite(4, a1));
      hexes.add(h);
      if (backwards) {
        arr[row][arr[0].length - x - 1] = h;
      } else {
        arr[row][x] = h;
      }
    }
  }
Example #29
0
  private void createSprites() {
    // Define the Sprite, as usual.
    //		vialTexture = new Texture(Gdx.files.internal("data/gfx/vial.png"));
    vialTexture = new Texture(Gdx.files.internal("data/basket/gfx/test01.png"));
    vialTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    vialSprite = new Sprite(vialTexture);
    vialSprite.setSize(VIAL_SIZE.x * 2, VIAL_SIZE.y * 2);

    // "vialModel.getPosition()" returns the reference point, which is the
    // bottom left corner of the asset used for each body defined with the
    // FixtureAtlas.
    Vector2 vialPos = vialModel.getPosition();
    vialSprite.setPosition(vialPos.x, vialPos.y);
    System.out.println("vialposition.x :" + vialPos.x + "vialposition.y :" + vialPos.y);

    // for basket
    //
    //		// Define the Sprite, as usual.
    //		vialTexture = new Texture(Gdx.files.internal("data/gfx/vial.png"));
    //		vialTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    //		vialSprite = new Sprite(vialTexture);
    //		vialSprite.setSize(VIAL_SIZE.x, VIAL_SIZE.y);
    //
    //		// "vialModel.getPosition()" returns the reference point, which is the
    //		// bottom left corner of the asset used for each body defined with the
    //		// FixtureAtlas.
    //		Vector2 vialPos = vialModel.getPosition();
    //		vialSprite.setPosition(vialPos.x, vialPos.y);
    /// basket end

    ballTexture = new Texture(Gdx.files.internal("data/basket/gfx/playball.png"));
    ballTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    ballSprites = new Sprite[MAX_BALL_COUNT];
    for (int i = 0; i < MAX_BALL_COUNT; i++) {
      ballSprites[i] = new Sprite(ballTexture);
      ballSprites[i].setSize(BALL_SIZE.x, BALL_SIZE.y);
      ballSprites[i].setOrigin(BALL_SIZE.x / 2, BALL_SIZE.y / 2);
    }
  }
Example #30
0
  /** Resets some important variables for sprite optimization and rendering. */
  protected void resetHelpers() {
    if (framePixels == null) framePixels = new Sprite(_pixels);
    framePixels.setRegion(_pixels, 0, 0, frameWidth, frameHeight);
    framePixels.setSize(frameWidth, frameHeight);
    framePixels.flip(false, true);
    origin.make(frameWidth * 0.5f, frameHeight * 0.5f);
    _curIndex = 0;
    _numFrames = 0;

    int widthHelper = _pixels.rotate ? _pixels.getRegionHeight() : _pixels.getRegionWidth();
    int maxFramesX = FlxU.floor(widthHelper / frameWidth);
    int maxFramesY =
        FlxU.floor(
            (_pixels.rotate ? _pixels.getRegionWidth() : _pixels.getRegionHeight()) / frameHeight);
    _maxFrames = maxFramesX * maxFramesY;

    // rotated texture region.
    if (_pixels.rotate) {
      framePixels.setRegion(_pixels.getRegionX(), _pixels.getRegionY(), frameHeight, frameWidth);
      framePixels.flip(false, true);
      dirty = true;
    }
  }