xxxxxxxxxx
//Project 2b: Infinite Hallway
// Instructions:
// Left mouse click: alternate wireframe
//
// At least one set of conditional statements using if, else if, and else
// • At least one while or for loop
// • Use of the random() function
// • Use of at least one event function, such as: keyPressed(), mousePressed(), mouseMoved(),
// mouseDragged()
// • Attention to visual detail (composition, color, line weight, etc.)
// • A title for the drawing and instructions to the user (included as a //comment in your code)
var boxsize = 100;
var x;
var y;
var z;
var xSpeed=1;
var ySpeed=1;
var zSpeed=1;
var r;
var g;
var b;
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
background(247,208,69);
x=0;
y=0;
z=0;
}
function draw() {
r = random(255);
g = random(255);
b = random(255);
background(247,208,69);
rotateX(frameCount * 0.01);
//Hallway Infrastructure
for (var i = 0; i<=windowWidth; i+=50){
fill(255,117,59,0.25);
stroke(255);
box(i);
}
//Alternate hallway; softer wireframe
if (mouseIsPressed == true) {
background(247,208,69);
for (var i = 0; i<=windowWidth; i+=75){
fill(255,117,59,0.75);
stroke(255,200,59);
box(i);
}
}
//Sprites
// x=x+xSpeed;
// y=y+ySpeed;
// z=z+zSpeed;
fill(r,g,b);
rotateY(frameCount * 0.11);
//rect(x,y,50,50);
push();
translate(x, y, z);
fill(r,g,b);
box(200);
z+=10;
pop();
push();
translate(x-100, y-100, z+100);
fill(r,g,b);
rotateY(frameCount*.05);
box(100);
z--;
pop();
function keyPressed() {
if (keyCode === LEFT_ARROW) {
fill(random(255),random(255),random(255));
sphere(70);
} else if (keyCode === RIGHT_ARROW) {
fill(0);
box(100);
}
}
}