Beispiel #1
0
	public final void AddPosition(Vector2f nextDestPosition) {
		Vector2f vector;
		nextDestPosition.y = MathUtils.clamp(nextDestPosition.y, 0f,
				LSystem.screenRect.height - 1f);
		nextDestPosition.x = MathUtils.clamp(nextDestPosition.x, 0f,
				LSystem.screenRect.width - 1f);

		vector = nextDestPosition;
		Vector2f position = this.position.cpy();
		if (this.destination.size() != 0) {
			position = this.destination.get(this.destination.size() - 1).cpy();
		}
		float num = MathUtils.atan2((nextDestPosition.y - position.y),
				(nextDestPosition.x - position.x));

		if (Vector2f.dst(position, nextDestPosition) > Tile.size) {
			vector = position.add(new Vector2f(MathUtils.cos(num) * Tile.size,
					MathUtils.sin(num) * Tile.size));
		}

		Vector2f item = new Vector2f(Tile.getBounds(vector).getCenterX(), Tile
				.getBounds(vector).getCenterY());

		if (!this.destination.contains(item)) {
			this.destination.add(item);
			AddPosition(vector);
		}
		int index = this.destination.indexOf(item);
		this.destination.subList(index + 1,
				(this.destination.size() - index) - 1 + index + 1).clear();
	}
Beispiel #2
0
	public final void AimToPosition(Vector2f position) {
		if (position.y > super.getPosition().y) {
			position.y = super.getPosition().y - 15f;
		}
		super.setRotation(Trigonometry.getAngle(position.sub(super
				.getPosition())) + 1.570796f);
		if (super.getRotation() < -1.4137166941154069) {
			super.setRotation(-1.413717f);
		}
		if (super.getRotation() > 1.4137166941154069) {
			super.setRotation(1.413717f);
		}
	}
 public final void draw(GLEx g) {
   if (isOnLoadComplete()) {
     batch.begin();
     before(batch);
     for (TileMap tile : tiles) {
       tile.draw(g, batch, offset.x(), offset.y());
     }
     for (SpriteBatchObject o : objects) {
       objX = o.getX() + offset.x;
       objY = o.getY() + offset.y;
       if (contains(objX, objY)) {
         o.draw(batch, offset.x, offset.y);
       }
     }
     if (content.isVisible()) {
       content.drawNode(batch);
     }
     after(batch);
     batch.end();
   }
 }