Android Open Source - linevslinerpg Smoke






From Project

Back to project page linevslinerpg.

License

The source code is released under:

Apache License

If you think the Android project linevslinerpg 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.jmpmain.lvslrpg.particles;
/*from   w w  w  .j  av a  2  s. c  o m*/
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;

public class Smoke extends Particle {

  public long createTime;
  public long liveTime;
  private Rect particle;
  
  private Paint paint;
  
  int spawnX;
  int spawnY;
  
  float xVelocity;
  
  float xPosition;
  
  public Smoke(int x, int y, long time){
    destroy = false;
    spawnX = x;
    xPosition = spawnX;
    spawnY = y;
    
    particle = new Rect(spawnX, spawnY, spawnX+5, spawnY+5);
    paint = new Paint();
    paint.setARGB(64, 0, 0, 0);
    liveTime = 0;
    createTime = 0;
  }
  
  @Override
  public void update(long time) {
    
    long delta = time - createTime;
    if(delta >= liveTime){
      particle = new Rect(spawnX, spawnY, spawnX+3, spawnY+3);
      xPosition = spawnX;
      createTime = time;
      xVelocity = (float) ((Math.random() - 0.5f));
      liveTime = (long) (1000 + Math.random()*500);
    }
    
    particle.top -= 1;
    particle.bottom -= 1;
    
    
    xPosition += xVelocity;
    particle.left = (int) xPosition;
    particle.right = (int) (xPosition + 5);
  }

  @Override
  public void draw(Canvas canvas) {
    canvas.drawRect(particle, paint);
  }

}




Java Source Code List

com.jmpmain.lvslrpg.AudioPlayer.java
com.jmpmain.lvslrpg.GameSurface.java
com.jmpmain.lvslrpg.GameThread.java
com.jmpmain.lvslrpg.LineCanvas.java
com.jmpmain.lvslrpg.MainActivity.java
com.jmpmain.lvslrpg.MapGenerator.java
com.jmpmain.lvslrpg.Map.java
com.jmpmain.lvslrpg.OptionsAdapter.java
com.jmpmain.lvslrpg.entities.AILineEntity.java
com.jmpmain.lvslrpg.entities.Entity.java
com.jmpmain.lvslrpg.entities.Item.java
com.jmpmain.lvslrpg.entities.LineEntity.java
com.jmpmain.lvslrpg.entities.PlayerLineEntity.java
com.jmpmain.lvslrpg.particles.Blood.java
com.jmpmain.lvslrpg.particles.Bomb.java
com.jmpmain.lvslrpg.particles.Energy.java
com.jmpmain.lvslrpg.particles.Heal.java
com.jmpmain.lvslrpg.particles.ItemParticle.java
com.jmpmain.lvslrpg.particles.Particle.java
com.jmpmain.lvslrpg.particles.Smoke.java