Shoot and kill all aliens. For each level, you have 5 lives, 20 seconds, and unlimited ammo. Good luck!
The showcase player uses a modified version of Processing.js in combination with jsweet to let students program their apps in Java code while still allowing for browser support.
Content created by students is scaled to fit the showcase frame while maintaining aspect ratio and cursor position. This is why some projects may appear blurry in fullscreen, or why some small details may not be visible on a small screen
<iframe width='500px' height='400px' src='https://nest.ktbyte.com/nest#402' allowfullscreen></iframe>
PImage spaceship; PImage bullets; PImage alien1, alien2, alien3; ArrayList <Bullet> arrayBullets= new ArrayList<Bullet>(); ArrayList <Aliena> arrayAliensa = new ArrayList<Aliena>(); ArrayList <Alienb> arrayAliensb = new ArrayList<Alienb>(); ArrayList <Alienc> arrayAliensc = new ArrayList<Alienc>(); int bulletTime = 5; int score = 0; int lives = 5; int stage = 2; String state = "game"; boolean shotA = false; boolean shotB = false; boolean shotC = false; class Bullet { int x, y; Bullet() { } void displayBullets() { image(bullets, x, y); } } class Aliena { float a, b; Aliena() { } void displayA() { image(alien1, a, b, 50, 50); } } class Alienb { float a, b; Alienb() { } void displayB() { image(alien2, a, b, 50, 50); } } class Alienc { float a, b; Alienc() { } void displayC() { image(alien3, a, b, 50, 50); } } void setup() { if (state == "game") { noCursor(); size(500, 700); spaceship = loadImage("http://www.clipartlord.com/wp-content/uploads/2014/04/spaceship4.png"); bullets = loadImage("http://icons.iconarchive.com/icons/calle/smith-and-wesson/32/Single-Bullet-icon.png"); alien1 = loadImage("http://png-1.findicons.com/files/icons/476/space/256/alien.png"); alien2 = loadImage("http://mascot.crystalxp.net/png/nelson-alien-2-2774.png"); alien3 = loadImage("http://dc604.4shared.com/img/1jHYYWI3/s3/13738cea1d8/Alien_Logo.png"); } } void draw() { background(0, 0, 0); if (state == "stagescreen") { // textSize(36); text("Level :" + stage, width/2-50, height/2-15); text("Click for Next Level", width/2-160, height/2+15); if (mousePressed == true) { state = "game"; stage++; frameCount = 0; arrayAliensa.clear(); arrayAliensb.clear(); arrayAliensc.clear(); } } if (state=="game over") { text("GAME OVER", width/2, height/2-10); text("CLICK TO TRY AGAIN", width/2, height/2+10); if (mousePressed == true) { state="game"; lives = 5; frameCount = 0; stage = 2; } } if (state=="game") { int alienTimea = 4+stage, alienTimeb = 6+stage, alienTimec = 8+stage; float timeFrame = 20-(frameCount/60); image(spaceship, mouseX-25, mouseY-25, 50, 50); // create bullet every 2 seconds text("Score: " + score, 10, 20); text("Lives: " + lives, 10, 30); text("Time: " + int(timeFrame), 10, 40); if (frameCount % 15 == 0) { Bullet b = new Bullet(); b.x = mouseX - 25; b.y = mouseY - 25; arrayBullets.add(b); } for (int i = 0; i < arrayBullets.size(); i++) { Bullet b = arrayBullets.get(i); b.y-=bulletTime; b.displayBullets(); // for(int i = 0; i < arrayAliensa.size; i++) { // Aliena a = arrayAliensa.get(i); for (Aliena a: arrayAliensa) { if (isColliding(b.x, b.y, bullets.width, bullets.height, a.a, a.b, alien1.width, alien1.height)) { shotA = true; } } for (Alienb bb: arrayAliensb) { if (isColliding(b.x, b.y, bullets.width, bullets.height, bb.a, bb.b, alien2.width, alien2.height)) { shotB = true; } } for (Alienc c: arrayAliensc) { if (isColliding(b.x, b.y, bullets.width, bullets.height, c.a, c.b, alien3.width, alien3.height)) { shotC = true; } } if (b.y < 0) { arrayBullets.remove(i); i--; } else if (shotA==true) { arrayBullets.remove(i); //i--; score+=1; } else if (shotB==true) { arrayBullets.remove(i); //i--; score+=2; } else if (shotC==true) { arrayBullets.remove(i); //i--; score+=3; } } if (frameCount%50==0) { if (random(0, 3)<1) { Aliena a = new Aliena(); a.a = random(50, 450); a.b = 0; arrayAliensa.add(a); } else if (random(0, 3)>2) { Alienb bb = new Alienb(); bb.a = random(50, 450); bb.b = 0; arrayAliensb.add(bb); } else { Alienc c = new Alienc(); c.a = random(50, 450); c.b = 0; arrayAliensc.add(c); } } for (int aaa = 0; aaa < arrayAliensa.size(); aaa++) { Aliena a = arrayAliensa.get(aaa); a.b+=alienTimea; a.displayA(); if (a.b >height) { arrayAliensa.remove(aaa); aaa--; lives--; } if (shotA==true) { arrayAliensa.remove(aaa); aaa--; shotA = false; } } for (int bbb = 0; bbb < arrayAliensb.size(); bbb++) { Alienb bb = arrayAliensb.get(bbb); bb.b+=alienTimeb; bb.displayB(); if (bb.b >height) { arrayAliensb.remove(bbb); lives--; } if (shotB==true) { arrayAliensb.remove(bbb); bbb--; shotB = false; } } for (int ccc = 0; ccc < arrayAliensc.size(); ccc++) { Alienc c = arrayAliensc.get(ccc); c.b+=alienTimec; c.displayC(); if (c.b > height) { arrayAliensc.remove(ccc); ccc--; lives--; } if (shotC==true) { arrayAliensc.remove(ccc); ccc--; shotC = false; } if (lives<=0) { state="game over"; } } if (timeFrame<=0) { state = "stagescreen"; } } } // detects whether rect 1 and rect 2 are overlapping boolean isColliding(float x1, float y1, float w1, float h1, float x2, float y2, float w2, float h2) { return (x2 - x1 < w1 && x1 - x2 < w2) && (y2 - y1 < h1 && y1 - y2 < h2); }