Ejemplo n.º 1
1
 @Override
 public void draw(Batch batch, float parentAlpha) {
   elapsedTime += Gdx.graphics.getDeltaTime();
   if (playerControlled == true) {
     batch.draw(standingAnimation.getKeyFrame(elapsedTime, true), this.x + 16, this.y + 16);
   } else {
     batch.draw(standingAnimation.getKeyFrame(elapsedTime, true), this.x, this.y);
   }
   batch.draw(texture, x, y);
   bitmapFont.draw(batch, characterList.get(heroNumber - 1).name, x, y + 74);
 }
Ejemplo n.º 2
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());
  }
Ejemplo n.º 3
0
  public TextureRegion getFrames(float dt) {
    currentState = getState();

    TextureRegion region;
    switch (currentState) {
      case JUMPING:
        region = jumpAnimation.getKeyFrame(stateTimer);
        break;
      case RUNNING:
        region = runAnimation.getKeyFrame(stateTimer, true);
        break;
      case FALLING:
      case STANDING:
      default:
        region = standAnimation.getKeyFrame(stateTimer, true);
        break;
    }

    if ((b2body.getLinearVelocity().x < 0 || !runningRight) && !region.isFlipX()) {
      region.flip(true, false);
      runningRight = false;
    } else if ((b2body.getLinearVelocity().x > 0 || runningRight) && region.isFlipX()) {
      region.flip(true, false);
      runningRight = true;
    }

    stateTimer = currentState == previousState ? stateTimer + dt : 0;
    previousState = currentState;
    return region;
  }
Ejemplo n.º 4
0
  public TextureRegion getFrame(float delta) {
    currentState = getState();
    TextureRegion region;
    switch (currentState) {
      case DEAD:
        region = playerDead;
        break;
      case JUMPING:
        region = playerJump.getKeyFrame(stateTimer);
        break;
      case RUNNING:
        region = playerRun.getKeyFrame(stateTimer, true);
        break;
      case FALLING:
        region = playerFalling.getKeyFrame(stateTimer, true);
        break;
      case STANDING:
      default:
        region = playerStand;
        break;
    }

    if ((b2body.getLinearVelocity().x < -0.1f || !runningRight) && !region.isFlipX()) {
      region.flip(true, false);
      runningRight = false;
    } else if ((b2body.getLinearVelocity().x > 0.1f || runningRight) && region.isFlipX()) {
      region.flip(true, false);
      runningRight = true;
    }

    stateTimer = currentState == previousState ? stateTimer + delta : 0;
    previousState = currentState;

    return region;
  }
Ejemplo n.º 5
0
  /** コンストラクタ */
  public Interface() {
    weapon = new ArrayList<Sprite>();

    // テクスチャ画像読み込み
    Texture texture = new Texture(Gdx.files.internal("data/interface.png"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    // 巻物アニメーション
    TextureRegion[][] tmp = TextureRegion.split(texture, 128, 128);
    TextureRegion[] frame = new TextureRegion[3];
    int index = 0;
    for (int i = 0; i < frame.length; i++) frame[index++] = tmp[0][i];
    scrollAnimation = new Animation(5.0f, frame);
    scroll = new Sprite(scrollAnimation.getKeyFrame(0, false));
    scroll.setOrigin(scroll.getWidth() * 0.5f, scroll.getHeight() * 0.5f);
    scroll.setScale(ScrollNinja.scale);

    nowFrame = scrollAnimation.getKeyFrame(0, false);

    // HP部分
    TextureRegion tmpRegion = new TextureRegion(texture, 0, 128, 512, 128);
    hp = new Sprite(tmpRegion);
    hp.setOrigin(hp.getWidth() * 0.5f, hp.getHeight() * 0.5f);
    hp.setScale(ScrollNinja.scale);

    // 巻物の右端部分
    tmpRegion = new TextureRegion(texture, 384, 0, 128, 128);
    scrollRight = new Sprite(tmpRegion);
    scrollRight.setOrigin(scrollRight.getWidth() * 0.5f, scrollRight.getHeight() * 0.5f);
    scrollRight.setScale(ScrollNinja.scale);

    // ひょうたん
    tmpRegion = new TextureRegion(texture, 0, 256, 128, 128);
    hyoutan = new Sprite(tmpRegion);
    hyoutan.setOrigin(hyoutan.getWidth() * 0.5f, hyoutan.getHeight() * 0.5f);
    hyoutan.setScale(ScrollNinja.scale);

    // チャクラ
    tmpRegion = new TextureRegion(texture, 128, 256, 128, 128);
    chakra = new Sprite(tmpRegion);
    chakra.setOrigin(chakra.getWidth() * 0.5f, chakra.getHeight() * 0.5f);
    chakra.setScale(ScrollNinja.scale);

    // 最初の設定;
    percentHP = 1;
    countHP = percentHP;
    percentChakra = 0;
    countChakra = percentChakra;
    calculateHP = false;
    calculateChakra = false;
    stopHP = true;
    stopChakra = true;
    stateTime = 0;
    transrateX = 0;
  }
Ejemplo n.º 6
0
 /** update function, calls before draw */
 public void update(float delta) {
   if (stateTime <= 1.5) {
     // animation
     keyFrame = anim.getKeyFrame(stateTime, true);
     setColor(1, 1, 1, stateTime);
   } else {
     keyFrame = anim.getKeyFrame(stateTime, false);
     setColor(1, 1, 1, 1);
   }
   stateTime += delta;
 }
Ejemplo n.º 7
0
  public TextureRegion getFrame(float dt) {
    // get marios current state. ie. jumping, running, standing...
    currentState = getState();

    TextureRegion region;

    // depending on the state, get corresponding animation keyFrame.
    switch (currentState) {
      case DEAD:
        region = marioDead;
        break;
      case GROWING:
        region = growMario.getKeyFrame(stateTimer);
        if (growMario.isAnimationFinished(stateTimer)) {
          runGrowAnimation = false;
        }
        break;
      case JUMPING:
        region = marioIsBig ? bigMarioJump : marioJump;
        break;
      case RUNNING:
        region =
            marioIsBig
                ? bigMarioRun.getKeyFrame(stateTimer, true)
                : marioRun.getKeyFrame(stateTimer, true);
        break;
      case FALLING:
      case STANDING:
      default:
        region = marioIsBig ? bigMarioStand : marioStand;
        break;
    }

    // if mario is running left and the texture isnt facing left... flip it.
    if ((b2body.getLinearVelocity().x < 0 || !runningRight) && !region.isFlipX()) {
      region.flip(true, false);
      runningRight = false;
    }

    // if mario is running right and the texture isnt facing right... flip it.
    else if ((b2body.getLinearVelocity().x > 0 || runningRight) && region.isFlipX()) {
      region.flip(true, false);
      runningRight = true;
    }

    // if the current state is the same as the previous state increase the state timer.
    // otherwise the state has changed and we need to reset timer.
    stateTimer = currentState == previousState ? stateTimer + dt : 0;
    // update previous state
    previousState = currentState;
    // return our final adjusted frame
    return region;
  }
Ejemplo n.º 8
0
  @Override
  public void draw(Batch batch, float parentAlpha) {
    TextureRegion currFrame = stanceAnimation.getKeyFrame(stateTime);
    if (state == State.BUMP) currFrame = bumpAnimation.getKeyFrame(stateTime);

    if (!currFrame.isFlipX()) currFrame.flip(true, false);

    // Draw
    Color color = batch.getColor();
    batch.setColor(getColor());
    super.draw(batch, parentAlpha, currFrame);
    batch.setColor(color);
  }
Ejemplo n.º 9
0
  @Override
  public void processEntity(Entity entity, float deltaTime) {
    TextureComponent tex = tm.get(entity);
    AnimationComponent anim = am.get(entity);
    StateComponent state = sm.get(entity);

    Animation animation = anim.animations.get(state.get());

    if (animation != null) {
      tex.region = animation.getKeyFrame(state.time);
    }

    state.time += deltaTime;
  }
  private void drawWorld() {
    camera.update();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    batch.draw(background, camera.position.x - background.getWidth() / 2, 0);
    for (Rock rock : rocks) {
      batch.draw(rock.image, rock.position.x, rock.position.y);
    }
    batch.draw(ground, groundOffsetX, 0);
    batch.draw(ground, groundOffsetX + ground.getRegionWidth(), 0);
    batch.draw(ceiling, groundOffsetX, 480 - ceiling.getRegionHeight());
    batch.draw(ceiling, groundOffsetX + ceiling.getRegionWidth(), 480 - ceiling.getRegionHeight());
    batch.draw(plane.getKeyFrame(planeStateTime), planePosition.x, planePosition.y);
    batch.end();

    batch.setProjectionMatrix(uiCamera.combined);
    batch.begin();
    if (gameState == GameState.Start) {
      batch.draw(
          ready,
          Gdx.graphics.getWidth() / 2 - ready.getRegionWidth() / 2,
          Gdx.graphics.getHeight() / 2 - ready.getRegionHeight() / 2);
    }
    if (gameState == GameState.GameOver) {
      batch.draw(
          gameOver,
          Gdx.graphics.getWidth() / 2 - gameOver.getRegionWidth() / 2,
          Gdx.graphics.getHeight() / 2 - gameOver.getRegionHeight() / 2);
    }
    if (gameState == GameState.GameOver || gameState == GameState.Running) {
      font.draw(batch, "" + score, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() - 60);
    }
    batch.end();
  }
Ejemplo n.º 11
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0.39f, 0.58f, 0.92f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Update deltaTime & animationTime
    deltaTime = Gdx.graphics.getDeltaTime();
    animationTime += Gdx.graphics.getDeltaTime();

    // Store Spritesheet to sprite
    sprite = new Sprite(animation.getKeyFrame(animationTime, true));
    sprite.setPosition(xPosition, 0);
    sprite.setScale(1.8f);

    // Set camera to batch and undate camera
    batch.setProjectionMatrix(camera.combined);
    camera.update();

    tiledMapRenderer.setView(camera);
    tiledMapRenderer.render(background);
    tiledMapRenderer.render(foreground);

    // Display on Screen
    batch.begin();
    sprite.draw(batch);
    batch.end();

    // update xPosition
    xPosition = xPosition + (speed * deltaTime);

    HUDBatch.begin();
    font1.draw(HUDBatch, "SCORE:100", 100, 450);
    HUDBatch.end();
  }
Ejemplo n.º 12
0
  public Player(float x, float y) {
    hp = 500;

    tex = new Texture(Gdx.files.internal("textures/player.png"));

    position = new Vector2(x, y);
    size = new Vector2(64, 64);
    deltaPos = new Vector2(0, 0);

    AABB =
        new Rectangle(
            x + (7 * (size.x / 32)),
            y + (7 * (size.y / 32)),
            18 * (size.x / 32),
            18 * (size.y / 32));

    angle = 0;
    animTime = 0;

    TextureRegion[] idleFrame = new TextureRegion[1];
    idleFrame[0] = new TextureRegion(tex, 0, 0, 32, 32);
    idle = new Animation(0.7f, idleFrame);

    TextureRegion[] walkingFrames = new TextureRegion[6];
    for (int i = 0; i < walkingFrames.length; i++) {
      walkingFrames[i] = new TextureRegion(tex, 32 + (i * 32), 0, 32, 32);
    }
    walking = new Animation(0.1f, walkingFrames);
    walking.setPlayMode(PlayMode.LOOP);

    TextureRegion[] shootingFrames = new TextureRegion[2];
    for (int i = 0; i < shootingFrames.length; i++) {
      shootingFrames[i] = new TextureRegion(tex, 224 + (i * 32), 0, 32, 32);
    }
    shooting = new Animation(0.09f, shootingFrames);
    shooting.setPlayMode(PlayMode.LOOP);

    bulletTex = new TextureRegion(tex, 288, 0, 32, 32);

    currentAnimation = idle;

    shootInterval = 150;
    attack = 25;
    shootDeviation = 25;
  }
 // Move caveman sprite along the screen (no limits applied)
 private void updateCaveman() {
   if (Gdx.input.isKeyPressed(Keys.DPAD_LEFT)) {
     if (goingRight) {
       for (TextureRegion t : cavemanWalk.getKeyFrames()) t.flip(true, false);
       goingRight = false;
     }
     cavemanX -= Gdx.graphics.getDeltaTime() * cavemanSpeed;
     currentFrame = cavemanWalk.getKeyFrame(animationTime, true);
   }
   if (Gdx.input.isKeyPressed(Keys.DPAD_RIGHT)) {
     if (!goingRight) {
       goingRight = true;
       for (TextureRegion t : cavemanWalk.getKeyFrames()) t.flip(true, false);
     }
     cavemanX += Gdx.graphics.getDeltaTime() * cavemanSpeed;
     currentFrame = cavemanWalk.getKeyFrame(animationTime, true);
   }
 }
Ejemplo n.º 14
0
  public Pete(Texture texture) {
    TextureRegion[] regions = TextureRegion.split(texture, WIDTH, HEIGHT)[0];

    walking = new Animation(0.25F, regions[0], regions[1]);
    walking.setPlayMode(Animation.PlayMode.LOOP);

    standing = regions[0];
    jumpUp = regions[2];
    jumpDown = regions[3];
  }
Ejemplo n.º 15
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);
 }
