vortdog
YaBB Newbies
Offline
Posts: 6
unexpected token: void
Dec 10th , 2008, 8:26pm
can't figure out why it's giving me this code: PImage img; // The source image PImage img1; PImage img2; int cellsize = 5; // Dimensions of each cell in the grid //int cols, rows; // Number of columns and rows in our system int cols = width; int rows = height; int speed = 0; int gravity = 1; /*int [][] pixelLoc = new int [cols][rows]; boolean [] wasTouched = new boolean [cols*rows]; boolean a = true; */ float distance = dist(x,y,mouseX,mouseY); Pixel pixel1; void setup() { size(600,450,P3D); frameRate(30); img1 = loadImage( "layer.jpg" ); img2 = loadImage( "black.jpg" ); img = loadImage( "grey.4.jpg" ); // Load the image cols = width/cellsize; // Calculate # of columns rows = height/cellsize; // Calculate # of rows pixel1 = new Pixel(distance); } void draw() { background(img1); img2.loadPixels(); img.loadPixels(); // frameRate(.8); // Begin loop for columns for (int i = 0; i < cols; i++ ) { // Begin loop for rows for (int j = 0; j < rows; j++ ) { int x = i*cellsize + cellsize/2; // x position int y = j*cellsize + cellsize/2; // y position int loc = x + y*width; // Pixel array location color c = img.pixels[loc]; // Grab the color //float distance = dist(x,y,mouseX,mouseY); // int z = 0; // Calculate a z position as a function of mouseX and pixel brightness float z = (mouseX/(float)width) * brightness(img.pixels[loc])- 100.0; /* if (distance <= 10 && mousePressed == true) { y = y + speed; speed = speed + gravity; /* if (y > height) { speed = speed * -1; y = height; }*/ /* if (y > height) { speed = speed * -1; y = height; }*/ } } // Translate to the location, set fill and stroke, and draw the rect pushMatrix(); translate(x,y,z); fill(c); noStroke(); rectMode(CENTER); rect(2,10,cellsize,cellsize); popMatrix(); pixel1.fall(); pixel1.move(); pixel1.display(); for (int i = 0; i < cols; i++ ) { // Begin loop for rows for (int j = 0; j < rows; j++ ) { int x = i*cellsize + cellsize/2; // x position int y = j*cellsize + cellsize/2; // y position int loc = x + y*width; // Pixel array location color c = img2.pixels[loc]; // Grab the color // Calculate a z position as a function of mouseX and pixel brightness float z = (mouseX/(float)width) * mouseY/(img2.pixels[loc])- 50.0;//brightness(img2.pixels[loc])- 100.0; // Translate to the location, set fill and stroke, and draw the rect pushMatrix(); translate(x,y,z); fill(c); noStroke(); rectMode(CENTER); rect(0,0,cellsize,cellsize); popMatrix(); } } } class Pixel { float r; // radius float x,y; // location float xspeed,yspeed; // speed // Constructor Pixel(float tempR) { r = tempR; x = random(width); y = random(height); xspeed = random( - 5,5); yspeed = random( - 5,5); } void fall() { float distance = dist(x,y,mouseX,mouseY); if (distance <= 10 && mousePressed == true) { y = y + speed; speed = speed + gravity; } void move() { x += xspeed; // Increment x y += yspeed; // Increment y // Check horizontal edges if (x > width || x < 0) { xspeed *= - 1; } //Check vertical edges if (y > height || y < 0) { yspeed *= - 1; } } } sorry for the mess