Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package CastleOfDreams;
- import java.awt.AlphaComposite;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.util.Random;
- public class Particle {
- int a, mode, life;
- double x, y, dx, dy;
- int[][] Octarine = {
- {118, 28, 236},
- {148, 35, 190},
- {189, 62, 127},
- {224, 94, 54},
- {253, 133, 3},
- };
- int tempA, tempB;
- int redColor, greenColor, blueColor;
- float alpha;
- Color particleColor;
- Game game;
- Random r = new Random();
- Particle (double inX, double inY, int inMode, Game game){
- x = inX - 2;
- y = inY - 2;
- mode = inMode;
- dx = (double) (r.nextInt(10+1)-5);
- dy = (double) (r.nextInt(10+1)-5);
- life = r.nextInt(15)+1;
- if (mode == 1) {
- tempA = r.nextInt(5);
- redColor = Octarine[tempA][0];
- greenColor = Octarine[tempA][1];
- blueColor = Octarine[tempA][2];
- } else if (mode == 2) {
- redColor = 129;
- greenColor = 250;
- blueColor = 255;
- } else if (mode == 3) {
- redColor = 255;
- greenColor = 215;
- blueColor = 20;
- }
- }
- public void tick() {
- x += dx;
- y += dy;
- life -= 1;
- //alpha = (float) life / 256;
- }
- public void render (Graphics g) {
- Graphics2D g2d = (Graphics2D) g;
- //g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
- particleColor = new Color (redColor, greenColor, blueColor);
- g2d.setPaint(particleColor);
- g2d.fillRect((int) x, (int) y, 5, 5);
- //g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
- }
- boolean hasDied () {
- boolean tempB = false;
- if (life <= 0) tempB = true;
- return tempB;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement