Skip to content

Commit

Permalink
fixes i guess
Browse files Browse the repository at this point in the history
  • Loading branch information
MutantPiggieGolem1 committed Aug 19, 2022
1 parent e38e37d commit 0545160
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 395 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ hs_err_pid*
# Maven
log/
target/
target/*
/target/

# Inclusions
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<mainClass>hugone.App</mainClass>
</manifest>
</archive>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/hugone/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import hugone.util.Utils;

class App {
public static java.util.HashMap<String,Object> shit = new java.util.HashMap<String,Object>(); // stores temporary vars to be relayed to main class

public static Story story;
public static Player player;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/hugone/Area.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
203 changes: 101 additions & 102 deletions src/main/java/hugone/Battle.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Battle implements Feature {
private Iterator<Note> notes;
private ArrayList<Note> renderedNotes;
private Integer notedamage;
public int notespeed;
public int bpm;
private int notespeed;
private int bpm;
private int beat;

private BattleState state = BattleState.INTRO;;
Expand Down Expand Up @@ -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<Note>(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 {
Expand All @@ -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
}
}
}
11 changes: 1 addition & 10 deletions src/main/java/hugone/Dialogues.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hugone;

import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.util.ArrayList;

Expand All @@ -15,12 +14,10 @@
import hugone.util.Audio;
import hugone.util.Image;

@SuppressWarnings("unused")
class Dialogues implements Feature {
public String id;
private ArrayList<Dialogue> dialogues = new ArrayList<Dialogue>();
private int index;
private Area area;

public Dialogues(String id) throws JSONException {
JSONObject data = App.story.data.getJSONObject("dialogue").getJSONObject(id);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hugone/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/hugone/util/Video.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -31,6 +38,7 @@ public boolean isPlayed() {
}

public void close() {
this.stop();
this.component.release();
}
}
Binary file removed target/classes/BOTTOM_FLOOR.png
Binary file not shown.
Binary file removed target/classes/closet_1.png
Binary file not shown.
Binary file removed target/classes/explore_closet_1.wav
Binary file not shown.
Binary file removed target/classes/faintcourage.wav
Binary file not shown.
14 changes: 0 additions & 14 deletions target/classes/nomma_battle_notes.json

This file was deleted.

Binary file removed target/classes/null.png
Binary file not shown.
Loading

0 comments on commit 0545160

Please sign in to comment.