Ejemplo n.º 16
0
  /**
   * 0 = gray. 1 = blue. 2 = red. 3 = green.
   *
   * @param color
   */
  public PoisonDart(TextureAtlas atlas, int color, float speed, BattleEntity entity) {
    super(speed, 0, entity);
    AtlasRegion atlasRegion = atlas.findRegion("battle/entities/fireball");
    TextureRegion[][] spriteSheet = atlasRegion.split(34, 25);
    TextureRegion[] frames = new TextureRegion[3];
    frames[0] = spriteSheet[color][0];
    frames[1] = spriteSheet[color][1];
    frames[2] = spriteSheet[color][2];
    Animation attacking = new Animation(0.1f, frames);
    attacking.setPlayMode(Animation.LOOP);
    this.animations.put("attacking", attacking);
    this.setState(BattleEntity.stateAttacking);

    this.setHeight(30);
    this.setWidth(30);
    offsetX = (int) entity.getWidth() - 120;
    offsetY = 0;
    this.addAction(color(Color.MAGENTA));
    this.setGrid(entity.getGridXInt() - 1, entity.getGridYInt());
  }
Ejemplo n.º 17
0
 @Override
 public void draw(Batch batch, float parentAlpha) {
   super.draw(batch, parentAlpha);
   stateTime += Gdx.graphics.getDeltaTime();
   batch.draw(
       animation.getKeyFrame(stateTime, true),
       (screenRectangle.x - (screenRectangle.width * 0.1f)),
       screenRectangle.y,
       screenRectangle.width * 1.2f,
       screenRectangle.height * 1.1f);
 }
Ejemplo n.º 18
0
  public void drawPlayer(SpriteBatch batch) {
    stateTime += Gdx.graphics.getDeltaTime();
    currentFrameRight = walkRight.getKeyFrame(stateTime, true);
    currentFrameLeft = walkLeft.getKeyFrame(stateTime, true);
    currentFrameUp = walkUp.getKeyFrame(stateTime, true);
    currentFrameDown = walkDown.getKeyFrame(stateTime, true);

    // draw method
    batch.begin();

    if (this.getVelocitySpeed().x == 1) {
      batch.draw(currentFrameRight, this.getVec2().x, this.getVec2().y, 0, 0, 15, 15, 1, 1, 1);
    } else if (this.getVelocitySpeed().x == -1) {
      batch.draw(currentFrameLeft, this.getVec2().x, this.getVec2().y, 0, 0, 15, 15, 1, 1, 1);
    } else if (this.getVelocitySpeed().y == 1) {
      batch.draw(currentFrameUp, this.getVec2().x, this.getVec2().y, 0, 0, 15, 15, 1, 1, 1);
    } else if (this.getVelocitySpeed().y == -1) {
      batch.draw(currentFrameDown, this.getVec2().x, this.getVec2().y, 0, 0, 15, 15, 1, 1, 1);
    } else {
      batch.draw(
          playerTexture,
          this.getVec2().x,
          this.getVec2().y,
          0,
          0,
          this.getWidth(),
          this.getHeight(),
          1,
          1,
          this.getRote(),
          0,
          0,
          playerTexture.getWidth(),
          playerTexture.getHeight(),
          false,
          false);
    }

    batch.end();
  }
  @Override
  public void render() {
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Update animationTime
    animationTime += Gdx.graphics.getDeltaTime();
    camera.update();
    batch.setProjectionMatrix(camera.combined);

    // Render background image
    batch.begin();
    batch.draw(background, 0, 0);
    batch.end();

    // Check if async load is done
    if (!loaded) {
      // Render Logo and Loading Bar
      batch.begin();
      batch.draw(logo, logoPos.x, logoPos.y);
      batch.draw(progressBarBaseImg, pbPos.x, pbPos.y);
      batch.draw(
          progressBarImg,
          pbPos.x,
          pbPos.y,
          progressBarImg.getWidth() * manager.getProgress(),
          progressBarImg.getHeight());
      batch.end();

      if (manager.update()) {
        // Initialize params for caveman
        loaded = true;
        cavemanAnims = manager.get("data/caveman-sheet.json");
        cavemanWalk = cavemanAnims.getAnimation("walk");
        currentFrame = cavemanWalk.getKeyFrames()[0];
        cavemanX = 0;
        cavemanSpeed = 180;
        goingRight = true;

        Gdx.app.log(TAG, "Instructions");
        Gdx.app.log(TAG, "- Press Left key to move left");
        Gdx.app.log(TAG, "- Press Right key to move right");
      }
    } else {
      // Caveman resources are loaded... let's have some fun
      updateCaveman();

      batch.begin();
      batch.draw(currentFrame, cavemanX, .0f);
      batch.end();
    }
  }
