daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.FilenameFilter;
  2.  
  3.  
  4. int counter = 1;
  5. int pn = 16;//number of puzzle pieces
  6. PImage img;  // Declare a variable of type PImage
  7. PImage[][] pieceArray = new PImage[pn][pn];//array of images
  8.  
  9. int width = 800;
  10. int height = 600;
  11.  
  12. void setup() {
  13.   frameRate(5);
  14.   size(800, 600);
  15.   loadNextImage();
  16. }//end of setup
  17.  
  18.  
  19. void draw() {
  20.   background(0);
  21.   image(pieceArray[0][0],width/pn, height/pn);
  22.  
  23.   }
  24.  
  25.   void loadNextImage(){
  26.     img = loadImage("images/" + counter + ".jpg");
  27.     img.resize(800, 600);
  28.     for (int i = 0; i < pn; i++) {
  29.     for (int j = 0; j < pn; j++) {
  30.       pieceArray[i][j] = img.get(i * width/pn, j * height/pn, width/pn, height/pn);
  31.     }
  32.   }
  33.  
  34.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top