Ok guys.. I'm stuck right now
this is my code so far:
Quote:int [] data = new int[361];
int selected = 1;
PFont font;
PImage a;
PImage b;
PImage c;
PImage d;
PImage e;
PImage f;
PImage g;
PImage h;
PImage i;
PImage j;
void setup(){
size(650,650);
font = loadFont("Aparajita-20.vlw");
a = loadImage("Erase.png");
b = loadImage("Wall.png");
c = loadImage("Door.png");
d = loadImage("Pacman.png");
e = loadImage("Blinky.png");
f = loadImage("Clyde.png");
g = loadImage("Inky.png");
h = loadImage("Pinky.png");
i = loadImage("Big-Fruit.png");
j = loadImage("Small-Fruit.png");
}
void draw(){
background(255);
textFont(font, 20);
// Draw the tiles.
for(int i=0; i < 19; i++){
for(int j=0; j < 19; j++){
drawTile(i,j);
}
}
// Draw the buttons.
stroke(0);
fill (255);
if (selected == 1) {
fill (100, 255, 100);
}
rect (20, 610, 32, 32);
image (a, 20, 610);
if (selected == 2) {
fill (100, 255, 100);
}
rect (52, 610, 32, 32);
image (b, 52, 610);
if (selected == 3) {
fill (100, 255, 100);
}
rect(84, 610, 32, 32 );
image (c, 84, 610);
if (selected == 4) {
fill (100, 255, 100);
}
rect(116, 610, 32, 32 );
image (d, 116, 610);
if (selected == 5) {
fill (100, 255, 100);
}
rect(148, 610, 32, 32 );
image (e, 148, 610);
if (selected == 6) {
fill (100, 255, 100);
}
rect(180, 610, 32, 32 );
image (f, 180, 610);
if (selected == 7) {
fill (100, 255, 100);
}
rect(212, 610, 32, 32 );
image (g, 212, 610);
if (selected == 8) {
fill (100, 255, 100);
}
rect(244, 610, 32, 32 );
image (h, 244, 610);
if (selected == 9) {
fill (100, 255, 100);
}
rect(276, 610, 32, 32 );
image (i, 276, 610);
if (selected == 10) {
fill (100, 255, 100);
}
rect(308, 610, 32, 32 );
image (j, 308, 610);
// Update tiles.
if(mousePressed){
if( mouseX > 30 && mouseX < 270 && mouseY > 30 && mouseY < 270 ){
int tempi = (mouseX-30)/80;
int tempj = (mouseY-30)/80;
data[tempi+3*tempj] = selected;
}
}
}
void drawTile(int i, int j){
drawBlank(i,j);
if( data[i+3*j] == 1 ){
drawCross(i,j);
}
if( data[i+3*j] == 2 ){
drawCircle(i,j);
}
}
void drawBlank(int i, int j){
stroke(0);
fill(200,255,200);
rect(30+30*i,30+30*j,30,30);
}
void drawCross(int i, int j){
noStroke();
fill(0,0,255);
rect(-10,-30,20,60);
rect(-30,-10,60,20);
}
void drawCircle(int i, int j){
noStroke();
fill(255,0,0);
ellipse(70+80*i,70+80*j, 60, 60 );
fill(200,255,200);
ellipse(70+80*i,70+80*j, 40, 40 );
}
I think I don't need the last 3 functions (void drawCircle, void drawCross, void drawBlank), but without them my code doesn't display 19x19 grid of cells for some reason...
here is a zip file of all images : http://rapidshare.com/files/389117381/PacManImages.zip.html
any ideas ?
and again big thanks to TfGuy44, without your code I would probably die