class PlantBullet { Vector2D position; Vector2D velocity; float angle; float size = 3; float speed = 3; int lifeCount; int strength = 10; int type = 0; int maxLifeCount = 10; public PlantBullet(Vector2D position_, float angle_, int type_) { position = position_; angle = angle_; type = type_; speed = 3; strength = 130; maxLifeCount = 100; velocity = new Vector2D(speed, 0); velocity.rotateTo(angle); } void update() { position.add(velocity); lifeCount ++; } int clean(int i) { if (lifeCount > maxLifeCount) { plantBullets = removeArrayItem(i, plantBullets); return 1; } return 0; } void draw() { pushMatrix(); translate(position.getX(), position.getY()); stroke(40,100,40); ellipse(0, 0, 12, 12); ellipse(0, 0, 6, 6); popMatrix(); } } public PlantBullet[] removeArrayItem(int index, PlantBullet[] plantBullets) { if(index < plantBulletsCount) { plantBullets[index] = null; for(int i = index + 1;i < plantBulletsCount; i++) { plantBullets[i - 1] = plantBullets[i]; } plantBulletsCount--; } return plantBullets; }