Category: Assignment-05-Ten-Lines

10 lines

10 lines to make an infinite hallway. Moving the mouse to the right when you’re at a window will turn the lights on or off. This a very basic version of what I originally wanted to. I was hoping to have the colors fade, not switch.

 

 

float winSpeed;
float winX;
float lineCol, backgroundCol;
float startPoint;


void setup() {
  size(700, 700, P3D);
  winX= width/7;
  lineCol=0;
  backgroundCol=255;
  startPoint=-2500;
}

void draw() {
  noStroke();
   background(backgroundCol);
  // winX= winX-1;
       if (winSpeed > 5300){
          winSpeed=startPoint;
//          if (backgroundCol == 0)backgroundCol=255;
//          if (backgroundCol == 255)backgroundCol=0;
//          if (lineCol == 0)lineCol=255;
//          if (lineCol == 255)lineCol=0;
       }
   winSpeed=winSpeed+20;
   
  moveZ(winX, height/2, startPoint, winSpeed); 
  if (pmouseX < mouseX && winSpeed > 3000 && winSpeed < 3400 ){
     if( backgroundCol == 255 ){
         while (backgroundCol > 0 )
         {backgroundCol= backgroundCol-10;
         }}
     if( backgroundCol == 0 ){
         while (backgroundCol < 255 )
         {backgroundCol= backgroundCol+10;
         }
       }
      if( lineCol == 255 ){
         while (lineCol > 0 )
         {lineCol= lineCol-10;
         }}
     if( lineCol == 0 ){
         while (lineCol < 255 )
         {lineCol= lineCol+10;
         }}
  }
  
  
 
}

void moveZ(float x, float y, float z, float speed) {

  z = z + speed;

  drawDoors(x*2, y, z);//left door
  drawDoors(x*5, y, z+50);//rightdoor
}

void drawDoors(float x, float y, float z) {
  float speed=10;
  float side = 103;
  stroke(lineCol);

//strokeWeight(winSpeed); //uncomment for something different
 //strokeWeight(sqrt(speed/100));
strokeWeight(pow(1.5,winSpeed*.001)-.2);  // the -1 gives the flicker at the beggining
  //REMEBER TO UNCOMMENT ^^^^^^^

  //z = z + speed;
  
  line(x, y+100, z+50, x, y+100, z-50);//top
  line(x, y+side, z-50, x, y-side, z-50);//right
  line(x, y-100, z-50, x, y-100, z+50);//bot
  line(x, y-side, z+50, x, y+side, z+50);//left
 
  //  line(x, y+100, z+50, x, y+100, z-50);//top
  //  line(x, y+side, z-50, x, y-side, z-50);//right
  //  line(x, y-100, z-50, x, y-100, z+50);//bot
  //  line(x, y-side, z+50, x, y+side, z+50);//left
  //     }



  //  beginCamera();
  //  camera(x,y,z+speed,x,y,z+speed, 0, 1, 0);
  //  endCamera();
}

Ten Lines (Evade the Lines)

Sorta broke the color rule (whoops!) but its sorta needed. Here’s a game that only has 10 active lines on the screen, one player line and the rest are white lines meant to dodge. Use left/right arrow keys to dodge the incoming randomly generated lines.
tenline

int speed = 4;//speed
int[] h = new int[10];
int width = 75; //width changes length of lines (lines = width/2)
int height = speed*150; //height (depends on speed for ease on eyes)
int x = 0; //start locatoin for red player line
int switcher = 1;
int start = 0;
int score=0;

void setup(){
  size(width,height);
     background(255);
     for(int i=0;i<10;i++){
  h[i]= -height/9*i+int(random(-20,20));}
}
void draw(){
  noStroke();
  fill(0,0,0);
  rect(0, 0, width, height);
  strokeWeight(5);
 stroke(255,0,0);
 line(x,height-2,x+width/2,height-2);
 stroke(#ffffff);

 for(int k=0;k<10;k++){
 if(switcher>0){start = width/2;}
 else{start =0;}
 line(start,h[k],start+width/2,h[k]);
   //fill(255,0,0);
   //text(k, start, h[k]);
   //fill(#ffffff);
 h[k] = h[k]+speed;//int(float(speed)*random(0,1));
 
 switcher=switcher*-1;
 if(h[k]>height && x==start){println(score);
 fill(#ffffff);
 text("Score: "+score, width/2-23, height/2);
 noLoop();

 }
 if(mousePressed){noLoop();}
 if(h[k]>height){
 h[k] = reset(k);
  // cleanup(k);
 }


 }
}

void keyPressed() {
  if (key == CODED) {
    if (keyCode == LEFT && x>0) {x=x-width/2;}
    else if (keyCode == RIGHT && x0 && h[m]<50) && h[k]< =0){
   for(int j=k; j<10; j++){
     if(h[j]<0){
     h[j]=h[j]-50;}}
   }
}
}

Ten Lines

Yeah I know this one’s kind of lame too, I tried to do something else and it didn’t do what I wanted but I ran out of a) time and b) patience.

tenlines

I was attempting to get the lines to all rotate independently depending on the movement of the mouse but it didn’t work and ended up rotating them all as a massive chunk together. So I goofed around a little and made it so that all the lines move according to the X position of the mouse, but only the bottom five also react to the Y position. It’s a little pointless and not very elegant or interesting sorry.

void setup(){
  size(300,300);
  background(0);
  stroke(255);
  strokeWeight(2);
}

void draw(){
  background(0,0,0);
  rotate(PI/mouseX);
    line(30,30, 50,30);
    line(50,50, 70,50);
    line(70,70, 90,70);
    line(90,90, 110,90);
    line(110,110, 130,110);
    
  rotate(PI/mouseY+100);
    line(130,130, 150,130);
    line(150,150, 170,150);
    line(170,170, 190,170);
    line(190,190, 210,190);
    line(210,210, 230,210);  
  
}

Ten Line

Ten_Line

My initial idea of ten lines was that the lines would move in a line according to the mouse movement and when the mouse stops moving the lines would spread out in circle and turn. However, I couldn’t figure out the way for the lines to follow the path that mouse had moved. So I changed my original idea of the ten lines following the path of mouse and just made the ten lines follow mouse similar to that of one line assignment.

 

float x;
float y;
float easing = 0.05;

void setup(){
    size(600, 600);
}

void draw(){
    background(0);
    stroke(255);
    follow();
}

void follow(){
    float followX = mouseX;
    float distanceX = followX - x;
    float followY = mouseY;
    float distanceY = followY - y;
  if(abs(distanceX)<=1 && abs(distanceY)<=1){
    noFill();
    float cx = mouseX;
    float cy = mouseY;
    int r = 40; 
    float t = millis()/4000.0f;

    for (int i = 1 ; i <= 10; i++) {         t = t + 120;         int x = (int)(cx + r * cos(t));         int y = (int)(cy + r * sin(t));         line(cx, cy, x, y);     }   }   else{     if(abs(distanceX) > 1) {
      x += distanceX * easing;
    }
    if(abs(distanceY) > 1) {
      y += distanceY * easing;
    }
    for (int i = 1; i<=10; i++){
       line(x-15+i*3, y-20, x-15+i*3, y+20);
    }
  }
}

IMG_20141001_145640

Ten Lines: Snappy Bird

tenLines2tenlinesconcept2Using the mouse’s x coordinate as input, I used my ten lines to draw a bird-like head that attempts to eat the mouse as it approaches the right side of the screen. The bird’s pupil also follows the mouse, but is constrained within the eye shape.

//Miranda Jacoby
//EMS Interactivity Section A
//majacoby@andrew.cmu.edu
//Copyright Miranda Jacoby 2014

//Implement offset to create spaces between lines

void setup() {
  size(400, 300);
}

void draw() {
  background(255); 
  strokeWeight(3); 
  
  //Center line
  line (200, 100, 200, 200); //Line 1

  float eyeX1 = map(mouseX, 0, 400, 140, 162);
  float eyeY1 = 150;
  float eyeX2 = map(mouseX, 0, 400, 140, 162);
  float eyeY2 = 160;

  float x1 = 50; 
  float y1 = 50;
  float x2 = 50; 
  float y2 = 150;
  
  
  float x3 = 350; 
  float y3 = 150; 
  float x4 = 350;
  float y4 = 50; 
  
  
//  float x5 = 350; 
//  float y5 = 350;
//  float x6 = 50; 
//  float y6 = 150;
//  
//  
//  float x7 = 350; 
//  float y7 = 150; 
//  float x8 = 350;
//  float y8 = 50; 
  
  //Top beak
  float beakLx1 = map(mouseX, 0,width, x1,x2); 
  float beakLy1 = map(mouseX, 0,width, y1,y2); 
  float beakRx1 = map(mouseX, 0,width, x3,x4); 
  float beakRy1 = map(mouseX, 0,width, y3,y4); 
  line (beakLx1, beakLy1,  beakRx1 , beakRy1 ); //Line 2
  
  //Inner top beak
  line(200, 150, beakRx1, beakRy1); //Line 3
  
  //Bottom beak
//  float beakLx2 = map(mouseX, 0,width, x5,x6); 
//  float beakLy2 = map(mouseX, 0,width, y5,y6); 
//  float beakRx2 = map(mouseX, 0,width, x7,x8); 
//  float beakRy2 = map(mouseX, 0,width, y7,y8); 
//  line (beakLx2, beakLy2,  beakRx2, beakRy2 );
  float beakLx2 = map(mouseX, 0,width, x1,x2); 
  float beakLy2 = map(mouseX, 0,width, y1 + 200 ,y2); 
  float beakRx2 = map(mouseX, 0,width, x3,x4); 
  float beakRy2 = map(mouseX, 0,width, y3, y4 + 200); 
  line (beakLx2, beakLy2,  beakRx2 , beakRy2 ); //Line 4
  
  //Inner bottom beak
  line(200, 150, beakRx2, beakRy2); //Line 5
  
  //Eye Shape
  line(125, 145, 175, 150); //Line 6
  line(175, 150, 150, 175); //Line 7
  line(150, 175, 125, 145); //Line 8
  
  //Pupil
  line(eyeX1, eyeY1, eyeX2, eyeY2); //Line 9
  
  //Back of head
  line(beakLx1, beakLy1, beakLx2, beakLy2); //Line 10
}

Ten Line

tenlinemessage

So according to Golan, apparently my first idea for the ten line assignment was crap, and I agree.   Originally, I intended all three line pieces to be connected to each other and show developmental progress, with more lines leading to more complexity.  For my original ten line step, it was basically a cheap rehash of my one line piece.  So I decided to make a complete overhaul with the same sneaky “flickering” effect to provide an illusion of an order of magnitude more lines in the same scene than what the limitation provided for.  So in my new piece, I have that effect magnified by a power of ten to allow only ten lines to render at any one frame while appearing to hold many more.  An inspirational quote from Golan: “You got ten lines.  What are you gonna do?”

tenlines2