First, without understanding what the rest of your class is doing and what the other variables like ‘options’, ‘mouse’, ‘currentChoice’, etc. are, all I can do is make assumptions;
So, assuming that ‘currentChoice’ uses an integer to represent which menu item the mouse is currently hovered over, then we need a conditional statement to print only that menu item in a different color;
The following code may work, but again, I’m only assuming based on your variable names and current code, since I don’t have enough code to test anything;
public Rectangle rect, mouse;
public void draw() {
Color.white.bind();
loadText();
backg();
handleInput();
Color colorSelected = Color.black;
if(currentChoice == 0) {
colorSelected = Color.yellow;
}
font.drawString(Display.getWidth() / 2 - 250, Display.getHeight() - 150, "Play", colorSelected);
colorSelected = Color.black;
if(currentChoice == 1) {
colorSelected = Color.yellow;
}
font.drawString(Display.getWidth() / 2 - 200, Display.getHeight() - 100, "Options", colorSelected);
colorSelected = Color.black;
if(currentChoice == 1) {
colorSelected = Color.yellow;
}
font.drawString(Display.getWidth() / 2- 100, Display.getHeight() - 50, "Quit", colorSelected);
cleanUp();
}
public void handleInput() {
if(Mouse.isInsideWindow()) {
if(mouse.intersects(rect)) {
// Something to do with 'currentChoice' should maybe go here? Or does it get set somewhere else...
}
}
}
What is currentChoice and how does it get set to 0-2?
Why are the string drawing commands in a for loop of and what is ‘options’?
Your current if-else statements are aimed in the right direction, but some of your drawing commands are running twice since the for loop runs all the commands at least once and then the if-else statements possibly run them again;