Android Open Source - Coloring-book Speedd Module And Range Initializer






From Project

Back to project page Coloring-book.

License

The source code is released under:

Apache License

If you think the Android project Coloring-book listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.plattysoft.leonids.initializers;
/*from   w ww .  j a v a 2 s. c  om*/
import java.util.Random;

import com.plattysoft.leonids.Particle;

public class SpeeddModuleAndRangeInitializer implements ParticleInitializer {

  private float mSpeedMin;
  private float mSpeedMax;
  private int mMinAngle;
  private int mMaxAngle;

  public SpeeddModuleAndRangeInitializer(float speedMin, float speedMax, int minAngle, int maxAngle) {
    mSpeedMin = speedMin;
    mSpeedMax = speedMax;
    mMinAngle = minAngle;
    mMaxAngle = maxAngle;
    // Make sure the angles are in the [0-360) range
    while (mMinAngle < 0) {
      mMinAngle+=360;
    }
    while (mMaxAngle < 0) {
      mMaxAngle+=360;
    }
    // Also make sure that mMinAngle is the smaller
    if (mMinAngle > mMaxAngle) {
      int tmp = mMinAngle;
      mMinAngle = mMaxAngle;
      mMaxAngle = tmp;
    }
  }

  @Override
  public void initParticle(Particle p, Random r) {
    float speed = r.nextFloat()*(mSpeedMax-mSpeedMin) + mSpeedMin;
    int angle;
    if (mMaxAngle == mMinAngle) {
      angle = mMinAngle;
    }
    else {
      angle = r.nextInt(mMaxAngle - mMinAngle) + mMinAngle;
    }
    float angleInRads = (float) (angle*Math.PI/180f);
    p.mSpeedX = (float) (speed * Math.cos(angleInRads));
    p.mSpeedY = (float) (speed * Math.sin(angleInRads));
  }

}




Java Source Code List

com.kidsgames.gamebase.DrawerActivity.java
com.kidsgames.gamebase.DrawingView.java
com.kidsgames.menu.DrawerSliderActivity.java
com.kidsgames.menu.FixedSpeedScroller.java
com.kidsgames.menu.FixedSpeedViewPager.java
com.kidsgames.menu.MainMenu.java
com.kidsgames.menu.SlideAdapter.java
com.kidsgames.utils.ResourceId.java
com.plattysoft.leonids.AnimatedParticle.java
com.plattysoft.leonids.ParticleField.java
com.plattysoft.leonids.ParticleSystem.java
com.plattysoft.leonids.Particle.java
com.plattysoft.leonids.initializers.AccelerationInitializer.java
com.plattysoft.leonids.initializers.ParticleInitializer.java
com.plattysoft.leonids.initializers.RotationInitiazer.java
com.plattysoft.leonids.initializers.RotationSpeedInitializer.java
com.plattysoft.leonids.initializers.ScaleInitializer.java
com.plattysoft.leonids.initializers.SpeeddByComponentsInitializer.java
com.plattysoft.leonids.initializers.SpeeddModuleAndRangeInitializer.java
com.plattysoft.leonids.modifiers.AccelerationModifier.java
com.plattysoft.leonids.modifiers.AlphaModifier.java
com.plattysoft.leonids.modifiers.ParticleModifier.java
com.plattysoft.leonids.modifiers.ScaleModifier.java