Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PImage elevator;
- int yPos=0, elevatorPos;
- boolean start;
- int inverter, down;
- void setup() {
- size(200, 400);
- background(255);
- elevator = loadImage("elevator.jpg");
- }
- void draw() {
- background(255);
- strokeWeight(4);
- line(width/2, 0, width/2, height);
- start = (mousePressed && (mouseButton == LEFT));
- //Condition
- if (start) {
- yPos = yPos +1;
- if (inverter % 2 != 0) {
- down = down +2;
- }
- }
- //Modulo
- inverter = yPos/(height-elevator.height);
- //Lift Movement
- elevatorPos= (height-elevator.height) - yPos + down;
- println(elevatorPos);
- //LiftImage
- image(elevator, width/2-elevator.width/2, elevatorPos);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement