Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PImage diskette;
- float rot = 0.0;
- float x = 50;
- float y = 680;
- boolean jump = false;
- boolean up = false;
- int counter = 0;
- ArrayList<Integer> platformX = new ArrayList<Integer>();
- ArrayList<Integer> platformY = new ArrayList<Integer>();
- ArrayList<Integer> platformWidth = new ArrayList<Integer>();
- void setup()
- {
- size(1024,864);
- background(#EBEBEB);
- diskette = loadImage("Diskette.png");
- //platform 1
- platformX.add(150);
- platformY.add(625);
- platformWidth.add(100);
- //platform 2
- platformX.add(250);
- platformY.add(500);
- platformWidth.add(250);
- }
- void draw()
- {
- background(#EBEBEB);
- fill(#CD5C5C);
- rect(0,750,1023,114);
- platforms();
- updateDiskette();
- }
- void platforms()
- {
- for(int i = 0; i<platformX.size(); i++)
- {
- rect(platformX.get(i),platformY.get(i),platformWidth.get(i),40);
- }
- }
- void updateDiskette()
- {
- if(jump)
- {
- if(up)
- {
- x+=1.5*(counter+5);
- y-=3*counter*counter;
- counter++;
- if (counter==0)
- {
- up=false;
- }
- }
- else //if(!onPlatform())
- {
- x+=1.5*(counter+5);
- y+=3*counter*counter;
- counter++;
- if(counter==6)
- {
- jump = false;
- }
- }
- }
- // gravity();
- image(diskette,x,y);
- }
- void keyPressed()
- {
- if (keyCode==RIGHT)
- {
- x+=4;
- }
- else if(keyCode==LEFT)
- {
- x-=4;
- }
- else if(key==' '&&!jump)
- {
- jump = true;
- up = true;
- counter = -5;
- }
- }
- // boolean onPlatform()
- // {
- // for(int i = 0; i<platformX.size(); i++)
- // {
- // if((x-80)>platformX.get(i) && x<(platformX.get(i) + platformWidth.get(i))&&y>platformY.get(i)&&(y-80)<(platformY.get(i)+40));
- // {
- // y = platformY.get(i)-80;
- // return true;
- // }
- // }
- // return false;
- // }
- // void gravity()
- // {
- // if(!onPlatform() && !jump && y < 680)
- // {
- // y++;
- // }
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement