The function display() does not exist.
in
Programming Questions
•
1 year ago
I started making a new program and I have encountered a problem that I can´t solve on my own. I´ve spent hours trying to figure out what´s the problem. When I try run the program it says "The function display() does not exist".
Any help is appreciated!
Here is the code:
Any help is appreciated!
Here is the code:
- int w = 800;
int h = 800;
int sz = 10;
int xs = w/sz;
int ys = h/sz;
block[][] blocks;
void setup()
{
blocks = new block[xs][ys];
size(w,h);
for(int i = 0; i < xs; i++)
{
for(int j = 0; j < ys; j++)
{
if(millis()%2 == 0) //to have some randomness
{
blocks[i][j] = new tile(i*sz, j*sz);
}
else
{
blocks[i][j] = new wall(i*sz,j*sz);
}
}
}
}
void draw()
{
for(int i = 0; i < xs; i++)
{
for(int j = 0; j < ys; j++)
{
blocks[i][j].display(); // The IDE highlights this part of the code.
}
}
} - class block
{
int x,y;
boolean mouseOver()
{
if(mouseX > x && mouseX < (x + sz) && mouseY > y && mouseY < (y + sz))
{
return(true);
}
else
{
return(false);
}
}
} - class tile extends block
{
tile(int ax,int ay)
{
x = ax;
y = ay;
}
void display()
{
if(mouseOver())
{
stroke(255,0,0);
}
else
{
stroke(0);
}
fill(160);
rect(x,y,sz,sz);
}
} - class wall extends block
{
wall(int ax,int ay)
{
x = ax;
y = ay;
}
void display()
{
if(mouseOver())
{
stroke(255,0,0);
}
else
{
stroke(0);
}
fill(0);
rect(x,y,sz,sz);
}
}
1