/*
WE COME IN HATE
by Mustafa Kirgul
The world is occupied by aliens. They come through a wormhole.
You manage to steal a UFO. It is time to attack back. Try to close the
wormhole, and save the earth.
Control UFO by keys "W,A,S,D". You can also move diagonally.
Control UFO's laser by left click. You have limited ammo and range. Ammo regenerates.
Beam your UFO to anywhere on screen by right click. You have limited beam power. It regenerates in time.
Kill enemies.
Collect Blue Boxes of Energy to gain health and shrink Wormhole.
You have 8 seconds to collect each box, other wise the wormhole will use the box's energy to grow.
Close the wormhole, save the earth.
*/
//-----------------------------------------------GLOBAL_VARIABLES
boolean waveDown=true;
boolean startSign=false;
boolean edge=false;
boolean NORTH, SOUTH, WEST, EAST;
boolean playGame=false;
boolean startable=false;
boolean enemy1Active=false;
boolean enemy2Active=false;
boolean enemy3Active=false;
boolean enemy4Active=false;
boolean enemy5Active=false;
boolean powerBox=false;
int ECGy=-200;
int text=0;
int textY=0;
int textX=0;
int returnAlpha=0;
int millisCheck=0;
int beamLimit=5;
int beam=beamLimit;
int beamtime=millis();
int laserLimit=50;
int laser=laserLimit;
int lasertime=millis();
int laserRange=200;
int holeSize=20;
int mainCounter=0;
int enemy1Alpha=0;
int enemy2Alpha=0;
int enemy3Alpha=0;
int enemy4Alpha=0;
int enemy5Alpha=0;
int enemy1Laser=6;
int enemy2Laser=6;
int enemy3Laser=6;
int enemy4Laser=6;
int enemy5Laser=6;
int enemy1LaserCounter=millis();
int enemy2LaserCounter=millis();
int enemy3LaserCounter=millis();
int enemy4LaserCounter=millis();
int enemy5LaserCounter=millis();
int enemyNumber=0;
int powerBoxAlpha=0;
int UFOLifeLimit=50;
int laserPrecision=12;
int gameResult=0;
float xoff = 0.0;
float yoff = 0.0;
float enemy1x, enemy1y, enemy2x, enemy2y, enemy3x, enemy3y, enemy4x, enemy4y, enemy5x, enemy5y;
float easing1 = 0.01;
float easing2 = 0.01;
float easing3 = 0.01;
float easing4 = 0.01;
float easing5 = 0.01;
float UFOx=25.0;
float UFOy=25.0;
float wormholex;
float wormholey;
float lx1, ly1, lx2, ly2;
float UFOLife=UFOLifeLimit;
float UFOSpeed=2.0;
float powerBoxX, powerBoxY, powerBoxDestX, powerBoxDestY;
void setup() {
size(400, 400);
frameRate(60);
background(255);
ellipseMode(CENTER);
}
void draw() {
if (playGame==false&&gameResult==0) { //--------Display Intro Screen
startBG();
introStars();
ECGLine();
displayStartSign();
} else if (playGame==false&&gameResult==1) { //--Display 'Game Lost' Screen
noStroke();
fill(255, 0, 0);
rect(0, 0, width, height);
pressEnter();
} else if (playGame==false&&gameResult==2) { //--Display 'Game Won' Screen
noStroke();
fill(0, 255, 0);
rect(0, 0, width, height);
pressEnter();
} else { // Display Game Screen
gameBG();
gameStars();
fill(255);
noStroke();
rect(0, 0, width, 13);
wormHole(width-holeSize, height-holeSize);
moveUFO();
enemies();
laserCharge();
beamCharge();
blueBox();
endGame();
}
}
void startBG() { // Draw Background For Intro Screen
int lineheight=height/2-1;
noStroke();
fill(0, 20);
rect(0, 0, width, height);
strokeWeight(1);
stroke(255);
//-----------------DRAW THE GRID------------------------
for (int b=-10; b<10; b++) {
line((width/2)-(20*b), height/2, (width/2)-(100*b)+(int(((width/2)+mouseX)/10)), height);
}
for (int b=0; b<17; b++) {
lineheight = lineheight + int(lineheight*(b*.005));
line(0, lineheight, width, lineheight);
}
//------------------------------------------------------
}
void ECGLine() { //--------------------------------Move the animated ECG Line down on the Intro Screen
if (waveDown==true) {
if (ECGy<0) {
int x1=0;
int y1=100+ECGy;
int x2=100;
int y2=100+ECGy;
int x3=150;
float y3=random(30, 170)+ECGy;
int x4=200;
float y4=random(30, 170)+ECGy;
int x5=250;
float y5=random(30, 170)+ECGy;
int x6=300;
int y6=100+ECGy;
int x7=400;
int y7=100+ECGy;
stroke(255, 0, 0);
strokeWeight(3);
line(x1, y1, x2, y2);
line(x2, y2, x3, y3);
line(x3, y3, x4, y4);
line(x4, y4, x5, y5);
line(x5, y5, x6, y6);
line(x6, y6, x7, y7);
ECGy++;
} else {
waveDown=false;
startSign=true;
}
} else { //---------------------------------------Keep animating the ECG Line after it is down on the Intro Screen
int x1=0;
int y1=100+ECGy;
int x2=100;
int y2=100+ECGy;
int x3=150;
float y3=random(30, 170)+ECGy;
int x4=200;
float y4=random(30, 170)+ECGy;
int x5=250;
float y5=random(30, 170)+ECGy;
int x6=300;
int y6=100+ECGy;
int x7=400;
int y7=100+ECGy;
stroke(255, 0, 0);
strokeWeight(3);
line(x1, y1, x2, y2);
line(x2, y2, x3, y3);
line(x3, y3, x4, y4);
line(x4, y4, x5, y5);
line(x5, y5, x6, y6);
line(x6, y6, x7, y7);
}
}
void displayStartSign() { //--------------------------------Draw the neon START text on the intro screen by using lines
if (startSign==true) {
if (text<255) {
text++;
} else {
pressEnter();
}
textY=height-int(text/1.5);
textX=58;
strokeWeight(3+(sin(millis())));
stroke(0, 255, 0, text);
//---------------------------------------------- The Letter 'S'
line(textX, textY, textX+45, textY);
line(textX+45, textY, textX+45, textY+15);
line(textX+45, textY+15, textX+15, textY+15);
line(textX+15, textY+15, textX+15, textY+30);
line(textX+15, textY+30, textX+45, textY+30);
line(textX+45, textY+30, textX+45, textY+75);
line(textX+45, textY+75, textX, textY+75);
line(textX, textY+75, textX, textY+60);
line(textX, textY+60, textX+30, textY+60);
line(textX+30, textY+60, textX+30, textY+45);
line(textX+30, textY+45, textX, textY+45);
line(textX, textY+45, textX, textY);
//---------------------------------------------- The Letter 'T'
line(textX+60, textY, textX+105, textY);
line(textX+105, textY, textX+105, textY+15);
line(textX+105, textY+15, textX+90, textY+15);
line(textX+90, textY+15, textX+90, textY+75);
line(textX+90, textY+75, textX+75, textY+75);
line(textX+75, textY+75, textX+75, textY+15);
line(textX+75, textY+15, textX+60, textY+15);
line(textX+60, textY+15, textX+60, textY);
//---------------------------------------------- The Letter 'A'
line(textX+120, textY, textX+165, textY);
line(textX+165, textY, textX+165, textY+75);
line(textX+165, textY+75, textX+150, textY+75);
line(textX+150, textY+75, textX+150, textY+45);
line(textX+150, textY+45, textX+135, textY+45);
line(textX+135, textY+45, textX+135, textY+75);
line(textX+135, textY+75, textX+120, textY+75);
line(textX+120, textY+75, textX+120, textY);
line(textX+135, textY+15, textX+150, textY+15);
line(textX+150, textY+15, textX+150, textY+30);
line(textX+150, textY+30, textX+135, textY+30);
line(textX+135, textY+30, textX+135, textY+15);
//---------------------------------------------- The Letter 'R'
line(textX+180, textY, textX+225, textY);
line(textX+225, textY, textX+225, textY+45);
line(textX+225, textY+45, textX+210, textY+45);
line(textX+210, textY+45, textX+225, textY+60);
line(textX+225, textY+60, textX+225, textY+75);
line(textX+225, textY+75, textX+210, textY+75);
line(textX+210, textY+75, textX+195, textY+45);
line(textX+195, textY+45, textX+195, textY+75);
line(textX+195, textY+75, textX+180, textY+75);
line(textX+180, textY+75, textX+180, textY);
line(textX+195, textY+15, textX+210, textY+15);
line(textX+210, textY+15, textX+210, textY+30);
line(textX+210, textY+30, textX+195, textY+30);
line(textX+195, textY+30, textX+195, textY+15);
//---------------------------------------------- The Letter 'T'
line(textX+240, textY, textX+285, textY);
line(textX+285, textY, textX+285, textY+15);
line(textX+285, textY+15, textX+270, textY+15);
line(textX+270, textY+15, textX+270, textY+75);
line(textX+270, textY+75, textX+255, textY+75);
line(textX+255, textY+75, textX+255, textY+15);
line(textX+255, textY+15, textX+240, textY+15);
line(textX+240, textY+15, textX+240, textY);
}
}
void pressEnter() { //--------------------------- Animate the Return Button on the Intro Screen
if (returnAlpha<255) {
returnAlpha=returnAlpha+5;
} else {
returnAlpha=0;
startable=true;
}
stroke(255, returnAlpha);
strokeWeight(4);
//--------------------------------------------- Draw Return Button by Lines
line(185, textY+100, 215, textY+100);
line(215, textY+100, 215, textY+145);
line(215, textY+145, 170, textY+145);
line(170, textY+145, 170, textY+115);
line(170, textY+115, 185, textY+115);
line(185, textY+115, 185, textY+100);
line(200, textY+107, 200, textY+130);
line(200, textY+130, 177, textY+130);
line(177, textY+130, 185, textY+123);
line(177, textY+130, 185, textY+137);
}
void mousePressed() { //---------------------------Check the Mouse Buttons and call related functions
if (playGame==true) {
if (mouseButton == LEFT) {
fireLaser();
} else if (mouseButton == RIGHT) {
ufoBeam();
}
}
}
void moveUFO() { //-------------------------------- Move the UFO on the screen
if (checkEdge()==false) {
if (NORTH==true) {
UFOy-=UFOSpeed;
}
if (WEST==true) {
UFOx-=UFOSpeed;
}
if (SOUTH==true) {
UFOy+=UFOSpeed;
}
if (EAST==true) {
UFOx+=UFOSpeed;
}
}
saucerDraw();
}
void gameBG() {//-----------------------------------Fill background with a black rectangle with low alpha to create old school ghosting effect
fill(0, 0, 0, 100);
rect(0, 0, width, height);
}
void saucerDraw() { //-------------------------------Draw the UFO
noStroke();
fill(255);
ellipse(UFOx, UFOy, 25, 25);
stroke(0);
line(UFOx, UFOy, (UFOx+(13*cos(millis()))), (UFOy+(13*sin(millis())))); //The animated line creates the illusion of a revolving UFO
noStroke();
fill(255*sin(millis()));
ellipse(UFOx, UFOy, 10, 10);
stroke(0, 155, 0);
strokeWeight(3);
line(0, 10, (width/UFOLifeLimit)*UFOLife, 10);//Shows the life of UFO on top of the screen
noStroke();
}
boolean checkEdge() { //--------------------------------Check if the UFO is within the screen limits, if not constrain it.
if (UFOx<15) {
UFOx=15;
return(true);
} else if (UFOx>385) {
UFOx=385
;
return(true);
} else if (UFOy<28) {
UFOy=28;
return(true);
} else if (UFOy>385) {
UFOy=385;
return(true);
} else {
return(false);
}
}
void fireLaser() { //------------------------------UFO shoots the enemies with its laser.
if (laser>0 && distance(UFOx, UFOy, mouseX, mouseY)<laserRange) {
laser--;
lx1=UFOx;
ly1=UFOy;
lx2=mouseX;
ly2=mouseY;
checkHit(mouseX, mouseY);
for (int i=0; i<=60; i++) {
stroke(255, 0, 0, (255-(i*2)));
strokeWeight(1);
line(lx1, ly1, lx2, ly2);
}
lasertime=millis();
}
}
void ufoBeam() {//-------------------------------UFO beams itself anywhere on the screen.
if (beam>0) {
lx2=mouseX;
ly2=mouseY;
for (int i=0; i<=60; i++) {
fill(0, 0, 255, (255-(i*4)));
ellipse(UFOx, UFOy, 30, 30);
fill(0, 255, 0, (i*4));
ellipse(lx2, ly2, 40, 40);
UFOx=mouseX;
UFOy=mouseY;
}
beamtime=millis();
beam--;
} else {
fill(255, 0, 0);
ellipse(UFOx, UFOy, 30, 30);
}
}
void laserCharge() {//--------------------------UFO's Laser charges 4 times a second.
if (laser<=laserLimit) {
if (millis() > lasertime + 250)
{
laser++;
lasertime = millis();
}
}
stroke(255, 0, 0);
strokeWeight(3);
line(0, 2, (width/laserLimit)*laser, 2);
noStroke();
}
void beamCharge() {//--------------------------UFO's Beaming System charges every 3 seconds.
if (beam<beamLimit) {
if (millis() > beamtime + 3000)
{
beam++;
beamtime = millis();
}
}
stroke(0, 0, 255);
strokeWeight(3);
line(0, 6, (width/beamLimit)*beam, 6);
noStroke();
}
void keyPressed() { //--------------------------Check keys to send moving commands through booleans.
if (playGame==true) {
if (key == 'w') {
NORTH = true;
} else if (key== 's') {
SOUTH = true;
} else if (key== 'a') {
WEST = true;
} else if (key== 'd') {
EAST = true;
}
}
if (startable==true) {//---------------------Starts game when you press Return Key, after the intro is loaded completely.
if (keyCode==ENTER|keyCode== RETURN) {
mainCounter=millis();
playGame=true;
}
}
if (key == 'm') { //--------------------------Shortcut to Skip Intro
reset();
playGame=true;
gameResult=0;
}
if (key == 'n') { //---------------------------Shortcut to Intro Screen
reset();
playGame=false;
gameResult=0;
}
}
void keyReleased() { //--------------------- Update Booleans when keys are released
if (playGame==true) {
if (key == 'w') {
NORTH = false;
} else if (key== 's') {
SOUTH = false;
} else if (key== 'a') {
WEST = false;
} else if (key== 'd') {
EAST = false;
}
}
}
void wormHole(int wormholeX, int wormholeY) { //Draw wormhole animation using perlin noise
wormholex=wormholeX;
wormholey=wormholeY;
noStroke();
fill(random(0, 255), random(0, 255), random(0, 255));
ellipse(wormholeX, wormholeY, (holeSize*2)+4, (holeSize*2)+4);
for (int y=-holeSize; y<=holeSize; y++) {
for (int x=-holeSize; x<=holeSize; x++) {
if (x*x+y*y <= holeSize*holeSize) {
strokeWeight(1);
stroke((noise(xoff, yoff)*255), (noise(xoff, yoff)*255)+100, (noise(xoff, yoff)*255)+200, 155);
point(wormholeX+x, wormholeY+y);
xoff += .1;
}
}
xoff=0.0;
yoff += .01;
}
}
void enemies() {//------------------------------------------Summon 5 Enemies with animation of coming out of the wormhole
if (playGame) {
//----------------------------------------------------- Enemy1
if (enemy1Active==false) {
if (enemy1x==0 &&enemy1y==0) {
enemy1x=wormholex;
enemy1y=wormholey;
easing1=random(.01, .03);
}
if (enemy1Alpha<255) {
enemy1Alpha+=int(random(1, 5));
enemy1x--;
strokeWeight(1);
fill(255, 255, 0, enemy1Alpha);
ellipse(enemy1x, enemy1y, 10, 10);
} else {
enemy1Alpha=255;
enemy1Active=true;
enemyNumber++;
enemy1LaserCounter=millis();
enemy1Laser=int(random(1, 5));
}
} else {
enemy1();
}
//-----------------------------------------------------Enemy 2
if (enemy2Active==false) {
if (enemy2x==0 &&enemy2y==0) {
enemy2x=wormholex;
enemy2y=wormholey;
easing2=random(.01, .03);
}
if (enemy2Alpha<255) {
enemy2Alpha+=int(random(1, 5));
enemy2x--;
enemy2y--;
strokeWeight(1);
fill(255, 255, 50, enemy2Alpha);
ellipse(enemy2x, enemy2y, 10, 10);
} else {
enemy2Alpha=255;
enemy2Active=true;
enemyNumber++;
enemy2LaserCounter=millis();
enemy2Laser=int(random(1, 5));
}
} else {
enemy2();
}
//-----------------------------------------------------Enemy 3
if (enemy3Active==false) {
if (enemy3x==0 &&enemy3y==0) {
enemy3x=wormholex;
enemy3y=wormholey;
easing3=random(.01, .03);
}
if (enemy3Alpha<255) {
enemy3Alpha+=int(random(1, 5));
enemy3x--;
enemy3y-=2;
strokeWeight(1);
fill(255, 255, 100, enemy3Alpha);
ellipse(enemy3x, enemy3y, 10, 10);
} else {
enemy3Alpha=255;
enemy3Active=true;
enemyNumber++;
enemy3LaserCounter=millis();
enemy3Laser=int(random(1, 5));
}
} else {
enemy3();
}
//-----------------------------------------------------Enemy 4
if (enemy4Active==false) {
if (enemy4x==0 &&enemy4y==0) {
enemy4x=wormholex;
enemy4y=wormholey;
easing4=random(.01, .03);
}
if (enemy4Alpha<255) {
enemy4Alpha+=int(random(1, 5));
enemy4x-=2;
enemy4y--;
strokeWeight(1);
fill(255, 255, 150, enemy4Alpha);
ellipse(enemy4x, enemy4y, 10, 10);
} else {
enemy4Alpha=255;
enemy4Active=true;
enemyNumber++;
enemy4LaserCounter=millis();
enemy4Laser=int(random(1, 5));
}
} else {
enemy4();
}
//-----------------------------------------------------Enemy 5
if (enemy5Active==false) {
if (enemy5x==0 &&enemy5y==0) {
enemy5x=wormholex;
enemy5y=wormholey;
easing5=random(.01, .03);
}
if (enemy1Alpha<255) {
enemy5Alpha+=int(random(1, 5));
enemy5y--;
strokeWeight(1);
fill(255, 255, 200, enemy5Alpha);
ellipse(enemy5x, enemy5y, 10, 10);
} else {
enemy5Alpha=255;
enemy5Active=true;
enemyNumber++;
enemy5LaserCounter=millis();
enemy5Laser=int(random(1, 5));
}
} else {
enemy5();
}
}
}
//------------------------------------------------------Artificial Intelligence code for the enemies
void enemy1() {//---------------------------------------Enemy 1 AI
if (enemy1Active) {
if (distance(UFOx, UFOy, enemy1x, enemy1y)<15) {//--if enemy collides with the UFO, it explodes and disappears.
enemyNumber--;
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
for (int i=0; i<=30; i++) {
fill(255, random(150, 255), random(150, 255), 255-(i*9));
noStroke();
ellipse(enemy1x, enemy1y, 15-(i/2), 15-(i/2));
}
enemy1Active=false;
enemy1x=wormholex;
enemy1y=wormholey;
enemy1Alpha=0;
}
if (powerBox==false) {//----------------------------if power box is not on the play screen chase the UFO
if (distance(UFOx, UFOy, enemy1x, enemy1y)>40) {
if (enemyCollision(1)==false) {//---------------if very close to UFO and colliding each other then stop moving
float dx = UFOx - enemy1x;
enemy1x += dx * easing1;
float dy = UFOy - enemy1y;
enemy1y += dy * easing1;
} else if (distance(UFOx, UFOy, enemy1x, enemy1y)>80) {//if UFO starts to get far away, restart chasing
float dx = UFOx - enemy1x;
enemy1x += dx * easing1;
float dy = UFOy - enemy1y;
enemy1y += dy * easing1;
}
}
if (distance(UFOx, UFOy, enemy1x, enemy1y)<80) {//Shoot at random intervals if UFO is in range
if (int((millis()-enemy1LaserCounter)/1000)==enemy1Laser) {
for (int i=0; i<=60; i++) {
stroke(0, 200, 200, 150);
strokeWeight(1);
line(enemy1x, enemy1y, UFOx, UFOy);
}
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
enemy1LaserCounter=millis();
enemy1Laser=int(random(1, 2));
}
}
} else {//--------------------------------------if power box is on the playscreen go to protect powerbox
if (distance(enemy1x, enemy1y, powerBoxX, powerBoxY)<30) {//when reached power box, start drawing circles around it
enemy1x=powerBoxX+10+(18*cos((second()*6)));
enemy1y=powerBoxY+10+(18*sin((second()*6)));
} else {//----------------------------------go to the powerbox to protect it
float dx = powerBoxX - enemy1x;
enemy1x += dx * easing1;
float dy = powerBoxY - enemy1y;
enemy1y += dy * easing1;
}
}
if (distance(UFOx, UFOy, enemy1x, enemy1y)<80) {//if UFO is in range while protecting the power box, shoot at random intervals
if (int((millis()-enemy1LaserCounter)/1000)==enemy1Laser) {
for (int i=0; i<=60; i++) {
stroke(0, 200, 200, 150);
strokeWeight(1);
line(enemy1x, enemy1y, UFOx, UFOy);
}
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
enemy1LaserCounter=millis();
enemy1Laser=int(random(1, 2));
}
}
strokeWeight(1);//---------------------------------Draw enemy ship on calculated coordinates
fill(255, 255, 0);
ellipse(enemy1x, enemy1y, 10, 10);
}
}
void enemy2() {//Enemy 2 AI
if (enemy2Active) {
if (distance(UFOx, UFOy, enemy2x, enemy2y)<15) {//if enemy collides with the UFO, it explodes and disappears.
enemyNumber--;
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
for (int i=0; i<=30; i++) {
fill(255, random(150, 255), random(150, 255), 255-(i*9));
noStroke();
ellipse(enemy2x, enemy2y, 15-(i/2), 15-(i/2));
}
enemy2Active=false;
enemy2x=wormholex;
enemy2y=wormholey;
enemy2Alpha=0;
}
if (powerBox==false) {//----------------------------if power box is not on the play screen chase the UFO
if (distance(UFOx, UFOy, enemy2x, enemy2y)>40) {
if (enemyCollision(2)==false) {//---------------if very close to UFO and colliding each other then stop moving
float dx = UFOx - enemy2x;
enemy2x += dx * easing2;
float dy = UFOy - enemy2y;
enemy2y += dy * easing2;
} else if (distance(UFOx, UFOy, enemy2x, enemy2y)>80) {//if UFO starts to get far away, restart chasing
float dx = UFOx - enemy2x;
enemy2x += dx * easing2;
float dy = UFOy - enemy2y;
enemy2y += dy * easing2;
}
}
if (distance(UFOx, UFOy, enemy2x, enemy2y)<80) {//Shoot at random intervals if UFO is in range
if (int((millis()-enemy2LaserCounter)/1000)==enemy2Laser) {
for (int i=0; i<=60; i++) {
stroke(0, 200, 200, 150);
strokeWeight(1);
line(enemy2x, enemy2y, UFOx, UFOy);
}
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
enemy2LaserCounter=millis();
enemy2Laser=int(random(1, 2));
}
}
} else {//--------------------------------------if power box is on the playscreen go to protect powerbox
if (distance(enemy2x, enemy2y, powerBoxX, powerBoxY)<30) {//when reached power box, start drawing circles around it
enemy2x=powerBoxX+10+(18*cos((second()*6)+72));
enemy2y=powerBoxY+10+(18*sin((second()*6)+72));
} else {//----------------------------------go to the powerbox to protect it
float dx = powerBoxX - enemy2x;
enemy2x += dx * easing1;
float dy = powerBoxY - enemy2y;
enemy2y += dy * easing1;
}
}
if (distance(UFOx, UFOy, enemy2x, enemy2y)<80) {//if UFO is in range while protecting the power box, shoot at random intervals
if (int((millis()-enemy2LaserCounter)/1000)==enemy2Laser) {
for (int i=0; i<=60; i++) {
stroke(0, 200, 200, 150);
strokeWeight(1);
line(enemy2x, enemy2y, UFOx, UFOy);
}
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
enemy2LaserCounter=millis();
enemy2Laser=int(random(1, 2));
}
}
strokeWeight(1);//---------------------------------Draw enemy ship on calculated coordinates
fill(255, 255, 50);
ellipse(enemy2x, enemy2y, 10, 10);
}
}
void enemy3() {//Enemy 3 AI
if (enemy3Active) {
if (distance(UFOx, UFOy, enemy3x, enemy3y)<15) {//if enemy collides with the UFO, it explodes and disappears.
enemyNumber--;
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
for (int i=0; i<=30; i++) {
fill(255, random(150, 255), random(150, 255), 255-(i*9));
noStroke();
ellipse(enemy3x, enemy3y, 15-(i/2), 15-(i/2));
}
enemy3Active=false;
enemy3x=wormholex;
enemy3y=wormholey;
enemy3Alpha=0;
}
if (powerBox==false) {//----------------------------if power box is not on the play screen chase the UFO
if (distance(UFOx, UFOy, enemy3x, enemy3y)>40) {
if (enemyCollision(3)==false) {//---------------if very close to UFO and colliding each other then stop moving
float dx = UFOx - enemy3x;
enemy3x += dx * easing3;
float dy = UFOy - enemy3y;
enemy3y += dy * easing3;
} else if (distance(UFOx, UFOy, enemy3x, enemy3y)>40) {//if UFO starts to get far away, restart chasing
float dx = UFOx - enemy3x;
enemy3x += dx * easing3;
float dy = UFOy - enemy3y;
enemy3y += dy * easing3;
}
}
if (distance(UFOx, UFOy, enemy3x, enemy3y)<80) {//Shoot at random intervals if UFO is in range
if (int((millis()-enemy3LaserCounter)/1000)==enemy3Laser) {
for (int i=0; i<=60; i++) {
stroke(0, 200, 200, 150);
strokeWeight(1);
line(enemy3x, enemy3y, UFOx, UFOy);
}
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
enemy3LaserCounter=millis();
enemy3Laser=int(random(1, 2));
}
}
} else {//--------------------------------------if power box is on the playscreen go to protect powerbox
if (distance(enemy3x, enemy3y, powerBoxX, powerBoxY)<30) {//when reached power box, start drawing circles around it
enemy3x=powerBoxX+10+(18*cos((second()*6)+144));
enemy3y=powerBoxY+10+(18*sin((second()*6)+144));
} else {//----------------------------------go to the powerbox to protect it
float dx = powerBoxX - enemy3x;
enemy3x += dx * easing1;
float dy = powerBoxY - enemy3y;
enemy3y += dy * easing1;
}
}
if (distance(UFOx, UFOy, enemy3x, enemy3y)<80) {//if UFO is in range while protecting the power box, shoot at random intervals
if (int((millis()-enemy3LaserCounter)/1000)==enemy3Laser) {
for (int i=0; i<=60; i++) {
stroke(0, 200, 200, 150);
strokeWeight(1);
line(enemy3x, enemy3y, UFOx, UFOy);
}
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
enemy3LaserCounter=millis();
enemy3Laser=int(random(1, 2));
}
}
strokeWeight(1);//---------------------------------Draw enemy ship on calculated coordinates
fill(255, 255, 100);
ellipse(enemy3x, enemy3y, 10, 10);
}
}
void enemy4() {//Enemy 4 AI
if (enemy4Active) {
if (distance(UFOx, UFOy, enemy4x, enemy4y)<15) {//if enemy collides with the UFO, it explodes and disappears.
enemyNumber--;
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
for (int i=0; i<=30; i++) {
fill(255, random(150, 255), random(150, 255), 255-(i*9));
noStroke();
ellipse(enemy4x, enemy4y, 15-(i/2), 15-(i/2));
}
enemy4Active=false;
enemy4x=wormholex;
enemy4y=wormholey;
enemy4Alpha=0;
}
if (powerBox==false) {//----------------------------if power box is not on the play screen chase the UFO
if (distance(UFOx, UFOy, enemy4x, enemy4y)>40) {
if (enemyCollision(4)==false) {//---------------if very close to UFO and colliding each other then stop moving
float dx = UFOx - enemy4x;
enemy4x += dx * easing4;
float dy = UFOy - enemy4y;
enemy4y += dy * easing4;
} else if (distance(UFOx, UFOy, enemy4x, enemy4y)>50) {//if UFO starts to get far away, restart chasing
float dx = UFOx - enemy4x;
enemy4x += dx * easing4;
float dy = UFOy - enemy4y;
enemy4y += dy * easing4;
}
}
if (distance(UFOx, UFOy, enemy4x, enemy4y)<80) {//Shoot at random intervals if UFO is in range
if (int((millis()-enemy4LaserCounter)/1000)==enemy4Laser) {
for (int i=0; i<=60; i++) {
stroke(0, 200, 200, 150);
strokeWeight(1);
line(enemy4x, enemy4y, UFOx, UFOy);
}
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
enemy4LaserCounter=millis();
enemy4Laser=int(random(1, 2));
}
}
} else {//--------------------------------------if power box is on the playscreen go to protect powerbox
if (distance(enemy4x, enemy4y, powerBoxX, powerBoxY)<30) {//when reached power box, start drawing circles around it
enemy4x=powerBoxX+10+(18*cos((second()*6)+216));
enemy4y=powerBoxY+10+(18*sin((second()*6)+216));
} else {//----------------------------------go to the powerbox to protect it
float dx = powerBoxX - enemy4x;
enemy4x += dx * easing1;
float dy = powerBoxY - enemy4y;
enemy4y += dy * easing1;
}
}
if (distance(UFOx, UFOy, enemy4x, enemy4y)<80) {//if UFO is in range while protecting the power box, shoot at random intervals
if (int((millis()-enemy4LaserCounter)/1000)==enemy4Laser) {
for (int i=0; i<=60; i++) {
stroke(0, 200, 200, 150);
strokeWeight(1);
line(enemy4x, enemy4y, UFOx, UFOy);
}
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
enemy4LaserCounter=millis();
enemy4Laser=int(random(1, 2));
}
}
strokeWeight(1);//---------------------------------Draw enemy ship on calculated coordinates
fill(255, 255, 150);
ellipse(enemy4x, enemy4y, 10, 10);
}
}
void enemy5() {//Enemy 5 AI
if (enemy5Active) {
if (distance(UFOx, UFOy, enemy5x, enemy5y)<15) {//if enemy collides with the UFO, it explodes and disappears.
enemyNumber--;
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
for (int i=0; i<=30; i++) {
fill(255, random(150, 255), random(150, 255), 255-(i*9));
noStroke();
ellipse(enemy5x, enemy5y, 15-(i/2), 15-(i/2));
}
enemy5Active=false;
enemy5x=wormholex;
enemy5y=wormholey;
enemy5Alpha=0;
}
if (powerBox==false) {//----------------------------if power box is not on the play screen chase the UFO
if (distance(UFOx, UFOy, enemy5x, enemy5y)>40) {
if (enemyCollision(5)==false) {//---------------if very close to UFO and colliding each other then stop moving
float dx = UFOx - enemy5x;
enemy5x += dx * easing5;
float dy = UFOy - enemy5y;
enemy5y += dy * easing5;
} else if (distance(UFOx, UFOy, enemy5x, enemy5y)>50) {//if UFO starts to get far away, restart chasing
float dx = UFOx - enemy5x;
enemy5x += dx * easing5;
float dy = UFOy - enemy5y;
enemy5y += dy * easing5;
}
}
if (distance(UFOx, UFOy, enemy5x, enemy5y)<80) {//Shoot at random intervals if UFO is in range
if (int((millis()-enemy5LaserCounter)/1000)==enemy5Laser) {
for (int i=0; i<=60; i++) {
stroke(0, 200, 200, 150);
strokeWeight(1);
line(enemy5x, enemy5y, UFOx, UFOy);
}
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
enemy5LaserCounter=millis();
enemy5Laser=int(random(1, 2));
}
}
} else {//--------------------------------------if power box is on the playscreen go to protect powerbox
if (distance(enemy5x, enemy5y, powerBoxX, powerBoxY)<30) {//when reached power box, start drawing circles around it
enemy5x=powerBoxX+10+(18*cos((second()*6)+288));
enemy5y=powerBoxY+10+(18*sin((second()*6)+288));
} else {//----------------------------------go to the powerbox to protect it
float dx = powerBoxX - enemy5x;
enemy5x += dx * easing1;
float dy = powerBoxY - enemy5y;
enemy5y += dy * easing1;
}
}
if (distance(UFOx, UFOy, enemy5x, enemy5y)<80) {//if UFO is in range while protecting the power box, shoot at random intervals
if (int((millis()-enemy5LaserCounter)/1000)==enemy5Laser) {
for (int i=0; i<=60; i++) {
stroke(0, 200, 200, 150);
strokeWeight(1);
line(enemy5x, enemy5y, UFOx, UFOy);
}
UFOLife--;
noFill();
strokeWeight(20);
stroke(255, 0, 0, 150);
rect(0, 0, width, height);
noStroke();
enemy5LaserCounter=millis();
enemy5Laser=int(random(1, 2));
}
}
strokeWeight(1);//---------------------------------Draw enemy ship on calculated coordinates
fill(255, 255, 200);
ellipse(enemy5x, enemy5y, 10, 10);
}
}
float distance (float x1, float y1, float x2, float y2) {
float distance=sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
return distance;
}
boolean enemyCollision (int SubjectEnemy) {// Check if enemy disks are colliding
boolean result=false;
if (SubjectEnemy==1) { //Check for enemy 1
if (distance(enemy1x, enemy1y, enemy2x, enemy2y)<12) {
result=true;
} else if (distance(enemy1x, enemy1y, enemy3x, enemy3y)<12) {
result=true;
} else if (distance(enemy1x, enemy1y, enemy4x, enemy4y)<12) {
result=true;
} else if (distance(enemy1x, enemy1y, enemy5x, enemy5y)<12) {
result=true;
}
} else if (SubjectEnemy==2) { //Check for enemy 2
if (distance(enemy1x, enemy1y, enemy2x, enemy2y)<12) {
result=true;
} else if (distance(enemy2x, enemy2y, enemy3x, enemy3y)<12) {
result=true;
} else if (distance(enemy2x, enemy2y, enemy4x, enemy4y)<12) {
result=true;
} else if (distance(enemy2x, enemy2y, enemy5x, enemy5y)<12) {
result=true;
}
} else if (SubjectEnemy==3) { //Check for enemy 3
if (distance(enemy1x, enemy1y, enemy3x, enemy3y)<12) {
result=true;
} else if (distance(enemy2x, enemy2y, enemy3x, enemy3y)<12) {
result=true;
} else if (distance(enemy3x, enemy3y, enemy4x, enemy4y)<12) {
result=true;
} else if (distance(enemy3x, enemy3y, enemy5x, enemy5y)<12) {
result=true;
}
} else if (SubjectEnemy==4) { //Check for enemy 4
if (distance(enemy1x, enemy1y, enemy4x, enemy4y)<12) {
result=true;
} else if (distance(enemy2x, enemy2y, enemy4x, enemy4y)<12) {
result=true;
} else if (distance(enemy3x, enemy3y, enemy4x, enemy4y)<12) {
result=true;
} else if (distance(enemy4x, enemy4y, enemy5x, enemy5y)<12) {
result=true;
}
} else if (SubjectEnemy==5) { //Check for enemy 5
if (distance(enemy1x, enemy1y, enemy5x, enemy5y)<12) {
result=true;
} else if (distance(enemy2x, enemy2y, enemy5x, enemy5y)<12) {
result=true;
} else if (distance(enemy3x, enemy3y, enemy5x, enemy5y)<12) {
result=true;
} else if (distance(enemy4x, enemy4y, enemy5x, enemy5y)<12) {
result=true;
}
}
return result;
}
void checkHit(int laserX, int laserY) {//----------------Check if enemy ships are hit bythe UFO laser.
if (distance(laserX, laserY, enemy1x, enemy1y)<laserPrecision) {//Check for enemy 1
for (int i=0; i<=30; i++) {
fill(255, random(150, 255), random(150, 255), 255-(i*9));
noStroke();
ellipse(enemy1x, enemy1y, 15-(i/2), 15-(i/2));
}
enemy1Active=false;
enemy1x=wormholex;
enemy1y=wormholey;
enemy1Alpha=0;
enemyNumber--;
} else if (distance(laserX, laserY, enemy2x, enemy2y)<laserPrecision) {//Check for enemy 2
for (int i=0; i<=30; i++) {
fill(255, random(150, 255), random(150, 255), 255-(i*9));
noStroke();
ellipse(enemy2x, enemy2y, 15-(i/2), 15-(i/2));
}
enemy2Active=false;
enemy2x=wormholex;
enemy2y=wormholey;
enemy2Alpha=0;
enemyNumber--;
} else if (distance(laserX, laserY, enemy3x, enemy3y)<laserPrecision) {//Check for enemy 3
for (int i=0; i<=30; i++) {
fill(255, random(150, 255), random(150, 255), 255-(i*9));
noStroke();
ellipse(enemy3x, enemy3y, 15-(i/2), 15-(i/2));
}
enemy3Active=false;
enemy3x=wormholex;
enemy3y=wormholey;
enemy3Alpha=0;
enemyNumber--;
} else if (distance(laserX, laserY, enemy4x, enemy4y)<laserPrecision) {//Check for enemy 4
for (int i=0; i<=30; i++) {
fill(255, random(150, 255), random(150, 255), 255-(i*9));
noStroke();
ellipse(enemy4x, enemy4y, 15-(i/2), 15-(i/2));
}
enemy4Active=false;
enemy4x=wormholex;
enemy4y=wormholey;
enemy4Alpha=0;
enemyNumber--;
} else if (distance(laserX, laserY, enemy5x, enemy5y)<laserPrecision) {//Check for enemy 5
for (int i=0; i<=30; i++) {
fill(255, random(150, 255), random(150, 255), 255-(i*9));
noStroke();
ellipse(enemy5x, enemy5y, 15-(i/2), 15-(i/2));
}
enemy5Active=false;
enemy5x=wormholex;
enemy5y=wormholey;
enemy5Alpha=0;
enemyNumber--;
}
}
void blueBox() {//---------------------------------------Blue Power Box that comes out of the wormhole every 8 seconds.
if (powerBox) {
if (distance(UFOx, UFOy, powerBoxX+10, powerBoxY+10)<26) {// Check if the player collected the Blue Power Box
strokeWeight(20);
stroke(150, 150, 255, 150);
rect(0, 0, width, height);
noStroke();
powerBox=false;
powerBoxX=wormholex;
powerBoxY=wormholey;
powerBoxAlpha=0;
if (holeSize>3) {//------------------------------Shrink wormhole if power box collected
holeSize-=1;
}
if (UFOLife<UFOLifeLimit) {//--------------------Give lifepoints to the UFO if power box collected
UFOLife+=5;
}
} else {//-----------------------------------------Draw the blue power box.
fill(155, 155, random(150, 255), powerBoxAlpha);
stroke(0);
strokeWeight(1);
rect(powerBoxX, powerBoxY, 20, 20);
}
}
if (millis()-mainCounter>7990 && millis()-mainCounter<8010) {//create new power box every 8 seconds
if (powerBox==false) {//--------------------------If box was collected just create a new one
enemy1LaserCounter=millis();
enemy2LaserCounter=millis();
enemy3LaserCounter=millis();
enemy4LaserCounter=millis();
enemy5LaserCounter=millis();
enemy1Laser=int(random(1, 4));
enemy2Laser=int(random(1, 4));
enemy3Laser=int(random(1, 4));
enemy4Laser=int(random(1, 4));
enemy5Laser=int(random(1, 4));
powerBox=true;
mainCounter=millis();
powerBoxDestX=random(0, 400);
powerBoxDestY=random(50, 350);
powerBoxX=wormholex;
powerBoxY=wormholey;
powerBoxAlpha=0;
for (int i=0; i<255; i++) {
powerBoxAlpha++;
float dx = powerBoxDestX - powerBoxX;
powerBoxX += dx/255;
float dy = powerBoxDestY - powerBoxY;
powerBoxY += dy/255;
fill(155, 155, random(150, 255), powerBoxAlpha);
stroke(0);
strokeWeight(1);
rect(powerBoxX, powerBoxY, 20, 20);
}
} else {//--------------------------------------If box is not collected destroy existing and grow wormhole
strokeWeight(20);
stroke(255, 255, 255, 150);
rect(0, 0, width, height);
noStroke();
holeSize+=1;
powerBoxX=wormholex;
powerBoxY=wormholey;
powerBoxAlpha=0;
powerBox=false;
mainCounter=millis();
enemy1LaserCounter=millis();
enemy2LaserCounter=millis();
enemy3LaserCounter=millis();
enemy4LaserCounter=millis();
enemy5LaserCounter=millis();
enemy1Laser=int(random(1, 4));
enemy2Laser=int(random(1, 4));
enemy3Laser=int(random(1, 4));
enemy4Laser=int(random(1, 4));
enemy5Laser=int(random(1, 4));
}
}
}
void endGame() {//----------------------------------Check and update game end condtitons and intervals
if (holeSize>50 || UFOLife<0) {//-----------------Player loose conditions
if (playGame) {
for (int i=0; i<180; i++) {
noStroke();
fill(75+i, 0, 0);
rect(0, 0, width, height);//---------------Paint screen Red.
}
}
reset();
playGame=false;
gameResult=1;
}
if (holeSize<8) {//------------------------------Player win condition
if (playGame) {
for (int i=0; i<180; i++) {
noStroke();
fill(0, 75+i, 0);
rect(0, 0, width, height);//---------------Paint screen Green.
}
reset();
playGame=false;
gameResult=2;
}
}
}
void reset() {//-----------------------------------Reset game start intervals
holeSize=20;
laser=laserLimit;
beam=beamLimit;
UFOLife=UFOLifeLimit;
UFOx=25.0;
UFOy=25.0;
enemy1x=0;
enemy1y=0;
enemy2x=0;
enemy2y=0;
enemy3x=0;
enemy3y=0;
enemy4x=0;
enemy4y=0;
enemy5x=0;
enemy5y=0;
enemy1Active=false;
enemy2Active=false;
enemy3Active=false;
enemy4Active=false;
enemy5Active=false;
mainCounter=millis();
powerBox=false;
powerBoxX=-50;
powerBoxY=-50;
NORTH=false;
SOUTH=false;
EAST=false;
WEST=false;
}
void gameStars() {//--------------------------- Draw stars for game background
stroke(random(200, 255));
strokeWeight(1);
point( 323, 246 );
point( 64, 103 );
point( 374, 194 );
point( 219, 8 );
point( 361, 200 );
point( 322, 2 );
point( 31, 226 );
point( 316, 46 );
point( 390, 326 );
point( 319, 128 );
point( 65, 89 );
point( 244, 21 );
point( 11, 391 );
point( 339, 272 );
point( 71, 390 );
point( 271, 93 );
point( 237, 36 );
point( 125, 162 );
point( 172, 171 );
point( 397, 28 );
point( 41, 287 );
point( 274, 329 );
point( 136, 156 );
point( 47, 5 );
point( 39, 378 );
point( 171, 196 );
point( 244, 255 );
point( 261, 100 );
point( 292, 60 );
point( 175, 126 );
point( 202, 327 );
point( 102, 128 );
point( 291, 213 );
point( 339, 133 );
point( 10, 248 );
point( 163, 140 );
point( 57, 35 );
point( 172, 159 );
point( 67, 83 );
point( 98, 261 );
point( 215, 87 );
point( 110, 149 );
point( 352, 70 );
point( 161, 25 );
point( 354, 311 );
point( 369, 190 );
point( 154, 54 );
point( 66, 255 );
point( 236, 51 );
point( 111, 157 );
point( 35, 152 );
point( 308, 195 );
point( 67, 324 );
point( 44, 280 );
point( 306, 139 );
point( 146, 58 );
point( 38, 356 );
point( 102, 233 );
point( 127, 398 );
point( 110, 60 );
point( 131, 312 );
point( 323, 310 );
point( 191, 134 );
point( 34, 234 );
point( 34, 228 );
point( 144, 297 );
point( 74, 316 );
point( 8, 18 );
point( 1, 90 );
point( 235, 381 );
point( 66, 300 );
point( 28, 160 );
point( 157, 133 );
point( 119, 166 );
point( 56, 264 );
point( 367, 124 );
point( 71, 53 );
point( 253, 359 );
point( 7, 253 );
point( 151, 187 );
point( 226, 335 );
point( 365, 305 );
point( 256, 213 );
point( 330, 64 );
point( 47, 388 );
point( 118, 308 );
point( 128, 395 );
point( 48, 2 );
point( 207, 122 );
point( 212, 261 );
point( 76, 339 );
point( 261, 63 );
point( 115, 193 );
point( 324, 175 );
point( 284, 114 );
point( 27, 48 );
point( 160, 194 );
point( 222, 151 );
point( 382, 178 );
point( 44, 134 );
point( 173, 321 );
point( 391, 21 );
point( 379, 23 );
point( 10, 114 );
point( 166, 181 );
point( 102, 96 );
point( 10, 53 );
point( 283, 354 );
point( 107, 9 );
point( 35, 16 );
point( 323, 20 );
point( 356, 301 );
point( 157, 26 );
point( 310, 101 );
point( 327, 80 );
point( 100, 287 );
point( 172, 392 );
point( 353, 181 );
point( 98, 211 );
point( 21, 207 );
point( 276, 220 );
point( 357, 4 );
point( 23, 68 );
point( 125, 121 );
point( 278, 251 );
point( 42, 280 );
point( 113, 284 );
point( 56, 216 );
point( 154, 20 );
point( 4, 109 );
point( 21, 387 );
point( 373, 127 );
point( 277, 398 );
point( 15, 387 );
point( 55, 166 );
point( 240, 245 );
point( 274, 326 );
point( 344, 393 );
point( 66, 116 );
point( 260, 388 );
point( 169, 310 );
point( 253, 238 );
point( 134, 148 );
point( 358, 124 );
point( 263, 120 );
point( 204, 194 );
point( 50, 166 );
point( 181, 78 );
point( 99, 1 );
point( 262, 321 );
point( 315, 390 );
point( 135, 114 );
point( 219, 294 );
point( 222, 20 );
point( 361, 165 );
point( 209, 386 );
point( 196, 160 );
point( 23, 264 );
point( 388, 72 );
point( 261, 190 );
point( 37, 364 );
point( 35, 228 );
point( 152, 390 );
point( 47, 204 );
point( 118, 124 );
point( 343, 352 );
point( 123, 246 );
point( 17, 270 );
stroke(random(200, 255));
strokeWeight(2);
point( 235, 344 );
point( 369, 340 );
point( 164, 347 );
point( 348, 311 );
point( 121, 358 );
point( 133, 107 );
point( 177, 93 );
point( 282, 306 );
point( 120, 296 );
point( 235, 330 );
point( 293, 174 );
point( 234, 103 );
point( 21, 291 );
point( 158, 211 );
point( 55, 210 );
point( 326, 75 );
point( 316, 189 );
point( 298, 138 );
point( 184, 318 );
point( 361, 242 );
point( 169, 201 );
point( 275, 137 );
point( 317, 37 );
point( 335, 361 );
point( 271, 383 );
point( 252, 91 );
point( 178, 217 );
point( 266, 264 );
point( 169, 251 );
point( 8, 175 );
point( 76, 296 );
point( 286, 195 );
point( 366, 296 );
point( 174, 298 );
point( 48, 215 );
point( 311, 251 );
point( 349, 29 );
point( 200, 14 );
point( 335, 399 );
point( 379, 275 );
point( 35, 61 );
point( 259, 392 );
point( 285, 212 );
point( 252, 17 );
point( 291, 2 );
point( 227, 66 );
point( 33, 92 );
point( 343, 389 );
point( 106, 243 );
point( 7, 295 );
point( 94, 86 );
point( 129, 239 );
point( 261, 199 );
point( 92, 81 );
point( 304, 266 );
point( 136, 216 );
point( 172, 368 );
point( 251, 11 );
point( 211, 286 );
point( 264, 145 );
point( 381, 245 );
point( 290, 334 );
point( 387, 231 );
point( 75, 168 );
point( 171, 348 );
point( 41, 81 );
point( 326, 103 );
point( 71, 117 );
stroke(random(200, 255));
strokeWeight(3);
point( 37, 278 );
point( 282, 215 );
point( 357, 105 );
point( 155, 231 );
point( 314, 54 );
point( 44, 324 );
point( 388, 124 );
point( 251, 79 );
point( 56, 6 );
point( 1, 291 );
point( 5, 87 );
point( 72, 247 );
point( 144, 35 );
point( 311, 313 );
}
void introStars() { //--------------------------Draw stars for Intro Screen Background (Size 1)
stroke(255);
strokeWeight(1);
for (int i=0; i<8; i++) {//-------------------Because you asked for at least one loop to create a repeating graphic pattern
point(random(0, 400), random(0, 400));
}
point( 316, 27 );
point( 96, 11 );
point( 385, 157 );
point( 300, 143 );
point( 234, 84 );
point( 82, 194 );
point( 93, 200 );
point( 105, 158 );
point( 108, 181 );
point( 378, 175 );
point( 374, 113 );
point( 21, 192 );
point( 79, 126 );
point( 194, 158 );
point( 31, 38 );
point( 191, 1 );
point( 367, 155 );
point( 154, 178 );
point( 289, 14 );
point( 256, 139 );
point( 343, 100 );
point( 125, 50 );
point( 98, 76 );
point( 146, 85 );
point( 71, 21 );
point( 354, 123 );
point( 171, 110 );
point( 324, 173 );
point( 200, 59 );
point( 98, 68 );
point( 275, 28 );
point( 243, 7 );
point( 289, 55 );
point( 44, 120 );
point( 345, 50 );
point( 5, 198 );
point( 30, 192 );
point( 216, 17 );
point( 223, 135 );
point( 258, 181 );
point( 196, 181 );
point( 73, 68 );
point( 2, 152 );
point( 9, 63 );
point( 246, 139 );
point( 69, 149 );
point( 357, 141 );
point( 358, 71 );
point( 305, 82 );
point( 226, 67 );
point( 0, 28 );
point( 101, 73 );
point( 111, 100 );
point( 16, 42 );
point( 381, 61 );
point( 261, 122 );
point( 143, 5 );
point( 133, 123 );
point( 380, 183 );
point( 213, 156 );
point( 39, 43 );
point( 73, 71 );
point( 18, 173 );
point( 12, 128 );
point( 45, 123 );
point( 57, 39 );
point( 327, 54 );
point( 297, 152 );
point( 307, 30 );
point( 362, 166 );
point( 400, 46 );
point( 109, 70 );
point( 37, 33 );
point( 51, 80 );
point( 341, 106 );
point( 375, 33 );
point( 26, 121 );
point( 400, 53 );
point( 174, 22 );
point( 149, 39 );
point( 266, 104 );
point( 375, 11 );
point( 69, 91 );
point( 153, 185 );
point( 131, 120 );
point( 2, 56 );
point( 298, 133 );
point( 17, 181 );
point( 241, 40 );
point( 302, 157 );
point( 88, 176 );
point( 33, 20 );
point( 235, 90 );
point( 88, 15 );
point( 308, 91 );
point( 297, 171 );
point( 332, 15 );
point( 267, 124 );
point( 74, 180 );
point( 312, 118 );
point( 379, 154 );
point( 370, 14 );
point( 326, 189 );
point( 328, 126 );
point( 191, 180 );
point( 280, 164 );
point( 69, 99 );
point( 307, 182 );
point( 72, 6 );
point( 174, 88 );
strokeWeight(2);//----------------------------Draw stars for Intro Screen Background (Size 2)
point( 365, 191 );
point( 366, 11 );
point( 324, 25 );
point( 292, 35 );
point( 254, 189 );
point( 71, 185 );
point( 80, 98 );
point( 127, 107 );
point( 173, 199 );
point( 57, 101 );
point( 389, 176 );
point( 99, 92 );
point( 184, 76 );
point( 242, 154 );
point( 130, 73 );
point( 368, 11 );
point( 225, 30 );
point( 82, 179 );
point( 98, 95 );
point( 242, 18 );
point( 379, 36 );
point( 178, 173 );
point( 177, 118 );
point( 283, 158 );
strokeWeight(3);//------------------------------Draw stars for Intro Screen Background (Size 3)
point( 241, 4 );
point( 63, 99 );
point( 150, 86 );
point( 367, 173 );
point( 283, 59 );
point( 41, 117 );
point( 206, 81 );
point( 15, 75 );
point( 152, 127 );
point( 338, 3 );
point( 391, 6 );
point( 185, 53 );
point( 155, 11 );
point( 197, 48 );
point( 0, 196 );
point( 94, 169 );
}