コード例 #1
0
ファイル: Utilities.java プロジェクト: coders-circle/Flipped
  public static void createSnow(Scene scene, Entity entity, float width) {
    entity.add(new Transformation(width / 2, 0, 0));
    GLRenderer renderer = scene.getGame().getRenderer();
    Emitter e =
        new Emitter(
            renderer, 500, ((SimpleTexture) scene.getGame().textureManager.get("snow")).textureId);

    e.startColor = new float[] {0.7f, 0.7f, 0.9f, 1};
    e.endColor = new float[] {0.7f, 0.7f, 0.9f, 1};
    e.size = 10;
    e.var_size = 8;
    e.accel_x = 0;
    e.accel_y = 5;
    e.var_accel_y = 3;
    e.var_x = width;
    e.emissionRate = width / 7300 * 25;
    e.life = 20;
    e.dimWithSize = true;

    entity.add(e);
  }
コード例 #2
0
ファイル: Utilities.java プロジェクト: coders-circle/Flipped
  public static void createFire(Scene scene, World world, Entity fire, JSONObject components)
      throws JSONException {
    Game game = scene.getGame();
    fire.add(
        new Sprite(
            /*game.getRenderer().addTexture(new float[]{1, 1, 0, 1}, 10, 10)*/ game.textureManager
                .get("fire"),
            -1.6f));
    fire.get(Sprite.class).postDrawn = true;
    JSONObject transformation = components.getJSONObject("Transformation");
    fire.add(
        new Transformation(
            (float) transformation.getDouble("Translate-X"),
            (float) transformation.getDouble("Translate-Y"),
            (float) transformation.getDouble("Angle")));

    PolygonShape shape = new PolygonShape();
    shape.setAsBox(
        60 / 2 * PhysicsSystem.METERS_PER_PIXEL,
        20 / 2 * PhysicsSystem.METERS_PER_PIXEL,
        new Vector2(0, (20 / 2 + 2) * PhysicsSystem.METERS_PER_PIXEL),
        0);
    PhysicsBody b =
        new PhysicsBody(
            world, BodyDef.BodyType.StaticBody, fire, shape, new PhysicsBody.Properties(0, 0, 0));
    fire.add(b);

    /*PolygonShape fireShape = new PolygonShape();
    fireShape.setAsBox(24 * PhysicsSystem.METERS_PER_PIXEL, 24 * PhysicsSystem.METERS_PER_PIXEL);
    b.createSensor(fireShape);*/

    Entity emitter = new Entity();
    emitter.add(new Transformation(0, 0, -90));
    emitter.add(createFireEmitter(game.getRenderer(), 28, 70));
    scene.addEntity(emitter);

    Burner burner = new Burner(emitter);
    fire.add(burner);

    burner.source = true;
    burner.position = 0;
    burner.sourceWidth = 24 * PhysicsSystem.METERS_PER_PIXEL;
    burner.sourceHeight = 24 * PhysicsSystem.METERS_PER_PIXEL;

    // Sound sound = new Sound();
    // fire.add(sound);
    // TODO: Add sound source for fire
    // sound.addSource(scene.getGame().getActivity(), R.raw.firesound, Sound.FIRE|Sound.AMBIANCE);
  }
コード例 #3
0
ファイル: Utilities.java プロジェクト: coders-circle/Flipped
  public static void createStick(Scene scene, World world, Entity stick, JSONObject components)
      throws JSONException {
    Game game = scene.getGame();
    stick.add(
        new Sprite(
            /*game.getRenderer().addTexture(new float[]{1, 1, 0, 1}, 16, 3)*/ game.textureManager
                .get("stick"),
            -0.05f));
    stick.get(Sprite.class).postDrawn = true;
    JSONObject transformation = components.getJSONObject("Transformation");
    stick.add(
        new Transformation(
            (float) transformation.getDouble("Translate-X"),
            (float) transformation.getDouble("Translate-Y"),
            (float) transformation.getDouble("Angle")));

    PhysicsBody b =
        new PhysicsBody(
            world,
            BodyDef.BodyType.DynamicBody,
            stick,
            new PhysicsBody.Properties(0.2f, 0.2f, 0.1f));
    stick.add(b);

    /*Filter d = b.body.getFixtureList().get(0).getFilterData();
    d.groupIndex = ExplosionSystem.NON_EXPLOSIVE_GROUP;
    b.body.getFixtureList().get(0).setFilterData(d);*/

    PolygonShape fireShape = new PolygonShape();
    fireShape.setAsBox(
        4 * PhysicsSystem.METERS_PER_PIXEL,
        4 * PhysicsSystem.METERS_PER_PIXEL,
        new Vector2(10 * PhysicsSystem.METERS_PER_PIXEL, 0),
        0);
    b.createSensor(fireShape);

    Carriable c = new Carriable();
    c.position = new Vector2(156, 136);
    c.angle = -30;
    for (int i = 0; i < 8; ++i) {
      c.positions.add(new Vector2(1628 - 1500, 256));
      c.angles.add(0f);
    }
    c.positions.add(new Vector2(128, 5128 - 266));
    c.angles.add(10f);
    c.positions.add(new Vector2(128, 5128 - 266));
    c.angles.add(10f);
    c.positions.add(new Vector2(638 - 500, 488 - 266));
    c.angles.add(15f);
    c.positions.add(new Vector2(890 - 750, 474 - 266));
    c.angles.add(10f);
    c.positions.add(new Vector2(1126 - 1000, 456 - 266));
    c.angles.add(-7f);
    c.positions.add(new Vector2(1368 - 1250, 440 - 266));
    c.angles.add(-10f);
    c.positions.add(new Vector2(1368 - 1250, 440 - 266));
    c.angles.add(-20f);
    c.positions.add(new Vector2(1368 - 1250, 440 - 266));
    c.angles.add(-20f);

    c.position.x *= 24f / 143;
    c.position.y *= 48f / 274;
    c.position.x -= 12;
    c.position.y -= 24;

    float xFactor = 48f / 250;
    float yFactor = 48f / 266;

    for (int i = 0; i < 16; ++i) {
      c.positions.get(i).x *= xFactor;
      c.positions.get(i).y *= yFactor;
      c.positions.get(i).x -= 12;
      c.positions.get(i).y -= 24;
    }

    stick.add(c);

    Entity emitter = new Entity();
    emitter.add(new Transformation(0, 0, -90));
    emitter.add(createFireEmitter(game.getRenderer(), 16, 70));
    scene.addEntity(emitter);

    Burner burner = new Burner(emitter);
    stick.add(burner);

    burner.source = false;
    burner.fullLife = 6;
  }