Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* On the first day at UCSC me and my partner saw people on bikes and the sun setting.
- We recreated that scene to demonstrate a bike moving to the right over and over again in UCSC and the sun setting*/
- void setup() {
- //the frame is made 500 by 500 pixels and made to look nice!//
- size(500, 500);
- smooth();
- }
- //all magic numbers are turned into variables//
- int trans1x = 250;
- int trans1y = 250;
- int floor_leftx = 0;
- int floor_lefty = 300;
- int floor_rightx = 500;
- int floor_righty = 500;
- int floor_right2y = 350;
- int floorx = 5;
- int floory = 320;
- int floor2x = 110;
- int floor2y = 330;
- int floor3x = 130;
- int floor4x = 235;
- int floor5x = 255;
- int floor6x = 360;
- int floor7x = 380;
- int floor8x = 485;
- int floor_color1 = 255;
- int floor_color2 = 0;
- int floor_color3 = 0;
- int wheel1x = 10;
- int wheel1y = 280;
- int wheel2x = 50;
- int wheel2y = 320;
- int wheel3x = 100;
- int wheel4x = 140;
- int wheel_color = 127;
- int thickness1 = 3;
- int thickness0 = 1;
- int stroke_color = 0;
- int triangle1x = 30;
- int triangle2x = 80;
- int triangle3x = 55;
- int triangle4x = 120;
- int triangle1y = 300;
- int triangle2y = 300;
- int triangle3y = 240;
- int triangle4y = 240;
- int seat1x = 40;
- int seat2x = 70;
- int seat1y = 230;
- int seat2y = 250;
- int front_rod1x = 120;
- int front_rod2x = 120;
- int front_rod1y = 220;
- int front_rod2y = 300;
- int handlex = 100;
- int handle2x = 140;
- int handley = 220;
- int handle2y = 220;
- int brake1x = 65;
- int brake2x = 90;
- int brake1y = 290;
- int brake2y = 310;
- float rotater = 2;
- int tree1x = 50;
- int tree2x = 120;
- int tree3x = 85;
- int tree4x = 160;
- int tree5x = 230;
- int tree6x = 195;
- int tree7x = 270;
- int tree8x = 340;
- int tree9x = 305;
- int tree10x = 380;
- int tree11x = 450;
- int tree12x = 415;
- int tree1y = 230;
- int tree2y = 230;
- int tree3y = 170;
- int trunk1x = 70;
- int trunk2x = 100;
- int trunk3x = 180;
- int trunk4x = 210;
- int trunk5x = 290;
- int trunk6x = 320;
- int trunk7x = 400;
- int trunk8x = 430;
- int trunk1y = 230;
- int trunk2y = 300;
- int trunk_color1 = 36;
- int trunk_color2 = 21;
- void draw() {
- //creates the ground, makes it green, and makes the background blue//
- rectMode(CORNERS);
- ellipseMode(CORNERS);
- background(floor_color2, floor_color3, floor_color1);
- fill(floor_color2, floor_color1, floor_color3);
- rect(floor_leftx, floor_lefty, floor_rightx, floor_righty);
- //creates the black concrete floor and makes the yellow tile dashed lines//
- fill(floor_color2);
- rect(floor_leftx, floor_lefty, floor_rightx, floor_right2y);
- fill(floor_color1, floor_color1, floor_color2);
- rect(floorx, floory, floor2x, floor2y);
- fill(floor_color1, floor_color1, floor_color2);
- rect(floor3x, floory, floor4x, floor2y);
- fill(floor_color1, floor_color1, floor_color2);
- rect(floor5x, floory, floor6x, floor2y);
- fill(floor_color1, floor_color1, floor_color2);
- rect(floor7x, floory, floor8x, floor2y);
- //creates the tree trunks and makes them dark-brown//
- fill(trunk_color1, trunk_color2, trunk_color2);
- noStroke();
- rect(trunk1x, trunk1y, trunk2x, trunk2y);
- rect(trunk3x, trunk1y, trunk4x, trunk2y);
- rect(trunk5x, trunk1y, trunk6x, trunk2y);
- rect(trunk7x, trunk1y, trunk8x, trunk2y);
- //creates the leaf part of the tree and makes them green//
- fill(floor_color2, floor_color1, floor_color2);
- noStroke();
- triangle(tree1x, tree1y, tree2x, tree2y, tree3x, tree3y);
- triangle(tree4x, tree1y, tree5x, tree2y, tree6x, tree3y);
- triangle(tree7x, tree1y, tree8x, tree2y, tree9x, tree3y);
- triangle(tree10x, tree1y, tree11x, tree2y, tree12x, tree3y);
- //creates the wheels, makes them red,and rotates at the same time//
- pushMatrix();
- strokeWeight(thickness1);
- translate(trans1x, trans1y);
- rotate(radians(rotater));
- noFill();
- stroke(floor_color1, floor_color2, floor_color2);
- ellipse(wheel1x, wheel1y, wheel2x, wheel2y);
- trans1x++;
- rotater+=1;
- popMatrix();
- noFill();
- stroke(floor_color1, floor_color2, floor_color2);
- ellipse(wheel3x, wheel1y, wheel4x, wheel2y);
- //creates the connecting rods of the bike itself, and makes it red//
- strokeWeight(thickness0);
- stroke(floor_color1, floor_color2, floor_color2);
- triangle(triangle1x, triangle1y, triangle2x, triangle2y, triangle3x, triangle3y);
- stroke(floor_color1, floor_color2, floor_color2);
- triangle(triangle2x, triangle1y, triangle3x, triangle3y, triangle4x, triangle4y);
- //creates the front rod that connects the front wheel and makes it red//
- fill(floor_color1, floor_color1, floor_color2);
- line(front_rod1x, front_rod1y, front_rod2x, front_rod2y);
- //creates the handle bars and makes them red//
- line(handlex, handley, handle2x, handle2y);
- //creates the brakes and makes them red//
- line(brake1x, brake1y, brake2x, brake2y);
- //creates the seat and makes it yellow//
- fill(floor_color1, floor_color1, floor_color2);
- noStroke();
- ellipse(seat1x, seat1y, seat2x, seat2y);
- //increments the bicycle to the right//
- triangle1x++;
- triangle2x++;
- triangle3x++;
- triangle4x++;
- wheel1x++;
- wheel2x++;
- wheel3x++;
- wheel4x++;
- seat1x++;
- seat2x++;
- front_rod1x++;
- front_rod2x++;
- handlex++;
- handle2x++;
- brake1x++;
- brake2x++;
- //if statement to return the bicycle to its original position once it reaches the end//
- if (wheel1x >= 500 && triangle1x >=500 && seat1x >= 500 && front_rod1x >=500 && handlex >= 500 && brake1x >=500) {
- wheel1x = 10;
- wheel2x = 50;
- wheel3x = 100;
- wheel4x = 140;
- triangle1x = 30;
- triangle2x = 80;
- triangle3x = 55;
- triangle4x =120;
- seat1x = 40;
- seat2x = 70;
- front_rod1x = 120;
- front_rod2x =120;
- handlex = 100;
- handle2x = 120;
- brake1x = 65;
- brake2x = 90;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement