当前位置: 首页>>代码示例>>Java>>正文


Java MathUtils.randomBoolean方法代码示例

本文整理汇总了Java中com.badlogic.gdx.math.MathUtils.randomBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.randomBoolean方法的具体用法?Java MathUtils.randomBoolean怎么用?Java MathUtils.randomBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.math.MathUtils的用法示例。


在下文中一共展示了MathUtils.randomBoolean方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: part4

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public void part4() {
	if (flag4) {
		flag4 = false;
		existTime = 0;
		moveBasic.velocity.set(0, 0);
		moveBasic.acc.set(0, 0);
		Entity.postUpdate.add(() -> { GameHelper.clearEnemyBullets(); });
	}
	if (existTime > 60) {
		for (int i=0; i<2; i++)
		{
			final int c = MathUtils.random(3);
			final Entity proj = BaseProjectile.Create(transform.position.cpy(), BulletType.FormCircleS, color4s[c]);
			final ImageRenderer renderer = proj.GetComponent(ImageRenderer.class);
			proj.AddComponent(new EnemyJudgeCircle(5));
			proj.AddComponent(new LambdaComponent(() -> {
				renderer.image.setColor(1, 1, 1, alpha4s[c]);
			}, 5));
			proj.AddComponent(new MoveBasic(new Vector2(1, 0).rotate(MathUtils.random(360f)).scl(MathUtils.random(2f, 7f))));
		}
	}
	if (existTime % 20 == 0) {
		for (int i=0; i<4; i++)
			alpha4s[i] = MathUtils.randomBoolean() || alpha4s[i] < 0.4f ? 0.88f : 0.12f;
	}
}
 
开发者ID:cn-s3bit,项目名称:TH902,代码行数:27,代码来源:AIS1LLastBoss.java

示例2: spawnCloud

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
private Cloud spawnCloud() {
    Cloud cloud = new Cloud();
    cloud.dimension.set(dimension);
    // 随机选取纹理
    cloud.setRegion(regClouds.random());
    // 位置
    Vector2 pos = new Vector2();
    pos.x = length + 10; // 关卡结束的位置
    pos.y += 1.75; // 基础位置
    // 随机高度位置
    pos.y += MathUtils.random(0.0f, 0.2f)
            * (MathUtils.randomBoolean() ? 1 : -1);
    cloud.position.set(pos);
    return cloud;
}
 
开发者ID:davyjoneswang,项目名称:libgdx-learnlib,代码行数:16,代码来源:Clouds.java

示例3: part5

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public void part5() {
	if (flag5) {
		flag5 = false;
		existTime = 0;
		moveBasic.velocity.set(0, 0);
		moveBasic.acc.set(0, 0);
		Entity.postUpdate.add(() -> { GameHelper.clearEnemyBullets(); });
		targetp5.set(transform.position.x, 400);
	}
	if (existTime <= 90) {
		GameHelper.snipeVct(transform.position, targetp5, 0, moveBasic.velocity);
		moveBasic.velocity.scl(1 / 45f);
	}
	else {
		if (existTime % 270 > 90) {
			for (int i=0; i<360; i+=90) {
				if (MathUtils.randomBoolean(0.3f)) continue;
				if (i == 0 || i == 180)
					deltap5.set(0, MathUtils.random(-15 * ((existTime % 270 - 90) / 9), 15 * ((existTime % 270 - 90) / 9)));
				else
					deltap5.set(MathUtils.random(-50 * ((existTime % 270 - 90) / 9), 50 * ((existTime % 270 - 90) / 9)), 0);
				final Entity proj = BaseProjectile.Create(transform.position.cpy().add(deltap5), BulletType.FormCircleM, BulletType.ColorBlueLight);
				proj.AddComponent(new EnemyJudgeCircle(12));
				proj.AddComponent(new MoveBasic(deltap5.set(6, 0).rotate(i)));
			}
		}
		else if (existTime % 270 == 0) {
			targetp5.set(MathUtils.random(20, 560), 400);
		}
		else {
			GameHelper.snipeVct(transform.position, targetp5, 0, moveBasic.velocity);
			moveBasic.velocity.scl(1 / 36f);
		}
	}
}
 
开发者ID:cn-s3bit,项目名称:TH902,代码行数:36,代码来源:AIS1LLastBoss.java

示例4: WorldGenerator

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public WorldGenerator(int gen_seed, int num_biomes, int map_width) {
    biome_list = new ArrayList<>();
    max_heights = new HashMap<>();
    biome_locations = new HashMap<>();

    /* separation of different biomes */
    Voronoi biomes = new Voronoi();
    biomes.setSeed(gen_seed);
    biomes.setFrequency(0.01);

    /* random variation sprinkled around the terrain */
    Perlin basefluct = new Perlin();
    basefluct.setSeed(gen_seed);
    basefluct.setFrequency(0.02f);

    /* generate the biomes of the world */
    for (int i = 0; i < num_biomes; i++) {
        biome_list.add(new Biome(i));
    }

    /* find which biome will be at each x-value of the world. */
    for (int i = 0; i < map_width; i++) {
        biome_locations.put(i, (int) (Math.abs(biomes.getValue(i, 0, 0)) * num_biomes));
    }

    /* add the base variation to the terrain */
    for (int i = 0; i < map_width; i++) {
        max_heights.put(i, 10 + (int) (Math.abs(basefluct.getValue(i, 0, 0)) * 7));
    }

    /* add hills */
    for (int i = 0; i < map_width; i++) {
        if (MathUtils.randomBoolean(biome_list.get(biome_locations.get(i)).getHilliness())) {
            buildHill(i, MathUtils.random(6, 10));
        }
    }
}
 
开发者ID:treeman1111,项目名称:Particles,代码行数:38,代码来源:WorldGenerator.java

示例5: killDudes

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
private void killDudes() {
    for (E e : allEntitiesWith(Wander.class)) {
        e.removeDolphinized();
        if (MathUtils.randomBoolean()) {
            e.died();
        }
    }
}
 
开发者ID:DaanVanYperen,项目名称:odb-little-fortune-planet,代码行数:9,代码来源:CardScriptSystem.java

示例6: randomizeAnger

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
private void randomizeAnger() {
    for (E e : allEntitiesWith(Wander.class)) {
        e.removeDolphinized();
        if (MathUtils.randomBoolean()) {
            e.removeAngry();
        } else {
            e.angry();
        }
    }
}
 
开发者ID:DaanVanYperen,项目名称:odb-little-fortune-planet,代码行数:11,代码来源:CardScriptSystem.java

示例7: createRing

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public Ring createRing(Ring ring) {
    Array<ColorGroup> colors = new Array<ColorGroup>();

    colors.add(new ColorGroup()
            .add(Color.rgba8888(223f / 255f, 233f / 255f, 180f / 255f, 1f))
            .add(Color.rgba8888(170f / 255f, 90f / 255f, 103f / 255f, 1f)));

    colors.add(new ColorGroup()
            .add(Color.rgba8888(191f / 255f, 231f / 255f, 231f / 255f, 1f))
            .add(Color.rgba8888(75f / 255f, 109f / 255f, 133f / 255f, 1f)));

    colors.add(new ColorGroup()
            .add(Color.rgba8888(169f / 255f, 194f / 255f, 175f / 255f, 1f))
            .add(Color.rgba8888(30f / 255f, 97f / 255f, 42f / 255f, 1f)));

    Ring innerRing = ring != null ? ring : previousRing;

    int objectCount = innerRing == null ? MathUtils.random(200, 300) : MathUtils.random(200, 350);
    float angularVelocity = 0;
    float zTilt = innerRing == null ? 30 : innerRing.getZTilt();
    float xTilt = innerRing == null ? -20 : innerRing.getXTilt();
    float minimumRadius = innerRing == null ? scene.getPlanet().getWidthAtY(0) + 25 : innerRing.getMaximumRadius() + 5;
    float maximumRadius = innerRing == null ? minimumRadius + MathUtils.random(20, 60) : minimumRadius + MathUtils.random(20, 50);
    ColorGroup colorGroup = colors.random();

    Array<Orbiter> ringObjects = new Array<>();
    for(int i = 0; i < objectCount; i++) {
        Orbiter.OrbiterBlueprint blueprint = new Orbiter.OrbiterBlueprint();
        blueprint.angularVelocity = angularVelocity;
        blueprint.zTilt = zTilt;
        blueprint.xTilt = xTilt;
        blueprint.angle = MathUtils.random(0, 360);
        blueprint.radius = MathUtils.random(minimumRadius, maximumRadius);

        Orbiter ringObject = null;
        if (MathUtils.randomBoolean(0.9f)) {
            ringObject = new Orbiter(createMoonSprite(MathUtils.random(4, 6)), blueprint, colorGroup.random());
        } else {
            ringObject = new Orbiter(createSquare(MathUtils.random(4, 5)), blueprint, colorGroup.random());
        }
        ringObjects.add(ringObject);
    }

    //scene.addSpaceObjects(ringObjects);

    Ring newRing = new Ring(ringObjects, colorGroup, minimumRadius, maximumRadius);
    scene.addRing(newRing);
    return newRing;
}
 
开发者ID:ZKasica,项目名称:Planet-Generator,代码行数:50,代码来源:ObjectGenerator.java

示例8: move

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
@Override
public void move(int initX, ParticleSystem particleSystem, VelocitySystem velocitySystem) {
    this.ticked = true;

    /* no need to try moving if every adjacent spot is occupied */
    if (adjacentsFull()) {
        return;
    }

    final int x_location = ((getX() - initX) / VCEL_W) + 1;
    final int y_location = (getY() / VCEL_W) + 1;

    /* move the particle according to the velocity system, so long as it can be affected by wind. */
    if (properties.getWindResistance() != 1) {
        particleSystem.move(
                this,
                (1 - properties.getWindResistance()) * velocitySystem.getXAt(x_location, y_location),
                (1 - properties.getWindResistance()) * velocitySystem.getYAt(x_location, y_location)
        );
    }

    /* the particle can only fall if it is affected by gravity. */
    if (properties.getGravity() != 0) {
        particleSystem.move(this, 0, -properties.getGravity());
    }

    /* other non-gravitational movements e.g. diffusion of gases, flow of liquids. */
    int move_idx = properties.getMove().getMoveChoice();

    if (move_idx != -1 && MathUtils.randomBoolean(properties.getMove().getProbability(move_idx))) {
        switch (move_idx) {
            case 0:
                particleSystem.move(this, -1, 1);
                return;
            case 1:
                particleSystem.move(this, 0, 1);
                return;
            case 2:
                particleSystem.move(this, 1, 1);
                return;
            case 3:
                particleSystem.move(this, -1, 0);
                return;
            case 4:
                particleSystem.move(this, 1, 0);
                return;
            case 5:
                particleSystem.move(this, -1, -1);
                return;
            case 6:
                particleSystem.move(this, 0, -1);
                return;
            case 7:
                particleSystem.move(this, 1, -1);
                return;
        }
    }
}
 
开发者ID:treeman1111,项目名称:Particles,代码行数:59,代码来源:Particle.java

示例9: update

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
@Override
    public void update(ParticleSystem ps) {
        this.ticked = false;

        if (properties.getLife().isFinite()) {
            System.out.println(life);
            life--;

            if (life < 0) {
                ps.removeParticle(getX(), getY());
            }
        }

        /* no need to try updating the particle if it can't go through any transformations. */
        if (properties.getTransformations() == null) {
            return;
        }

        final Transformation[] transformations = properties.getTransformations();

        /* iterate over each of the possible transformations that the particle can go through */
        for (int i = 0; i < transformations.length; i++) {
            final Transformation transformation = transformations[i];
            boolean canTransform = true;

            /* iterate over the required type and number of particle needed for this transformation. */
            for (int j = 0; j < transformation.getTypesNeeded().length; j++) {
                /* if one of the checks fails, we know that the transform can't occur, so we break */
                if (!containsN(transformation.getTypesNeeded()[j], transformation.getNumbersNeeded()[j])) {
                    canTransform = false;
                    break;
                }
            }

            /* if we can't use this transformation, we move to the next one. */
            if (!canTransform) {
                continue;
            }

            /* toss a biased coin to see if we can transform the particle. */
            if (MathUtils.randomBoolean(transformation.getProbability())) {
//                ps.addParticle(new Particle(transformation.getTypeProduced(), x, y));
                /* if the transformation occurred, see if we can remove any adjacent particles. */
                // TODO
            }

            /* only one transformation can be applied. return after one has been applied. */
            return;
        }
    }
 
开发者ID:treeman1111,项目名称:Particles,代码行数:51,代码来源:Particle.java


注:本文中的com.badlogic.gdx.math.MathUtils.randomBoolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。