Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PImage diskette;
- PImage world1;
- float rot = 0.0;
- float x = 382;
- float y = 580;
- boolean jump = false;
- boolean up = false;
- int counter = 0;
- boolean start;
- int worldX;
- Magnet magnetList[] = new Magnet[10];
- void setup()
- {
- size(1024,764);
- background(#EBEBEB);
- diskette = loadImage("Diskette.png");
- world1 = loadImage("DisketteWorld.png");
- int x = 900;
- int y = 625 ;
- start = false;
- worldX = 0;
- for(int i = 0; i < magnetList.length; i++)
- {
- magnetList[i] = new Magnet (x,y);
- x += 200;
- y += (int)random(-10,10);
- }
- }
- void draw()
- {
- //here is my background
- image(world1,0,0,width,height, worldX,0,worldX+width,height);
- if(start)
- {
- //for(int i = 0; i < magnetList.length; i++)
- //{
- // magnetList[i].update();
- //}
- }
- fill(#CD5C5C);
- rect(0,650,1023,114);
- updateDiskette();
- }
- void updateDiskette()
- {
- if(jump)
- {
- if(up)
- {
- y-=3;
- counter++;
- if (counter==0)
- {
- up=false;
- counter = -40;
- }
- }
- else //if(!onPlatform())
- {
- y+=3;
- counter++;
- if(counter==0)
- {
- jump = false;
- }
- }
- }
- image(diskette,x,y);
- for(int i = 0; i < magnetList.length; i++)
- {
- if(magnetList[i].getXVal() > x && magnetList[i].getXVal() < x + diskette.width && magnetList[i].getYVal() > y && magnetList[i].getYVal() < y + diskette.height )
- {
- start = false;
- }
- }
- }
- void keyPressed()
- {
- if (keyCode==RIGHT)
- {
- worldX+=4;
- }
- else if(keyCode==LEFT)
- {
- worldX-=4;
- }
- else if(key==' '&&!jump)
- {
- jump = true;
- up = true;
- counter = -40;
- }
- }
- void mouseClicked()
- {
- start = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement