Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float rectX;
- float rectY;
- float rectR = 37.5;
- float ballX = 200;
- float ballY = 350;
- float ballR = 25;
- var lives = 3;
- void setup() {
- size(600,400);
- rectY = 0;
- rectX = random(0,600);
- }
- void draw() {
- background(0,0,0);
- string s = "Lives:" + lives;
- textSize(32);
- text(s, 10, 50);
- if( dist(rectX,rectY,ballX,ballY)<= ballR + rectR) {
- background(255,0,0);
- lives = lives - 1;
- }
- rectY += 8;
- fill(255)
- ellipse( rectX, rectY, 75, 75);
- if(rectY > height) {
- rectY = 0;
- rectX = random(0,600);
- }
- ellipse( ballX, ballY, 50, 50);
- }
- void keyPressed() {
- if(key == 'a') {
- ballX = ballX +100;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement