public GameScreen() {
    leftWallAnimation = new Animation(1 / 15f, leftWallTextureAtlas.getRegions());
    rightWallAnimation = new Animation(1 / 15f, rightWallTextureAtlas.getRegions());
    pentagramAtlas = new TextureAtlas(Gdx.files.internal("data/pentagram.atlas"));
    stairsAtlas = new TextureAtlas(Gdx.files.internal("data/stairs.atlas"));
    stairsAnimation = new Animation(1, stairsAtlas.getRegions());

    // batch = new SpriteBatch();
    stage = new Stage();
    // TODO Auto-generated constructor stub
    stage = new Stage(new StretchViewport(WIDTH, HEIGHT));
    Gdx.input.setInputProcessor(stage);

    WIDTH = Gdx.graphics.getWidth();
    HEIGHT = Gdx.graphics.getHeight();

    batch = new SpriteBatch();

    // rightWall = new Texture(Gdx.files.internal("rightWall1.png"));
    // leftWall = new Texture(Gdx.files.internal("leftWall1.png"));
    perspectiveTexture = new Texture(Gdx.files.internal("perspective2.png"));
    rightFootprintTexture = new Texture(Gdx.files.internal("footprintWhite.png"));
    stairTexture = new Texture(Gdx.files.internal("stairs.png"));
    frontTexture = new Texture(Gdx.files.internal("whiteGradient.png"));
    smokeTexture = new Texture(Gdx.files.internal("smoke.jpg"));
  }
  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());
  }
Exemple #3
0
  public static void load() {
    cheifRunningAtlas =
        new TextureAtlas(Gdx.files.internal("data/cheif-running-packed/cheif-running.atlas"));
    cheifRunning = new Animation(1 / 10f, cheifRunningAtlas.getRegions());

    cheifNeutralAtlas =
        new TextureAtlas(Gdx.files.internal("data/cheif-neutral-packed/cheif-neutral.atlas"));
    cheifNeutral = new Animation(1 / 10f, cheifNeutralAtlas.getRegions());

    cheifAirborneAtlas =
        new TextureAtlas(Gdx.files.internal("data/cheif-airborne-packed/cheif-airborne.atlas"));
    cheifAirborne = new Animation(1 / 10f, cheifAirborneAtlas.getRegions());

    cheifSlidingAtlas =
        new TextureAtlas(Gdx.files.internal("data/cheif-sliding-packed/cheif-sliding.atlas"));
    cheifSliding = new Animation(1 / 10f, cheifSlidingAtlas.getRegions());
  }
Exemple #4
0
  public Assets() {
    // Load all backgroundlayers into regionlist
    TextureAtlas assetatlas = new TextureAtlas("packedImgs/Starscroller.pack");

    regionlist = assetatlas.getRegions();

    iterator = regionlist.iterator();
  }
 public Animation(Character character, String name, int repeat, int framerate) {
   TextureAtlas atlas =
       SpriteSheetService.getInstance()
           .getSpriteSheet(character.getName().toLowerCase() + "_" + name);
   for (TextureRegion texture : atlas.getRegions()) {
     this.getTextures().add(texture);
     this.width = texture.getRegionWidth();
     this.height = texture.getRegionHeight();
   }
   this.framerate = framerate;
   this.repeat = repeat;
 }
  private void init(TextureAtlas atlas, String caller, int framesPerSecond, GameObject parent) {
    this.atlas = atlas;
    this.caller = caller;
    this.parent = parent;

    currentTexture = 1;
    numTextures = atlas.getRegions().size;

    countDownTime = 1f / (float) framesPerSecond;
    timer = countDownTime;

    TextureRegion r = atlas.findRegion(caller + 1);
    parent.setRegion(r);
  }
 @Override
 public void show() {
   startLevel("theme1.txt");
   leftWallAnimation = new Animation(1 / 15f, leftWallTextureAtlas.getRegions());
   rightWallAnimation = new Animation(1 / 15f, rightWallTextureAtlas.getRegions());
 }
  @Override
  public void render(float delta) {
    super.render();

    totalGameTimer += delta;
    // if ((totalGameTimer >= 5) && (levelStarted == false)) {
    // startLevel("theme1.txt");
    // levelStarted = true;
    // return;
    // }

    Gdx.gl.glClearColor(0, 0, 0.2f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();
    {
      // batch.draw(rightFootprintTexture, WIDTH / 2 + footSpacing - 50,
      // 0);
      // batch.draw(leftFootprintTexture, WIDTH / 2 - footSpacing - 50,
      // 0);
      // batch.draw(rightWall, 0, 0, WIDTH, HEIGHT);
      // batch.draw(leftWall, 0, 0, WIDTH, HEIGHT);
      // batch.draw(perspectiveTexture, 0, 0, WIDTH, HEIGHT);

    }
    batch.end();

    batch.begin();
    // sprite.draw(batch);
    elapsedTime += Gdx.graphics.getDeltaTime();
    // batch.draw(), x, y, originX, originY, width, height, scaleX, scaleY,
    // rotation);
    batch.draw(smokeTexture, 0, 0, WIDTH, HEIGHT);

    // System.out.println(level.getSkipped());
    int damage = (level.getSkipped() + level.getMisses()) / 3;

    // System.out.println(damage);

    if (damage == 5) {
      leftWallAnimation = new Animation(1 / 45f, leftWallTextureAtlas.getRegions());
      rightWallAnimation = new Animation(1 / 45f, rightWallTextureAtlas.getRegions());
    }

    if (damage >= 6) {
      deathCounter++;
      ScreenManager.getInstance().show(ScreenManager.Screens.TITLE);
      endingLevel = true;
      music.stop();
      music.dispose();
    } else {
      batch.draw(
          pentagramAtlas.findRegion("000" + Integer.toString((damage % 7) + 1)),
          WIDTH / 2 - (72 / 2),
          HEIGHT - 72,
          72,
          72);
    }
    // batch.draw(stairTexture, 0, (float) -(level.getCurrPos() * 10),
    // WIDTH, HEIGHT);
    batch.draw(
        stairsAnimation.getKeyFrame(level.getFootstepsBetween(-level.getCurrPos(), 0).size(), true),
        (float) 0,
        0,
        WIDTH,
        HEIGHT / 2);
    batch.draw(leftWallAnimation.getKeyFrame(elapsedTime, true), 0, 0, 225, HEIGHT);
    batch.draw(rightWallAnimation.getKeyFrame(elapsedTime, true), WIDTH - 225, 0, 225, HEIGHT);
    batch.end();

    // Advance in level
    // level.addCurrPos(delta);
    // TODO:
    level.syncWithMusic(music);

    // // Announce next footstep, if one has been passed
    // if (level.getFootsteps().get(nextFootstep).getTime() <
    // level.getCurrPos()) {
    // // "Next" footstep is in the past
    // nextFootstep++;
    //
    // // Announce
    // System.out.println("Next footstep is now: " +
    // level.getFootsteps().get(nextFootstep).toString());
    // }

    // TODO: Look for input
    boolean leftPressed = Gdx.input.isKeyJustPressed(Input.Keys.SHIFT_LEFT);
    boolean rightPressed = Gdx.input.isKeyJustPressed(Input.Keys.SHIFT_RIGHT);
    if (leftPressed || rightPressed) {
      // TODO: If pressed BEFORE a footstep, miss the next footstep

      // If pressed DURING a footstep, mark footstep as hit if it is left.
      // Otherwise miss.
      for (Footstep f : level.getActiveFootsteps(HIT_THRESHOLD)) {
        if (f != null) {
          Footstep active = f;
          if ((!active.isDidHit()) && (!active.isDidMiss())) {
            if (((active.getType() == FootstepType.LEFT) && leftPressed)
                || ((active.getType() == FootstepType.RIGHT) && rightPressed)) {
              // HIT!
              active.setDidHit(true);
              // System.out.println("HIT FOOTSTEP: " +
              // active.toString());
            } else {
              // Miss.
              active.setDidMiss(true);
              // System.out.println("MISSED FOOTSTEP: " +
              // active.toString());
            }
          }
        }
      }
    }

    // Render visible footsteps
    batch.begin();
    {
      double startTime = -2;
      double farthestTime = 5.0f;
      for (Footstep f : level.getFootstepsBetween(startTime, farthestTime)) {
        float distanceOnRoad =
            (float) ((f.getTime() - level.getCurrPos()) / (farthestTime - startTime));
        distanceOnRoad -= 1;
        distanceOnRoad = -(-Math.abs(distanceOnRoad * distanceOnRoad * distanceOnRoad) - 1);
        distanceOnRoad = 2 - (distanceOnRoad);
        Sprite sprite = new Sprite(rightFootprintTexture);
        // Flip for left foot
        sprite.flip(f.getType() == FootstepType.LEFT, false);
        // Add alpha
        if (distanceOnRoad > 0) {
          sprite.setAlpha((1f - distanceOnRoad) * 0.9f + 0.1f);
        }
        // Add scaling
        sprite.setScale((1f - distanceOnRoad) * 0.6f);
        // Light footsteps that are "active"
        double distanceTo = f.getTime() - level.getCurrPos();
        if (Math.abs(distanceTo) < LIT_THRESHOLD) {
          sprite.setColor(Color.BLUE);
        }
        if (-distanceTo > LIT_THRESHOLD && (!(f.isDidHit() || f.isDidMiss()))) {
          sprite.setRotation((int) (level.getCurrPos() * 2000));
          sprite.setColor(Color.FIREBRICK);
        }

        // Mark hits or misses
        if (f.isDidHit()) {
          sprite.setColor(Color.GREEN);
        } else if (f.isDidMiss()) {
          sprite.setColor(Color.RED);
        }

        float leftFactor = 1;
        if (f.getType() == FootstepType.LEFT) {
          leftFactor = -1;
        }
        float x = WIDTH / 2 + (leftFactor * (WIDTH / 11) * (1 - distanceOnRoad));
        float y = (distanceOnRoad * (HEIGHT / 2 + 50 - FOOTSTEP_LINE)) + FOOTSTEP_LINE;

        // Celebrate hits!
        if (f.isDidHit()) {
          y += -distanceTo * 100;
        }

        sprite.setCenter(x, y);
        sprite.draw(batch);
      }
    }
    batch.end();
  }