// use all the classes provided in package ddf.minim import ddf.minim.*; // the minim "manager" Minim minim; // the audio clip object AudioSnippet explode; AudioSnippet boing; // animation Animation anim; // PFont variable declariation PFont f; // Score an Lives int score= 0; int lives = 5; int superbullet = 5; boolean end = false; boolean start = false; // an ArrayList to store the bullets ArrayList bullets = new ArrayList(); ArrayList sbullets = new ArrayList(); Enemy[] enemy = new Enemy[20]; Stars[] stars = new Stars[200]; Avatar avatar = new Avatar(); void setup() { size(600,600); colorMode(RGB, 100); smooth(); noCursor(); // fontloading f = loadFont("BankGothic-Light-14.vlw"); // image loading for avatar avatar.img = loadImage("ship.gif"); avatar.img_l = loadImage("shipl.gif"); avatar.img_r = loadImage("shipr.gif"); // Create an animation of 2 frames, with a delay of 5 anim = new Animation("enemy_a_", "gif", 2, 5); // initialize the enemies for (int i = 0; i 0) { avatar.y -= avatar.speed; } else if(keyCode==DOWN && avatar.y < height-70) avatar.y += avatar.speed; else if(keyCode==LEFT && avatar.x > 10) { avatar.x -= avatar.speed; avatar.dir = -1; } else if(keyCode==RIGHT && avatar.x < height-60) { avatar.x += avatar.speed; avatar.dir = 1; } } } // Avatar on Stage avatar.paint(); // Stars on Stage for (int i = 0; i= 0) { superbullet = 0; superbullet +=5; } score = 0; avatar.paint(); avatar.x = 275; end = false; for (int i = 0; i 0) { if (key == 'x') { superbullet -= 1; Sbullet oneSbullet = new Sbullet(); oneSbullet.x = avatar.x+25; oneSbullet.y = avatar.y+10; sbullets.add(oneSbullet); } } } // move and draw every bullet in the bullets list // remove bullets which are offscreen void processBullets() { // for each bullet in the list for (int i = 0; i < bullets.size(); ) { // get the bullet at index i of the list Bullet oneBullet = (Bullet)bullets.get(i); // if the bullet is offscreen then remove it from the list // BUT don't increase the counting index i if (oneBullet.y < 0) { bullets.remove(i); } // else, move and draw the bullet // AND increase the counting index i else { oneBullet.y -= oneBullet.speed; oneBullet.paint(); i++; for (int r = 0; r