Aayush – Snake Game Inspiration

Link To Video

For my second assignment as I was brainstorming I came across a photo of the Nokia 3310 and I remember the snake game that the phone used to have. I was reminded about how complicated the snake got as the game continued as it got longer. For the assignment I then decided to make that exact pattern but the direction and the orientation will be determined by the computer. The framecount determines when to call the change orientation and direction functions. For the orientation, when called it simply changes from x to y or vice versa. For the direction, it is determine by the modulus of a random number.

 

To make the line more interesting, color is added to the point. Whenever a new point is drawn it is drawn with a new color, when the change color function is called, the red, green and the blue values are changed by 1.  This gives the effect of a smooth color transition.

void setup() {
  size(640, 480);
}

int x = floor(random(640));
int y = floor(random(480));
int orientation = floor(random(10))%2; // 0 -> x, y -> 1
int direction = floor(random(10))%2; // 0 for up or right | 1 for down or left

//colors
int r = floor(random(255));
int rAddition = 1;
int g = floor(random(255));
int gAddition = 1;
int b = floor(random(255));
int bAddition = 1;

void draw() {
  // println(x,y); // debugging code
  int length = floor(random(7)); // to determine of segment
  for (int i=0; i< length; i++)
  {
    strokeWeight(10); // make the point thicker
    drawPoint(); // draw a point
    updateCoordinate();
    offScreenFix();
  }
  int nextInterval = floor(random(25, 60));
  if (frameCount%nextInterval ==0) // to change the direction
  {
    orientation();
    direction();
  }

  changeColor();
}

void offScreenFix() {
  
  //if point off screen
  if (y>478) {
    y-=1;
    println("off screen");
  } else if (y<2) {
    y+=1;
    println("off screen");
  }

  if (x>638) {
    x-=1;
    println("off screen");
  } else if (x<2) {
    x+=1;
    println("off screen");
  }
}


void updateCoordinate() {
  if (orientation == 0) {
    // do x operations
    if (direction == 0) x+=1;
    else if (direction ==1) x-=1;
  } else if (orientation == 1) {
    // do y operations
    if (direction == 1) y+=1;
    else if (direction == 0) y-=1;
  }
}


void orientation() {
  if (orientation==0) orientation = 1;
  else if (orientation==1) orientation = 0;
}

void direction() {  
  direction = floor(random(10))%2;
}

void drawPoint() {
  stroke(r, g, b);
  point(x, y);
}

void changeColor() {
  if (r==255) {
    rAddition = -1;
    r += rAddition;
  } else if (r==0) {
    rAddition = 1;
  }
  if (g==255) {
    gAddition = -1;
  } else if (g==0) {
    gAddition = 1;
  }

  if (b==255) {
    bAddition = -1;
  } else if (g==0) {
    bAddition = 1;
  }
  r += rAddition;
  g += gAddition;
  b += bAddition;
}

 

Aayush Deo: Self Portrait

Self Portrait Aayush

 

For the first assignment for Intro To IM for Fall 2020, we were required to create a self portrait using processing. At the beginning the process seemed a bit daunting as I only had experience create visuals for the web or for print using design tools like Adobe Photoshop and Illustrator. I completed this project by breaking up the feature of the portrait into in different parts and then break up those features [if required] into more parts.

Feature of the face [or the further broken down feature] was a function. I opted to make my the self portrait this way because it made it easy to layer features since I would only have move one line of code to this since a feature is encapsulated as a single function.

The main components of the self portraits were  the face neck and hair. Each of these features were different functions and were called from the “draw” function.

The face was further broken down into components. These were forehead, chin, eyes, eyesbrows, nose and lips.

 

void setup() {
  size(640, 480);
  background(111, 143, 114);
}

int scale = 2;
int faceWidth = 80;

float centerX = 320;
float centerY = 240;

void draw() {
  neck();
  face();
  hair();
}

void face() {
  fill(210, 153, 108); //skin color
  middleOfFace();
  foreHead();
  chin();
  eye();
  eyeBrows();
  nose();
  lips();
}

void foreHead() {
  arc(centerX, centerY-100, faceWidth*scale, 50*scale, PI, 2*PI, OPEN);
}

void middleOfFace() {
  rect(centerX-faceWidth*scale/2, centerY-102, faceWidth*scale, 84);
}

void chin() {
  arc(centerX, centerY-20, faceWidth*scale, 85*scale, 0, PI);
}
void hair() {
  pushStyle();
  fill(0, 0, 0);
  arc(centerX, centerY-105, 160, 105, PI, 2*PI);
  triangle(centerX-faceWidth, centerY-105, centerX-faceWidth+20, centerY-105, centerX-faceWidth, centerY-40);
  triangle(centerX+faceWidth, centerY-105, centerX+faceWidth-20, centerY-105, centerX+faceWidth, centerY-40);
  
    popStyle();
}

void eye() {
  //left sclera
  fill(255, 255, 255);
  arc(centerX-30, centerY-80, 30, 13, PI, PI*2);
  arc(centerX-30, centerY-80, 30, 13, 0, PI);
  //right sclera
  fill(255, 255, 255);
  arc(centerX+30, centerY-80, 30, 13, PI, PI*2);
  arc(centerX+30, centerY-80, 30, 13, 0, PI);

  //iris
  pushStyle();
  fill(0, 0, 0);
  circle(centerX-30, centerY-80, 8);
  circle(centerX+30, centerY-80, 8          );
  popStyle();
}

void eyeBrows() {
  pushStyle();
  noFill();
  stroke(0, 0, 0);
  strokeWeight(2);
  arc(centerX-30, centerY-87, 38, 8, PI, PI*2); //left eyebrow
  arc(centerX+30, centerY-87, 38, 8, PI, PI*2); //right eyebrow
  popStyle();
}

void neck() {
  pushStyle();
  fill(210, 153, 108); //skin color
  noStroke();
  int neckWidth = 55;
  rect(centerX-neckWidth/2, centerY+50, neckWidth, 70);
  popStyle();
}


void nose() {
  int noseWidth=30;
  int yShift = -10;
  fill(217, 168, 130);
  quad(centerX, centerY-45+yShift, centerX-noseWidth/2, centerY+yShift, centerX, centerY+5+yShift, centerX+noseWidth/2, centerY+yShift);
}

void lips() {
  pushStyle();
  fill(210, 153, 133);
  int lipsWidth = 50;
  int lipsHeight = 16;
  ellipse(centerX, centerY+25, lipsWidth, lipsHeight);
  arc(centerX, centerY+23, lipsWidth, 6, 0, PI);
  popStyle();
}