- made program exit on pressing red button by having a JOptionPane pop up
- made a second gamePane to make a second BorderLayout
- second BorderLayout will act as a menu for the user with "quit", "instructions", and "map" (maybe)
- the 1st BorderLayout goes into the 2nd BorderLayout
Everything of that works fine and awesome after I fiddled with some things. Now my issue is how to use the booleans to make the rooms clickable or not. Because at the moment, this is working:
if(whatClicked.getButton()==whatClicked.BUTTON1)
{
if(roomArray[cRow][cCol]==roomArray[2][0])
{
prev=false;
}
else
{
prev=true;
}
if(roomArray[cRow][cCol]!=roomArray[2][0])
{
cRow++;
if(tracing)
{
System.out.println("CHARACTER HAS ENTERED PREVIOUS ROOM");
}
}
}
What's not working, is if I replace if(roomArray[cRow][cCol]!=roomArray[2][0]) with if(prev=true);
Which I think should work unless I'm missing something very obvious, which I probably am, but it really looks like it should work. I don't get why it won't work. My computer crashes when I try to use if(prev=true);.
So. I got a back to menu button, plus an "exit screen" of sorts, but this part, which I was actually supposed to do today, won't work.
Nice.
Isn't it usually:
ReplyDeleteif (whatClicked.getSource()==INSERT_NAME_OF_BUTTON_HERE)
? What's whatClicked.BUTTON1? o_O
Have you tried a tracing statement before the if statement to determine whether prev is t/f? And same thing inside the if statement to see whether it turned false; and then in the else statement to see if it made it true? And then after if if/else that deals with prev?
Also, what is the code in the console window that causes the program to crash?
The BUTTON1 thing was part of the lesson document and I assumed that it meant the left mouse button. It works and I haven't gotten around to asking about it.
DeleteAnd I haven't tried the tracing statement although I should.
Oh. I see. Left click.....interesting o_O
DeleteI forgot about that XD
The right click is BUTTON3... does that mean BUTTON2 is the scroll? I never considered that as a button.
Delete