//--------------------------------------------- class Mine { float mineX, mineY; int age, maxAge; boolean ignore; Mine nextMine; //next object in a linked list //--------------------------------------------- Mine(float x, float y){ ignore = false; age = 0; maxAge = 200; mineX = x; mineY = y; } //--------------------------------------------- void addMine(float x, float y){ if(nextMine!=null){ nextMine.addMine( x, y); } else { nextMine = new Mine(x, y); } } //--------------------------------------------- void update(){ //Updates the mine's position if(!ignore){ age++; if( age > maxAge ){ explode(); } if( dist(enemy.x,enemy.y,mineX,mineY) < 20){ enemy.kill(); explode(); } if( dist(shuttle.shipX,shuttle.shipY,mineX,mineY) < 10){ shuttle.kill(); explode(); } visualize(); } //Updates the rest of the mines in the linked list if(nextMine!=null){ nextMine.update(); // Removes redundant objects if(nextMine.ignore) nextMine = nextMine.nextMine; } } //--------------------------------------------- void explode(){ ignore = true; explosion.addBlast(mineX,mineY,1.0,80,30,100,0,255); if( dist(enemy.x,enemy.y,mineX,mineY) < 30) enemy.kill(); if( dist(shuttle.shipX,shuttle.shipY,mineX,mineY) < 30) shuttle.kill(); } //--------------------------------------------- void visualize(){ //Draws the mine stroke(0,0,255); ellipse(mineX, mineY,7,7); float t = (age%50)/50f; if(maxAge-age < 45) t = (age%8)/8f; stroke(0,0,230-230*t); ellipse(mineX, mineY,9+30*t,9+30*t); } }