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 > mouseY - h
- )
- ) {
- y = height;
- x = int (random(width));
- }
- noStroke();
- fill (255);
- circle (x, y, height / 10);
- }
- 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