Ejemplo n.º 20
0
  // Resets the state of the projectile to put it back in the pool
  public void reset() {
    isActive = false;
    isVisible = false;
    sprite.setRegion(animTravel.getKeyFrame(0));
    hitEntities.clear();

    if (explosionRadius > 0) {
      ExplosionSkill explosion = (ExplosionSkill) SkillManager.getSkill("Explosion");
      explosion.setRadius(explosionRadius);
      explosion.use(caster, getPosition());
    }
    explosionRadius = 0;
  }
Ejemplo n.º 21
0
  /**
   * Constructeur
   *
   * @param res Resource qui correspond au personnage
   * @param textures TextureRegions qui ont ete decoupees
   */
  public AnimationProvider(ResourceAnimated res, TextureRegion[][] textures) {
    mResource = res;
    mAnimationMatrix = textures;
    mCurrentAnimation = "idle";
    mAnimationMap = new HashMap<String, Animation>();

    // On lit les animations depuis le fichier resource et on cree toutes les
    // classes Animation necessaires.
    Iterator<AnimationDef> iter = mResource.anims.iterator();
    while (iter.hasNext()) {
      // Pour chaque animation...
      AnimationDef anim = iter.next();

      // On calcule le nombre d'images dans l'animation
      int frameCount =
          (anim.end_col - anim.start_col + 1) + (anim.end_line - anim.start_line) * res.columns;

      // On cree un tableau avec chaque image de l'animation, dans l'ordre
      TextureRegion[] frames = new TextureRegion[frameCount];
      int frameIndex = 0;
      for (int line = anim.start_line; line <= anim.end_line; line++) {
        for (int col = anim.start_col; col <= anim.end_col; col++) {
          frames[frameIndex] = mAnimationMatrix[line][col];
          frameIndex++;
        }
      }

      Animation gdxAnim = new Animation(0.05f, frames);

      if (anim.loop) {
        gdxAnim.setPlayMode(Animation.LOOP_PINGPONG);
      } else {
        gdxAnim.setPlayMode(Animation.NORMAL);
      }

      mAnimationMap.put(anim.name, gdxAnim);
    }
  }
Ejemplo n.º 22
0
 @Override
 public void activate() {
   super.activate();
   // doctor.Floating = true;
   originAcceleration = doctor.getAcceleration().y;
   doctor.setAcceleration(0, 0);
   doctor.setVelocity(0, FLOATER_VELOCITY);
   doctor.changeStatus(Doctor.STATUS_JUMP);
   animation = Assets.getFloaterAct();
   keyFrame = animation.getKeyFrame(0, true);
   this.setWidth(FLOATER_WIDTH);
   this.setHeight(FLOATER_HEIGHT);
   this.setPosition(doctor.getX(), doctor.getY());
 }
Ejemplo n.º 23
0
  /**
   * Retourne la frame a afficher en fonction de l'animation en cours
   *
   * @param delta
   * @return
   */
  public TextureRegion getKeyFrame(float delta) {
    mAccumulatedTime += delta / 2.0f;

    if (mEnforcedAnimation != null) {
      // On a une animation forcee, on la joue jusqu'a ce qu'elle soit finie
      Animation forcedAnim = mAnimationMap.get(mEnforcedAnimation);

      TextureRegion region = forcedAnim.getKeyFrame(mEnforcedTime);
      mEnforcedTime += delta;

      if (forcedAnim.isAnimationFinished(mEnforcedTime)) {
        // L'animation est finie, on jouera l'animation mCurrentAnimation a la prochaine frame
        mEnforcedAnimation = null;
        mEnforcedTime = 0;
      }

      return region;
    } else {
      if (mAnimationMap.containsKey(mCurrentAnimation))
        return mAnimationMap.get(mCurrentAnimation).getKeyFrame(mAccumulatedTime, true);
      else return null;
    }
  }
Ejemplo n.º 24
0
  public void update(float runtime) {
    x -= 1 / 10f;
    rectNemici.set(x, y, 35, 35);

    batch.begin();
    batch.draw(nemiciAnimation.getKeyFrame(runtime, true), x, y);
    // batch.draw(nemiciAnimation.getKeyFrame(runtime, true), 400, 300);
    batch.end();

    shapeRenderer.begin(ShapeType.Filled);
    shapeRenderer.setColor(55 / 255.0f, 80 / 255.0f, 100 / 255.0f, 1);
    shapeRenderer.rect(x, y, 35, 35);
    shapeRenderer.end();
  }
Ejemplo n.º 25
0
 public void draw(SpriteBatch batch) {
   batch.draw(
       currentAnimation.getKeyFrame(animTime),
       position.x,
       position.y,
       size.x / 2,
       size.y / 2,
       size.x,
       size.y,
       1,
       1,
       angle);
   deltaPos.x = deltaPos.y = 0;
 }
Ejemplo n.º 26
0
  @Override
  public void render(float delta, SpriteBatch batch) {
    if ((extra & 0x1) == 1) {
      walkDuration += delta;
      if (vX < -15f) {
        sprite.setRegion(walk.getKeyFrame(walkDuration));
        previousXFlip = false;
      } else if (vX > 15f) {
        sprite.setRegion(walk.getKeyFrame(walkDuration));
        sprite.flip(true, false);
        previousXFlip = true;
      } else {
        sprite.setRegion(walk.getKeyFrame(walkDuration));
        sprite.flip(previousXFlip, false);
      }
    } else {
      sprite.setRegion(AssetLoader.instance.getTexture("sprites/green_loader.png"));
    }

    float x = position.x - sprite.getWidth() / 2 + 1f;
    float y = position.y - sprite.getHeight() / 2 + ServerBlob.YOFFSET;
    drawAll(sprite, batch, x, y);
  }
Ejemplo n.º 27
0
 @Override
 public void act(float delta) {
   super.act(delta);
   if (state == State.BUMP && bumpAnimation.isAnimationFinished(stateTime))
     addAction(
         Actions.sequence(
             Actions.fadeOut(0.1f),
             new Action() {
               @Override
               public boolean act(float delta) {
                 remove();
                 return true;
               }
             }));
 }
  @Override
  public void create() {
    shapeRenderer = new ShapeRenderer();
    batch = new SpriteBatch();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, 800, 480);
    uiCamera = new OrthographicCamera();
    uiCamera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    uiCamera.update();

    font = new BitmapFont(Gdx.files.internal("arial.fnt"));

    background = new Texture("background.png");
    ground = new TextureRegion(new Texture("ground.png"));
    ceiling = new TextureRegion(ground);
    ceiling.flip(true, true);

    rock = new TextureRegion(new Texture("rock.png"));
    rockDown = new TextureRegion(rock);
    rockDown.flip(false, true);

    Texture frame1 = new Texture("plane1.png");
    frame1.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    Texture frame2 = new Texture("plane2.png");
    Texture frame3 = new Texture("plane3.png");

    ready = new TextureRegion(new Texture("ready.png"));
    gameOver = new TextureRegion(new Texture("gameover.png"));

    plane =
        new Animation(
            0.05f,
            new TextureRegion(frame1),
            new TextureRegion(frame2),
            new TextureRegion(frame3),
            new TextureRegion(frame2));
    plane.setPlayMode(PlayMode.LOOP);

    music = Gdx.audio.newMusic(Gdx.files.internal("music.mp3"));
    music.setLooping(true);
    music.play();

    explode = Gdx.audio.newSound(Gdx.files.internal("explode.wav"));

    resetWorld();
  }
Ejemplo n.º 29
0
  public Health(ShooterGame g) {

    lifeManager = new LifeManager(3);

    game = g;
    lifeManager.setGame(game);

    backBarTexture = new Texture(Gdx.files.internal("hud/health/backbar2.png"));
    backBarDangerTexture = new Texture(Gdx.files.internal("hud/health/backbar-danger.png"));
    backBarSprite = new Sprite(backBarTexture);
    backBarWarningSprite = new Sprite(backBarTexture);

    healthBarTexture = new Texture(Gdx.files.internal("hud/health/healthbar.png"));
    healthBarSprite = new Sprite(healthBarTexture);

    setHealthBarSprite(healthBarSprite);

    topLeftWingTexture = new Texture(Gdx.files.internal("hud/health/topleftwing.png"));
    topLeftWingSprite = new Sprite(topLeftWingTexture);

    bottomLeftWingTexture = new Texture(Gdx.files.internal("hud/life/bottomleftwing.png"));
    bottomLeftWingSprite = new Sprite(bottomLeftWingTexture);

    // Initial Positions
    backBarSprite.setPosition(50, 688);
    healthBarSprite.setPosition(50, 688);
    topLeftWingSprite.setPosition(10, 670);
    bottomLeftWingSprite.setPosition(64, 640);

    // Set up animated health bar when health goes below 20
    animationFrames = new TextureRegion[DANGER_HEALTH_FRAMES];

    TextureRegion[][] tmpFrames = TextureRegion.split(backBarDangerTexture, 454, 15);

    int index = 0;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 11; j++) {
        animationFrames[index++] = tmpFrames[i][j];
      }
    }

    backbarAnimation = new Animation(1f / 22f, animationFrames);
    backbarAnimation.setPlayMode(Animation.PlayMode.LOOP);
  }
Ejemplo n.º 30
0
  public Nemici() {

    batch = new SpriteBatch();
    // nemiciText = new Texture ();

    rectNemici = new Rectangle();
    shapeRenderer = new ShapeRenderer();

    nemiciAnimation =
        new Animation(
            1 / 10f,
            new TextureRegion(new Texture("nemici/e_f1.png")),
            new TextureRegion(new Texture("nemici/e_f2.png")),
            new TextureRegion(new Texture("nemici/e_f3.png")),
            new TextureRegion(new Texture("nemici/e_f4.png")),
            new TextureRegion(new Texture("nemici/e_f5.png")),
            new TextureRegion(new Texture("nemici/e_f6.png")));
    nemiciAnimation.setPlayMode(Animation.PlayMode.LOOP);
  }