Beispiel #1
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;
  }
Beispiel #2
0
  @Override
  public void setValues(Sprite sprite, int i, float[] floats) {
    switch (Mode.values()[i]) {
      case SCALE:
        sprite.setScale(floats[0]);
        break;

      case ALPHA:
        Color color = sprite.getColor();
        sprite.setColor(color.r, color.g, color.b, floats[0]);
        break;

      case POSITION:
        sprite.setX(floats[0]);
        sprite.setY(floats[1]);
        break;

      case ROTATION:
        sprite.setRotation(floats[0]);
        break;

      default:
        assert false;
    }
  }
  public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0.2f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // tell the camera to update its matrices.
    camera.update(
        car.body.getPosition().x * PIXELS_PER_METER, car.body.getPosition().y * PIXELS_PER_METER);

    spriteBatch.setProjectionMatrix(camera.getCombined());

    if (Gdx.input.isKeyPressed(Input.Keys.UP) || Gdx.input.isTouched()) {
      car.setAccelerate(Car.ACC_ACCELERATE);
    } else if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
      car.setAccelerate(Car.ACC_BRAKE);
    } else {
      car.setAccelerate(Car.ACC_NONE);
    }

    if (Gdx.input.isKeyPressed(Input.Keys.LEFT) || Gdx.input.getAccelerometerY() < -2.5) {
      car.setSteer(Car.STEER_HARD_LEFT);
    } else if (Gdx.input.getAccelerometerY() < -1) {
      car.setSteer(Car.STEER_LEFT);
    } else if (Gdx.input.isKeyPressed(Input.Keys.RIGHT) || Gdx.input.getAccelerometerY() > 2.5) {
      car.setSteer(Car.STEER_HARD_RIGHT);
    } else if (Gdx.input.getAccelerometerY() > 1) {
      car.setSteer(Car.STEER_RIGHT);
    } else {
      car.setSteer(Car.STEER_NONE);
    }

    car.update(Gdx.app.getGraphics().getDeltaTime());

    /**
     * Have box2d update the positions and velocities (and etc) of all tracked objects. The second
     * and third argument specify the number of iterations of velocity and position tests to perform
     * -- higher is more accurate but is also slower.
     */
    world.step(Gdx.app.getGraphics().getDeltaTime(), 3, 3);

    world.clearForces();

    // draw the sprites
    spriteBatch.begin();

    playerSprite.setPosition(
        PIXELS_PER_METER * car.body.getPosition().x - playerTexture.getRegionWidth() / 2,
        PIXELS_PER_METER * car.body.getPosition().y - playerTexture.getRegionHeight() / 2);
    playerSprite.setRotation((MathUtils.radiansToDegrees * car.body.getAngle()));

    playerSprite.setFlip(false, true);
    playerSprite.setScale(0.3f);

    playerSprite.draw(spriteBatch);

    spriteBatch.end();

    /** Draw this last, so we can see the collision boundaries on top of the sprites and map. */
    debugRenderer.render(
        world, camera.getCombined().scale(PIXELS_PER_METER, PIXELS_PER_METER, PIXELS_PER_METER));
  }
Beispiel #4
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();
  }
 public Sprite loadSprite(String id, String file, float scaleX, float scaleY) {
   Sprite sprite = new Sprite(new Texture(Gdx.files.internal(file)));
   sprite.getTexture().setFilter(TextureFilter.Linear, TextureFilter.Nearest);
   sprite.setScale(scaleX, scaleY);
   sprite.setOrigin(0, 0);
   sprites.put(id, sprite);
   return sprite;
 }
Beispiel #6
0
  private void renderDoorLight(SpriteBatch batch) {
    BatchUtils.setBlendFuncAdd(batch);
    Sprite s = Assets.openingDoorLight;
    s.setColor(1, 1, 1, 1);
    s.setScale(1, doorLightScale);
    Utils.drawCenter(batch, s, -114f, (s.getHeight() / 2 - 28) * doorLightScale);

    float tint = ((float) Math.sin(stateTime * 2) + 1) / 2 * 0.5f + 0.0f;
    tint *= doorLightScale;
    s.setColor(tint, tint, tint, 1);
    Utils.drawCenter(batch, s, -114f, (s.getHeight() / 2 - 28) * doorLightScale);
    BatchUtils.setBlendFuncNormal(batch);
  }
 @Override
 public void setValues(Sprite target, int tweenType, float[] newValues) {
   switch (tweenType) {
     case ALPHA:
       target.setColor(
           target.getColor().r, target.getColor().g, target.getColor().b, newValues[0]);
       break;
     case SCALE:
       target.setScale(newValues[0], newValues[1]);
       break;
     default:
       assert false;
   }
 }
 @Override
 public void setValues(Sprite target, int tweenType, float[] newValues) {
   switch (tweenType) {
     case ALPHA:
       target.setColor(
           target.getColor().r, target.getColor().g, target.getColor().b, newValues[0]);
       break;
     case SCALE:
       target.setScale(newValues[0]);
       break;
     case VERTICAL:
       target.setY(newValues[0]);
       break;
   }
 }
