Exemplo n.º 1
0
	public WalkingBiped(LTexture t2DHead, LTexture t2DTorso,
			LTexture t2DUpperArm, LTexture t2DLowerArm, LTexture t2DUpperLeg,
			LTexture t2DLowerLeg, Vector2f positionGround, int day) {
		this.t2DHead = t2DHead;
		this.t2DTorso = t2DTorso;
		this.t2DLowerArm = t2DLowerArm;
		this.t2DLowerLeg = t2DLowerLeg;
		this.t2DUpperArm = t2DUpperArm;
		this.t2DUpperLeg = t2DUpperLeg;
		this.positionGround = positionGround.cpy();
		this.cycleLength = (int) (((MathUtils.random() * 40f) + 40f) / ((1f + (((float) day) / 22f))));
		this.speed = 60f / ((float) this.cycleLength);
		this.angleBody = 0f;
		this.isDead = false;
		this.iCycle = 0;
		this.angleUppLegL = (((this.angleUppLegMax - this.angleUppLegMin) / 2f) * ((float) Math
				.sin(((((float) this.iCycle) / ((float) this.cycleLength)) * 2f) * 3.1415926535897931)))
				+ ((this.angleUppLegMax + this.angleUppLegMin) / 2f);
		this.angleUppLegR = (((this.angleUppLegMax - this.angleUppLegMin) / 2f) * ((float) Math
				.sin((((((float) this.iCycle) / ((float) this.cycleLength)) * 2f) * 3.1415926535897931) + 3.1415926535897931)))
				+ ((this.angleUppLegMax + this.angleUppLegMin) / 2f);
		this.angleLowLegL = (((this.angleLowLegMax - this.angleLowLegMin) / 2f) * ((float) Math
				.sin((((((float) this.iCycle) / ((float) this.cycleLength)) * 2f) * 3.1415926535897931)
						+ (6.2831853071795862 * this.phaseDelay))))
				+ ((this.angleLowLegMax + this.angleLowLegMin) / 2f);
		this.angleLowLegR = (((this.angleLowLegMax - this.angleLowLegMin) / 2f) * ((float) Math
				.sin(((((((float) this.iCycle) / ((float) this.cycleLength)) * 2f) * 3.1415926535897931) + 3.1415926535897931)
						+ (6.2831853071795862 * this.phaseDelay))))
				+ ((this.angleLowLegMax + this.angleLowLegMin) / 2f);
		this.position = positionGround.cpy();
		float num = (((float) (Math.cos((double) this.angleUppLegL) + Math
				.cos((double) this.angleLowLegL))) > ((float) (Math
				.cos((double) this.angleUppLegR) + Math
				.cos((double) this.angleLowLegR)))) ? ((float) (t2DUpperLeg.getHeight() * (Math
				.cos((double) this.angleUppLegL) + Math
				.cos((double) this.angleLowLegL))))
				: ((float) (t2DUpperLeg.getHeight() * (Math
						.cos((double) this.angleUppLegR) + Math
						.cos((double) this.angleLowLegR))));
		this.position.y = positionGround.y - num;
		this.angleUppArmL = (((this.angleUppArmMax - this.angleUppArmMin) / 2f) * ((float) Math
				.sin(((((float) this.iCycle) / ((float) this.cycleLength)) * 2f) * 3.1415926535897931)))
				+ ((this.angleUppArmMax + this.angleUppArmMin) / 2f);
		this.angleUppArmR = (((this.angleUppArmMax - this.angleUppArmMin) / 2f) * ((float) Math
				.sin((((((float) this.iCycle) / ((float) this.cycleLength)) * 2f) * 3.1415926535897931) + 3.1415926535897931)))
				+ ((this.angleUppArmMax + this.angleUppArmMin) / 2f);
		this.angleLowArmL = (((this.angleLowArmMax - this.angleLowArmMin) / 2f) * ((float) Math
				.sin((((((float) this.iCycle) / ((float) this.cycleLength)) * 2f) * 3.1415926535897931)
						+ (6.2831853071795862 * this.phaseDelay))))
				+ ((this.angleLowArmMax + this.angleLowArmMin) / 2f);
		this.angleLowArmR = (((this.angleLowArmMax - this.angleLowArmMin) / 2f) * ((float) Math
				.sin(((((((float) this.iCycle) / ((float) this.cycleLength)) * 2f) * 3.1415926535897931) + 3.1415926535897931)
						+ (6.2831853071795862 * this.phaseDelay))))
				+ ((this.angleLowArmMax + this.angleLowArmMin) / 2f);
		this.head = new BodyPart(t2DHead, this.position
				.sub(0f,
						(float) (t2DTorso.getHeight() + (t2DHead.getHeight() / 2))));
		this.torso = new BodyPart(t2DTorso, this.position);
		this.upperArmL = new BodyPart(t2DUpperArm, this.position
				.sub(0f, ((float) t2DTorso.getHeight()) / 1.2f));
		this.upperArmR = new BodyPart(t2DUpperArm, this.position
				.sub(0f, ((float) t2DTorso.getHeight()) / 1.2f));
		this.lowerArmL = new BodyPart(
				t2DLowerArm,
				(this.position.sub(0f,
						((float) t2DTorso.getHeight()) / 1.2f))
						.add(
								t2DUpperArm.getHeight()
										* ((float) Math
												.sin((double) this.angleUppArmL)),
								t2DUpperArm.getHeight()
										* ((float) Math
												.cos((double) this.angleUppArmL))));
		this.lowerArmR = new BodyPart(
				t2DLowerArm,
				(this.position.sub(0f,
						((float) t2DTorso.getHeight()) / 1.2f))
						.add(
								t2DUpperArm.getHeight()
										* ((float) Math
												.sin((double) this.angleUppArmR)),
								t2DUpperArm.getHeight()
										* ((float) Math
												.cos((double) this.angleUppArmR))));
		this.upperLegL = new BodyPart(t2DUpperLeg, this.position);
		this.upperLegR = new BodyPart(t2DUpperLeg, this.position);
		this.lowerLegL = new BodyPart(
				t2DLowerLeg,
				this.position
						.add(
								t2DUpperLeg.getHeight()
										* ((float) Math
												.sin((double) this.angleUppLegL)),
								(t2DUpperLeg.getHeight() * 0.8f)
										* ((float) Math
												.cos((double) this.angleUppLegL))));
		this.lowerLegR = new BodyPart(
				t2DLowerLeg,
				this.position
						.add(
								t2DUpperLeg.getHeight()
										* ((float) Math
												.sin((double) this.angleUppLegR)),
								(t2DUpperLeg.getHeight() * 0.8f)
										* ((float) Math
												.cos((double) this.angleUppLegR))));
		this.torso.origin = new Vector2f((float) (t2DTorso.getWidth() / 2),
				(float) t2DTorso.getHeight());
		this.upperArmL.origin = new Vector2f((float) (t2DUpperArm.getWidth() / 2),
				0f);
		this.upperArmR.origin = new Vector2f((float) (t2DUpperArm.getWidth() / 2),
				0f);
		this.lowerArmL.origin = new Vector2f((float) (t2DLowerArm.getWidth() / 2),
				4f);
		this.lowerArmR.origin = new Vector2f((float) (t2DLowerArm.getWidth() / 2),
				4f);
		this.upperLegL.origin = new Vector2f((float) (t2DUpperLeg.getWidth() / 2),
				6f);
		this.upperLegR.origin = new Vector2f((float) (t2DUpperLeg.getWidth() / 2),
				6f);
		this.lowerLegL.origin = new Vector2f((float) t2DUpperLeg.getWidth(), 6f);
		this.lowerLegR.origin = new Vector2f((float) t2DUpperLeg.getWidth(), 6f);
		this.bodyPartList = new java.util.ArrayList<BodyPart>();
		this.bodyPartList.add(this.lowerLegL);
		this.bodyPartList.add(this.lowerLegR);
		this.bodyPartList.add(this.upperLegL);
		this.bodyPartList.add(this.upperLegR);
		this.bodyPartList.add(this.torso);
		this.bodyPartList.add(this.head);
		this.bodyPartList.add(this.lowerArmL);
		this.bodyPartList.add(this.lowerArmR);
		this.bodyPartList.add(this.upperArmL);
		this.bodyPartList.add(this.upperArmR);
	}