The code is down below.
//declare variables
int locX;
int speedX;
void setup(){
size(800,800);
background(#96F0DD);
speedX=0;
}
void draw(){
//I wanted to make the buildings move the opposite direction
//but I can't figure out how to add another direction
// with mouseX on the right side of the screen.
//float background=map(mouseX,0,width,0,7);
//locX-=background;
float shifter=map(mouseX,0,width,0,10);
locX+=shifter;
background(255);
stroke(0);
fill(#099824);
rect(0,500,width,height);
fill(#04791A);
rect(0,400,width,300);
fill(#005F12);
rect(0,400,width,200);
//sky and stars
strokeWeight(0); stroke(0,0,0,0);
fill(mouseY-220,mouseY-200,mouseY);
rect(0,0,width,500);
fill(mouseY-180,mouseY-150,mouseY);
rect(0,0,width,300);
fill(mouseY-130,mouseY-100,mouseY);
rect(0,0,width,150);
fill(mouseY-70,mouseY-50,mouseY);
rect(0,0,width,50);
stroke(0,0,0,0); strokeWeight(0);
fill(#03A9FF,120);
rect(0,0,width,500);
fill (255,255,240); ellipse (250, 250, 5,5);
ellipse (470, 200, 5,5);
ellipse (780, 60, 5,5);
ellipse (100, 30, 5,5);
ellipse (600, 380, 5,5);
ellipse (360, 300, 5,5);
ellipse (400, 20, 5,5);
ellipse (550, 150, 10,10);
ellipse (500, 100, 10,10);
ellipse (300, 20, 10,10);
ellipse (660, 370, 10,10);
ellipse (750, 260, 10,10);
ellipse (10, 240, 10,10);
ellipse (490, 320, 10,10);
ellipse (170, 280, 10,10);
ellipse (90, 250,10,10);
//city
fill(0);
strokeWeight(1); stroke(#FDFF98);
rect(width/2-35,height/3-300,10,550);
rect(width/2,height/3,100,200);
rect(width/2+100,height/3-100,200,300);
rect(width/2-50,height/3-150,50,400);
rect(width/2-250,height/3-100,200,350);
rect(width/2-325,height/3+50,100,100);
rect(width/2-550,height/3-50,200,250);
strokeWeight(0);
fill(#01460E);
rect(0,height/2+5,width,10);
fill(#D8D8D8);
rect(0,height/2+15,width, 125);
fill(#B4B4B4);
rect(0,height/2+15,width, 50);
strokeWeight(1);
fill(#939393); stroke(0); strokeWeight(0);
rect(0,height/2+15,width, 20);
//car
stroke(0,0,0); strokeWeight(1);
fill(#BCC6C6);
ellipse(locX-3,height/2,25,25);
fill(#FFFFFF);
rect(locX+15,height/2-4,5,10);
rect(locX+20,height/2-4,5,10);
fill(#ED3E3E);
rect(locX-20,height/2,60,20);
//wheels
fill(#343434);
ellipse(locX+25,height/2+15,20,20);
fill(#F0F0F0);
ellipse(locX+25,height/2+15,5,5);
fill(#343434);
ellipse(locX-20,height/2+13,25,25);
fill(#F0F0F0);
ellipse(locX-20,height/2+13,5,5);
strokeWeight(2); stroke(255,255,255);
line(locX-20,height/2,locX-25,height/2-7);
line(locX-30,height/2-7,locX-20,height/2-7);
strokeWeight(1);
fill(0,0,0);
//arc(locX,height/2-40,100,100);
if(locX > 800){
locX= 0;
}
}
No comments:
Post a Comment