Beispiel #9
0
 public void draw(
     Batch batch,
     float x,
     float y,
     float originX,
     float originY,
     float width,
     float height,
     float scaleX,
     float scaleY,
     float rotation) {
   sprite.setOrigin(originX, originY);
   sprite.setRotation(rotation);
   sprite.setScale(scaleX, scaleY);
   sprite.setBounds(x, y, width, height);
   Color color = sprite.getColor();
   sprite.setColor(Color.tmp.set(color).mul(batch.getColor()));
   sprite.draw(batch);
   sprite.setColor(color);
 }
  @Override
  public void create() {
    camera = new OrthoCamera();
    camera.resize();
    touch = new Vector2(0, 0);
    TextureRegion back =
        new TextureRegion(Assets.manager.get(Assets.guisheet, Texture.class), 0, 270, 150, 150);
    backButton =
        new Button(
            back,
            new Vector2(
                (back.getRegionWidth() / 3),
                MainGame.HEIGHT - (back.getRegionHeight() + (back.getRegionWidth() / 3))));
    bgManager = new BackgroundManager();

    Tween.registerAccessor(Sprite.class, new SpriteAccessor());
    tweenManager = new TweenManager();
    cardAnimSprite = new Sprite();
    cardAnimSprite.setCenter(MainGame.WIDTH / 2, MainGame.HEIGHT / 2);
    cardAnimSprite.setScale(0.001f);

    alpha = Assets.manager.get(Assets.alpha, Texture.class);
    randomCardButton =
        new SpriteButton(
            new TextureRegion(Assets.manager.get(Assets.random_card, Texture.class)),
            new Vector2(MainGame.WIDTH / 4 - 250, 300));
    rareCardButton =
        new SpriteButton(
            new TextureRegion(Assets.manager.get(Assets.rare_card, Texture.class)),
            new Vector2(MainGame.WIDTH - MainGame.WIDTH / 4 - 250, 300));

    unlockedText = new SpriteText("You Have Unlocked", Fonts.menuFont);
    unlockedText.setPosition(
        MainGame.WIDTH / 2 - Fonts.menuFont.getBounds(unlockedText.getText()).width / 2,
        MainGame.HEIGHT - 100);

    currGold = "Gold: " + MainGame.userStats.getPlayerGold();
  }
  @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();
  }
  @Override
  public void start() {
    OwnedObjectData data = new OwnedObjectData();

    data.drawAfter = true;

    if (bullet.getTicksAlive() < 20) animationPlaying = true;

    createTick = game.getTick();

    bullet.addOwnedObject(this, data);

    final Sprite current = (Sprite) this.ani.getKeyFrame(getTicksAlive());

    Polygon hitbox = bullet.getHitbox();
    Rectangle rect =
        hitbox != null ? hitbox.getBoundingRectangle() : current.getBoundingRectangle();

    final float modifier = 3f;
    float width = rect.getWidth() * modifier;
    float height = rect.getHeight() * modifier;

    final float scaleX = width / current.getWidth();
    final float scaleY = height / current.getHeight();

    current.setScale(scaleX, scaleY);
    current.setRotation(bullet.getRotationDeg());

    current.setOriginCenter();

    Color c = bullet.getDeletionColor().cpy();

    float min = Math.min(c.g, Math.min(c.r, c.b));
    c.r -= min;
    c.g -= min;
    c.b -= min;

    float mul = 0.8f;
    float start = (1f - mul) + 0.3f;

    Color color = new Color(start + (c.r * mul), start + (c.g * mul), start + (c.b * mul), 0f);

    current.setColor(color);
    current.setAlpha(1f);

    final SaveableObject<ScaleAlphaPhaseAnimation> sani =
        new SaveableObject<ScaleAlphaPhaseAnimation>();

    Getter<Sprite> getter =
        new Getter<Sprite>() {
          @Override
          public Sprite get() {
            Sprite current = (Sprite) ani.getKeyFrame(getTicksAlive());

            int over = 5;

            int ticks = (int) ((time.toTicks() - over) - getTicksAlive());

            double mul = 1f - (ticks <= 0 ? -(float) ticks / over : 0f);

            ScaleAlphaPhaseAnimation ani = sani.getObject();

            if (ani == null) return current;

            if (ticks <= 0) {
              animationPlaying = false;
              ani.setAlpha((float) Math.max(0, mul));
            }

            current.setPosition(
                bullet.getX() - current.getWidth() / 2f, bullet.getY() - current.getHeight() / 2f);

            current.setOriginCenter();

            current.setRotation(bullet.getRotationDeg());

            return current;
          }
        };

    final ScaleAlphaPhaseAnimation ani = new ScaleAlphaPhaseAnimation(getter, bullet);

    sani.setObject(ani);

    ani.setTime(time);
    ani.setAddedScale(scaleX * 3f, scaleY * 3f);
    ani.setAlpha(-0.1f);
    ani.start();

    bullet.removeOwnedObject(ani);
    bullet.addOwnedObject(ani, data);
  }
  public GameScreen(Game game, Array<Integer> playerList, Array<Integer> cpuList) {
    super(game);
    Gdx.input.setCatchBackKey(true);
    Gdx.input.setInputProcessor(this);

    cam = new OrthographicCamera(width, height);

    cam.position.x = 400;
    cam.position.y = 240;
    cam.update();

    numPlayers = playerList.size;

    if (numPlayers == 1) {
      touchAreaP1 =
          new BoundingBox(
              new Vector3(-((this.width - 800) / 2), -((this.height - 480) / 2), 0),
              new Vector3(
                  -((this.width - 800) / 2) + (this.width),
                  -((this.height - 480) / 2) + this.height,
                  0));
    } else if (numPlayers == 2) {
      touchAreaP1 =
          new BoundingBox(
              new Vector3(-((this.width - 800) / 2), -((this.height - 480) / 2), 0),
              new Vector3(
                  -((this.width - 800) / 2) + (this.width / 2),
                  -((this.height - 480) / 2) + this.height,
                  0));
      touchAreaP2 =
          new BoundingBox(
              new Vector3(
                  -((this.width - 800) / 2) + (this.width / 2), -((this.height - 480) / 2), 0),
              new Vector3(
                  -((this.width - 800) / 2) + this.width,
                  -((this.height - 480) / 2) + this.height,
                  0));
    } else if (numPlayers == 3) {
      touchAreaP1 =
          new BoundingBox(
              new Vector3(-((this.width - 800) / 2), -((this.height - 480) / 2), 0),
              new Vector3(
                  -((this.width - 800) / 2) + (this.width / 2),
                  -((this.height - 480) / 2) + (this.height / 2),
                  0));
      touchAreaP2 =
          new BoundingBox(
              new Vector3(
                  -((this.width - 800) / 2), -((this.height - 480) / 2) + (this.height / 2), 0),
              new Vector3(
                  -((this.width - 800) / 2) + (this.width / 2),
                  -((this.height - 480) / 2) + this.height,
                  0));
      touchAreaP3 =
          new BoundingBox(
              new Vector3(
                  -((this.width - 800) / 2) + (this.width / 2), -((this.height - 480) / 2), 0),
              new Vector3(
                  -((this.width - 800) / 2) + this.width,
                  -((this.height - 480) / 2) + this.height,
                  0));
    } else if (numPlayers == 4) {
      touchAreaP1 =
          new BoundingBox(
              new Vector3(-((this.width - 800) / 2), -((this.height - 480) / 2), 0),
              new Vector3(
                  -((this.width - 800) / 2) + (this.width / 2),
                  -((this.height - 480) / 2) + (this.height / 2),
                  0));
      touchAreaP2 =
          new BoundingBox(
              new Vector3(
                  -((this.width - 800) / 2), -((this.height - 480) / 2) + (this.height / 2), 0),
              new Vector3(
                  -((this.width - 800) / 2) + (this.width / 2),
                  -((this.height - 480) / 2) + this.height,
                  0));
      touchAreaP3 =
          new BoundingBox(
              new Vector3(
                  -((this.width - 800) / 2) + (this.width / 2), -((this.height - 480) / 2), 0),
              new Vector3(
                  -((this.width - 800) / 2) + this.width,
                  -((this.height - 480) / 2) + (this.height / 2),
                  0));
      touchAreaP4 =
          new BoundingBox(
              new Vector3(
                  -((this.width - 800) / 2) + (this.width / 2),
                  -((this.height - 480) / 2) + (this.height / 2),
                  0),
              new Vector3(
                  -((this.width - 800) / 2) + this.width,
                  -((this.height - 480) / 2) + this.height,
                  0));
    }

    //		camera = new OrthographicCamera(800, 480);
    //		camera.translate(400, 240, 0);

    if (playerList.size + cpuList.size != 3) {
      POSITIONS.add(new Vector2(150, 180));
      POSITIONS.add(new Vector2(450, 180));
      POSITIONS.add(new Vector2(300, 335));
      POSITIONS.add(new Vector2(300, 25));
    } else {
      POSITIONS.add(new Vector2(170, 92));
      POSITIONS.add(new Vector2(432, 100));
      POSITIONS.add(new Vector2(300, 335));
    }

    // Fade
    blackFade = Resources.getInstance().blackFade;
    fadeBatch = new SpriteBatch();
    fadeBatch.getProjectionMatrix().setToOrtho2D(0, 0, 2, 2);

    stouchAreaP1 = Resources.getInstance().touchArea1;
    stouchAreaP2 = Resources.getInstance().touchArea2;
    stouchAreaP3 = Resources.getInstance().touchArea3;
    stouchAreaP4 = Resources.getInstance().touchArea4;

    if (playerList.size > 0 && playerList.get(0) == 1) {
      p1 = Resources.getInstance().factoryP1Small;
    } else if (playerList.size > 0 && playerList.get(0) == 2) {
      p1 = Resources.getInstance().factoryP2Small;
    } else if (playerList.size > 0 && playerList.get(0) == 3) {
      p1 = Resources.getInstance().factoryP3Small;
    } else if (playerList.size > 0 && playerList.get(0) == 4) {
      p1 = Resources.getInstance().factoryP4Small;
    }

    if (playerList.size > 1 && playerList.get(1) == 1) {
      p2 = Resources.getInstance().factoryP1Small;
    } else if (playerList.size > 1 && playerList.get(1) == 2) {
      p2 = Resources.getInstance().factoryP2Small;
    } else if (playerList.size > 1 && playerList.get(1) == 3) {
      p2 = Resources.getInstance().factoryP3Small;
    } else if (playerList.size > 1 && playerList.get(1) == 4) {
      p2 = Resources.getInstance().factoryP4Small;
    }

    if (playerList.size > 2 && playerList.get(2) == 1) {
      p3 = Resources.getInstance().factoryP1Small;
    } else if (playerList.size > 2 && playerList.get(2) == 2) {
      p3 = Resources.getInstance().factoryP2Small;
    } else if (playerList.size > 2 && playerList.get(2) == 3) {
      p3 = Resources.getInstance().factoryP3Small;
    } else if (playerList.size > 2 && playerList.get(2) == 4) {
      p3 = Resources.getInstance().factoryP4Small;
    }

    if (playerList.size > 3 && playerList.get(3) == 1) {
      p4 = Resources.getInstance().factoryP1Small;
    } else if (playerList.size > 3 && playerList.get(3) == 2) {
      p4 = Resources.getInstance().factoryP2Small;
    } else if (playerList.size > 3 && playerList.get(3) == 3) {
      p4 = Resources.getInstance().factoryP3Small;
    } else if (playerList.size > 3 && playerList.get(3) == 4) {
      p4 = Resources.getInstance().factoryP4Small;
    }

    if (playerList.size > 0) p1.setScale(.2f);
    if (playerList.size > 1) p2.setScale(.2f);
    if (playerList.size > 2) p3.setScale(.2f);
    if (playerList.size > 3) p4.setScale(.2f);

    if (playerList.size > 0) p1.rotate(-90);
    if (playerList.size > 1) p2.rotate(90);
    if (playerList.size > 2) p3.rotate(-90);
    if (playerList.size > 3) p4.rotate(90);

    stouchAreaP1.setRotation(-90);
    stouchAreaP2.setRotation(90);
    stouchAreaP1.setRotation(-90);
    stouchAreaP2.setRotation(90);

    gameBatch = new SpriteBatch();
    gameBatch.getProjectionMatrix().set(cam.combined);

    // init player positions
    //		Array<Vector2> positons = generatePositions(numPlayers + 1);

    int currentPos = 0;

    for (int i = 0; i < playerList.size; ++i) {
      Vector2 temp1 = new Vector2(POSITIONS.get(currentPos).x, POSITIONS.get(currentPos).y);
      Vector2 temp2 = new Vector2(POSITIONS.get(currentPos).x, POSITIONS.get(currentPos).y);
      Vector2 facing = new Vector2(-temp1.sub(CENTER).y, temp2.sub(CENTER).x).nor();
      playerProduction = new PlayerProduction(playerList.get(i), POSITIONS.get(currentPos), facing);
      GameInstance.getInstance().factorys.add(playerProduction);
      ++currentPos;
    }

    for (int i = 0; i < cpuList.size; ++i) {
      Vector2 temp1 = new Vector2(POSITIONS.get(currentPos).x, POSITIONS.get(currentPos).y);
      Vector2 temp2 = new Vector2(POSITIONS.get(currentPos).x, POSITIONS.get(currentPos).y);
      Vector2 facing = new Vector2(-temp1.sub(CENTER).y, temp2.sub(CENTER).x).nor();
      if (GameInstance.getInstance().difficultyConfig == 0) {
        enemyProduction =
            new EasyEnemyProduction(cpuList.get(i), POSITIONS.get(currentPos), facing);
      } else if (GameInstance.getInstance().difficultyConfig == 1) {
        enemyProduction =
            new MediumEnemyProduction(cpuList.get(i), POSITIONS.get(currentPos), facing);
      } else {
        enemyProduction =
            new HardEnemyProduction(cpuList.get(i), POSITIONS.get(currentPos), facing);
      }
      GameInstance.getInstance().factorys.add(enemyProduction);
      ++currentPos;
    }

    //		// add cpu if only one player plays
    //		if (idP2 == -1) {
    //			temp1 = new Vector2(POSITIONS.get(1).x, POSITIONS.get(1).y);
    //			temp2 = new Vector2(POSITIONS.get(1).x, POSITIONS.get(1).y);
    //			facing = new Vector2(-temp1.sub(CENTER).y, temp2.sub(CENTER).x).nor();
    //			if(GameInstance.getInstance().difficultyConfig == 0) {
    //				enemyProduction = new EasyEnemyProduction((idP1+1)%4, POSITIONS.get(1), facing);
    //			} else if(GameInstance.getInstance().difficultyConfig == 1) {
    //				enemyProduction = new MediumEnemyProduction((idP1+1)%4, POSITIONS.get(1), facing);
    //			} else {
    //				enemyProduction = new HardEnemyProduction((idP1+1)%4, POSITIONS.get(1), facing);
    //			}
    //			GameInstance.getInstance().factorys.add(enemyProduction);
    //			touchedP2 = true;
    //			touchFadeP2 = 0;
    //
    //			temp1 = new Vector2(POSITIONS.get(2).x, POSITIONS.get(2).y);
    //			temp2 = new Vector2(POSITIONS.get(2).x, POSITIONS.get(2).y);
    //			facing = new Vector2(-temp1.sub(CENTER).y, temp2.sub(CENTER).x).nor();
    //			if(GameInstance.getInstance().difficultyConfig == 0) {
    //				enemyProduction = new EasyEnemyProduction((idP1+2)%4, POSITIONS.get(2), facing);
    //			} else if(GameInstance.getInstance().difficultyConfig == 1) {
    //				enemyProduction = new MediumEnemyProduction((idP1+2)%4, POSITIONS.get(2), facing);
    //			} else {
    //				enemyProduction = new HardEnemyProduction((idP1+2)%4, POSITIONS.get(2), facing);
    //			}
    //			GameInstance.getInstance().factorys.add(enemyProduction);
    //			touchedP2 = true;
    //			touchFadeP2 = 0;
    //
    //			temp1 = new Vector2(POSITIONS.get(3).x, POSITIONS.get(3).y);
    //			temp2 = new Vector2(POSITIONS.get(3).x, POSITIONS.get(3).y);
    //			facing = new Vector2(-temp1.sub(CENTER).y, temp2.sub(CENTER).x).nor();
    //			if(GameInstance.getInstance().difficultyConfig == 0) {
    //				enemyProduction = new EasyEnemyProduction((idP1+3)%4, POSITIONS.get(3), facing);
    //			} else if(GameInstance.getInstance().difficultyConfig == 1) {
    //				enemyProduction = new MediumEnemyProduction((idP1+3)%4, POSITIONS.get(3), facing);
    //			} else {
    //				enemyProduction = new HardEnemyProduction((idP1+3)%4, POSITIONS.get(3), facing);
    //			}
    //			GameInstance.getInstance().factorys.add(enemyProduction);
    //			touchedP2 = true;
    //			touchFadeP2 = 0;
    //		} else {
    //			temp1 = new Vector2(POSITIONS.get(1).x, POSITIONS.get(1).y);
    //			temp2 = new Vector2(POSITIONS.get(1).x, POSITIONS.get(1).y);
    //			facing = new Vector2(-temp1.sub(CENTER).y, temp2.sub(CENTER).x).nor();
    //			playerProduction = new PlayerProduction(idP2, POSITIONS.get(1), facing);
    //			GameInstance.getInstance().factorys.add(playerProduction);
    //		}

    Gdx.gl.glDisable(GL20.GL_CULL_FACE);
    Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);
  }
Beispiel #14
0
  /** Called by game loop, updates then blits or renders current frame of animation to the screen */
  @Override
  public void draw() {
    if (_flicker) return;

    if (dirty) // rarely
    calcFrame();

    if (_newTextureData != null) // even more rarely
    {
      _pixels.getTexture().load(_newTextureData);
      _newTextureData = null;
    }

    FlxCamera camera = FlxG._activeCamera;

    if (cameras == null) cameras = FlxG.cameras;

    if (!cameras.contains(camera, true)) return;

    if (!onScreen(camera)) return;
    _point.x = x - (camera.scroll.x * scrollFactor.x) - offset.x;
    _point.y = y - (camera.scroll.y * scrollFactor.y) - offset.y;
    _point.x += (_point.x > 0) ? 0.0000001f : -0.0000001f;
    _point.y += (_point.y > 0) ? 0.0000001f : -0.0000001f;

    // tinting
    int tintColor = FlxU.multiplyColors(_color, camera.getColor());
    framePixels.setColor(
        ((tintColor >> 16) & 0xFF) * 0.00392f,
        ((tintColor >> 8) & 0xFF) * 0.00392f,
        (tintColor & 0xFF) * 0.00392f,
        _alpha);

    // rotate
    if (_pixels.rotate) framePixels.rotate90(false);

    if (isSimpleRender()) { // Simple render
      framePixels.setPosition(_point.x, _point.y);
      renderSprite();
    } else { // Advanced render
      framePixels.setOrigin(origin.x, origin.y);
      framePixels.setScale(scale.x, scale.y);
      if ((angle != 0) && (_bakedRotation <= 0)) framePixels.setRotation(angle);
      framePixels.setPosition(_point.x, _point.y);
      if (blend != null && currentBlend != blend) {
        currentBlend = blend;
        int[] blendFunc = BlendMode.getOpenGLBlendMode(blend);
        FlxG.batch.setBlendFunction(blendFunc[0], blendFunc[1]);
      } else if (FlxG.batchShader == null || ignoreBatchShader) {
        // OpenGL ES 2.0 shader render
        renderShader();
        // OpenGL ES 2.0 blend mode render
        renderBlend();
      }
      renderSprite();
    }

    // re-rotate
    if (_pixels.rotate) framePixels.rotate90(true);

    _VISIBLECOUNT++;
    if (FlxG.visualDebug && !ignoreDrawDebug) drawDebug(camera);
  }
Beispiel #15
0
  public Ringo(float maxHealth, float x, float y) {
    super(maxHealth, x, y);

    int chunkHeight = 160;
    int chunkWidth = 128;

    Texture sprite = Loader.texture(FOLDER.child("anm.png"));
    sprite.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest);

    Sprite fbs = new Sprite(Loader.texture(FOLDER.child("fbs.png")));
    fbs.setScale(2F);

    TextureRegion nameTag = new TextureRegion(Loader.texture(FOLDER.child("nametag.png")));

    Animation idle =
        ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 1, 2, 3, 4, 5);
    idle.setPlayMode(PlayMode.LOOP);

    Animation left =
        new MovementAnimation(
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 11, 12),
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 13, 14, 15),
            8f);
    Animation right =
        new MovementAnimation(
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 6, 7),
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 8, 9, 10),
            8f);

    Animation special =
        new StartupLoopAnimation(
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 16, 17),
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 18, 19, 20),
            8f);
    special.setPlayMode(PlayMode.NORMAL);

    Music bgm = new J2hMusic(Gdx.audio.newMusic(FOLDER.child("bgm.mp3")));
    bgm.setLooping(true);

    setAuraColor(AllStarUtil.from255RGB(104, 19, 52).mul(6f));
    setBgAuraColor(AllStarUtil.from255RGB(40, 40, 40));

    set(nameTag, bgm);
    set(fbs, idle, left, right, special);

    backgroundSpawner =
        new Setter<BackgroundBossAura>() {
          @Override
          public void set(final BackgroundBossAura t) {
            final Background bg =
                new Background(Loader.texture(FOLDER.child("bg.png"))) {
                  @Override
                  public void onDraw() {
                    setBlendFunc(GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_COLOR);

                    super.onDraw();
                  };
                };

            bg.setFrameBuffer(t.getBackgroundBuffer());
            bg.setVelV(0.05d);
            bg.setVelU(-0.05d);
            bg.getSprite().setScale(0.75f);
            bg.getSprite().setAlpha(1f);
            bg.setZIndex(bg.getZIndex() - 20);

            game.spawn(bg);

            float speed = 10;

            // Layer 1
            final Background bge =
                new Background(Loader.texture(FOLDER.child("bge.png"))) {
                  @Override
                  public void onDraw() {
                    setBlendFunc(GL20.GL_DST_ALPHA, GL20.GL_ONE_MINUS_SRC_COLOR);

                    super.onDraw();
                  };
                };

            bge.setFrameBuffer(t.getBackgroundBuffer());
            bge.getSprite().setScale(1.5f);
            bge.setRotationDegs(speed);
            bge.getSprite().setAlpha(1f);
            bge.setZIndex(bg.getZIndex() - 2);

            game.spawn(bge);

            // Layer 2
            {
              Background bgeTwo =
                  new Background(Loader.texture(FOLDER.child("bge.png"))) {
                    @Override
                    public void onDraw() {
                      setBlendFunc(GL20.GL_SRC_COLOR, GL20.GL_ZERO);

                      super.onDraw();
                    };
                  };

              bgeTwo.getSprite().setScale(1.5f);
              bgeTwo.setFrameBuffer(t.getBackgroundBuffer());
              bgeTwo.setRotationDegs(-speed);
              bgeTwo.getSprite().setAlpha(1f);
              bgeTwo.setZIndex(bg.getZIndex() - 4);
              game.spawn(bgeTwo);
            }

            Game.getGame()
                .spawn(
                    new ClearBackground(bg.getZIndex() - 10) {
                      {
                        setFrameBuffer(t.getBackgroundBuffer());
                      }
                    });
          }
        };
  }
Beispiel #16
0
  // コンストラクタ
  public MainMenu(Game game) {
    this.scrollNinja = game;

    // カメラ作成
    camera =
        new OrthographicCamera(
            ScrollNinja.window.x * ScrollNinja.scale, ScrollNinja.window.y * ScrollNinja.scale);
    // スプライトバッチ作成
    spriteBatch = new SpriteBatch();

    nextStageNum = 0;
    // TODO 読み込んだセーブファイルからコンティニューする時のステージを設定
    // stage =
    // StageManager.StageTrance(stage);
    // nextStageNum = StageManager.GetNowStage();
    BackgroundManager.CreateBackground(nextStageNum, false);

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

    spritePositionX = -105;
    // TODO 位置は後で要調整
    // 選択肢コンテニュー
    TextureRegion region = new TextureRegion(texture, 0, 0, 256, 35);
    modeContinue = new Sprite(region);
    modeContinue.setPosition(spritePositionX, 0);
    modeContinue.setScale(ScrollNinja.scale);

    // 選択肢ニューゲーム
    region = new TextureRegion(texture, 0, 40, 256, 35);
    modeNewGame = new Sprite(region);
    modeNewGame.setPosition(spritePositionX, -4);
    modeNewGame.setScale(ScrollNinja.scale);

    // 選択肢ロードゲーム
    region = new TextureRegion(texture, 0, 85, 256, 35);
    modeLoadGame = new Sprite(region);
    modeLoadGame.setPosition(spritePositionX, -8);
    modeLoadGame.setScale(ScrollNinja.scale);

    // 選択肢ネットワーク
    region = new TextureRegion(texture, 0, 128, 256, 35);
    modeNetwork = new Sprite(region);
    modeNetwork.setPosition(spritePositionX, -12);
    modeNetwork.setScale(ScrollNinja.scale);

    // 選択肢オプション
    region = new TextureRegion(texture, 0, 176, 256, 35);
    modeOption = new Sprite(region);
    modeOption.setPosition(spritePositionX, -16);
    modeOption.setScale(ScrollNinja.scale);

    // 選択肢終了
    region = new TextureRegion(texture, 0, 218, 256, 35);
    modeExit = new Sprite(region);
    modeExit.setPosition(spritePositionX, -20);
    modeExit.setScale(ScrollNinja.scale);

    // 初期化
    scrollFlag = false;
  }