Add in note judgements.
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
ae3a07e9cd
commit
3973e122cf
@ -46,10 +46,12 @@ public class Canvas extends JPanel{
|
|||||||
int noteCounter = 0;
|
int noteCounter = 0;
|
||||||
while (lane.noteExists(noteCounter)) {
|
while (lane.noteExists(noteCounter)) {
|
||||||
Note n = lane.getNote(noteCounter);
|
Note n = lane.getNote(noteCounter);
|
||||||
double PLAYTIME_RATIO = (1-(((double)n.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition())/LLSIG.game.NOTE_SPEED));
|
if (n.active) {
|
||||||
if (n.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition()<LLSIG.game.NOTE_SPEED) {
|
double PLAYTIME_RATIO = (1-(((double)n.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition())/LLSIG.game.NOTE_SPEED));
|
||||||
g.fillOval((int)(MIDDLE_X-Math.cos(Math.toRadians(22.5*i))*(PLAYTIME_RATIO*NOTE_DISTANCE)-NOTE_SIZE/2),(int)(MIDDLE_Y+Math.sin(Math.toRadians(22.5*i))*(PLAYTIME_RATIO*NOTE_DISTANCE)-NOTE_SIZE/2),
|
if (n.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition()<LLSIG.game.NOTE_SPEED) {
|
||||||
(int)(Math.min(PLAYTIME_RATIO/2+0.5,1)*NOTE_SIZE),(int)(Math.min(PLAYTIME_RATIO/2+0.5,1)*NOTE_SIZE));
|
g.fillOval((int)(MIDDLE_X-Math.cos(Math.toRadians(22.5*i))*(PLAYTIME_RATIO*NOTE_DISTANCE)-NOTE_SIZE/2),(int)(MIDDLE_Y+Math.sin(Math.toRadians(22.5*i))*(PLAYTIME_RATIO*NOTE_DISTANCE)-NOTE_SIZE/2),
|
||||||
|
(int)(Math.min(PLAYTIME_RATIO/2+0.5,1)*NOTE_SIZE),(int)(Math.min(PLAYTIME_RATIO/2+0.5,1)*NOTE_SIZE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
noteCounter++;
|
noteCounter++;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,11 @@ public class LLSIG implements KeyListener{
|
|||||||
|
|
||||||
public static boolean[] lanePress = new boolean[9]; //A lane is being requested to being pressed.
|
public static boolean[] lanePress = new boolean[9]; //A lane is being requested to being pressed.
|
||||||
public static boolean[] keyState = new boolean[9]; //Whether or not the key is pressed down.
|
public static boolean[] keyState = new boolean[9]; //Whether or not the key is pressed down.
|
||||||
|
|
||||||
|
final static int PERFECT_TIMING_WINDOW = 20;
|
||||||
|
final static int EXCELLENT_TIMING_WINDOW = 50;
|
||||||
|
final static int GREAT_TIMING_WINDOW = 100;
|
||||||
|
final static int BAD_TIMING_WINDOW = 150;
|
||||||
|
|
||||||
LLSIG(JFrame f) {
|
LLSIG(JFrame f) {
|
||||||
this.window = f;
|
this.window = f;
|
||||||
@ -55,15 +60,6 @@ public class LLSIG implements KeyListener{
|
|||||||
gameLoop = new Thread() {
|
gameLoop = new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
frameCount++;
|
frameCount++;
|
||||||
for (int i=0;i<9;i++) {
|
|
||||||
if (lanePress[i]) {
|
|
||||||
lanePress[i]=false;
|
|
||||||
if (lanes.get(i).noteExists()) {
|
|
||||||
lanes.get(i).getNote()
|
|
||||||
}
|
|
||||||
//TODO Hit detection goes here.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
window.repaint();
|
window.repaint();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -145,7 +141,19 @@ public class LLSIG implements KeyListener{
|
|||||||
LLSIG.game.lanes.get(lane).addNote(new Note(NoteType.NORMAL,musicPlayer.getPlayPosition()));
|
LLSIG.game.lanes.get(lane).addNote(new Note(NoteType.NORMAL,musicPlayer.getPlayPosition()));
|
||||||
}
|
}
|
||||||
if (lane!=-1) {
|
if (lane!=-1) {
|
||||||
lanePress[lane]=true;
|
if (PLAYING) {
|
||||||
|
Lane l = lanes.get(lane);
|
||||||
|
if (l.noteExists()) {
|
||||||
|
Note n = l.getNote();
|
||||||
|
int diff = n.getStartFrame()-LLSIG.game.musicPlayer.getPlayPosition();
|
||||||
|
if (Math.abs(diff)<=PERFECT_TIMING_WINDOW) {l.lastRating=TimingRating.PERFECT;} else
|
||||||
|
if (Math.abs(diff)<=EXCELLENT_TIMING_WINDOW) {l.lastRating=TimingRating.EXCELLENT;} else
|
||||||
|
if (Math.abs(diff)<=GREAT_TIMING_WINDOW) {l.lastRating=TimingRating.GREAT;} else
|
||||||
|
if (Math.abs(diff)<=BAD_TIMING_WINDOW) {l.lastRating=Math.signum(diff)>0?TimingRating.EARLY:TimingRating.LATE;}
|
||||||
|
l.lastNote=LLSIG.game.musicPlayer.getPlayPosition();
|
||||||
|
n.active=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
keyState[lane]=true;
|
keyState[lane]=true;
|
||||||
}
|
}
|
||||||
//System.out.println("Pressed "+e.getKeyChar()+" on frame "+musicPlayer.getPlayPosition());
|
//System.out.println("Pressed "+e.getKeyChar()+" on frame "+musicPlayer.getPlayPosition());
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package main.java.LLSIG;
|
package main.java.LLSIG;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Lane{
|
public class Lane{
|
||||||
List<Note> noteChart;
|
List<Note> noteChart;
|
||||||
int currentNoteIndex = 0;
|
int currentNoteIndex = 0;
|
||||||
|
TimingRating lastRating = TimingRating.MISS;
|
||||||
|
int lastNote = -1;
|
||||||
public Lane(List<Note> noteChart) {
|
public Lane(List<Note> noteChart) {
|
||||||
super();
|
super();
|
||||||
this.noteChart = noteChart;
|
this.noteChart = noteChart;
|
||||||
|
10
LLSIG/src/main/java/LLSIG/TimingRating.java
Normal file
10
LLSIG/src/main/java/LLSIG/TimingRating.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package main.java.LLSIG;
|
||||||
|
|
||||||
|
public enum TimingRating {
|
||||||
|
PERFECT, // +/-20ms
|
||||||
|
EXCELLENT, // +/-50ms
|
||||||
|
GREAT, // +/-100ms
|
||||||
|
EARLY, // +/-150ms
|
||||||
|
LATE, // +/-150ms
|
||||||
|
MISS; // >150ms
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user