Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float obspos, obsw = 20, h, d, obsspeed = 5;
- boolean gameover = false;
- PImage flappy;
- void setup(){
- size(500, 800);
- obspos = width;
- h = random(50, 600);
- d = random(50, 150);
- flappy = loadImage("flappy.png");
- }
- void draw(){
- if (!gameover){
- background(0, 0, 255);
- obstacle();
- image(flappy, mouseX, mouseY, 50, 50);
- } else {
- }
- }
- void obstacle(){
- fill(0, 255, 0);
- rect(obspos, 0, obsw, h);
- rect(obspos, h + d, obsw, height - (h + d));
- obspos = obspos - obsspeed;
- if (obspos < 0){
- obspos = width;
- h = random(50, 600);
- d = random(50, 150);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement