Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. float xMoon;
  2. float yUnicorn;
  3. PImage background;
  4. PImage unicorn;
  5.  
  6.  
  7. void setup(){
  8. size(600,350);
  9. background = loadImage("background.jpg");
  10. unicorn = loadImage("unicorn.png");
  11.  
  12. }
  13.  
  14. void draw(){
  15. image(background,0,0);
  16. ellipse(xMoon,50,50,50);
  17. fill(255,255,0);
  18. image(unicorn,50,yUnicorn,50,50);
  19. xMoon = xMoon + 1;
  20. yUnicorn = yUnicorn +2;
  21.  
  22. if(dist(xMoon,50,50,yUnicorn)<10){
  23. println("Tada");
  24. }
  25.  
  26.  
  27. if(xMoon > 500){
  28. xMoon = 0;
  29. }
  30.  
  31. if(keyPressed){
  32. yUnicorn = yUnicorn - 10; //decreases by 10
  33. }
  34.  
  35. if(yUnicorn >300){
  36. text("Game over",500,300);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement