Example #1
0
	public Animation(LTexture texture, float frameTime, boolean isLooping) {
		this.texture = texture;
		this.frameTime = frameTime;
		this.isLooping = isLooping;
		this.frameCount = texture.getWidth() / texture.getHeight();
		this.originFactor = new Vector2f(0.5f);
	}
  public static AnimationHelper makeObject(
      String fileName, int tileWidth, int tileHeight, LColor col) {
    String key = fileName.trim().toLowerCase();
    AnimationHelper animation = animations.get(key);
    if (animation == null) {
      LTexture texture = TextureUtils.filterColor(fileName, col);

      int wlength = texture.getWidth() / tileWidth;
      int hlength = texture.getHeight() / tileHeight;

      LTexture[][] images = TextureUtils.getSplit2Textures(texture, tileWidth, tileHeight);

      LTexture[][] result = new LTexture[hlength][wlength];
      for (int y = 0; y < wlength; y++) {
        for (int x = 0; x < hlength; x++) {
          result[x][y] = images[y][x];
        }
      }

      images = null;

      animations.put(key, animation = makeObject(result[0], result[1], result[3], result[2]));
    }
    return animation;
  }
Example #3
0
 public void setPauseIconAnimation(Animation animation) {
   this.animation = animation;
   if (animation != null) {
     LTexture image = animation.getSpriteImage(0);
     if (image != null) {
       this.dw = image.getWidth();
       this.dh = image.getHeight();
       this.updateIcon();
     }
   }
 }
Example #4
0
 public synchronized void draw(GLEx g) {
   if (isExist()) {
     int i = index;
     if (max <= i) {
       i = max - 1;
     }
     SRPGMessage mes = getMessage(i);
     if (listener != null) {
       listener.drawBackground(i, g);
     }
     if (character != null) {
       g.drawTexture(character, chara_x, chara_y);
     }
     LFont font = g.getFont();
     if (face != null) {
       int w = face.getWidth();
       int h = face.getHeight();
       int x = mes.getX();
       int y = mes.getY() - h;
       g.setColor(LColor.black);
       g.fillRect(x, y, w, h);
       g.drawTexture(face, x, y);
     }
     g.setFont(mes.getFont());
     if (background == null) {
       LGradation.getInstance(LColor.white, LColor.black, mes.getWidth(), mes.getHeight())
           .drawHeight(g, mes.getX(), mes.getY());
       g.setColor(LColor.black);
       g.drawRect(mes.getX(), mes.getY(), mes.getWidth(), mes.getHeight());
     } else {
       g.drawTexture(background, mes.getX(), mes.getY());
     }
     mes.update(delay);
     g.setColor(LColor.white);
     mes.draw(g);
     if (listener != null) {
       listener.drawForeground(i, g);
     }
     g.setFont(font);
     g.resetColor();
   }
 }
Example #5
0
 public LMessage(LTexture formImage, int x, int y, int width, int height) {
   super(x, y, width, height);
   this.animation = new Animation();
   if (formImage == null) {
     this.setBackground(new LTexture(width, height, true, Format.SPEED));
     this.setAlpha(0.3F);
   } else {
     this.setBackground(formImage);
     if (width == -1) {
       width = formImage.getWidth();
     }
     if (height == -1) {
       height = formImage.getHeight();
     }
   }
   this.print = new Print(getLocation(), messageFont, width, height);
   this.setTipIcon(LSystem.FRAMEWORK_IMG_NAME + "creese.png");
   this.totalDuration = 80;
   this.customRendering = true;
   this.setWait(false);
   this.setElastic(true);
   this.setLocked(true);
   this.setLayer(100);
 }
Example #6
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);
	}
Example #7
0
 public LMessage(LTexture formImage, int x, int y) {
   this(formImage, x, y, formImage.getWidth(), formImage.getHeight());
 }