Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PVector location; // Location of shape
- PVector velocity; // Velocity of shape
- PVector gravity; // Gravity acts at the shape's acceleration
- float qtdFrames = 0; //contador de frames
- void setup() {
- size(640,360);
- location = new PVector(30,height-140-30);
- velocity = new PVector(4.9,10);
- gravity = new PVector(0,0.5);
- //frameRate(10);
- }
- void draw() {
- qtdFrames++;
- //println("frameRate", frameRate); //qtd de frames por segundo
- background(225,225,225);
- // Add velocity to the location.
- location.add(velocity);
- // Add gravity to velocity
- velocity.add(gravity);
- // Bounce off edges
- if ((location.x > width-30) || (location.x < 30)) {
- velocity.x = velocity.x * -1;
- //println(qtdFrames, "Frames"); //qtd de frames total para bater na parede
- //println(qtdFrames/frameRate, "Segundos"); //tempo em segundos para bater na parede
- qtdFrames = 0;
- }
- if (location.y > height-140-30) { //105
- // We're reducing velocity ever so slightly
- // when it hits the bottom of the window
- velocity.y = velocity.y * -0.95;
- location.y = height-140-30;
- }
- // Display circle at location vector
- stroke(255);
- strokeWeight(0);
- fill(0);
- ellipse(location.x,location.y,60,60);
- line(0,220,640,220);
- color c = color(175, 100, 220); // Define color 'c'
- fill(c); // Use color variable 'c' as fill color
- rect(0, 220, 640, 220);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement