Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.FilenameFilter;
- int counter = 1;
- int pn = 16;//number of puzzle pieces
- PImage img; // Declare a variable of type PImage
- PImage[][] pieceArray = new PImage[pn][pn];//array of images
- int width = 800;
- int height = 600;
- void setup() {
- frameRate(5);
- size(800, 600);
- loadNextImage();
- }//end of setup
- void draw() {
- background(0);
- image(pieceArray[0][0],width/pn, height/pn);
- }
- void loadNextImage(){
- img = loadImage("images/" + counter + ".jpg");
- img.resize(800, 600);
- for (int i = 0; i < pn; i++) {
- for (int j = 0; j < pn; j++) {
- pieceArray[i][j] = img.get(i * width/pn, j * height/pn, width/pn, height/pn);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement