Guest User

Untitled

a guest
Oct 18th, 2019
381
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PImage elevator;
  2. int yPos=0, elevatorPos;
  3. boolean start;
  4. int inverter, down;
  5.  
  6. void setup() {
  7. size(200, 400);
  8. background(255);
  9. elevator = loadImage("elevator.jpg");
  10. }
  11.  
  12. void draw() {
  13. background(255);
  14.  
  15. strokeWeight(4);
  16. line(width/2, 0, width/2, height);
  17.  
  18.  
  19. start = (mousePressed && (mouseButton == LEFT));
  20.  
  21. //Condition
  22.  
  23. if (start) {
  24.  
  25. yPos = yPos +1;
  26.  
  27. if (inverter % 2 != 0) {
  28. down = down +2;
  29. }
  30. }
  31.  
  32. //Modulo
  33.  
  34. inverter = yPos/(height-elevator.height);
  35.  
  36. //Lift Movement
  37.  
  38.  
  39. elevatorPos= (height-elevator.height) - yPos + down;
  40.  
  41.  
  42. println(elevatorPos);
  43.  
  44. //LiftImage
  45.  
  46.  
  47. image(elevator, width/2-elevator.width/2, elevatorPos);
  48. }
RAW Paste Data