// Asteroid_Field
// By: Lucas Lemmond
// Move the ship with mouse and advoid hiting the astreoids
//Random number for rock X value
float randomStars = random(1, 400);
float randomStars2 = random(1, 400);
float randomRock = (int) random(1, 400);
float randomRock2 = random(1, 400);
float randomRock3 = random(1, 400);
float randomRock4 = random(1, 400);
float randomRock5 = random(1, 400);
float randomRock6 = random(1, 400);
float randomRock7 = random(1, 400);
float randomRock8 = random(1, 400);
float randomRock9 = random(1, 400);
float randomRock10 = random(1, 400);
float randomRock11 = random(1, 400);
float randomRock12 = random(1, 400);
float randomRock13 = random(1, 400);
float randomRock14 = random(1, 400);
float randomRock15 = random(1, 400);
// Random number for rock speed
int Speed = (int) random (1, 6);
int Speed2 = (int) random (1, 6);
int Speed3 = (int) random (1, 6);
int Speed4 = (int) random (1, 6);
int Speed5 = (int) random (1, 6);
int Speed6 = (int) random (1, 6);
int Speed7 = (int) random (1, 6);
int Speed8 = (int) random (1, 6);
int Speed9 = (int) random (1, 6);
int Speed10 = (int) random (1, 6);
int Speed11 = (int) random (1, 6);
int Speed12 = (int) random (1, 6);
int Speed13 = (int) random (1, 6);
int Speed14 = (int) random (1, 6);
int Speed15 = (int) random (1, 6);
//shipMove
int y = 0;
//Speed Value for each rock
int x = 1;
int x2 = 0;
int x3 = 0;
int x4 = 0;
int x5 = 0;
int x6 = 0;
int x7 = 0;
int x8 = 0;
int x9 = 0;
int x10 = 0;
int x11 = 0;
int x12 = 0;
int x13 = 0;
int x14 = 0;
int x15 = 0;
int whiteline = 255;
int blackfill = 0;
////////////////////////////////////////////////////////////////////////////////
void setup() {
//size of window
size(400, 400);
}
/////////////////////////////////////////////////////////////////////////////
//Star Variables (I used these to created the illution that multiple stars are moving across the screen. But actaully its two start moving quickly across the screen)
void randomize() {
randomStars = random(1, 400);
}
void randomize2() {
randomStars2 = random(1, 400);
}
// Loop to make star move
void stars() {
fill(255);
for (int y=0; y!=1; ++y)
rect( randomStars2, randomStars, 1, 1);
//Stars
fill(255);
rect( randomStars, randomStars2, 1, 1);
fill(255);
rect( randomStars, randomStars2, 1, 1);
}
void moveStar() {
//ChangingStars (changes postions of the stars on the screen)
for (int y=0; y!=1; ++y) {
randomize();
randomize2();
}
}
//////////////////////////////////////////////////////////////////////////////
void player() {
//spaceShip (moves on Y axis with mouse)
stroke(255);
fill(0);
triangle( 320, mouseY, 360, mouseY + 10, 360, mouseY - 10);
fill(255);
rect( randomStars, randomStars2, 1, 1);
fill(255);
rect( randomStars, randomStars2, 1, 1);
}
///////////////////////////////////////////////////////////////////////////////
void rock() {
//Space Rock(s)
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x, randomRock, 30, 30);
}
void rock2() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x2, randomRock2, 30, 30);
}
void rock3() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x3, randomRock3, 30, 30);
}
void rock4() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x4, randomRock4, 30, 30);
}
void rock5() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x5, randomRock5, 30, 30);
}
void rock6() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x6, randomRock6, 30, 30);
}
void rock7() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x7, randomRock7, 30, 30);
}
void rock8() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x8, randomRock8, 30, 30);
}
void rock9() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x9, randomRock9, 30, 30);
}
void rock10() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x10, randomRock10, 30, 30);
}
void rock11() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x11, randomRock11, 30, 30);
}
void rock12() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x12, randomRock12, 30, 30);
}
void rock13() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x13, randomRock13, 30, 30);
}
void rock14() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x14, randomRock14, 30, 30);
}
void rock15() {
rectMode(CENTER);
stroke( whiteline);
fill( blackfill);
rect( x15, randomRock15, 30, 30);
}
////////////////////////////////////////////////////////////////////////////////
//Rock(s) Movement This moves the the rocks from right to left. when rock hits the edge it resets.
void moveRock() {
if (x < width) {
x = x + Speed;
}
//Space Rock repeat
else if (x>width) {
x = 1;
}
}
void moveRock2() {
if (x2 < width) {
x2 = x2 + Speed2;
}
//Space Rock repeat
else if (x2>width) {
x2 = 1;
}
}
void moveRock3() {
if (x3 < width) {
x3 = x3 + Speed3;
}
//Space Rock repeat
else if (x3>width) {
x3 = 1;
}
}
void moveRock4() {
if (x4 < width) {
x4 = x4 + Speed4;
}
//Space Rock repeat
else if (x4>width) {
x4 = 1;
}
}
void moveRock5() {
if (x5 < width) {
x5 = x5 + Speed5;
}
//Space Rock repeat
else if (x5>width) {
x5 = 1;
}
}
void moveRock6() {
if (x6 < width) {
x6 = x6 + Speed6;
}
//Space Rock repeat
else if (x6>width) {
x6 = 1;
}
}
void moveRock7() {
if (x7 < width) {
x7 = x7 + Speed7;
}
//Space Rock repeat
else if (x7>width) {
x7 = 1;
}
}
void moveRock8() {
if (x8 < width) {
x8 = x8 + Speed8;
}
//Space Rock repeat
else if (x8>width) {
x8 = 1;
}
}
void moveRock9() {
if (x9 < width) {
x9 = x9 + Speed9;
}
//Space Rock repeat
else if (x9>width) {
x9 = 1;
}
}
void moveRock10() {
if (x10 < width) {
x10 = x10 + Speed10;
}
//Space Rock repeat
else if (x10>width) {
x10 = 1;
}
}
void moveRock11() {
if (x11 < width) {
x11 = x11 + Speed11;
}
//Space Rock repeat
else if (x11>width) {
x11 = 1;
}
}
void moveRock12() {
if (x12 < width) {
x12 = x12 + Speed12;
}
//Space Rock repeat
else if (x12>width) {
x12 = 1;
}
}
void moveRock13() {
if (x13 < width) {
x13 = x13 + Speed13;
}
//Space Rock repeat
else if (x13>width) {
x13 = 1;
}
}
void moveRock14() {
if (x14 < width) {
x14 = x14 + Speed14;
}
//Space Rock repeat
else if (x14>width) {
x14 = 1;
}
}
void moveRock15() {
if (x15 < width) {
x15 = x15 + Speed15;
}
//Space Rock repeat
else if (x15>width) {
x15 = 1;
}
}
////////////////////////////////////////////////////////////////////////////////////
//Rock(s) Hits when the rock hit thes spaceship......
void hitRock() {
if ((randomRock <= mouseY+ 15) && (randomRock >= mouseY- 15)&& x > 320) {
x = 1;
background(255, 0, 0);
}
}
void hitRock2() {
if ((randomRock2 <= mouseY+ 15) && (randomRock2 >= mouseY- 15)&& x2 > 320) {
x2 = 1;
background(255, 0, 0);
}
}
void hitRock3() {
if ((randomRock3 <= mouseY+ 15) && (randomRock3 >= mouseY- 15)&& x3 > 320) {
x3 = 1;
background(255, 0, 0);
}
}
void hitRock4() {
if ((randomRock4 <= mouseY+ 15) && (randomRock4 >= mouseY- 15)&& x4 > 320) {
x4 = 1;
background(255, 0, 0);
}
}
void hitRock5() {
if ((randomRock5 <= mouseY+ 15) && (randomRock5 >= mouseY- 15)&& x5 > 320) {
x5 = 1;
background(255, 0, 0);
}
}
void hitRock6() {
if ((randomRock6 <= mouseY+ 15) && (randomRock6 >= mouseY- 15)&& x6 > 320) {
x6 = 1;
background(255, 0, 0);
}
}
void hitRock7() {
if ((randomRock7 <= mouseY+ 15) && (randomRock7 >= mouseY- 15)&& x7 > 320) {
x7 = 1;
background(255, 0, 0);
}
}
void hitRock8() {
if ((randomRock8 <= mouseY+ 15) && (randomRock8 >= mouseY- 15)&& x8 > 320) {
x8 = 1;
background(255, 0, 0);
}
}
void hitRock9() {
if ((randomRock9 <= mouseY+ 15) && (randomRock9 >= mouseY- 15)&& x9 > 320) {
x9 = 1;
background(255, 0, 0);
}
}
void hitRock10() {
if ((randomRock10 <= mouseY+ 15) && (randomRock10 >= mouseY- 15)&& x10 > 320) {
x10 = 1;
background(255, 0, 0);
}
}
void hitRock11() {
if ((randomRock11 <= mouseY+ 15) && (randomRock11 >= mouseY- 15)&& x11 > 320) {
x11 = 1;
background(255, 0, 0);
}
}
void hitRock12() {
if ((randomRock12 <= mouseY+ 15) && (randomRock12 >= mouseY- 15)&& x12 > 320) {
x12 = 1;
background(255, 0, 0);
}
}
void hitRock13() {
if ((randomRock13 <= mouseY+ 15) && (randomRock13 >= mouseY- 15)&& x13 > 320) {
x13 = 1;
background(255, 0, 0);
}
}
void hitRock14() {
if ((randomRock14 <= mouseY+ 15) && (randomRock14 >= mouseY- 15)&& x14 > 320) {
x14 = 1;
background(255, 0, 0);
}
}
void hitRock15() {
if ((randomRock15 <= mouseY+ 15) && (randomRock15 >= mouseY- 15)&& x15 > 320) {
x15 = 1;
background(255, 0, 0);
}
}
void draw() {
println(mouseY+ 15, mouseY- 15, x, randomRock);
background(0);
player();
rock();
rock2();
rock3();
rock4();
rock5();
rock6();
rock7();
rock8();
rock9();
rock10();
rock11();
rock12();
rock13();
rock14();
rock15();
moveRock();
moveRock2();
moveRock3();
moveRock4();
moveRock5();
moveRock6();
moveRock7();
moveRock8();
moveRock9();
moveRock10();
moveRock11();
moveRock12();
moveRock13();
moveRock14();
moveRock15();
moveStar();
hitRock();
hitRock2();
hitRock3();
hitRock4();
hitRock5();
hitRock6();
hitRock7();
hitRock8();
hitRock9();
hitRock10();
hitRock11();
hitRock12();
hitRock13();
hitRock14();
hitRock15();
}