Final Project: Covid-19 Precaution Simulator

In my final project, I showcase somewhat of a Covid-19 Precaution Simulation. The user is situated in the right side of the window and with the refreshing of the page, red virus balls and green mask/safety balls appear. The red viruses will come across the page at different speeds and sizes to symbolize the various ways of possibly contracting Covid-19. Hovering over the green safety orbs will help the users glowing shield to grow larger and brighter. As the shield grows, the viruses will be eliminated; at one point due to the immense “precautions and safety measures” that have been collected/taken by the user, the viruses die before reaching the shield, signifying that we can never be too safe in these times.

sketch
var shieldAttribute; //tracks size + color of shield
var mask=[]; //masks (green circles)
var virus = []; //virus (red circles)
var virusCount=10; //number of virus
var maskCount =15 // number of masks
var waves=10;
var x;
var y;
var speed;
var maskx;
var masky;
var maskr;
var checkMask;
var checkVirus;

function setup() {
  createCanvas(600, 400);
  shieldAttribute = 60; 
  for (var i = 0; i < virusCount; i++) {  //setting up to create virus objects
    var x;
    var y;
    var speed ;
    virus[i] = new Covid19(x, y, speed);
  }
  let checkMask = false;
  for (var j = 0; j < maskCount; j++) {  //creat mask objects
    mask[j] = new Masks(maskx, masky, maskr);
  }
}

function draw() {
  background(0);
  userGen();  //create user + shield 
  for (var i = 0; i < virusCount ; i++){  //functionality of virus implemented
    virus[i].generate();
    virus[i].forward();
    if(dist(virus[i].x, virus[i].y, 550, height/2)<= shieldAttribute-120){  //the virus balls get eliminated as they approach the growing shield
    virus[i].x = -600
  }
  }
  for (var j = 0; j < maskCount ; j++){  //functionality of virus implemented
    mask[j].build();
    mask[j].collect();
    mask[j].move();
  } 
}
//function for creating user
function userGen(){
  noStroke();
  fill(20,255,238,shieldAttribute/5);  //shield
  ellipse(550, height/2, shieldAttribute, shieldAttribute);
  
  fill(60, 198, 177);  //user circle
  ellipse(550, height/2 ,40, 40);
}

//COVID19 VIRUS CLASS
class Covid19 {
  constructor(){
    this.x = 0;
    this.y = random(20, 380);
    this.speed = random(0.5,2.5);
    this.virRad = random (30,50);
    this.checkVirus = false;
  }
  
  forward (){
  //  for (var i = 0; i < 5; i++){
    this.x += this.speed;
  }
  
  generate (){   //create the virus
    if (this.checkVirus == false){
    noStroke();
    fill(255,80,10);
    ellipse(this.x, this.y, this.virRad, this.virRad);
    }
  }
}

//MASK CLASS
class Masks {  
  constructor(){
    this.maskx = random(550);
    this.masky = random(350);
    this.maskr = random(10,80);
    this.checkMask = false;
  }
  
  build(){   //create the mask
    noStroke();  
    fill(50,240,80);
    if (this.checkMask == false){
    ellipse(this.maskx, this.masky, this.maskr);
    }
  }
  collect(){   //the mask balls disappear when hovered over, giving the illusion of "collecting"
    let d = dist(mouseX, mouseY, this.maskx , this.masky);
    if (d <= 20){
      shieldAttribute += this.maskr;
      this.checkMask = true;
      this.maskx = -600
      this.masky = -600
      this.maskr = 0
    }
  }
  
  move(){    //masks jittering to make collecting a bit more difficult
    this.maskx += random(-2,2);
    this.masky += random(-2,2);
  }
  
}

Final Project-Protect Sam from Coronavirus!

This project was inspired by the biggest theme of the year 2020—COVID-19. It is an invisible enemy that humanities struggled to fight against. The U.S. is surely losing the war on COVID-19, but it did not have to be this way. If people are more aware of how they could be infected by the virus, and understand how to protect themselves, then the pandemic would be more under control. I wanted this program to be educational and relatable to the player.

In my program, the players need to actively engage in using three different tools to protect the character from the coronavirus for 80 seconds. By applying the mask to Sam’s face, you could protect him from viruses that are spreading through the air. By sanitizing the table with disinfectant spray, you could prevent viruses from getting attached to Sam’s hand. However, there might be a few viruses that survived or escaped from the spray, so you need to apply hand sanitizer constantly just in case Sam starts rubbing his eyes.

If I had more time, I probably will explore how to parent the virus to the hand once it is attached. I would also like to make the background and surrounding more like a public space where other characters are also involved in this interaction.

sketch
//jiaqiwa2; Jiaqi Wang; Section C
//final project fall 2020 15-104
var num=0;
var VirusA;
var VirusS;
//the mask variables
var MaskPic;
var mx=445;
var my=60;
var mdragging=false;
var offsetMX;
var offsetMY;
var fhighlight=false;
var maskON=false;

//variables for virus
var airVirus=[];
var surfVirus=[];


//the spray variable
var Spray;
var sx=460;
var sy=125;
var sdragging=false;
var offsetSX;
var offsetSY;
var shighlight=false;
var SprayON=false;
var Sapplied=false;

//variables for animation
var Writing=[];
var Drinking=[];
var Rubbing=[];
var rubbing=false;
var count=0;
var stopwatch=0;
var EndGame=false;
var z;
var win=false;

var mug;
//the hand sanitizer variables
var handSanitizer;
var hx=480;
var hy=230;
var hdragging=false;
var offsetHX;
var offsetHY;
var Hhighlight=false;
var HON=false;
var Happlied=false;


function preload(){
 VirusA=loadImage("https://i.imgur.com/teJshOW.png");
 VirusS=loadImage("https://i.imgur.com/Vs0Z6HV.png");
 Mask=loadImage("https://i.imgur.com/3KxEFPC.png");
 Spray=loadImage("https://i.imgur.com/u0X1SgO.png");


 //writing
 var filenames = [];
    filenames[0] = "https://i.imgur.com/YJbLiPT.png";
    filenames[1] = "https://i.imgur.com/HCMWQFZ.png";
    filenames[2] = "https://i.imgur.com/rx4PTch.png";
    filenames[3] = "https://i.imgur.com/lI2EDs4.png";
    filenames[4] = "https://i.imgur.com/K4I9fup.png";
    filenames[5] = "https://i.imgur.com/EUNV9c7.png";
    filenames[6] = "https://i.imgur.com/HCMWQFZ.png";
    filenames[7] = "https://i.imgur.com/YJbLiPT.png";
    filenames[8] = "https://i.imgur.com/HCMWQFZ.png";
	filenames[9] = "https://i.imgur.com/YJbLiPT.png";
	filenames[10] = "https://i.imgur.com/HCMWQFZ.png";
    filenames[11] = "https://i.imgur.com/YJbLiPT.png";
    filenames[12] = "https://i.imgur.com/HCMWQFZ.png";
	filenames[13] = "https://i.imgur.com/YJbLiPT.png";

	for (var i = 0; i<filenames.length; i++) {
        Writing[i] = loadImage(filenames[i]);
    }
//drinking
var filenames2 = [];
    filenames2[0] = "https://i.imgur.com/YI78DMb.png";
    filenames2[1] = "https://i.imgur.com/pFFMlNc.png";
    filenames2[2] = "https://i.imgur.com/M6VWA4T.png";
    filenames2[3] = "https://i.imgur.com/YIN1o3J.png";
    filenames2[4] = "https://i.imgur.com/Eu7gh1b.png";
    filenames2[5] = "https://i.imgur.com/UlWmeif.png";
    filenames2[6] = "https://i.imgur.com/WFkzYAg.png";
    filenames2[7] = "https://i.imgur.com/xjnNAFU.png";
    filenames2[8] = "https://i.imgur.com/ISv7MwT.png";
	filenames2[9] = "https://i.imgur.com/X6FYgwF.png";
	filenames2[10] = "https://i.imgur.com/ISv7MwT.png";
	filenames2[11] = "https://i.imgur.com/xjnNAFU.png";
	filenames2[12] = "https://i.imgur.com/WFkzYAg.png";
	filenames2[13] = "https://i.imgur.com/UlWmeif.png";
	filenames2[14] = "https://i.imgur.com/Eu7gh1b.png";
	filenames2[15] = "https://i.imgur.com/YIN1o3J.png";
	filenames2[16] = "https://i.imgur.com/M6VWA4T.png";
	filenames2[17] = "https://i.imgur.com/pFFMlNc.png";
	 
    for (var i = 0; i<filenames2.length; i++) {
        Drinking[i] = loadImage(filenames2[i]);
    }
    // mug
    mug=loadImage("https://i.imgur.com/rlJA4yY.png");
    //hand sanitizer
    handSanitizer=loadImage("https://i.imgur.com/d5h6GeR.png");
//rubbing
var filenames3 = [];
    filenames3[0] = "https://i.imgur.com/B1Kr1t2.png";
    filenames3[1] = "https://i.imgur.com/8T6UUR4.png";
    filenames3[2] = "https://i.imgur.com/untVivz.png";
    filenames3[3] = "https://i.imgur.com/DaIu3C6.png";
    filenames3[4] = "https://i.imgur.com/Wvif1mI.png";
    filenames3[5] = "https://i.imgur.com/66gOJPD.png";
    filenames3[6] = "https://i.imgur.com/XhPbm01.png";
    filenames3[7] = "https://i.imgur.com/bDfotS2.png";
    filenames3[8] = "https://i.imgur.com/dzKQ4d7.png";
	filenames3[9] = "https://i.imgur.com/N3plYyV.png";
	filenames3[10] = "https://i.imgur.com/dzKQ4d7.png";
	filenames3[11] = "https://i.imgur.com/N3plYyV.png";
	filenames3[12] = "https://i.imgur.com/dzKQ4d7.png";
	filenames3[13] = "https://i.imgur.com/N3plYyV.png";
	filenames3[14] = "https://i.imgur.com/dzKQ4d7.png";
	filenames3[15] = "https://i.imgur.com/bDfotS2.png";
	filenames3[16] = "https://i.imgur.com/XhPbm01.png";
	filenames3[17] = "https://i.imgur.com/66gOJPD.png";
	filenames3[18] = "https://i.imgur.com/Wvif1mI.png";
	filenames3[19] = "https://i.imgur.com/DaIu3C6.png";
	filenames3[20] = "https://i.imgur.com/untVivz.png";
	filenames3[21] = "https://i.imgur.com/8T6UUR4.png";
 
    for (var i = 0; i<filenames3.length; i++) {
        Rubbing[i] = loadImage(filenames3[i]);
    }
}
function setup() {
    createCanvas(560,400);
    for(var i=0;i<3;i++){
    	var brith=random(1,3);
    	airVirus[i]=makeAirVirus(-20*brith,-20*brith,(360+20*brith)/(150*random(2,4)),(120+20*brith)/(150*random(2,4)));
        surfVirus[i]=makeSurfVirus(-20,random(270,380),random(1,3),0);

    }  
    frameRate(10);   
}
function draw() {
	background(220);
	noStroke();
	if(!EndGame){
	    //drinking
	    //drinking will cause mask removal	    
        if((count>=102&count<=119)||(count>=510&&count<=527)||(count>=918&&count<=935)){
        	print("drink");
        	var j=count%17;
        	image(Drinking[j],0,0,560,400);
        	mx=445;
        	my=60;
        	maskON=false;  
        }
        //rubbing
		else if((count>=189&count<=201)||(count>=567&&count<=588)||(count>=987&&count<=1008)){
			 z=count%21;
			 if(z<10) rubbing=true;
			//print("rub",z);
			image(Rubbing[z],0,0,560,400);
			image(mug,88,263,70,65);

		}
		//writing
        else{
        	rubbing=false;
        	var i=count%13;
        	image(Writing[i],0,0,560,400);
        	image(mug,88,263,70,65);

        }
    }

    // the user interface & text
    fill(235,100);
	rect(440,40,100,300);
	strokeWeight(2);
	fill(255,190);
	textSize(12);
	text("PROTECT SAM FROM CORONAVIRUS WITH TOOLS", 10,20);
	push();
	textSize(30);
	var time=floor(80-(map(count,0,1200,0,80,true)));
	text(time,80,50);
	pop();
	text("FOR", 50,40);
	text("SECONDS",120,40);
	text("TOOLS",470,30);
	text("MASK",470,110);
	text("DISINFECTANT",445,200);
	text("SPRAY",470, 215);
	text("HAND",470, 295);
	text("SANITIZER",460, 310);
	
	//display the mask
	image(Mask,mx,my,80,40);
    //display the spray
	image(Spray,sx,sy,50,60);
	//display the hand sanitizer
	image(handSanitizer, hx,hy,17,50);

	//update and show the virus   	
	removeVirusThatHaveSlippedOutOfView();
	addNewVirusWithSomeRandomProbability();

	for(var i=0;i<airVirus.length;i++){
		airVirus[i].range();
	    airVirus[i].move();
	    airVirus[i].show();
	}

	for(var j=0; j<surfVirus.length;j++){
		if(count>=102){
			//print(j);
			surfVirus[j].range();
			surfVirus[j].range2();
			surfVirus[j].move();
			surfVirus[j].show();
			

		}
	}
//show the tools behaviors
	mask();
	spray();
	HSanitizer();


	count++;
	endGame();
	
}

function removeVirusThatHaveSlippedOutOfView(){
    var AVirusToKeep = [];
    var SVirusToKeep = [];
    for (var i = 0; i < airVirus.length; i++){
        if (airVirus[i].x>-60 & airVirus[i].x-60 && airVirus[i].y0 && surfVirus[i].y=250)&&(my<=400)){
			Project_highlight();

		}
		
	}

}

function HSanitizer(){
	//move the hand sanitizer if it is selected
	if(hdragging){
		hx=mouseX+offsetHX;
		hy=mouseY+offsetHY;
	}
	if(Happlied){
		hx=480;
		hy=230;
		protection();
		stopwatch+=1;
		if(stopwatch==10){
			Happlied=false;
			stopwatch=0;
		}
		

	}
    // highlight the effective area of hand sanitizer
    if(Hhighlight){
		highlight(250,260,80,50);
    }

}

function protection(){
	//visual effect for protection
	for(var i=0;i<5; i++){
	push();
	translate(250+random(i*20),280+random(i*20));
	rectMode(CENTER);
	fill(114,204,82,100);
	rect(0,0,20,9);
	rect(0,0,9,20);
	pop();

	}
	
}

//Virus that moves on the surface
function makeSurfVirus(sx,sy,sdx,sdy){
	var sv={x: sx, y: sy, dx: sdx, dy:sdy, attach:false, VirusTransp: false,
			show: SVirusDraw, move:SVirusMove, range: CheckInProjection, range2:SCheckInBound};
		return sv;
}

function SVirusDraw(){
	image(VirusS,this.x,this.y,30,30);
	if(this.attach &!Sapplied){
		textSize(20);
		fill(255,10,10);
		text("!",this.x,this.y);
		
	}
}
function SVirusMove(){
	this.y+=this.dy;
	this.x+=this.dx;
	if(win){
		this.dy=30;
		this.dx=-30;
	}
}

function CheckInProjection(){
	//check if surface Virus get to the spray area
	if(InATriangle(this.x,this.y)){
		//check if spray is applied
		if(Sapplied){
			//reject virus if spray is applied
			print("reject Surface Virus");
			this.dy=5;
		}
		
	}

}
function SCheckInBound(){
	//check if surface virus is being transported
	if(this.VirusTransp){
		this.dx=0;
		this.dy=-20;
		//check if hand reaches the face
		if(z==9){
			EndGame=true;
		}
	}
	//check if surface Virus get to the hand area
	if((this.x>=250)&(this.x<=250+90)&&(this.y>=270)&&(this.y<=270+30)){
		//check if Hand sanitizer is applied
		if(Happlied){
			//reject virus if hand sanitizer is applied
			print("reject Surface Virus");
			this.dx=0;
			this.dy=5;
		}
		else if(! rubbing){
			//if not applied, attach virus to hand, virus stops moving if not rubbing
			print("Attached");
			this.dx=0;
			this.attach=true;
		}
		else if(rubbing& Happlied==false){
			this.VirusTransp=true;
			
		}
	}
}


//Virus that spreads through air
function makeAirVirus(ax,ay,adx,ady){
	var av={x: ax, y: ay, dx: adx, dy: ady, reject: false, 
		range: CheckInBound, show: AVirusDraw, move:AVirusMove};
	return av;
}

function AVirusDraw(){
	image(VirusA,this.x,this.y,30,30);
}

function AVirusMove(){
	if(this.reject){
		//virus go off canvas if you win
		if(win){
			this.dy=50;
			this.dx=50;
		}		
		this.x-=this.dx;
		this.y-=this.dy;		
	}
	else{
		//virus go off canvas if you win
        if(win){
			this.dy=-50;
			this.dx=-50;
		}
		this.x+=this.dx;
		this.y+=this.dy;	
	}
	    
}

function CheckInBound(){
	//check if air Virus get to the face area
	if((this.x>=240)&(this.x<=320)&&(this.y>=70)&&(this.y<=160)){
		//check if mask is on
		if(maskON){
			//reject virus if mask is on
			this.reject=true;
			print("reject Air Virus");
		}
		else{
			//end game if failed to protect face with mask
			EndGame=true;
			

		}
	}
}

function mousePressed(){
	//select mask
	if((mouseX>=445)&(mouseX<=445+80)&&(mouseY>=60)&&(mouseY<=60+40)){
		mdragging=true;
		fhighlight=true;
		offsetMX=mx-mouseX;
		offsetMY=my-mouseY;
	}
	//select spray
	else if((mouseX>=sx)&(mouseX<=sx+50)&&(mouseY>=sy)&&(mouseY<=sy+60)){
		sdragging=true;
		shighlight=true;
		offsetSX=sx-mouseX;
		offsetSY=sy-mouseY;
		
	}
	//select hand sanitizer
	else if((mouseX>=hx)&(mouseX<=hx+17)&&(mouseY>=hy)&&(mouseY<=hy+50)){
		hdragging=true;
		Hhighlight=true;
		offsetHX=hx-mouseX;
		offsetHY=hy-mouseY;
	}


}

function mouseReleased(){
    //when the mouse is released, mask dragging stops
    if((mx>=250)&(mx<=370)&&(my>=90)&&(my<=145)){
    	mdragging = false;
    	mx=260;
    	my=125;
    	maskON=true;
    	fhighlight=false;
    }
    //when the mouse is released, spray dragging stops
    if((sx>=10)&(sx<=320)&&(sy>=250)&&(my<=400)){
    	sdragging = false;
		Sapplied=true;
		sdragging = false;
    	SprayON=true;
    	shighlight=false;

    }
       //when the mouse is released, hand sanitizer dragging stops
    if((hx>=250)&(hx<=250+90)&&(hy>=270)&&(hy<=270+80)){
    	hdragging = false;
		Happlied=true;
		hdragging = false;
    	HON=true;
    	Hhighlight=false;

    }


    
}

function endGame(){
	//lose game
	if(EndGame){
		fill(120,54,55,100);
		rect(0,0,width,height);
		fill(0);
		textSize(20);
		noStroke();
		text("YOU FAILED TO PROTECT SAM:(", width/4,height/2);	
		airVirus.dx=0;
		airVirus.dy=0;
		surfVirus.dx=0;
		
		noLoop();
	}
	//win game
	if(!EndGame& count>=1200){
		win=true;
		fill(120,191,58,100);
		noStroke();
		rect(0,0,width,height);
		push();
		fill(255);
		textSize(20);
		text("YOU PROTECTED SAM :)", width/3,height/2);
		pop();
		airVirus.dx=-100;
		airVirus.dy=-100;
		surfVirus.dx=-100;
		stopwatch+=1;
		if(stopwatch==10){
			fhightlight=false;
			Hhighlight=false;
			shighlight=false;
			noLoop();
			stopwatch=0;
		}
		
	}
	
}
//highlight area for application
function highlight(x,y,w,h){
	noFill();
	stroke(98,232,228,150);
	strokeWeight(3);
	rect(x,y,w,h);

}

function Project_highlight(){
	noFill();
	stroke(98,232,228,150);
	strokeWeight(5);
	triangle(sx,sy+5,sx-90,sy-50, sx-90, sy+60);

}



function InATriangle(px,py){
var x1 = sx;      // three points of the triangle
var y1 = sy+5;
var x2 = sx-90;
var y2 = sy-50;
var x3 = sx-90;
var y3 = sy+60;

  // get the area of the triangle
  var areaOrig = abs( (x2-x1)*(y3-y1) - (x3-x1)*(y2-y1) );

  // get the area of 3 triangles made between the point
  // and the corners of the triangle
  var area1 =    abs( (x1-px)*(y2-py) - (x2-px)*(y1-py) );
  var area2 =    abs( (x2-px)*(y3-py) - (x3-px)*(y2-py) );
  var area3 =    abs( (x3-px)*(y1-py) - (x1-px)*(y3-py) );

  // if the sum of the three areas equals the original,
  // we're inside the triangle!
  if (area1 + area2 + area3 == areaOrig) {
    return true;
  }
  else{
  	return false;
  }

}

Project 15 – COVID Shooter Game

For this project, I was inspired by scrolling shooter games. These games were popular in arcades and on older gaming consoles. I used to play games like these a lot as a kid, so I was really looking forward to creating this. As COVID-19 is something that affected us all this year, I used this theme for my project. You move the ship around in this game by using the WASD keys and you shoot by using the spacebar. The goal is to shoot the coronavirus molecules that are coming at the ship. If you shoot enough, you’ll win the game and prevent the world from getting infected. If the ship gets hit too many times, you’ll lose the game. If too many molecules pass the screen, you’ll lose the game and the world will be infected. There is a bit of a randomness factor to this game as the bullets will shoot from either the left or right gun on the ship. If I had more time, I would have wanted to add animations to this game. For example, I was considering having the viruses explode when hit. 

sketch
//Dreami Chambers; Section C; dreamic@andrew.cmu.edu; Assignment-14-Project

var stars = []
var bullets = []
var viruses = []
var hearts = []
var hearts2 = []
var x = 170 //ship x position
var y = 320 //ship y position
var dx = 0 //ship x velocity
var dy = 0 //ship y velocity
var health = 3
var worldHealth = 3
var virusesHit = 0
var gameStart = false //checks if game was started

function preload() {
	ship=loadImage("https://i.imgur.com/te1SxyO.png")
	bullet=loadImage("https://i.imgur.com/YHVJAW8.png")
	virus=loadImage("https://i.imgur.com/RrjmBFe.png")
	hearts[0]=loadImage("https://i.imgur.com/eEYu6KF.png")
	hearts[1]=loadImage("https://i.imgur.com/xe4b6B7.png")
	hearts[2]=loadImage("https://i.imgur.com/Jupb3vO.png")
	hearts[3]=loadImage("https://i.imgur.com/ByIC9eQ.png")
	hearts2[0]=loadImage("https://i.imgur.com/GdyaHu7.png")
	hearts2[1]=loadImage("https://i.imgur.com/chdj98I.png")
	hearts2[2]=loadImage("https://i.imgur.com/onnPuBv.png")
	hearts2[3]=loadImage("https://i.imgur.com/6ZwZ3ej.png")
} 

function setup() {
	noLoop() //game does not start at first
    createCanvas(400, 400);
    //stars setup
    for (var i = 0; i < 100; i++) {
    	var rx = random(width)
    	var ry = random(height)
    	var rdy = random(4)
        stars[i] = makeStars(rx, ry, 2, rdy)
    }
    //virus setup
    for (var j = 0; j < 1; j++) {
    	var rx = random(50, 350)
    	var ry = random(-50, 0)
        viruses[j] = makeVirus(rx, ry)
    }
}

function draw() {
	background(0)
	//draws, removes, and adds stars
	starUpdate()
	starsRemove()
	starsAdd()
	//draws, removes, and adds viruses
	virusUpdate()
	virusRemove()
	virusAdd()
	//draws and removes bullets
	bulletUpdate()
	bulletRemove()
	image(ship, x, y, 60, 70) //spaceship
	image(hearts[health], 10, 10, 60, 20) //healthbar
	image(hearts2[worldHealth], 330, 10, 60, 20) //world healthbar

	if (gameStart == false){ //if game has not been started, a start message will show
		start()
	}
	if (collides() == true){ //if bullet hits virus, remove virus
		virusesHit += 1
		viruses.splice(0, 1)
	}
	if (collides2() == true){ //if virus hits the spaceship, remove a heart from the healthbar
		health -= 1
		viruses.splice(0, 1)
	}
	if (viruses[0].y > height){
		worldHealth -= 1
		print(worldHealth)
	}
	if (keyIsDown(87) & y > 0){ //move up
		y-=2
	}
	if (keyIsDown(83) && y < 380){ //move down
		y+=2
	}
	if (keyIsDown(68) && x < 380){ //move right
		x+=2
	}
	if (keyIsDown(65) && x > -40){ //move left
		x-=2
	}
	endings() //different ending screens depending on whether or not the game is won
}

function start(){ //start message
	strokeWeight(3)
	stroke(240, 175, 0)
	textSize(40)
	translate(200, 190)
	textAlign(CENTER, CENTER)
	text("Click to Start", 0, 0)
}

function mousePressed(){ //starts game when mouse clicked
	loop()
	gameStart = true
}

//if spacebar pressed, shoot bullet
function keyPressed(){
	if (key === ' '){
		x2 = random([x+5, x+45]) //bullet shoots from either left or right gun
		var bullet = makeBullets(x2, y, 2)
		bullets.push(bullet)
	}
}

//star functions
function starUpdate(){
	for (var i = 0; i < stars.length; i++){
        stars[i].stepFunction()
        stars[i].drawFunction()
	}
}

//removes stars when off screen
function starsRemove(){
	starsToKeep = []
	for (var i = 0; i < stars.length; i++){
        if (stars[i].y + stars[i].size > 0){
        	starsToKeep.push(stars[i])
        }
	}
	stars = starsToKeep
}

