Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float xMoon;
- float yUnicorn;
- PImage background;
- PImage unicorn;
- void setup(){
- size(600,350);
- background = loadImage("background.jpg");
- unicorn = loadImage("unicorn.png");
- }
- void draw(){
- image(background,0,0);
- ellipse(xMoon,50,50,50);
- fill(255,255,0);
- image(unicorn,50,yUnicorn,50,50);
- xMoon = xMoon + 1;
- yUnicorn = yUnicorn +2;
- if(dist(xMoon,50,50,yUnicorn)<10){
- println("Tada");
- }
- if(xMoon > 500){
- xMoon = 0;
- }
- if(keyPressed){
- yUnicorn = yUnicorn - 10; //decreases by 10
- }
- if(yUnicorn >300){
- text("Game over",500,300);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement