finished options menu
This commit is contained in:
@@ -199,6 +199,7 @@ public class GamePanel extends JPanel implements Runnable {
|
|||||||
// MUSIC
|
// MUSIC
|
||||||
public void playMusic(int i) {
|
public void playMusic(int i) {
|
||||||
Clip c = music.clips[i];
|
Clip c = music.clips[i];
|
||||||
|
music.clip = c;
|
||||||
music.fc = (FloatControl) c.getControl(FloatControl.Type.MASTER_GAIN);
|
music.fc = (FloatControl) c.getControl(FloatControl.Type.MASTER_GAIN);
|
||||||
music.checkVolume();
|
music.checkVolume();
|
||||||
if(c.isRunning()) c.stop();
|
if(c.isRunning()) c.stop();
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ public class UI {
|
|||||||
case OVERVIEW -> optionsTop(frameX, frameY);
|
case OVERVIEW -> optionsTop(frameX, frameY);
|
||||||
case SCREENNF -> optionsFSNotify(frameX, frameY);
|
case SCREENNF -> optionsFSNotify(frameX, frameY);
|
||||||
case CONTROLS -> optionsControls(frameX, frameY);
|
case CONTROLS -> optionsControls(frameX, frameY);
|
||||||
|
case QUITNF -> optionsQuitNotify(frameX, frameY);
|
||||||
}
|
}
|
||||||
panel.keyH.spacePressed = false;
|
panel.keyH.spacePressed = false;
|
||||||
}
|
}
|
||||||
@@ -372,7 +373,10 @@ public class UI {
|
|||||||
graphics2d.drawString("Quit Game", textX, textY);
|
graphics2d.drawString("Quit Game", textX, textY);
|
||||||
if(commandNum == 4) {
|
if(commandNum == 4) {
|
||||||
graphics2d.drawString(">", textX-25, textY);
|
graphics2d.drawString(">", textX-25, textY);
|
||||||
if(panel.keyH.spacePressed) System.exit(0);
|
if(panel.keyH.spacePressed) {
|
||||||
|
optionState = OptionState.QUITNF;
|
||||||
|
commandNum = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BACK
|
// BACK
|
||||||
@@ -383,6 +387,10 @@ public class UI {
|
|||||||
if(panel.keyH.spacePressed) panel.gameState = GameState.PLAY;
|
if(panel.keyH.spacePressed) panel.gameState = GameState.PLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// FUNCTIONALITY
|
||||||
|
//
|
||||||
|
|
||||||
// FULL SCREEN CHECKBOX
|
// FULL SCREEN CHECKBOX
|
||||||
textX = frameX + (int)(panel.tileSize*4.5);
|
textX = frameX + (int)(panel.tileSize*4.5);
|
||||||
textY = frameY + panel.tileSize*2 - panel.tileSize/2;
|
textY = frameY + panel.tileSize*2 - panel.tileSize/2;
|
||||||
@@ -402,6 +410,39 @@ public class UI {
|
|||||||
graphics2d.drawRect(textX, textY, 120, panel.tileSize/2); // 120/5 = 24
|
graphics2d.drawRect(textX, textY, 120, panel.tileSize/2); // 120/5 = 24
|
||||||
graphics2d.fillRect(textX, textY, 24 * panel.se.volumeScale, panel.tileSize/2);
|
graphics2d.fillRect(textX, textY, 24 * panel.se.volumeScale, panel.tileSize/2);
|
||||||
}
|
}
|
||||||
|
public void optionsControls(int frameX, int frameY) {
|
||||||
|
int textX;
|
||||||
|
int textY;
|
||||||
|
|
||||||
|
// TITLE
|
||||||
|
String text = "Controls";
|
||||||
|
textX = getCenteredX(text);
|
||||||
|
textY = frameY + panel.tileSize;
|
||||||
|
graphics2d.drawString(text, textX, textY);
|
||||||
|
|
||||||
|
textX = frameX + panel.tileSize;
|
||||||
|
textY +=panel.tileSize;
|
||||||
|
String[] options = {"Move", "Confirm/Attack", "Shoot/Cast", "Inventory", "Pause/Settings"};
|
||||||
|
for(String option : options) {
|
||||||
|
graphics2d.drawString(option, textX, textY);
|
||||||
|
textY += panel.tileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
textX = frameX + panel.tileSize*6;
|
||||||
|
textY = frameY + panel.tileSize*2;
|
||||||
|
options = new String[]{"WASD", "SPACE", "F", "C", "ESC"};
|
||||||
|
for(String option : options) {
|
||||||
|
graphics2d.drawString(option, textX, textY);
|
||||||
|
textY += panel.tileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BACK
|
||||||
|
textX = frameX + panel.tileSize;
|
||||||
|
textY = frameY + panel.tileSize*9;
|
||||||
|
graphics2d.drawString("Back", textX, textY);
|
||||||
|
graphics2d.drawString(">", textX-25, textY);
|
||||||
|
if(panel.keyH.spacePressed) optionState = OptionState.OVERVIEW;
|
||||||
|
}
|
||||||
public void optionsFSNotify(int frameX, int frameY) {
|
public void optionsFSNotify(int frameX, int frameY) {
|
||||||
int textX = frameX + panel.tileSize;
|
int textX = frameX + panel.tileSize;
|
||||||
int textY = frameY + panel.tileSize*3;
|
int textY = frameY + panel.tileSize*3;
|
||||||
@@ -421,22 +462,36 @@ public class UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void optionsControls(int frameX, int frameY) {
|
public void optionsQuitNotify(int frameX, int frameY) {
|
||||||
int textX;
|
int textX = frameX + panel.tileSize;
|
||||||
int textY;
|
int textY = frameY + panel.tileSize*3;
|
||||||
|
|
||||||
// TITLE
|
currentDialogue = "Quit the game and \nreturn to the title screen?";
|
||||||
String text = "Controls";
|
for(String line : currentDialogue.split("\n")) {
|
||||||
|
graphics2d.drawString(line, textX, textY);
|
||||||
|
textY += 40;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DISPLAY OPTIONS
|
||||||
|
String text = "Yes";
|
||||||
textX = getCenteredX(text);
|
textX = getCenteredX(text);
|
||||||
textY = frameY + panel.tileSize;
|
textY += panel.tileSize*3;
|
||||||
graphics2d.drawString(text, textX, textY);
|
graphics2d.drawString(text, textX, textY);
|
||||||
|
if(commandNum == 0) {
|
||||||
|
graphics2d.drawString(">", textX-25, textY);
|
||||||
|
if(panel.keyH.spacePressed) {
|
||||||
|
panel.gameState = GameState.TITLE;
|
||||||
|
panel.stopMusic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
textX = frameX + panel.tileSize;
|
text = "No";
|
||||||
textY +=panel.tileSize;
|
textX = getCenteredX(text);
|
||||||
String[] options = {"Move", "Confirm/Attack", "Shoot/Cast", "Inventory", "Pause/Settings"};
|
|
||||||
for(String option : options) {
|
|
||||||
graphics2d.drawString(option, textX, textY);
|
|
||||||
textY += panel.tileSize;
|
textY += panel.tileSize;
|
||||||
|
graphics2d.drawString(text, textX, textY);
|
||||||
|
if(commandNum == 1) {
|
||||||
|
graphics2d.drawString(">", textX-25, textY);
|
||||||
|
if(panel.keyH.spacePressed) optionState = OptionState.OVERVIEW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,6 +499,7 @@ public class UI {
|
|||||||
OVERVIEW,
|
OVERVIEW,
|
||||||
SCREENNF,
|
SCREENNF,
|
||||||
CONTROLS,
|
CONTROLS,
|
||||||
|
QUITNF;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class KeyHandler implements KeyListener {
|
|||||||
case KeyEvent.VK_DOWN -> {
|
case KeyEvent.VK_DOWN -> {
|
||||||
if(panel.ui.commandNum != 2) panel.ui.commandNum++;
|
if(panel.ui.commandNum != 2) panel.ui.commandNum++;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_ENTER -> {
|
case KeyEvent.VK_ENTER, KeyEvent.VK_SPACE -> {
|
||||||
switch (panel.ui.commandNum) {
|
switch (panel.ui.commandNum) {
|
||||||
case 0:
|
case 0:
|
||||||
panel.gameState = GameState.PLAY;
|
panel.gameState = GameState.PLAY;
|
||||||
@@ -72,6 +72,7 @@ public class KeyHandler implements KeyListener {
|
|||||||
|
|
||||||
switch (panel.ui.optionState) {
|
switch (panel.ui.optionState) {
|
||||||
case OVERVIEW -> maxCommandNum = 5;
|
case OVERVIEW -> maxCommandNum = 5;
|
||||||
|
case QUITNF -> maxCommandNum = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(code) {
|
switch(code) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class Sound {
|
public class Sound {
|
||||||
|
|
||||||
Clip clip;
|
public Clip clip;
|
||||||
URL[] soundURL = new URL[30];
|
URL[] soundURL = new URL[30];
|
||||||
public Clip[] clips = new Clip[30];
|
public Clip[] clips = new Clip[30];
|
||||||
public FloatControl fc;
|
public FloatControl fc;
|
||||||
|
|||||||
Reference in New Issue
Block a user