add Tent object and implement sleep functionality with lighting adjustments

This commit is contained in:
2025-12-13 14:37:36 +01:00
parent 27c36d880d
commit 7f8d9d7e9b
9 changed files with 75 additions and 32 deletions

View File

@@ -4,6 +4,7 @@ import de.miaurizius.jgame2d.core.enums.GameState;
import de.miaurizius.jgame2d.entity.Entity;
import de.miaurizius.jgame2d.entity.item.CoinObj;
import de.miaurizius.jgame2d.entity.item.HeartObj;
import de.miaurizius.jgame2d.environment.Lighting;
import java.awt.*;
import java.awt.image.BufferedImage;
@@ -25,7 +26,8 @@ public class UI {
public int commandNum;
public int playerSlotCol, playerSlotRow;
public int npcSlotCol, npcSlotRow;
private int transCounter;
private int transCount;
private int sleepCount;
// SUB-STATES
public TradeState tradeState = TradeState.SELECT;
@@ -64,6 +66,7 @@ public class UI {
case GAMEOVER -> drawGameOverScreen();
case TRANSITION -> drawTransitionScreen();
case TRADE -> drawTradeScreen();
case SLEEP -> drawSleepScreen();
}
}
@@ -375,11 +378,11 @@ public class UI {
if(commandNum == 1) graphics2d.drawString(">", x-panel.tileSize, y);
}
private void drawTransitionScreen() {
transCounter++;
graphics2d.setColor(new Color(0,0,0, transCounter*5));
transCount++;
graphics2d.setColor(new Color(0,0,0, transCount *5));
graphics2d.fillRect(0, 0, panel.screenWidth, panel.screenHeight);
if(transCounter != 50) return;
transCounter = 0;
if(transCount != 50) return;
transCount = 0;
panel.gameState = GameState.PLAY;
panel.currentMap = panel.eventH.tempMap;
panel.player.worldX = panel.tileSize * panel.eventH.tempCol;
@@ -395,6 +398,22 @@ public class UI {
}
panel.keyH.spacePressed = false;
}
private void drawSleepScreen() {
sleepCount++;
if(sleepCount < 120) {
panel.eManager.lighting.filterAlpha += 0.01F;
if(panel.eManager.lighting.filterAlpha >= 1F) panel.eManager.lighting.filterAlpha = 1F;
}
if(sleepCount >= 120) {
panel.eManager.lighting.filterAlpha -= 0.01F;
if(panel.eManager.lighting.filterAlpha <= 0F) {
panel.eManager.lighting.filterAlpha = 0F;
sleepCount = 0;
panel.eManager.lighting.dayState = Lighting.DayState.DAY;
panel.gameState = GameState.PLAY;
}
}
}
// TRADING
private void tradeSelect() {