package com.cdm.view.enemy;

import java.util.List;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector3;
import com.cdm.view.IRenderer;
import com.cdm.view.Position;

public class ShakingLines {

	private static final double FACTOR = 0.1f;
	private static final float SPEED = 3.1415f*4;
	private float shakeTime = -1;
	private Position tmp = new Position(0, 0, Position.LEVEL_REF);

	public void shake() {
		shakeTime = 1.4f;
	}

	public void move(float t) {
		shakeTime -= t;
	}

	public void draw(IRenderer renderer, Position position,
			List<Vector3> lines, float angle, Color outercolor, float size) {
		if (shakeTime > 0) {
			tmp.set(position);

			tmp.x -= Math.sin(shakeTime*SPEED) * shakeTime * FACTOR;
			tmp.y -= Math.sin(shakeTime*SPEED) * shakeTime * FACTOR;
			renderer.drawLines(tmp, lines, angle, outercolor, size);
			tmp.set(position);

			tmp.x += Math.sin(shakeTime*SPEED) * shakeTime * FACTOR;
			tmp.y += Math.sin(shakeTime*SPEED) * shakeTime * FACTOR;
			renderer.drawLines(tmp, lines, angle, outercolor, size);
		} else {
			renderer.drawLines(position, lines, angle, outercolor, size);
		}
	}
}

@@ -302,17 +302,19 @@
  3.1415f
-*
+ * 
 4;%0A%09priv
@@ -402,16 +402,43 @@
 EL_REF);
+%0A%09private float shakeAngle;
 %0A%0A%09publi
@@ -470,17 +470,65 @@
 ime = 1.
-4
+1f;%0A%09%09shakeAngle = (float) Math.random() * 3.1415
 f;%0A%09%7D%0A%0A%09
@@ -756,16 +756,55 @@
 %0A%09%09%09
-tmp.
+float d
 x 
--
 =
+ (float) (Math.sin(shakeAngle)%0A%09%09%09%09%09*
  Mat
@@ -810,33 +810,35 @@
 th.sin(shakeTime
-*
+ * 
 SPEED) * shakeTi
@@ -852,21 +852,61 @@
 CTOR
+)
 ;%0A%09%09%09
-tmp.
+float d
 y 
--
 =
+ (float) (Math.cos(shakeAngle)%0A%09%09%09%09%09*
  Mat
@@ -912,33 +912,35 @@
 th.sin(shakeTime
-*
+ * 
 SPEED) * shakeTi
@@ -954,211 +954,96 @@
 CTOR
+)
 ;%0A%09%09%09
-renderer.drawLines(tmp, lines, angle, outercolor, size);%0A%09%09%09tmp.set(position);%0A%0A%09%09%09tmp.x += Math.sin(shakeTime*SPEED) * shakeTime * FACTOR;%0A%09%09%09tmp.y += Math.sin(shakeTime*SPEED) * shakeTime * FACTOR
+tmp.x -= dx;%0A%09%09%09tmp.y -= dy;%0A%09%09%09tmp.set(position);%0A%0A%09%09%09tmp.x += dx;%0A%09%09%09tmp.y += dy
 ;%0A%09%09

improve shaking