added transition effect to map change
This commit is contained in:
@@ -23,6 +23,7 @@ public class UI {
|
||||
public String currentDialogue;
|
||||
public int commandNum;
|
||||
public int slotCol, slotRow;
|
||||
private int transCounter;
|
||||
|
||||
public UI(GamePanel panel) {
|
||||
this.panel = panel;
|
||||
@@ -47,12 +48,13 @@ public class UI {
|
||||
|
||||
if(panel.gameState == null) return;
|
||||
switch (panel.gameState) {
|
||||
case GameState.PLAY -> drawPlayScreen();
|
||||
case GameState.PAUSE -> drawPauseScreen();
|
||||
case GameState.DIALOGUE -> drawDialogueScreen();
|
||||
case PLAY -> drawPlayScreen();
|
||||
case PAUSE -> drawPauseScreen();
|
||||
case DIALOGUE -> drawDialogueScreen();
|
||||
case TITLE -> drawTitleScreen();
|
||||
case CHARACTER -> drawCharacterScreen();
|
||||
case GAMEOVER -> drawGameOverScreen();
|
||||
case TRANSITION -> drawTransitionScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,6 +329,19 @@ public class UI {
|
||||
graphics2d.drawString(text, x, y);
|
||||
if(commandNum == 1) graphics2d.drawString(">", x-panel.tileSize, y);
|
||||
}
|
||||
private void drawTransitionScreen() {
|
||||
transCounter++;
|
||||
graphics2d.setColor(new Color(0,0,0, transCounter*5));
|
||||
graphics2d.fillRect(0, 0, panel.screenWidth, panel.screenHeight);
|
||||
if(transCounter != 50) return;
|
||||
transCounter = 0;
|
||||
panel.gameState = GameState.PLAY;
|
||||
panel.currentMap = panel.eventH.tempMap;
|
||||
panel.player.worldX = panel.tileSize * panel.eventH.tempCol;
|
||||
panel.player.worldY = panel.tileSize * panel.eventH.tempRow;
|
||||
panel.eventH.prevEventX = panel.player.worldX;
|
||||
panel.eventH.prevEventY = panel.player.worldY;
|
||||
}
|
||||
|
||||
// UTILITY
|
||||
private void drawSubWindow(int x, int y, int width, int height) {
|
||||
|
||||
@@ -8,5 +8,6 @@ public enum GameState {
|
||||
TITLE,
|
||||
CHARACTER,
|
||||
GAMEOVER,
|
||||
TRANSITION,
|
||||
|
||||
}
|
||||
|
||||
@@ -11,9 +11,13 @@ public class EventHandler {
|
||||
|
||||
GamePanel panel;
|
||||
EventRect[][][] eventRect;
|
||||
int prevEventX, prevEventY;
|
||||
public int prevEventX, prevEventY;
|
||||
boolean canTouchEvent = true;
|
||||
|
||||
// TMP VARS FOR TRANSITION
|
||||
public int tempCol, tempRow;
|
||||
public Map tempMap;
|
||||
|
||||
public EventHandler(GamePanel panel) {
|
||||
this.panel = panel;
|
||||
eventRect = new EventRect[Map.values().length][panel.maxWorldCol][panel.maxWorldRow];
|
||||
@@ -100,11 +104,10 @@ public class EventHandler {
|
||||
panel.assetSetter.setMonster();
|
||||
}
|
||||
public void changeMap(Map map, int col, int row) {
|
||||
panel.currentMap = map;
|
||||
panel.player.worldX = panel.tileSize*col;
|
||||
panel.player.worldY = panel.tileSize*row;
|
||||
prevEventX = panel.player.worldX;
|
||||
prevEventY = panel.player.worldY;
|
||||
panel.gameState = GameState.TRANSITION;
|
||||
tempMap = map;
|
||||
tempCol = col;
|
||||
tempRow = row;
|
||||
canTouchEvent = false;
|
||||
panel.playSE(13);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user