package com.plattysoft.leonids.initializers;

import java.util.Random;

import com.plattysoft.leonids.Particle;

public class AccelerationInitializer implements ParticleInitializer {

	private float mMinValue;
	private float mMaxValue;
	private int mMinAngle;
	private int mMaxAngle;

	public AccelerationInitializer(float minAcceleration, float maxAcceleration, int minAngle, int maxAngle) {
		mMinValue = minAcceleration;
		mMaxValue = maxAcceleration;
		mMinAngle = minAngle;
		mMaxAngle = maxAngle;
	}

	@Override
	public void initParticle(Particle p, Random r) {
		int randomParam = mMaxAngle - mMinAngle;
		float angle = r.nextInt(randomParam<=0?randomParam+1:randomParam) + mMinAngle;
		float angleInRads = (float) (angle*Math.PI/180f);
		float value = r.nextFloat()*(mMaxValue-mMinValue)+mMinValue;
		p.mAccelerationX = (float) (value * Math.cos(angleInRads));
		p.mAccelerationY = (float) (value * Math.sin(angleInRads));
	}

}

@@ -581,16 +581,25 @@
 Param = 
+Math.abs(
 mMaxAngl
@@ -603,32 +603,33 @@
 ngle - mMinAngle
+)
 ;%0A%09%09float angle 
@@ -655,12 +655,16 @@
 aram
-%3C=0?
+ == 0 ? 
 rand
@@ -676,9 +676,11 @@
 am+1
-:
+ : 
 rand
@@ -752,16 +752,17 @@
 I/180f);
+ 
 %0A%09%09float

Update AccelerationInitializer.java