Android Open Source - linevslinerpg Blood






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  om*/
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;

/**
 * A blood particle.
 */
public class Blood extends Particle {

  public long createTime;
  
  private Paint paint;
  private Rect particle;
  
  private float xVelocity;
  private float yVelocity;
  
  public Blood(int x, int y, long time){
    destroy = false;
    createTime = time;
    
    particle = new Rect(x, y, x+8, y+8);
    
    xVelocity = (float)(Math.random()-0.5)*7;
    yVelocity = (float)(Math.random()-0.5)*7;
    
    paint = new Paint();
    paint.setARGB(180, 255, 0, 0);
  }
  
  @Override
  public void update(long time) {
    if(time - createTime >= 1000){
      destroy = true;
      return;
    }
    
    paint.setAlpha(Math.max(0, (int)(180.0f*(1 - (float)(time - createTime)/1000.0f))));
    
    particle.top += yVelocity;
    particle.bottom += yVelocity;
    
    particle.left += xVelocity;
    particle.right += xVelocity;
    
  }

  @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