Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement