Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float
- frequency, // dažnis
- // ball
- x,
- y,
- speed;
- int
- // gates
- w, // half width
- h, // half height
- weight,
- angle,
- points = 0; // taškai
- boolean flag = true; // leidžia arba neleidžia didinti greičio
- void setup() {
- size(1280, 740);
- rectMode (CENTER);
- textSize (height / 10);
- frequency = frameRate * 6;
- frameRate (frequency);
- 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) { // jei kamuolys pasiekė viršų
- y = height; // grįžtu į apačią
- x = int (random(width)); // bet kokia x pozicija
- }
- if (points % 4 == 0 && points % 5 != 0)
- flag = true;
- if (points % 5 == 0 && points != 0 && flag == true) { // kas penkis taškus
- --speed;
- //frameRate (frameRate + 5); // alternatyvus variantas didinti greitį
- flag = false;
- }
- noStroke();
- fill (255);
- circle (x, y, height / 10);
- }
- void gates () {
- strokeWeight(weight);
- stroke (0);
- noFill ();
- // back
- rect (mouseX + angle, mouseY - angle, w * 2, h * 2, width / 500); // +suapvalinimas
- // front
- line (mouseX - w, mouseY - h, mouseX + w, mouseY - h); // upper
- line (mouseX - w, mouseY - h, mouseX - w, mouseY + h); // left
- line (mouseX + w, mouseY - h, mouseX + w, mouseY + h); // right
- // angle
- line (mouseX - w,mouseY - h, mouseX - w + angle, mouseY - h - angle); // left top
- line (mouseX - w, mouseY + h, mouseX - w + angle, mouseY + h - angle); // left bottom
- line (mouseX + w, mouseY - h, mouseX + w + angle, mouseY - h - angle); // right top
- line (mouseX + w, mouseY + h, mouseX + w + angle, mouseY + h - angle); // right bottom
- if ( // kamuolys yra vartuose
- x > mouseX - w &&
- x < mouseX + w &&
- y < mouseY &&
- y > mouseY - h
- ) {
- y = height; // grįžtu į apačią
- x = int (random(width)); // bet kokia x pozicija
- ++points; // padidinti taškus
- }
- }
- void draw () {
- background (125, 255, 125);
- gates ();
- ball();
- //println (speed);
- fill (0, 0, 255);
- text (points, width * 0.9, height / 8);
- println (frameRate);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement