diff --git a/.gitignore b/.gitignore index b0e6400..a5026e6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ hs_err_pid* # Maven log/ target/ +target/* /target/ # Inclusions diff --git a/pom.xml b/pom.xml index 92846c2..bbf8207 100644 --- a/pom.xml +++ b/pom.xml @@ -71,6 +71,7 @@ hugone.App + false jar-with-dependencies diff --git a/src/main/java/hugone/App.java b/src/main/java/hugone/App.java index 0adefdc..6f2f454 100644 --- a/src/main/java/hugone/App.java +++ b/src/main/java/hugone/App.java @@ -10,8 +10,6 @@ import hugone.util.Utils; class App { - public static java.util.HashMap shit = new java.util.HashMap(); // stores temporary vars to be relayed to main class - public static Story story; public static Player player; diff --git a/src/main/java/hugone/Area.java b/src/main/java/hugone/Area.java index a5492ea..0e349a3 100644 --- a/src/main/java/hugone/Area.java +++ b/src/main/java/hugone/Area.java @@ -172,7 +172,6 @@ public Furniture(JSONObject data, Area area) throws JSONException { this.collide = data.has("collide") ? data.getBoolean("collide") : true; if (data.has("dialogue")) { this.dialogue = App.story.getDialogue(data.getString("dialogue")); - this.dialogue.setParent(area); } JSONArray location = data.getJSONArray("location"); // top left diff --git a/src/main/java/hugone/Battle.java b/src/main/java/hugone/Battle.java index cdad978..db3f313 100644 --- a/src/main/java/hugone/Battle.java +++ b/src/main/java/hugone/Battle.java @@ -34,8 +34,8 @@ class Battle implements Feature { private Iterator notes; private ArrayList renderedNotes; private Integer notedamage; - public int notespeed; - public int bpm; + private int notespeed; + private int bpm; private int beat; private BattleState state = BattleState.INTRO;; @@ -245,17 +245,17 @@ public int getBeat() { public void reccieveKeyPress(KeyEvent e, KeyPress p) { if (this.introscene != null) this.introscene.reccieveKeyPress(e, p); - if (this.introcard != null) this.introcard.reccieveKeyPress(e, p); + if (this.introcard != null) this.introcard.reccieveKeyPress(e, p); if (!this.state.equals(BattleState.FIGHT)) return; for (Note n : new ArrayList(this.renderedNotes)) { if (Utils.keydirs.get(n.direction) != e.getKeyCode()) continue; - if (n instanceof HoldNote) { + if (n instanceof HoldNote h) { switch (p) { case KEYDOWN: if (Math.abs(n.getY()-this.getEndY()) > Constants.Battle.HITMARGIN && this.debouncebeat < 1) break; this.debouncebeat = 0; case KEYUP: - ((HoldNote)n).hit(p); + h.hit(p); return; // only one note per beat per column } } else { @@ -279,124 +279,123 @@ public void close() { public String getNext() { return this.next; } -} - -class Note { - public final Direction direction; - protected Battle parent; - protected Image image; - protected Point location; - protected boolean hit; - private long lasttime; - public Note(Battle p, Direction dir) { - this.parent = p; - this.direction = dir; - this.image = Utils.arrowimages.get(dir).scaleToWidth(p.getNoteSize()); - } + class Note { + protected final Direction direction; + protected Battle parent; + protected Image image; + protected Point location; + protected boolean hit; + private long lasttime; + + public Note(Battle p, Direction dir) { + this.parent = p; + this.direction = dir; + this.image = Utils.arrowimages.get(dir).scaleToWidth(p.getNoteSize()); + } - public void spawn() { - this.hit = false; - this.location = new Point( this.parent.getSpawnX(this.direction), this.parent.getSpawnY() ); - this.lasttime = System.currentTimeMillis(); - } + public void spawn() { + this.hit = false; + this.location = new Point( this.parent.getSpawnX(this.direction), this.parent.getSpawnY() ); + this.lasttime = System.currentTimeMillis(); + } - public void beat() { - if (!this.hit && this.pastBound()) { - this.parent.miss(); - this.hit = true; + public void beat() { + if (!this.hit && this.pastBound()) { + this.parent.miss(); + this.hit = true; + } } - } - protected void moveDown() { - int dist = Math.round((System.currentTimeMillis()-this.lasttime)*this.parent.notespeed)/(60*1000/this.parent.bpm); - if (dist > Constants.Battle.MINNOTEMOVE) { - this.location.translate(0, dist); - this.lasttime = System.currentTimeMillis(); + protected void moveDown() { + int dist = Math.round((System.currentTimeMillis()-this.lasttime)*this.parent.notespeed)/(60*1000/this.parent.bpm); + if (dist > Constants.Battle.MINNOTEMOVE) { + this.location.translate(0, dist); + this.lasttime = System.currentTimeMillis(); + } } - } - public void render(Graphics2D g) { - if (this.hit) return; - this.moveDown(); + public void render(Graphics2D g) { + if (this.hit) return; + this.moveDown(); - this.image.draw(this.location.x, this.location.y, g); - } + this.image.draw(this.location.x, this.location.y, g); + } - public boolean update() { // when should i stop attempting to render this note? - return this.hit; - } + public boolean update() { // when should i stop attempting to render this note? + return this.hit; + } - public void hit() { - this.parent.hit(this.direction); - this.hit = true; - } + public void hit() { + this.parent.hit(this.direction); + this.hit = true; + } - public int getY() { - return this.location.y; - } + public int getY() { + return this.location.y; + } - protected boolean pastBound() { - return this.location.y > this.parent.getEndY(); - } -} - -class HoldNote extends Note { - private int notelength; - private Image tailimage; - private int keydownon; - - public HoldNote(Battle p, Direction dir, int leng) { - super(p, dir); - this.notelength = leng; - this.tailimage = Utils.arrowtailimages.get(this.direction) - .scaleToWidth(this.parent.getNoteSize()) - .stretchToHeight((int)(this.notelength*this.parent.getNoteSize()*1.2d)); + protected boolean pastBound() { + return this.location.y > this.parent.getEndY(); + } } - @Override - public void spawn() { - super.spawn(); - this.keydownon = -1; - } + class HoldNote extends Note { + private int notelength; + private Image tailimage; + private int keydownon; + + public HoldNote(Battle p, Direction dir, int leng) { + super(p, dir); + this.notelength = leng; + this.tailimage = Utils.arrowtailimages.get(this.direction) + .scaleToWidth(this.parent.getNoteSize()) + .stretchToHeight((int)(this.notelength*this.parent.getNoteSize()*1.2d)); + } - public void hit(KeyPress p) { - switch (p) { - case KEYDOWN: - if (this.keydownon >= 0) break; - this.keydownon = this.parent.getBeat(); - System.out.println("Battle Beat: ["+super.parent.getBeat()+"]"); - break; - case KEYUP: - if (this.keydownon >= 0 && super.parent.getBeat()-this.keydownon == this.notelength) {super.hit();} - System.out.println("Battle Beat: ["+super.parent.getBeat()+"] | Button held for: ["+(super.parent.getBeat()-this.keydownon)+"] | Note Length: ["+this.notelength+"] | Hold Difference: ["+((super.parent.getBeat()-this.keydownon) - this.notelength)+"] Valid: "+(super.parent.getBeat()-this.keydownon == this.notelength)+";"); - this.keydownon = -1; - break; + @Override + public void spawn() { + super.spawn(); + this.keydownon = -1; } - } - @Override - public void render(Graphics2D g) { - if (this.hit) return; - this.moveDown(); + public void hit(KeyPress p) { + switch (p) { + case KEYDOWN: + if (this.keydownon >= 0) break; + this.keydownon = this.parent.getBeat(); + System.out.println("Battle Beat: ["+super.parent.getBeat()+"]"); + break; + case KEYUP: + if (this.keydownon >= 0 && super.parent.getBeat()-this.keydownon == this.notelength) {super.hit();} + System.out.println("Battle Beat: ["+super.parent.getBeat()+"] | Button held for: ["+(super.parent.getBeat()-this.keydownon)+"] | Note Length: ["+this.notelength+"] | Hold Difference: ["+((super.parent.getBeat()-this.keydownon) - this.notelength)+"] Valid: "+(super.parent.getBeat()-this.keydownon == this.notelength)+";"); + this.keydownon = -1; + break; + } + } - this.tailimage.draw(this.location.x, this.location.y - this.notelength*this.parent.getNoteSize(), g); - this.image.draw(this.location.x, this.location.y, g); - } + @Override + public void render(Graphics2D g) { + if (this.hit) return; - @Override - protected boolean pastBound() { - return this.keydownon < 0 ? super.pastBound() : this.location.y-this.parent.getNoteSize()*this.notelength > this.parent.getEndY(); - } -} + super.render(g); + this.tailimage.draw(this.location.x, this.location.y - this.notelength*this.parent.getNoteSize(), g); + } -class DeathNote extends Note { - public DeathNote(Battle p) { - super(p, Direction.NONE); + @Override + protected boolean pastBound() { + return this.keydownon < 0 ? super.pastBound() : this.location.y-this.parent.getNoteSize()*this.notelength > this.parent.getEndY(); + } } - @Override - public void hit() { - // L cant hit this bozo + class DeathNote extends Note { + public DeathNote(Battle p) { + super(p, Direction.NONE); + } + + @Override + public void hit() { + // L cant hit this bozo + } } } \ No newline at end of file diff --git a/src/main/java/hugone/Dialogues.java b/src/main/java/hugone/Dialogues.java index 277edb5..0508f52 100644 --- a/src/main/java/hugone/Dialogues.java +++ b/src/main/java/hugone/Dialogues.java @@ -1,7 +1,6 @@ package hugone; import java.awt.Graphics2D; -import java.awt.RenderingHints; import java.awt.event.KeyEvent; import java.util.ArrayList; @@ -15,12 +14,10 @@ import hugone.util.Audio; import hugone.util.Image; -@SuppressWarnings("unused") class Dialogues implements Feature { public String id; private ArrayList dialogues = new ArrayList(); private int index; - private Area area; public Dialogues(String id) throws JSONException { JSONObject data = App.story.data.getJSONObject("dialogue").getJSONObject(id); @@ -39,13 +36,7 @@ public Dialogues(String id) throws JSONException { this.index = 0; } - public void init() { - - } - - public void setParent(Area p) { - this.area = p; - } + public void init() {} public void reset() { this.index = 0; diff --git a/src/main/java/hugone/Menu.java b/src/main/java/hugone/Menu.java index ca80aff..93fa3e0 100644 --- a/src/main/java/hugone/Menu.java +++ b/src/main/java/hugone/Menu.java @@ -12,8 +12,8 @@ import hugone.util.Image; import hugone.util.Utils; -@SuppressWarnings("unused") public class Menu implements Feature { + @SuppressWarnings("unused") private String id; private Image background; private Button[] buttons; diff --git a/src/main/java/hugone/util/Video.java b/src/main/java/hugone/util/Video.java index 8b88e8c..c6524be 100644 --- a/src/main/java/hugone/util/Video.java +++ b/src/main/java/hugone/util/Video.java @@ -2,23 +2,30 @@ import uk.co.caprica.vlcj.player.component.EmbeddedMediaPlayerComponent; -public class Video { // TODO: No idea why this doesn't render +public class Video { private EmbeddedMediaPlayerComponent component; + private javax.swing.JFrame f; + private String filepath; public Video(String filepath, javax.swing.JFrame f) { + this.f = f; + this.filepath = filepath; this.component = new EmbeddedMediaPlayerComponent(); this.component.setFocusable(false); - f.setVisible(true); - f.add(this.component); - this.component.mediaPlayer().media().startPaused(filepath); - this.component.mediaPlayer().controls().setRepeat(false); + this.component.setVisible(false); } public void play() { - this.component.mediaPlayer().controls().play(); + this.f.add(this.component); + this.component.setVisible(true); + this.f.setVisible(true); + this.component.mediaPlayer().controls().setRepeat(false); + if (!this.component.mediaPlayer().media().play(this.filepath)) System.out.println("!WARNING! Video failed to play!"); } public void stop() { + this.f.remove(this.component); + this.component.setVisible(false); this.component.mediaPlayer().controls().stop(); } @@ -31,6 +38,7 @@ public boolean isPlayed() { } public void close() { + this.stop(); this.component.release(); } } \ No newline at end of file diff --git a/target/classes/BOTTOM_FLOOR.png b/target/classes/BOTTOM_FLOOR.png deleted file mode 100644 index 773c32e..0000000 Binary files a/target/classes/BOTTOM_FLOOR.png and /dev/null differ diff --git a/target/classes/closet_1.png b/target/classes/closet_1.png deleted file mode 100644 index 2a588a4..0000000 Binary files a/target/classes/closet_1.png and /dev/null differ diff --git a/target/classes/explore_closet_1.wav b/target/classes/explore_closet_1.wav deleted file mode 100644 index c14124d..0000000 Binary files a/target/classes/explore_closet_1.wav and /dev/null differ diff --git a/target/classes/faintcourage.wav b/target/classes/faintcourage.wav deleted file mode 100644 index cfd02ce..0000000 Binary files a/target/classes/faintcourage.wav and /dev/null differ diff --git a/target/classes/nomma_battle_notes.json b/target/classes/nomma_battle_notes.json deleted file mode 100644 index 456a5d9..0000000 --- a/target/classes/nomma_battle_notes.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "LEFT", - "DOWN", - "REST2", - "UP", - "DOWN", - "LEFT", - "UP", - "LEFT", - "RIGHT9", - "DOWN8", - "REST8", - "DEATH4" -] \ No newline at end of file diff --git a/target/classes/null.png b/target/classes/null.png deleted file mode 100644 index 606bb1a..0000000 Binary files a/target/classes/null.png and /dev/null differ diff --git a/target/classes/story.json b/target/classes/story.json deleted file mode 100644 index c2ba680..0000000 --- a/target/classes/story.json +++ /dev/null @@ -1,259 +0,0 @@ -{ - "menus": { - "STARTMENU": { - "background": "STARTMENU.png", - "buttonloc": [ - 650, - 600 - ], - "buttondim": [ - 250, - 75 - ], - "buttons": [ - { - "title": "Settings", - "image": "STARTMENU_settings.png", - "func": 1 - }, - { - "title": "Play", - "image": "STARTMENU_play.png", - "func": 0 - }, - { - "title": "Gallery", - "image": "STARTMENU_gallery.png", - "func": 2 - } - ] - } - }, - "scenes": { - "STARTMENU": { - "type": "MENU", - "id": "STARTMENU" - }, - "gallery": { - "type": "CARD", - "id": "gallery", - "image": "gallery.png", - "next": "STARTMENU" - }, - "intro": { - "type": "CUTSCENE", - "id": "intro", - "video": "intro.mp4", - "next": "bottomfloor" - }, - "bottomfloor": { - "type": "EXPLORATION", - "id": "bottomfloor", - "next": "nommabattle" - }, - "nommabattle": { - "type": "BATTLE", - "id": "nommabattle", - "next": "STARTMENU" - }, - "nommabattlesave": { - "type": "CUTSCENE", - "id": "nommabattlesave", - "video": "I hate your guts", - "next": "STARTMENU" - }, - "death": { - "type": "CARD", - "id": "death", - "image": "death.png" - } - }, - "characters": { - "SYSTEM": { - "name": "System", - "emotions": { - "HAPPY": "SYSTEM_HAPPY.png" - } - }, - "PLAYER": { - "name": "mc", - "health": 100, - "emotions": { - "HAPPY": "PLAYER_HAPPY.png", - "SAD": "PLAYER_SAD.png" - }, - "directions": { - "UP": { - "STOP": "KyleBackIdle.png", - "MOVE0": "KyleBackWalk1.png", - "MOVE1": "KyleBackIdle.png", - "MOVE2": "KyleBackWalk2.png" - }, - "DOWN": { - "STOP": "KyleFrontIdle.png", - "MOVE0": "KyleFrontWalk1.png", - "MOVE1": "KyleFrontIdle.png", - "MOVE2": "KyleFrontWalk2.png" - }, - "LEFT": { - "STOP": "KyleLeftIdle.png", - "MOVE0": "KyleLeftWalk1.png", - "MOVE1": "KyleLeftIdle.png", - "MOVE2": "KyleLeftWalk2.png" - }, - "RIGHT": { - "STOP": "KyleRightIdle.png", - "MOVE0": "KyleRightWalk1.png", - "MOVE1": "KyleRightIdle.png", - "MOVE2": "KyleRightWalk2.png" - } - } - }, - "ENEMY_1": { - "name": "Nomma", - "health": 60, - "emotions": { - "MAD": "NOMMA_MAD.png", - "BOP": "NOMMA_BOP.png", - "HURT_UP": "NOMMA_HURT_UP.png", - "HURT_DOWN": "NOMMA_HURT_DOWN.png", - "HURT_LEFT": "NOMMA_HURT_LEFT.png", - "HURT_RIGHT": "NOMMA_HURT_RIGHT.png", - "HIT": "NOMMA_HIT.png" - }, - "directions": {} - }, - "KYLE": { - "name": "Kyle", - "emotions": { - "HAPPY": "KYLE_HAPPY.png" - }, - "directions": { - "LEFT": { - "STOP": "KYLE_LEFT_STOP.png" - } - } - } - }, - "areas": { - "bottomfloor": { - "image": "BOTTOM_FLOOR.png", - "find": [ - "wallet" - ], - "music": "explore_bottom_floor.wav", - "startlocation": [ - 160, - 160 - ], - "dimensions": [ - [ - 50, - 50 - ], - [ - 1366, - 768 - ] - ], - "furniture": [ - { - "objectid": "closet1", - "image": "closet_1.png", - "location": [ - 100, - 100 - ], - "dimensions": [ - 50, - 100 - ], - "collide": true, - "dialogue": "explore_closet_1", - "item": "wallet" - }, - { - "objectid": "exit", - "image": "door_1.png", - "location": [ - 200, - 300 - ], - "dimensions": [ - 50, - 100 - ] - }, - { - "objectid": "save", - "location": [ - 400, 400 - ] - } - ] - } - }, - "battles": { - "nommabattle": { - "enemy": "ENEMY_1", - "damage": 25, - "introcard": "NOMMA_BATTLE_INTROCARD.png", - "introscene": "i hate java", - "background": "NOMMA_BATTLE_BG.png", - "overlay": "NOMMA_BATTLE_OV.png", - "song": "NOMMA_BATTLE_SONG.wav", - "missimage": "NOMMA_BATTLE_MISS.png", - "misssound": "NOMMA_BATTLE_MISS.wav", - "bpm": 60, - "speed": 300, - "notes": [ - "LEFT6", - "REST2", - "RIGHT", - "UP", - "DOWN2", - "REST", - "RIGHT3", - "DOWN", - "REST4", - "DEATH4" - ], - "maxdeaths": 3, - "save": "nommabattlesave" - } - }, - "dialogue": { - "explore_closet_1": { - "lines": [ - { - "character": "KYLE", - "emotion": "HAPPY", - "line": "There's still lots of clothes in here... Oh sick! There's a wallet in one of the pockets.", - "audio": "explore_closet_1.wav", - "textbox": "textbox.png" - } - ] - }, - "cant_exit": { - "lines": [ - { - "character": "KYLE", - "emotion": "HAPPY", - "line": "We should probably look around more before we leave this room.", - "audio": "cant_exit.wav", - "textbox": "textbox.png" - } - ] - }, - "save": { - "lines": [{ - "character": "SYSTEM", - "emotion": "HAPPY", - "line": "Game Saved!", - "audio": "saved.wav", - "textbox": "saved.png" - }] - } - }, - "version": 1 -} \ No newline at end of file diff --git a/target/classes/textbox.png b/target/classes/textbox.png deleted file mode 100644 index d5bab7b..0000000 Binary files a/target/classes/textbox.png and /dev/null differ