Advertisement
MrsMcLead

Diskette 3.0

Feb 16th, 2016
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. PImage diskette;
  2. PImage world1;
  3. float rot = 0.0;
  4. float x = 382;
  5. float y = 580;
  6. boolean jump = false;
  7. boolean up = false;
  8. int counter = 0;
  9.  
  10. boolean start;
  11. int worldX;
  12.  
  13. Magnet magnetList[] = new Magnet[10];
  14.  
  15. void setup()
  16. {
  17.  size(1024,764);
  18.  background(#EBEBEB);
  19.  diskette = loadImage("Diskette.png");
  20.  world1 = loadImage("DisketteWorld.png");
  21.  
  22.  
  23.  int x = 900;
  24.  int y = 625 ;
  25.  start = false;
  26.  worldX = 0;
  27.  
  28.  
  29.  for(int i = 0; i < magnetList.length; i++)
  30.  {
  31.     magnetList[i] = new Magnet (x,y);
  32.     x += 200;
  33.     y += (int)random(-10,10);
  34.  }
  35.  
  36.  
  37. }
  38.  
  39. void draw()
  40. {
  41.  //here is my background
  42.  image(world1,0,0,width,height, worldX,0,worldX+width,height);
  43.  
  44.   if(start)
  45.  {
  46.  
  47.  //for(int i = 0; i < magnetList.length; i++)
  48.  //{
  49.  //   magnetList[i].update();
  50.    
  51.  //}
  52.  }
  53.    
  54.   fill(#CD5C5C);
  55.   rect(0,650,1023,114);
  56.   updateDiskette();
  57.  
  58. }
  59.  
  60. void updateDiskette()
  61. {
  62.  
  63.  
  64.   if(jump)
  65.   {
  66.     if(up)
  67.     {
  68.       y-=3;
  69.       counter++;
  70.       if (counter==0)
  71.         {
  72.          up=false;
  73.          counter = -40;
  74.         }
  75.     }
  76.     else //if(!onPlatform())
  77.     {
  78.       y+=3;
  79.       counter++;
  80.       if(counter==0)
  81.       {
  82.        jump = false;
  83.       }
  84.     }
  85.   }
  86.  
  87.   image(diskette,x,y);
  88.    for(int i = 0; i < magnetList.length; i++)
  89.   {
  90.    if(magnetList[i].getXVal() > x && magnetList[i].getXVal() < x + diskette.width && magnetList[i].getYVal() > y && magnetList[i].getYVal() < y + diskette.height )
  91.    {
  92.     start = false;
  93.    }
  94.   }
  95. }
  96. void keyPressed()
  97. {
  98.  if (keyCode==RIGHT)
  99.  {
  100.    worldX+=4;
  101.  }
  102.  else if(keyCode==LEFT)
  103.  {
  104.   worldX-=4;
  105.  }
  106.  else if(key==' '&&!jump)
  107.  {
  108.   jump = true;
  109.   up = true;
  110.   counter = -40;
  111.  }
  112.  
  113. }
  114.  
  115. void mouseClicked()
  116. {
  117.  start = true;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement