first i added a background to the splash, that is needed to refresh the screen and to render the font without aliasing when drawn.
i painted the start and end screen red, but could be anything else just not black as the lines, cause i do a colorcheck at mouse position to reset to splashMode. (if you still want a black line, just use color(1))
Code: PFont font;
boolean isSplash;
boolean isDiff;
int [][] lines = {{102,76,102,0},{76,30,30,30},{102,32,562,32},{65,120,0,120},{447,30,447,120},
{447,120,485,120},{485,120,485,77},{485,77,524,77},{562,30,562,467},{562,467,522,467},
{522,467,522,422},{522,422,295,422},{295,422,295,470},{65,167,65,121},{65,120,0,120},
{28,120,28,555},{28,555,485,555},{485,555,485,465},{408,555,408,470},{141,555,141,511},
{67,555,67,426},{67,426,103,426},{103,426,103,340},{485,510,447,510},{28,383,66,383},
{66,383,66,296},{66,296,141,296},{141,296,141,427},{447,426,447,467},{141,337,260,337},
{218,294,218,382},{218,382,180,382},{180,382,180,469},{221,469,102,469},{102,469,102,515},
{218,294,255,294},{255,294,255,208},{255,208,333,208},{294,120,294,208},{371,120,217,120},
{256,120,256,76},{256,76,179,76},{179,76,179,162},{256,162,103,162},{103,119,103,207},
{103,207,63,207},{220,162,220,250},{28,252,141,252},{141,252,141,207},{141,207,180,207},
{180,207,180,295},{368,422,368,515},{368,515,180,515},{255,515,255,470},{332,515,332,470},
{332,421,332,381},{332,381,254,381},{254,381,254,425},{254,425,216,425},{296,381,296,296},
{484,422,484,340},{523,340,332,340},{332,340,332,296},{523,122,523,384},{523,250,483,250},
{523,162,333,162},{403,162,403,76},{403,76,333,76},{487,162,487,207},{371,210,371,380},
{371,380,450,380},{371,210,448,210},{448,210,448,293},{408,293,485,293},{294,253,412,253}};
void setup()
{
size(600,600);
background(255,255,255);
isSplash = true;
font = createFont("Serif-48 ",48);
textFont(font);
if (keyPressed == true)
if (key == 'q')
{
background(255,255,255);
drawSplash();
}
}
void draw()
{
if(get(mouseX,mouseY)==color(0))isSplash = true;
if (isSplash == true)
{
drawSplash();
}
else
{
drawMaze1();
}
}
void drawSplash()
{
background(255);
fill(0,0,0);
text("Click Black Box to Start.",100,100);
text("Go through the maze",100,150);
text("and try not to touch the",100,200);
text("walls. There may",100,250);
text("be a catch.",100,300);
text("Press 'q' to exit.",100,350);
if ((mouseX > 25) && (mouseX < 75) && (mouseY > 25) &&( mouseY < 75))
{
if (mousePressed == true)
{
isSplash = false;
background(255,255,255);
}
}
fill(255,0,0);
noStroke();
rect(25,25,50,50);
}
void drawMaze1()
{
strokeWeight(2);
stroke(255,0,0);
line(mouseX,mouseY,pmouseX,pmouseY);
strokeWeight(10);
// draw the maze
stroke(0);
for(int i = 0; i < 75; i++)
{
line(lines[i][0], lines[i][1], lines[i][2], lines[i][3]);
}
if ((mouseX > 525) && (mouseX < 575) && (mouseY > 525) &&( mouseY < 575))
{
if (mousePressed == true)
{
isSplash = true;
background(255,255,255);
}
}
fill(255,0,0);
noStroke();
rect(525,525,50,50);
}
// check for mouse intersections with maze
for(int i = 0; i < 75; i++)
{
// Testing to see if the line is vertical
if(lines[i][0] == lines[i][2])
{
// Test to see if the mouse is intersecting the maze wall
// println("MouseX: " + mouseX + " (" + lines[i][0] + "," + lines[i][2] + ")");
if ( (mouseX > lines[i][0]) && (mouseX < lines[i][2]) && (mouseY > (lines[i][1]-5)) && (mouseY < (lines[i][3]+5)) )
{
println("Vertical line " + i + " intersected");
// Revert to intro screen
isSplash = true;
drawSplash();
}
}
// Test to see if the line is horizontal
if (lines[i][1] == lines[i][3])
{
// // Test to see if the mouse is intersecting the maze wall
//println("MouseY: " + mouseY + " (" + lines[i][1] + "," + lines[i][3] + ")");
if (mouseX > lines[i][1] && mouseX < lines[i][3] && (mouseY > (lines[i][0]-5)) && (mouseY < lines[i][2]+5)) )
{
println("Horizontal line " + i + " intersected");
// Revert to intro screen
isSplash = true;
drawSplash();
}
}
}
some might mention that you should use pixels insteadt of get as it is faster. if you want to you can replace it with the equivalent statement to "get(x, y)" using pixels[] is "pixels[y*width+x]".