//adds new stars
function starsAdd(){
	var starProb = 0.5
	if (random(1) < starProb){
		stars.push(makeStars(random(width), random(-5, 0), 2, random(4)))
	}
}

//moves stars down
function starStep() {
    this.y += this.dy
}

function starDraw() {
	stroke(this.c)
	strokeWeight(this.size)
	point(this.x, this.y)
}

function makeStars(px, py, pdy, ps) {
	var s = {x: px, y: py, dy: pdy, 
		size: ps, c: color(random(200, 255),random(150, 230),random(100, 145)),
		drawFunction: starDraw, stepFunction: starStep
	}
	return s
}

//bullet functions
function bulletUpdate(){
	for (var i = 0; i < bullets.length; i++){
	    bullets[i].stepFunction()
	    bullets[i].drawFunction()
	}
}

//moves bullet up
function bulletStep() {
    this.y -= this.dy
}

function bulletDraw() {
	image(bullet, this.x, this.y, 10, 20)
}

//removes bullet when off screen
function bulletRemove(){
	bulletsToKeep = []
	for (var i = 0; i < bullets.length; i++) {
        if (bullets[i].y > 0){
        	bulletsToKeep.push(bullets[i])
        }
	}
	bullets = bulletsToKeep
}

function makeBullets(px, py, pdy) {
	var b = {x: px, y: py, dy: pdy, 
		drawFunction: bulletDraw, stepFunction: bulletStep
	}
	return b
}

//virus functions
function virusUpdate(){
	for (var i = 0; i < 1; i++){
        viruses[i].stepFunction()
        viruses[i].drawFunction()
	}
}

//adds virus when there are none on the screen
function virusAdd(){
	var virusProb = 0.7
	if (random(1) < virusProb){
		viruses.push(makeVirus(random(50, 350), random(-100, -20)))
	}
}

//removes virus when off screen
function virusRemove(){
	virusToKeep = []
	for (var i = 0; i < viruses.length; i++) {
        if (viruses[i].y < height+2){
        	virusToKeep.push(viruses[i])
        }
	}
	viruses = virusToKeep
}

//moves virus down
function virusStep() {
    this.y += this.dy
}

function virusDraw() {
	image(virus, this.x, this.y, this.size, this.size)
}

function makeVirus(px, py) {
	var v = {x: px, y: py, dy: 2, 
		size: random(40,50),
		drawFunction: virusDraw, stepFunction: virusStep
	}
	return v
}

//checks to see if any bullet hits the virus
function collides() {
	for (var i = 0; i < bullets.length; i++){
		var d = dist(bullets[i].x, bullets[i].y, viruses[0].x, viruses[0].y)
		if (d < viruses[0].size-10){
			return true
		}
	}	
}

//checks to see if any virus hits the spaceship
function collides2() {
	var d = dist(x, y, viruses[0].x, viruses[0].y)
		if (d < viruses[0].size){
			return true
		}
	}

function endings(){
	if (health == 0 ){ //bad ending
		image(hearts[0], 10, 10, 60, 20) //makes sure that the heart bar shows zero hearts
		strokeWeight(3)
		stroke(240, 175, 0)
		textSize(40)
		translate(200, 190)
		textAlign(CENTER, CENTER)
		text("GAME OVER", 0, 0)
		stroke(0)
		fill(240, 175, 0)
		textSize(12)
		translate(0, 40)
		text("You were unable to prevent the spread of the virus.\nBetter luck next time!", 0, 0)
		noLoop()
	}
	if (worldHealth == 0){ //second bad ending
		strokeWeight(3)
		stroke(240, 175, 0)
		textSize(40)
		translate(200, 190)
		textAlign(CENTER, CENTER)
		text("GAME OVER", 0, 0)
		stroke(0)
		fill(240, 175, 0)
		textSize(12)
		translate(0, 40)
		text("You let too many viruses pass and the world has been infected.\nBetter luck next time!", 0, 0)
		noLoop()
	}
	if (virusesHit == 10){ //good ending
		strokeWeight(3)
		stroke(240, 175, 0)
		textSize(40)
		translate(200, 190)
		textAlign(CENTER, CENTER)
		text("YOU WIN", 0, 0)
		stroke(0)
		fill(240, 175, 0)
		textSize(12)
		translate(0, 40)
		text("You have successfully destroyed all the viruses.\nRefresh to play again!", 0, 0)
		noLoop()
	}
}

Project 11: Landscape Story

sketch – Copy
//Rachel Kim
//15-104(Section C)
//rachelki@andrew.cmu.edu
//Project 11


//global variables
var fish = [];

//background variables 
var mountainShapeA= 0.035;
var mountainSpeedA = 0.0009;

var mountainShapeB = 0.0175;
var mountainSpeedB = 0.0005;

var waterShape = 0.003;
var waterSpeed = 0.00005;


function setup() {
    
    createCanvas(480, 480);
    frameRate(10);

    //number of fish
    for (var j = 0; j < 30; j++) {

        fishX = random(width);
        fishY = random(350, 450);
        fish[j] = makeFish(fishX, fishY);

    }

}

function draw(){

    background(255, 225, 225);
    sun();
    mountainB();
    mountainA();
    boatPeople();
    water();
    drawFishies();

}

//LANDSCAPE BKGD ---MOUNTAINS, SUN, WATER
function mountainA(){
    noStroke();
    fill(255, 241, 224);
    beginShape();
    
    for (var i = 0; i < width; i ++){
        var x = (i * mountainShapeA) + (millis() * mountainSpeedA);
        var y = map(noise(x), 0, 1.2, 150, 250);
        vertex(i, y);
    }
    
    vertex(width, height);
    vertex(0, height);
    endShape();
}

function mountainB(){
    noStroke();
    fill(255, 251, 240);
    beginShape();
    
    for (var i = 0; i < width; i ++){
        var x = (i * mountainShapeB) + (millis() * mountainSpeedB);
        var y = map(noise(x), 0, 1.5, 50, 300);
        vertex(i, y);
    }
    
    vertex(width, height);
    vertex(0, height);
    endShape();
}

function sun(){

    noStroke();
    fill(255, 210, 210);
    ellipse(240, 180, 450, 450);
    fill(255, 195, 195);
    ellipse(240, 180, 400, 400);
    fill(255, 187.5, 187.5);
    ellipse(240, 180, 350, 350);
    fill(255, 183, 183);
    ellipse(240, 180, 300, 300);
    fill(255, 175, 175);
    ellipse(240, 180, 250, 250);
    fill(255, 157, 157);
    ellipse(240, 180, 200, 200);
    fill(255, 135, 135);
    ellipse(240, 180, 150, 150);
    fill(255, 123, 123);
    ellipse(240, 180, 100, 100);

}


function water(){

    noStroke();
    fill(255, 218, 203);
    beginShape();
    
    for (var i = 0; i < width; i ++){
        var x = (i * waterShape) + (millis() * waterSpeed);
        var y = map(noise(x), 0, 1.5, 320, 240);
        vertex(i, y);
    }

    vertex(width, height);
    vertex(0, height);
    endShape();

    noStroke();
    fill(255, 228, 213);
    beginShape();
    
    for (var i = 0; i < width; i ++){
        var x = (i * waterShape) + (millis() * waterSpeed);
        var y = map(noise(x), 0, 1.5, 320, 250);
        vertex(i, y);
    }

    vertex(width, height);
    vertex(0, height);
    endShape();
}

//TRAVELLERS
function boatPeople(){

	noStroke();
	fill(217, 154, 144);
    ellipse(330,280, 5, 20);
    ellipse(330, 270, 5, 5);
    ellipse(300,280, 5, 20);
    ellipse(300, 270, 5, 5);
    ellipse(270,280, 5, 20);
    ellipse(270, 270, 5, 5);
    ellipse(250,280, 5, 20);
    ellipse(250, 270, 5, 5);
    ellipse(220,280, 5, 20);
    ellipse(220, 270, 5, 5);
    ellipse(200,280, 5, 20);
    ellipse(200, 270, 5, 5);
    ellipse(175,280, 5, 20);
    ellipse(175, 270, 5, 5);

    noStroke();
    fill(239, 168, 158);
    triangle(258, 250, 140, 250, 258, 100);
    triangle(262, 250, 375, 250, 262, 100);

	strokeWeight(1.5);
	stroke(239, 168, 158);
	line(260, 100, 260, 300);//flag pole

    noStroke();
    fill(239, 168, 158);//color of boat
    arc(255,280, 200, 150, 0, PI); //boat
}

//FISH DETAILS
function drawFish() {
    var tailLength = 7;

    noStroke();
    fill(this.fishColor);
    ellipse(this.fx, this.fy, 12, 6);
    triangle(this.fx + (tailLength / 2.5), this.fy, this.fx + tailLength, this.fy - 2, this.fx + tailLength, this.fy + 2);
}

function makeFish(fishX, fishY) {//fish as object 
    
    var fish = {
    	fishColor: color(random(150,200), 100, 110),
    	fishSpeed: random(-1, -10),
    	fishAction: fishMotion,
        fx: fishX,
        fy: fishY,
        fishMaker: drawFish
    }

    return fish;
}

function fishMotion() { //movement of fish
    this.fx += this.fishSpeed;
    if (this.fx <= -20) {
        this.fx += width;
    }
}

function drawFishies() { //show onto canvas 
    for (i = 0; i < fish.length; i++) {
        fish[i].fishAction();
        fish[i].fishMaker();
    }

}



For this project, I wanted to focus on different aspects that are within a landscape. It was fun to see how many factors make up an environment. With the usage of different topics/functions we learn in labs, I was able to create mountains and water as well as a sea of fish. Lastly, a boat full of people were added to the landscape to show that it is a continuous journey.

LookingOutwards-11

The Problem of Other Minds by Kate Armstrong

One female artist whom I researched was Kate Armstrong. An example of interesting work that she created was The Problem of Other Minds, which is a voice activated robotic sculpture in a glass orb (http://katearmstrong.com/artwork/robot.php). When it hears words that it recognizes, it unrolls paper that has on it it thoughts, observations and diagrams. I found this really unique because it has an interactive aspect, and humans trigger the action that the robot produces. This work was made in 2006, and the unravelling of paper represents how the robot stored information and is now recalling it. To describe the artist, she is a curator and Vancouver based writer. Her practice is interdisciplinary and she works with generative systems, objects, photography, video and many more fields combining art and technology. She has produced many exhibitions over the years and has experience writing for museums, schools, and various presses about her artistic contributions.

Project 11- Landscape

sketchDownload




//Shruti Prasanth
//Section C
//Project 11


var move = 5; 
var cx = 100; //starting location of clouds
var cy = 100; 
var clouds = []; 
var terrainSpeed = 0.0005; 
var terrainDetail = 0.005; 

function setup() {

    createCanvas(480, 480); 
    frameRate(4); 

    //initial display of clouds  
    for(var i = 0; i < 3; i++){
        var cX = random(width); 
        var cY = random(75, 150); 
        clouds[i] = makeClouds(cX, cY); 

    }

}
   
function draw() {
    background(154,73,147);

    //sun
    noStroke(); 
    fill(236,210,108);
    ellipse(width / 3, height / 3, 125, 125);  

    var mountain1 = mountains("#purple", height * 0.20, height * 0.65, 4); //backmost mountain
    var mountain2 = mountains("darkgrey", height * 0.37, height * 0.65, 2); // middle ground mountains 
    var mountain3 = mountains("grey", height * 0.50, height * 0.65, 3); //foreground mountains 


    //ocean 
    noStroke(); 
    fill(137,172,315); 
    rect(0, height * 0.65, width, height * 0.35); 

    //sun reflection 
    noStroke(); 
    fill(250, 103, 71, 100); 
    arc(width / 3, height * 0.65, 125, 125, 0, PI, OPEN);


    update(); 
    removeClouds(); 
    addCloud();   

}

function update(){ //update all the clouds 
    for(var i = 0; i < clouds.length; i++){
        clouds[i].move(); 
        clouds[i].display(); 
    }
}

function removeClouds(){ //checks to see where clouds are and changes positions accordingly
    var cloudKeep = []; 
    for(var i = 0; i < clouds.length; i++){
        if(clouds[i].x + 25 > 0){ // cloud is 50 wide, so 25 is point from center
            cloudKeep.push(clouds[i]); 
        }
    }
    clouds = cloudKeep; //keep only clouds still on screen
}

function addCloud(){ //randomly adds clouds at intervals 
    var newCloud = 0.03; 
    if(random(0,1) < newCloud){
        var cloudY = random(75, 150); 
        clouds.push(makeClouds(480, cloudY)); 
    }
}

function cloudMove(){ // move the clouds 
    this.x += this.speed; 
}

function cloudDisplay(){ //draw the clouds 
    fill(255); //white
    noStroke(); 
    ellipse(this.x, this.y, 90, 15); 
    ellipse(this.x - 25, this.y - 10, 35, 30);
    ellipse(this.x, this.y - 20, 40, 40);
    ellipse(this.x + 20, this.y - 15, 35, 30);  

}

function makeClouds(cloudLocX, cloudLocY){ //cloud object definition 
    var cloud = { x: cloudLocX,
                y: cloudLocY,
                speed: -5, 
                move: cloudMove, 
                display: cloudDisplay}

    return cloud; 
} 
function mountains(color, min, max, noiseS) {

    noStroke(); 
    fill(color); 
    noiseSeed(noiseS); 

    beginShape(); 
    for(var x = 0; x < width; x++){
        var t = (x * terrainDetail + (millis() * terrainSpeed)); 
        var y = map(noise(t), 0, 1, min, max); 
        vertex(x, y); 
    }
    vertex(width, height); 
    vertex(0, height); 
    endShape(); 




}

For this project, I wanted to play with complimentary colors like purple and yellow and create a different version of a sunset landscape. The clouds are moving and the snow peaked mountains fluctuate in peaks.

Project-11

sketch
//Robert Rice
//rdrice
//section c

var sun = {filename:'https://i.imgur.com/74H6zli.png', //original URL https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/7bcda634-15a0-43a8-9de8-2800412220c0/datjxhn-b3b3c9fa-946d-43e2-b2b4-28dc84b56ca0.png/v1/fit/w_150,h_150,strp/retrowave_sun_with_alpha_background_by_robilo_datjxhn-150.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9MTAyNCIsInBhdGgiOiJcL2ZcLzdiY2RhNjM0LTE1YTAtNDNhOC05ZGU4LTI4MDA0MTIyMjBjMFwvZGF0anhobi1iM2IzYzlmYS05NDZkLTQzZTItYjJiNC0yOGRjODRiNTZjYTAucG5nIiwid2lkdGgiOiI8PTEwMjQifV1dLCJhdWQiOlsidXJuOnNlcnZpY2U6aW1hZ2Uub3BlcmF0aW9ucyJdfQ.sdt5sozezYuJLi-b3ecAoqszmafFkXh8VGg3G1-YSqE
            x:300,
            y:175,
            drawFunc: drawImg}

var mustang = {filename:'https://i.imgur.com/ZQ6wSq5.png', //I DREW THIS (i traced it but still)
            x:100,
            y:279,
            drawFunc: drawImg}

var wheels = {filename:'https://i.imgur.com/5edjrVN.png', //I DREW THIS (okay i traced but still its technically original)
            x:103,
            y:289,
            drawFunc: drawImg}


var dx = 2; //the speed at which the furthest background objects pass by

var marketvalue = [];   //Reusing my code from assignment 07-a to make an undulating middleground
var noiseParam = 0;
var noiseStep = 0.005;
var n;  //end reused code, appears as DUNES below

var hills=[];

var sign = 1    //the value that the car is pushed up/down by
var pushCount = 0   //keeps track of how far the car has bumped up/down


function preload() {
    // call loadImage() and loadSound() for all media files here
    sun.image = loadImage(sun.filename);
    mustang.image = loadImage(mustang.filename);
    wheels.image = loadImage(wheels.filename);
}

function setup() {
    createCanvas(500, 300);
    background(0);
    imageMode(CENTER);

    strokeWeight(5);
    stroke(119, 179, 0);

    n = (width / 5) + 1 //sets up initial points for the dunes
    for(i = 0; i <= n; i++) {
        noiseParam = noiseStep*i
        marketvalue[i] = (noise(noiseParam) * 150)+150;
    }
}

function draw() {
    //BEGIN BACKGROUND

    push();
    background(38, 0, 77);  //gradient background
    for(i=0; i<300; i++) {
        strokeWeight(1);
        stroke(255-(0.723*i), 77-(0.256*i), 196-(0.396*i))
        line(0, 299-i, 500, 299-i);
    }
    sun.drawFunc(150, 150); //background Sun
    pop();

    //END BACKGROUND
    //BEGIN HILLS. makes some hills/mesas that lazily move along in the background
    
    push();
    if(random(1) > 0.99) {
        makeHill(random(50, 200), random(50, 125), color(random(169, 189), random(49, 69), random(0, 10)));
    }

    var numH = hills.length;
    if (numH > 0) {
        for (i=0; i<numH; i++) {
            hills[i].drawFunc();
            hills[i].upFunc();
        }

        if (hills[0].x+hills[0].r < 0) {
            hills.shift();
        }
    }
    pop();

    //END HILLS
    //BEGIN DUNES (the 07-a reused code i mentioned)

    push();
    marketvalue.shift();    //gets rid of the first value in the list in order to make room for a new one

    strokeWeight(5);
    stroke(179, 119, 0);
    fill(204, 170, 0);
    beginShape();
    vertex(0, height);
    for(i=0; i<n; i++) {
        vertex(5*i, marketvalue[i])
    }
    vertex(width, height);
    endShape(CLOSE);
    
    noiseParam = noiseParam + noiseStep;    //increases the noise paramter, generates a new rolling value
    marketvalue.push(noise(noiseParam)*150+150); //appends the new value
    pop();

    //END DUNES
    //BEGIN ROAD
    push();
    strokeWeight(20);
    stroke(150);
    line(0, 295, 499, 295)
    stroke(75);
    line(0, 299, 499, 299);
    pop();
    //END ROAD
    //BEGIN CAR
    push();
        mustang.y += sign/4
        wheels.drawFunc(77, 15);
        mustang.drawFunc(100, 35);

    pushCount++
    if (pushCount > 8) {
        sign = -sign
        pushCount = 0
    }
    pop();
    //END CAR
}

//END CODE
//BEGIN HELPERFUNCTIONS

function drawImg(w, h) {
    image(this.image, this.x, this.y, w, h);
}

function makeHill(r, h, c) {
    var newHill = {r: r,
        h: h,
        x: 499,
        y: 299,
        drawFunc: drawHill,
        upFunc: updateHill,
        color: c,
        speed: dx}

    hills.push(newHill);
}

function drawHill() {
    noStroke();
    fill(this.color);
    rect(this.x, this.y, this.r, -this.h);
    ellipse(this.x+this.r/2, this.y-this.h, this.r, this.r);
}

function updateHill() {
    this.x -= this.speed;
}

LO – 11

I’m choosing to focus on FIELD’s “10,000 Digital Paintings,” which is a brochure design for GF Smith (fine quality paper company.) What caught my attention about this project is its beautiful colors and aesthetics and its slight resemblance of paint in water. Looking into it more, I was able to appreciate the practical quality of generative design. FIELD used custom software to generate 10,000 iterations (different views) of a hypercomplex structure. The results are thousands of brochures that are unique yet fit into a cohesive design theme. I find the intersection between modern generative design and the more traditional print medium interesting and relevant to what I want to study. 

The female artist behind FIELD is Vera-Maria Glahn. She started out as a producer and curator of media arts, performance and film for European film and media festivals in 2003. She later studied Visual Communication several years after and co-founded FIELD. FIELD is a creative studio based in London, U.K. specializing in art and technology; they make both independent and commissioned works for brands and cultural institutions.

Generative art in print!

Project 11 – Landscape

I wanted to create a landscape from the perspective of a car driving. You can see the cars on the other side of the road travelling in the opposite direction and the scrolling background. I wanted to have cars pass each other so they have random speeds.

sketchDownload
var trees = [];
var cars = [];
var hillHeight = []; //Stores the y values of the hills
var noiseParam = 5;
var noiseStep = 0.02; //Varies the smoothness of the hills
var x = [];

function setup() {
    createCanvas(480, 480);
    background(220);
    //creates a canvas that starts with trees
    for (var i = 0; i < 10; i++){
        var rx = random(width);
        trees[i] = makeTree(rx);
    }

    //for loop creates the values for the mountains in the background
    for(var i = 0; i<=width/5; i++){
        var n = noise(noiseParam);
        //Adjust size to fit the canvas
        var value = map(n, 0, 1, 0, .5*height);
        hillHeight.push(value);
        noiseParam += noiseStep;
    }

    frameRate(10);
}

function draw() {
    //sky
    background(0, 230, 255);
    //continually makes the mountains in the background scroll
    if(hillHeight.length>width/5){
        hillHeight.shift();
        for(var i = 0; i <= width / 5; i++){
            var n = noise(noiseParam);
            var value = map(n, 0, 1, 0, .5*height);
            hillHeight.push(value);
            noiseParam += noiseStep;
        }
    }
    //color of the hills
    fill(130, 130, 130);
    //creates the shape of hills to be able to fill under the line
    beginShape();
    vertex(0, height);
    for(var i = 0; i <= width/5; i++){
        vertex(i*5, hillHeight[i])
    }
    vertex(width, height);
    endShape();
    //foreground grass
    fill(0, 255, 0);
    noStroke();
    rect(0, 360, width, 120);
    //road
    fill(35);
    stroke(0);
    rect(0, 260, width, 100);
    //background grass
    fill(0, 225, 0);
    noStroke();
    rect(0, 200, width, 60);

    //creates the trees on the canvas and conditions for new/old
    updateAndDisplayTrees();
    removeTreesThatHaveSlippedOutOfView();
    addNewTreesWithSomeRandomProbability();
    //creates the cars on the canvas and conditions for new/old
    updateAndDisplayCars();
    removeCarsThatHaveSlippedOutOfView();
    addNewCarsWithSomeRandomProbability();
}


function updateAndDisplayTrees(){
    // Update the trees' positions, and display them.
    for (var i = 0; i < trees.length; i++){
        trees[i].move();
        trees[i].display();
    }
}


function removeTreesThatHaveSlippedOutOfView(){
    //defines trees that have gone off canvas and recreates the array
    //without those trees
    var treesToKeep = [];
    for (var i = 0; i < trees.length; i++){
        if (trees[i].x + trees[i].breadth > 0) {
            treesToKeep.push(trees[i]);
        }
    }
    trees = treesToKeep;
}


function addNewTreesWithSomeRandomProbability() {
    //add a tree at the end based upon a probability
    var newTreeLikelihood = 0.02;
    if (random(0,1) < newTreeLikelihood) {
        trees.push(makeTree(width));
    }
}


// method to update position of tree every frame
function treeMove() {
    this.x += this.speed;
}


function treeDisplay() {
    fill(255);
    stroke(0);
    push();
    translate(this.x, 240);
    fill(133, 87, 35);
    //tree trunk
    rect(0, -this.tHeight, this.breadth, this.tHeight);
    noStroke();
    //tree branches
    fill(78, 105, 26);
    circle(this.breadth/6, -this.tHeight, this.breadth*2);
    circle(this.breadth*(5/6), -this.tHeight, this.breadth*2);
    circle(this.breadth/2, -this.tHeight-this.breadth/2, this.breadth*2);
    pop();
}


function makeTree(birthLocationX) {
    var tr = {x: birthLocationX,
                //width of the trees
                breadth: random(10, 40),
                speed: -3.0,
                //tree height
                tHeight: random(50, 130),
                move: treeMove,
                display: treeDisplay}
    return tr;
}

function updateAndDisplayCars(){
    // Update the cars' positions, and display them.
    for (var i = 0; i < cars.length; i++){
        cars[i].move();
        cars[i].display();
    }
}


function removeCarsThatHaveSlippedOutOfView(){
    //defines if a car is off the canvas, recreates the array to keep
    //cars still on canvas and remove ones that have moved off
    var carsToKeep = [];
    for (var i = 0; i < cars.length; i++){
        if (cars[i].x + cars[i].breadth > 0) {
            carsToKeep.push(cars[i]);
        }
    }
    cars = carsToKeep;
}


function addNewCarsWithSomeRandomProbability() {
    // Adds a car based upon a probability
    var newCarLikelihood = 0.02;
    if (random(0,1) < newCarLikelihood) {
        cars.push(makeCar(width));
    }
}


// method to update position of tree every frame
function carMove() {
    this.x += this.speed;
}

function carDisplay() {
    //colors the car randomly
    fill(this.clr);
    push();
    translate(this.x, 290);
    //body of the car
    rect(0, 0, this.breadth, 30);
    //windows as roof of the car
    fill(255, 255, 255, 50);
    quad(15, 0, this.breadth*.25, -20, this.breadth*.75,
         -20, this.breadth-5, 0);
    //wheels
    fill(0);
    circle(20, 25, 25);
    circle(80, 25, 25);
    pop();
}

function makeCar(startLocationX){
    var car = {x: startLocationX,
               breadth: 100, // length of car
               //random color of each car
               clr: color(random(255), random(255), random(255)),
               //random speeds of cars
               speed: random(-5, -10),
               move: carMove,
               display: carDisplay}
    return car;
}

LO 11 – Female Practitioners

Creator: Allison Parrish
Piece: Semantic Similarity Chatbot
Date: 2018

Allison Parrish is a programmer and a linguist. Allison currently works at NYU as a faculty member. She also graduated from NYU with her master’s degree. A lot of her projects involve bots and poetry as these are the topics she is most interested in. All of her projects that I have seen mix language and coding to create unique tools and artwork. The Semantic Similarity Chatbot is a creation of hers which allows people to text with historical figures of their choice. She wrote programs that dissected the way that different characters wrote and then added AI that could replicate similar patterns. One of the coolest aspects of this project in my opinion is that fact that it was created for her students to modify. She started with a few people from history, but as a project, she had her students write more code to add even more unique figures. I really enjoy the concept of this and love that she taught her students through such an interesting project.

https://gist.github.com/aparrish/114dd7018134c5da80bae0a101866581

bot screenshot