Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int
- // ball
- x,
- y,
- speed,
- // gates
- w, // half width
- h, // half height
- weight,
- angle;
- void setup() {
- size(1280, 740);
- rectMode (CENTER);
- x = width / 2;
- y = height;
- speed = - (height / 50);
- w = width / 6; // half width
- h = width / 10; // half height
- weight = width / 60;
- angle = w / 4;
- }
- void ball () {
- y += speed;
- if (
- (y < 0) || (
- x > mouseX - w &&
- x < mouseX + w &&
- y < mouseY
- )
- ) {
- y = height;
- x = int (random(width));
- }
- noStroke();
- fill (255);
- circle (x, y, height / 10);
- }
- void net () {
- strokeWeight(5);
- stroke (0);
- for (int y = -h; y < h; y += h / 4) { // horizontal
- // main
- line (mouseX - w + angle, mouseY + y - angle, mouseX + w + angle, mouseY + y - angle);
- //sides
- line (mouseX - w, mouseY + y, mouseX - w + angle, mouseY + y - angle);
- line (mouseX + w, mouseY + y, mouseX + w + angle, mouseY + y - angle);
- }
- for (int x = -w; x < w; x += w / 5){ // vertical
- line (mouseX + x + angle, mouseY - h - angle, mouseX + x + angle, mouseY + h - angle);
- line (mouseX + x, mouseY - h, mouseX + x + angle, mouseY - h - angle);
- }
- }
- void gates () {
- strokeWeight(weight);
- stroke (0);
- noFill ();
- rect ( // back
- mouseX + angle, mouseY - angle,
- w * 2, h * 2,
- width / 500 // suapvalinimas
- );
- // front
- line ( // upper
- mouseX - w, mouseY - h,
- mouseX + w, mouseY - h
- );
- line ( // left
- mouseX - w, mouseY - h,
- mouseX - w, mouseY + h
- );
- line ( // right
- mouseX + w, mouseY - h,
- mouseX + w, mouseY + h
- );
- // angle
- line ( // left top
- mouseX - w,
- mouseY - h,
- mouseX - w + angle,
- mouseY - h - angle
- );
- line ( // left bottom
- mouseX - w,
- mouseY + h,
- mouseX - w + angle,
- mouseY + h - angle
- );
- line ( // right top
- mouseX + w,
- mouseY - h,
- mouseX + w + angle,
- mouseY - h - angle
- );
- line ( // right bottom
- mouseX + w,
- mouseY + h,
- mouseX + w + angle,
- mouseY + h - angle
- );
- }
- void draw() {
- background (125, 255, 125);
- gates ();
- //net ();
- ball();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement