/*
Freespace Training
By: Khan-ali Ibrahim for IMC @ Sheridan College
September 2016
The entire code relies on basically a parallax/reverse paralax effect to create the illustion of 3d
Instead of moving entire objects, only certain points are moved
When the mouse is moved, the co-ordinates of the object change depending on how far said point would be from the center
ie. the "closer" points of a plane move more than the points "farther" away to create the illusion of perspective
-move mouse to move/look around
-mouse or key press to fire a laser at the enemy
*/
void setup() {
//creates window size
size(400, 400);
//removes cursor
noCursor();
}
void draw() {
frameRate(120);
background(0);
//stars //how am I not dead?
point(363, 93);
point(368, 159);
point(194, 218);
point(2, 392);
point(213, 263);
point(100, 271);
point(286, 151);
point(380, 94);
point(267, 11);
point(398, 328);
point(311, 262);
point(114, 397);
point(78, 47);
point(57, 9);
point(354, 378);
point(315, 383);
point(202, 127);
point(273, 116);
point(285, 155);
point(62, 236);
point(78, 77);
point(64, 322);
point(89, 306);
point(310, 383);
point(387, 308);
point(278, 305);
point(91, 254);
point(106, 133);
point(287, 106);
point(13, 201);
point(231, 227);
point(83, 341);
point(355, 167);
point(77, 356);
point(7, 188);
point(124, 219);
point(183, 336);
point(33, 366);
point(186, 246);
point(363, 2);
point(253, 247);
point(3, 387);
point(369, 70);
point(120, 117);
point(374, 197);
point(267, 303);
point(188, 223);
point(251, 355);
point(65, 166);
point(178, 64);
point(260, 310);
point(333, 320);
point(78, 238);
point(56, 327);
point(382, 358);
point(102, 358);
point(169, 178);
point(32, 187);
point(302, 239);
point(34, 9);
point(223, 304);
point(288, 108);
//Enemy Spaceship
strokeWeight(0.5);
///its just a cube
quad(190 - (mouseX - width/2) * 3.5, 190 - (mouseY - width/2) * 3.5, 190 - (mouseX - width/2) * 3.5, 210 - (mouseY - width/2) * 3.5,
190 - (mouseX - width/2) * 3.7, 210 - (mouseY - width/2) * 3.7, 190 - (mouseX - width/2) * 3.7, 190 - (mouseY - width/2) * 3.7);
quad(190 - (mouseX - width/2) * 3.5, 210 - (mouseY - width/2) * 3.5, 210 - (mouseX - width/2) * 3.5, 210 - (mouseY - width/2) * 3.5,
210 - (mouseX - width/2) * 3.7, 210 - (mouseY - width/2) * 3.7, 190 - (mouseX - width/2) * 3.7, 210 - (mouseY - width/2) * 3.7);
quad(210 - (mouseX - width/2) * 3.5, 210 - (mouseY - width/2) * 3.5, 210 - (mouseX - width/2) * 3.5, 190 - (mouseY - width/2) * 3.5,
210 - (mouseX - width/2) * 3.7, 190 - (mouseY - width/2) * 3.7, 210 - (mouseX - width/2) * 3.7, 210 - (mouseY - width/2) * 3.7);
quad(210 - (mouseX - width/2) * 3.5, 190 - (mouseY - width/2) * 3.5, 190 - (mouseX - width/2) * 3.5, 190 - (mouseY - width/2) * 3.5,
190 - (mouseX - width/2) * 3.7, 190 - (mouseY - width/2) * 3.7, 210 - (mouseX - width/2) * 3.7, 190 - (mouseY - width/2) * 3.7);
//outside area
stroke(255);
strokeWeight(1);
fill(0);
///walls
quad(0, 0, 0, 400,
100 - (mouseX - width/2) * 3, 300 - (mouseY - width/2) * 3, 100 - (mouseX - width/2) * 3, 100 - (mouseY - width/2) * 3); //L
quad(0, 400, 400, 400,
300 - (mouseX - width/2) * 3, 300 - (mouseY - width/2) * 3, 100 - (mouseX - width/2) * 3, 300 - (mouseY - width/2) * 3); //D
quad(400, 400, 400, 0,
300 - (mouseX - width/2) * 3, 100 - (mouseY - width/2) * 3, 300 - (mouseX - width/2) * 3, 300 - (mouseY - width/2) * 3); //R
//quad(400, 0, 0, 0,
//100 - (mouseX - width/2) * 3, 100 - (mouseY - width/2) * 3, 300 - (mouseX - width/2) * 3, 100 - (mouseY - width/2) * 3); //U
//Spaceshit - not fixing that spelling mistake
///black backing
fill(0);
noStroke();
//body
quad(180 + (mouseX - width/2) * 2.5, 180 + (mouseY - width/2) * 2.5, 220 + (mouseX - width/2) * 2.5, 180 + (mouseY - width/2) * 2.5,
220 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2, 180 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2);
quad(180 + (mouseX - width/2) * 2.5, 220 + (mouseY - width/2) * 2.5, 220 + (mouseX - width/2) * 2.5, 220 + (mouseY - width/2) * 2.5,
220 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2, 180 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2);
line(180 + (mouseX - width/2) * 2.5, 180 + (mouseY - width/2) * 2.5, 180 + (mouseX - width/2) * 2.5, 220 + (mouseY - width/2) * 2.5);
line(220 + (mouseX - width/2) * 2.5, 180 + (mouseY - width/2) * 2.5, 220 + (mouseX - width/2) * 2.5, 220 + (mouseY - width/2) * 2.5);
//wings
triangle(180 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2,
180 + (mouseX - width/2) * 2.5, 200 + (mouseY - width/2) * 2.5,
120 + (mouseX - width/2) * 2.5, 200 + (mouseY - width/2) * 2.5);
triangle(220 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2,
220 + (mouseX - width/2) * 2.5, 200 + (mouseY - width/2) * 2.5,
280 + (mouseX - width/2) * 2.5, 200 + (mouseY - width/2) * 2.5);
///wireframe
noFill();
stroke(255);
strokeWeight(2);
//body
quad(180 + (mouseX - width/2) * 2.5, 180 + (mouseY - width/2) * 2.5, 220 + (mouseX - width/2) * 2.5, 180 + (mouseY - width/2) * 2.5,
220 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2, 180 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2);
quad(180 + (mouseX - width/2) * 2.5, 220 + (mouseY - width/2) * 2.5, 220 + (mouseX - width/2) * 2.5, 220 + (mouseY - width/2) * 2.5,
220 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2, 180 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2);
line(180 + (mouseX - width/2) * 2.5, 180 + (mouseY - width/2) * 2.5, 180 + (mouseX - width/2) * 2.5, 220 + (mouseY - width/2) * 2.5);
line(220 + (mouseX - width/2) * 2.5, 180 + (mouseY - width/2) * 2.5, 220 + (mouseX - width/2) * 2.5, 220 + (mouseY - width/2) * 2.5);
//wings
triangle(180 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2,
180 + (mouseX - width/2) * 2.5, 200 + (mouseY - width/2) * 2.5,
120 + (mouseX - width/2) * 2.5, 200 + (mouseY - width/2) * 2.5);
triangle(220 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2,
220 + (mouseX - width/2) * 2.5, 200 + (mouseY - width/2) * 2.5,
280 + (mouseX - width/2) * 2.5, 200 + (mouseY - width/2) * 2.5);
}
//when a key or mouse is pressed, fires a laser at the enemy
void mousePressed() {
frameRate(4);
//FIRING THE LAZER BWWAAAAGGGG
line(180 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2, 200 - (mouseX - width/2) * 3.5, 200 - (mouseY - width/2) * 3.5);
line(220 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2, 200 - (mouseX - width/2) * 3.5, 200 - (mouseY - width/2) * 3.5);
}
void keyPressed() {
frameRate(4);
//FIRING THE LAZER BWWAAAAGGGG
line(180 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2, 200 - (mouseX - width/2) * 3.5, 200 - (mouseY - width/2) * 3.5);
line(220 + (mouseX - width/2) * 2, 200 + (mouseY - width/2) * 2, 200 - (mouseX - width/2) * 3.5, 200 - (mouseY - width/2) * 3.5);
}
//how am I not dead