Compare commits
3 Commits
fb0273afb0
...
5192c8df87
| Author | SHA1 | Date | |
|---|---|---|---|
|
5192c8df87
|
|||
|
2abdb3b5fb
|
|||
|
7ac1207c83
|
@@ -13,7 +13,7 @@ public class Boot {
|
|||||||
window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
window.setResizable(false);
|
window.setResizable(false);
|
||||||
window.setTitle("JGame2D");
|
window.setTitle("JGame2D");
|
||||||
window.setUndecorated(true);
|
//window.setUndecorated(true);
|
||||||
|
|
||||||
GamePanel gamePanel = new GamePanel();
|
GamePanel gamePanel = new GamePanel();
|
||||||
window.add(gamePanel);
|
window.add(gamePanel);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class GamePanel extends JPanel implements Runnable {
|
|||||||
int fScreenHeight = screenHeight;
|
int fScreenHeight = screenHeight;
|
||||||
BufferedImage tempScreen;
|
BufferedImage tempScreen;
|
||||||
Graphics2D fg2;
|
Graphics2D fg2;
|
||||||
|
public boolean fullscreen;
|
||||||
|
|
||||||
// WORLD SETTINGS
|
// WORLD SETTINGS
|
||||||
public final int maxWorldCol = 50;
|
public final int maxWorldCol = 50;
|
||||||
@@ -223,7 +224,7 @@ public class GamePanel extends JPanel implements Runnable {
|
|||||||
tempScreen = new BufferedImage(screenWidth, screenHeight, BufferedImage.TYPE_INT_RGB);
|
tempScreen = new BufferedImage(screenWidth, screenHeight, BufferedImage.TYPE_INT_RGB);
|
||||||
fg2 = (Graphics2D) tempScreen.getGraphics();
|
fg2 = (Graphics2D) tempScreen.getGraphics();
|
||||||
|
|
||||||
setFullscreen();
|
//setFullscreen();
|
||||||
}
|
}
|
||||||
public void setFullscreen() {
|
public void setFullscreen() {
|
||||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class UI {
|
|||||||
BufferedImage heart_full, heart_half, heart_blank;
|
BufferedImage heart_full, heart_half, heart_blank;
|
||||||
ArrayList<String> messages = new ArrayList<>();
|
ArrayList<String> messages = new ArrayList<>();
|
||||||
ArrayList<Integer> messageCounter = new ArrayList<>();
|
ArrayList<Integer> messageCounter = new ArrayList<>();
|
||||||
|
public OptionState optionState;
|
||||||
public String currentDialogue;
|
public String currentDialogue;
|
||||||
public int commandNum;
|
public int commandNum;
|
||||||
public int slotCol, slotRow;
|
public int slotCol, slotRow;
|
||||||
@@ -221,11 +222,19 @@ public class UI {
|
|||||||
|
|
||||||
// GAME STATES
|
// GAME STATES
|
||||||
public void drawPauseScreen() {
|
public void drawPauseScreen() {
|
||||||
drawPlayerLife();
|
graphics2d.setColor(Color.white);
|
||||||
graphics2d.setFont(graphics2d.getFont().deriveFont(Font.PLAIN, 80));
|
graphics2d.setFont(graphics2d.getFont().deriveFont(32F));
|
||||||
String text = "PAUSED";
|
|
||||||
int y = panel.screenHeight / 2;
|
// SUB WINDOW
|
||||||
graphics2d.drawString(text, getCenteredX(text), y);
|
int frameX = panel.tileSize*6;
|
||||||
|
int frameY = panel.tileSize;
|
||||||
|
int frameWidth = panel.tileSize*8;
|
||||||
|
int frameHeight = panel.tileSize*10;
|
||||||
|
drawSubWindow(frameX, frameY, frameWidth, frameHeight);
|
||||||
|
|
||||||
|
switch(optionState) {
|
||||||
|
case OVERVIEW -> optionsTop(frameX, frameY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void drawDialogueScreen() {
|
public void drawDialogueScreen() {
|
||||||
drawPlayerLife();
|
drawPlayerLife();
|
||||||
@@ -314,4 +323,68 @@ public class UI {
|
|||||||
messageCounter.add(0);
|
messageCounter.add(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void optionsTop(int frameX, int frameY) {
|
||||||
|
int textX, textY;
|
||||||
|
String title = "Options";
|
||||||
|
textX = getCenteredX(title);
|
||||||
|
textY = frameY + panel.tileSize;
|
||||||
|
graphics2d.drawString(title, textX, textY);
|
||||||
|
|
||||||
|
// FULLSCREEN ON/OFF
|
||||||
|
textX = frameX + panel.tileSize;
|
||||||
|
textY += panel.tileSize;
|
||||||
|
graphics2d.drawString("Full Screen", textX, textY);
|
||||||
|
if(commandNum == 0) {
|
||||||
|
graphics2d.drawString(">", textX-25, textY);
|
||||||
|
if(panel.keyH.spacePressed) panel.fullscreen = !panel.fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MUSIC
|
||||||
|
textY += panel.tileSize;
|
||||||
|
graphics2d.drawString("Music", textX, textY);
|
||||||
|
if(commandNum == 1) graphics2d.drawString(">", textX-25, textY);
|
||||||
|
|
||||||
|
// SOUND EFFECTS
|
||||||
|
textY += panel.tileSize;
|
||||||
|
graphics2d.drawString("SFX", textX, textY);
|
||||||
|
if(commandNum == 2) graphics2d.drawString(">", textX-25, textY);
|
||||||
|
|
||||||
|
// CONTROL
|
||||||
|
textY += panel.tileSize;
|
||||||
|
graphics2d.drawString("Controls", textX, textY);
|
||||||
|
if(commandNum == 3) graphics2d.drawString(">", textX-25, textY);
|
||||||
|
|
||||||
|
// END GAME
|
||||||
|
textY += panel.tileSize;
|
||||||
|
graphics2d.drawString("Quit Game", textX, textY);
|
||||||
|
if(commandNum == 4) graphics2d.drawString(">", textX-25, textY);
|
||||||
|
|
||||||
|
// BACK
|
||||||
|
textY += panel.tileSize*2;
|
||||||
|
graphics2d.drawString("Back to Game", textX, textY);
|
||||||
|
if(commandNum == 5) graphics2d.drawString(">", textX-25, textY);
|
||||||
|
|
||||||
|
// FULL SCREEN CHECKBOX
|
||||||
|
textX = frameX + (int)(panel.tileSize*4.5);
|
||||||
|
textY = frameY + panel.tileSize*2 - panel.tileSize/2;
|
||||||
|
graphics2d.setStroke(new BasicStroke(3));
|
||||||
|
graphics2d.drawRect(textX, textY, panel.tileSize/2, panel.tileSize/2);
|
||||||
|
|
||||||
|
// MUSIC VOLUME
|
||||||
|
textY += panel.tileSize;
|
||||||
|
graphics2d.drawRect(textX, textY, 120, panel.tileSize/2);
|
||||||
|
|
||||||
|
// SFX VOLUME
|
||||||
|
textY += panel.tileSize;
|
||||||
|
graphics2d.drawRect(textX, textY, 120, panel.tileSize/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum OptionState {
|
||||||
|
OVERVIEW,
|
||||||
|
SCREEN,
|
||||||
|
MUSIC,
|
||||||
|
SFX,
|
||||||
|
CONTROLS,
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.miaurizius.jgame2d.core.handlers;
|
package de.miaurizius.jgame2d.core.handlers;
|
||||||
|
|
||||||
import de.miaurizius.jgame2d.core.GamePanel;
|
import de.miaurizius.jgame2d.core.GamePanel;
|
||||||
|
import de.miaurizius.jgame2d.core.UI;
|
||||||
import de.miaurizius.jgame2d.core.enums.GameState;
|
import de.miaurizius.jgame2d.core.enums.GameState;
|
||||||
|
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
@@ -56,11 +57,35 @@ public class KeyHandler implements KeyListener {
|
|||||||
case KeyEvent.VK_R -> panel.tileM.loadMap(panel.currentMap);
|
case KeyEvent.VK_R -> panel.tileM.loadMap(panel.currentMap);
|
||||||
|
|
||||||
// GAME STATES
|
// GAME STATES
|
||||||
case KeyEvent.VK_ESCAPE -> panel.gameState = GameState.PAUSE;
|
case KeyEvent.VK_ESCAPE -> {
|
||||||
|
panel.gameState = GameState.PAUSE;
|
||||||
|
panel.ui.optionState = UI.OptionState.OVERVIEW;
|
||||||
|
}
|
||||||
case KeyEvent.VK_C -> panel.gameState = GameState.CHARACTER;
|
case KeyEvent.VK_C -> panel.gameState = GameState.CHARACTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void handlePause(int code) {
|
public void handlePause(int code) {
|
||||||
|
if(code == KeyEvent.VK_SPACE) spacePressed = true;
|
||||||
|
|
||||||
|
int maxCommandNum = 0;
|
||||||
|
|
||||||
|
switch (panel.ui.optionState) {
|
||||||
|
case OVERVIEW -> maxCommandNum = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(code) {
|
||||||
|
case KeyEvent.VK_UP:
|
||||||
|
if(panel.ui.commandNum <= 0) break;
|
||||||
|
panel.ui.commandNum--;
|
||||||
|
panel.playSE(9);
|
||||||
|
break;
|
||||||
|
case KeyEvent.VK_DOWN:
|
||||||
|
if(panel.ui.commandNum >= maxCommandNum) break;
|
||||||
|
panel.ui.commandNum++;
|
||||||
|
panel.playSE(9);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// EXIT STATE
|
// EXIT STATE
|
||||||
if(code == KeyEvent.VK_ESCAPE) panel.gameState = GameState.PLAY;
|
if(code == KeyEvent.VK_ESCAPE) panel.gameState = GameState.PLAY;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user