Advertisement
Guest User

Particle.java

a guest
Sep 8th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. package main.Entity.particle;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import main.Screen;
  7. import main.Sprite;
  8. import main.Entity.Entity;
  9.  
  10. public class Particle extends Entity {
  11.  
  12. public static Sprite sprite;
  13.  
  14. private int life;
  15. private int time = 0;
  16.  
  17. protected double xx, xa, yy, ya;
  18.  
  19. public Particle(int x, int y, int life) {
  20. this.x = x;
  21. this.y = y;
  22. this.xx = x;
  23. this.yy = y;
  24. this.life = life + (random.nextInt(50) - 25);
  25. sprite = Sprite.particle_normal;
  26.  
  27. this.xa = random.nextGaussian();
  28. this.ya = random.nextGaussian();
  29. }
  30.  
  31. public void update() {
  32. time++;
  33. if (time >= 7400) time = 0;
  34. if (time > life) remove();
  35. this.xx += xa;
  36. this.yy += ya;
  37. }
  38.  
  39. public void render(Screen screen) {
  40. screen.renderSprite((int) xx, (int) yy, sprite, true);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement