Compare commits

...

2 Commits

6 changed files with 44 additions and 6 deletions

22
build.bat Normal file
View File

@@ -0,0 +1,22 @@
@echo off
echo [1/4] Clearing old files...
rd /s /q "out/app"
echo [2/4] Building game...
jpackage --type app-image ^
--dest "out/app" ^
--name "JGame2D" ^
--input "out/artifacts/JGame2D_jar" ^
--main-jar "JGame2D.jar" ^
--main-class de.miaurizius.jgame2d.core.Boot
echo [3/4] Copy assets
robocopy "assets" "out/app/JGame2D/assets" /e > nul
echo [4/4] Zipping...
cd out\app
tar -a -c -f ..\JGame2D.zip JGame2D
cd ../..
echo Done!

View File

@@ -29,7 +29,7 @@ public class UI {
private int transCount; private int transCount;
private int sleepCount; private int sleepCount;
private int charIndex; private int charIndex;
private String combinedText = ""; private String combinedText;
// SUB-STATES // SUB-STATES
public TradeState tradeState = TradeState.SELECT; public TradeState tradeState = TradeState.SELECT;
@@ -757,7 +757,6 @@ public class UI {
if(commandNum == 1) { if(commandNum == 1) {
graphics2d.drawString(">", textX-25, textY); graphics2d.drawString(">", textX-25, textY);
if(panel.keyH.spacePressed) optionState = OptionState.OVERVIEW; if(panel.keyH.spacePressed) optionState = OptionState.OVERVIEW;
panel.resetGame(true);
} }
} }

View File

@@ -59,6 +59,10 @@ public class CollisionHandler {
} }
public int checkObject(Entity entity, boolean player) { public int checkObject(Entity entity, boolean player) {
int index = 999; int index = 999;
Direction direction = entity.direction;
if(entity.knockback) direction = entity.knockbackDirection;
int c = -1; int c = -1;
for(Entity obj : panel.obj[panel.currentMap.getIndex()]) { for(Entity obj : panel.obj[panel.currentMap.getIndex()]) {
@@ -71,7 +75,7 @@ public class CollisionHandler {
obj.solidArea.x += obj.worldX; obj.solidArea.x += obj.worldX;
obj.solidArea.y += obj.worldY; obj.solidArea.y += obj.worldY;
parseSolidArea(entity); parseSolidArea(entity, direction);
if (entity.solidArea.intersects(obj.solidArea)) { if (entity.solidArea.intersects(obj.solidArea)) {
if (obj.collision) entity.collisionOn = true; if (obj.collision) entity.collisionOn = true;
@@ -90,6 +94,10 @@ public class CollisionHandler {
//NPC OR MONSTER COLLISION //NPC OR MONSTER COLLISION
public int checkEntity(Entity entity, Entity[] target) { public int checkEntity(Entity entity, Entity[] target) {
int index = 999; int index = 999;
Direction direction = entity.direction;
if(entity.knockback) direction = entity.knockbackDirection;
int c = -1; int c = -1;
for(Entity e : target) { for(Entity e : target) {
@@ -102,7 +110,7 @@ public class CollisionHandler {
e.solidArea.x += e.worldX; e.solidArea.x += e.worldX;
e.solidArea.y += e.worldY; e.solidArea.y += e.worldY;
parseSolidArea(entity); parseSolidArea(entity, direction);
if (entity.solidArea.intersects(e.solidArea) && e != entity) { if (entity.solidArea.intersects(e.solidArea) && e != entity) {
entity.collisionOn = true; entity.collisionOn = true;
@@ -149,4 +157,13 @@ public class CollisionHandler {
} }
} }
private void parseSolidArea(Entity entity, Direction direction) {
switch (direction) {
case UP -> entity.solidArea.y -= entity.speed;
case DOWN -> entity.solidArea.y += entity.speed;
case LEFT -> entity.solidArea.x -= entity.speed;
case RIGHT -> entity.solidArea.x += entity.speed;
}
}
} }

View File

@@ -33,6 +33,7 @@ public class KeyHandler implements KeyListener {
switch (panel.ui.commandNum) { switch (panel.ui.commandNum) {
case 0: case 0:
panel.gameState = GameState.PLAY; panel.gameState = GameState.PLAY;
panel.resetGame(true);
panel.playMusic(0); panel.playMusic(0);
break; break;
case 1: case 1:

View File

@@ -118,7 +118,7 @@ public class SaveLoad {
panel.obj[mapNum][i] = getObject(ds.mapObjectNames[mapNum][i]); panel.obj[mapNum][i] = getObject(ds.mapObjectNames[mapNum][i]);
panel.obj[mapNum][i].worldX = ds.mapObjectWorldX[mapNum][i]; panel.obj[mapNum][i].worldX = ds.mapObjectWorldX[mapNum][i];
panel.obj[mapNum][i].worldY = ds.mapObjectWorldY[mapNum][i]; panel.obj[mapNum][i].worldY = ds.mapObjectWorldY[mapNum][i];
if (ds.mapObjectLootNames[mapNum][i] != null) panel.obj[mapNum][i].loot = getObject(ds.mapObjectLootNames[mapNum][i]); if (ds.mapObjectLootNames[mapNum][i] != null) panel.obj[mapNum][i].setLoot(getObject(ds.mapObjectLootNames[mapNum][i]));
panel.obj[mapNum][i].opened = ds.mapObjectOpened[mapNum][i]; panel.obj[mapNum][i].opened = ds.mapObjectOpened[mapNum][i];
panel.obj[mapNum][i].setDialogue(); panel.obj[mapNum][i].setDialogue();
if(panel.obj[mapNum][i].opened) panel.obj[mapNum][i].down1 = panel.obj[mapNum][i].image2; if(panel.obj[mapNum][i].opened) panel.obj[mapNum][i].down1 = panel.obj[mapNum][i].image2;

View File

@@ -367,7 +367,6 @@ public class Player extends Entity {
inventory.add(currentWeapon); inventory.add(currentWeapon);
inventory.add(currentShield); inventory.add(currentShield);
inventory.add(new KeyObj(panel)); inventory.add(new KeyObj(panel));
inventory.add(new LanternObj(panel));
} }
public void setDialogue() { public void setDialogue() {
dialogue[0][0] = "You are level " + level + " now!\nYou feel stronger!"; dialogue[0][0] = "You are level " + level + " now!\nYou feel stronger!";