Merge remote-tracking branch 'origin/master'

master
Chara1236 2022-06-19 15:57:30 -04:00
commit 7ee87d65eb
7 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,2 @@
Have you heard of the tragedy of
Darth Charlie the Wise?

View File

@ -0,0 +1,2 @@
Have you heard of the tragedy of
Darth Charlie the Wise?

20
saves/Level3-dialogue.txt Normal file
View File

@ -0,0 +1,20 @@
$Villain
I am having a seizure.
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

View File

@ -18,12 +18,16 @@ public class DialogueMenu extends TextBox implements Serializable {
public DialogueMenu(int y, int yHeight, Font font, BufferedImageWrapper portrait, boolean isNarrator) { public DialogueMenu(int y, int yHeight, Font font, BufferedImageWrapper portrait, boolean isNarrator) {
super(y, GamePanel.GAME_WIDTH - PORTRAIT_WIDTH - PADDING*3, yHeight, 0, font, null, null); super(y, GamePanel.GAME_WIDTH - PORTRAIT_WIDTH - PADDING*3, yHeight, 0, font, null, null);
PORTRAIT = portrait; PORTRAIT = portrait;
checkForNarrator();
this.isNarrator = isNarrator;
}
public void checkForNarrator() {
if (isNarrator) { if (isNarrator) {
newX = PORTRAIT_WIDTH + PADDING*2; newX = PORTRAIT_WIDTH + PADDING*2;
} else { } else {
newX = PADDING; newX = PADDING;
} }
this.isNarrator = isNarrator;
} }
public void drawCenteredTextBox(Graphics g, String text, Color backgroundColor, Color textColor) { public void drawCenteredTextBox(Graphics g, String text, Color backgroundColor, Color textColor) {
@ -72,6 +76,7 @@ public class DialogueMenu extends TextBox implements Serializable {
} }
public boolean draw(Graphics g, String text, Color backgroundColor, Color textColor) { public boolean draw(Graphics g, String text, Color backgroundColor, Color textColor) {
checkForNarrator();
if (frameCounter >= FREQUENCY) { if (frameCounter >= FREQUENCY) {
frameCounter -= FREQUENCY; frameCounter -= FREQUENCY;
currentFrame += 1; currentFrame += 1;

View File

@ -1,7 +1,10 @@
import javax.imageio.ImageIO;
import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
public class LevelManager implements Serializable { public class LevelManager implements Serializable {
public static int level = 1; public static int level = 1;
@ -34,6 +37,16 @@ public class LevelManager implements Serializable {
} }
try { try {
MapReader.inputMap(filePath); MapReader.inputMap(filePath);
GameFrame.game.dialogueArray = new ArrayList<String>(Arrays.asList(MapReader.inputDialogue(filePath)));
if (GameFrame.game.dialogueArray.get(0).contains("$Villain")) {
GameFrame.game.dialogueArray.remove(0);
GameFrame.game.dialogueMenu.isNarrator = false;
// TODO: move img path to GamePanel
GameFrame.game.dialogueMenu.PORTRAIT = new BufferedImageWrapper("img\\dialogue\\Bouncer.png");
}
GameFrame.game.dialogueMenu.currentFrame = 0;
GameFrame.game.dialogueMenu.frameCounter = 0;
GameFrame.game.isDialogue = true;
} catch (IOException | SpriteException | UnsupportedAudioFileException | LineUnavailableException e) { } catch (IOException | SpriteException | UnsupportedAudioFileException | LineUnavailableException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -109,6 +109,12 @@ public class MapReader implements Serializable {
x+=1; x+=1;
} }
} }
public static String[] inputDialogue(String mapFilePath) throws IOException {
String filePath = mapFilePath.replace(".txt", "-dialogue.txt");
return FileManager.readFile(filePath).split("\n");
}
public static void newTile(String filePath) throws IOException, SpriteException { public static void newTile(String filePath) throws IOException, SpriteException {
GameFrame.game.map[x][y]=(new SingleTile(TileX,TileY, new BufferedImageWrapper((filePath)))); GameFrame.game.map[x][y]=(new SingleTile(TileX,TileY, new BufferedImageWrapper((filePath))));
} }

View File

@ -166,6 +166,8 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{
try { try {
GameFrame.main.remove(GameFrame.game); GameFrame.main.remove(GameFrame.game);
GameFrame.game.isRunning = false; GameFrame.game.isRunning = false;
GameFrame.game.player.xVelocity = 0;
GameFrame.game.player.yVelocity = 0;
GameFrame.game = new GamePanel(GameFrame.main); //run GamePanel constructor GameFrame.game = new GamePanel(GameFrame.main); //run GamePanel constructor
GameFrame.game.startThread(); GameFrame.game.startThread();
GameFrame.main.add(GameFrame.game, "game", 0); GameFrame.main.add(GameFrame.game, "game", 0);