class BasicBullet { float x; float y; float vx; float vy; float angle; int lifeCount; Particle p; public BasicBullet() { //p = new Particle(new Vector2D(40, 40), new Vector2D(2,2), new Vector2D(0,0), 10); } void update() { vx = cos(angle) * 5; vy = sin(angle) * 5; x = x + vx; y = y + vy; //if (x > 500) x = 0; // if (y > 400) y = 0; // if (x < 0) x = 500; // if (y < 0) y = 400; lifeCount ++; } int clean(int i) { // p.render(); //p.move(); if (lifeCount > 10) { bullets = removeArrayItem(i, bullets); return 1; } return 0; } void draw() { pushMatrix(); translate(x, y); rotate(angle); noStroke(); fill(color(120 - (9*(lifeCount)), 30 - (2*(lifeCount)), 30 - (1*(lifeCount)))); rect (5, -5, 10, 10); fill(color(200, 160, 50)); rect (7, -3, 6 * (10-lifeCount)/10, 6 * (10-lifeCount)/10); popMatrix(); } } public BasicBullet[] removeArrayItem(int index, BasicBullet[] bullets) { if(index < bulletsCount) { bullets[index] = null; for(int i = index + 1;i < bulletsCount; i++) { bullets[i - 1] = bullets[i]; } bulletsCount--; } return bullets; }