Add Lanes
This commit is contained in:
parent
785d505492
commit
6e834e7f9c
@ -19,6 +19,7 @@ public class Canvas extends JPanel{
|
||||
final int JUDGEMENT_LINE_WIDTH = 64;
|
||||
final int JUDGEMENT_LINE_HEIGHT = 4;
|
||||
final int NOTE_SIZE = 16;
|
||||
final int LANE_SPACING_X = 100;
|
||||
|
||||
super.paintComponent(g);
|
||||
if (LLSIG.game!=null) {
|
||||
@ -27,17 +28,21 @@ public class Canvas extends JPanel{
|
||||
g.setColor(Color.WHITE);
|
||||
g.drawString(Integer.toString(LLSIG.game.frameCount),0,16);
|
||||
|
||||
g.setColor(Color.GRAY);
|
||||
g.fillRect(MIDDLE_X-JUDGEMENT_LINE_WIDTH/2,MIDDLE_Y-JUDGEMENT_LINE_HEIGHT/2,JUDGEMENT_LINE_WIDTH,JUDGEMENT_LINE_HEIGHT);
|
||||
for (int i=0;i<9;i++) {
|
||||
int LANE_X_OFFSET = (i-5)*LANE_SPACING_X+LANE_SPACING_X/2+JUDGEMENT_LINE_WIDTH/2;
|
||||
|
||||
g.setColor(NOTE_COLOR);
|
||||
int noteCounter = 0;
|
||||
Lane lane1 = LLSIG.game.lanes.get(0);
|
||||
while (lane1.noteExists(noteCounter)) {
|
||||
Note n = lane1.getNote(noteCounter);
|
||||
int NOTE_Y_OFFSET = (int)((((double)LLSIG.game.musicPlayer.getPlayPosition()-n.getStartFrame())/1000)*60*LLSIG.game.noteSpeed);
|
||||
g.fillOval(MIDDLE_X-NOTE_SIZE/2,MIDDLE_Y-NOTE_SIZE/2+NOTE_Y_OFFSET,NOTE_SIZE,NOTE_SIZE);
|
||||
noteCounter++;
|
||||
g.setColor(Color.GRAY);
|
||||
g.fillRect(MIDDLE_X-JUDGEMENT_LINE_WIDTH/2+LANE_X_OFFSET,MIDDLE_Y-JUDGEMENT_LINE_HEIGHT/2,JUDGEMENT_LINE_WIDTH,JUDGEMENT_LINE_HEIGHT);
|
||||
g.setColor(NOTE_COLOR);
|
||||
|
||||
Lane lane = LLSIG.game.lanes.get(i);
|
||||
int noteCounter = 0;
|
||||
while (lane.noteExists(noteCounter)) {
|
||||
Note n = lane.getNote(noteCounter);
|
||||
int NOTE_Y_OFFSET = (int)((((double)LLSIG.game.musicPlayer.getPlayPosition()-n.getStartFrame())/1000)*60*LLSIG.game.noteSpeed);
|
||||
g.fillOval(MIDDLE_X-NOTE_SIZE/2+LANE_X_OFFSET,MIDDLE_Y-NOTE_SIZE/2+NOTE_Y_OFFSET,NOTE_SIZE,NOTE_SIZE);
|
||||
noteCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.io.File;
|
||||
@ -26,6 +27,8 @@ public class LLSIG implements KeyListener{
|
||||
int noteSpeed = 4;
|
||||
List<Lane> lanes = new ArrayList<Lane>();
|
||||
|
||||
final static Dimension WINDOW_SIZE = new Dimension(1024,800);
|
||||
|
||||
public boolean EDITMODE = true;
|
||||
|
||||
LLSIG(JFrame f) {
|
||||
@ -33,7 +36,9 @@ public class LLSIG implements KeyListener{
|
||||
this.musicPlayer = new Player("music/MiChi - ONE-315959669.mp3");
|
||||
musicPlayer.play();
|
||||
|
||||
lanes.add(new Lane(new ArrayList<Note>()));
|
||||
for (int i=0;i<9;i++) {
|
||||
lanes.add(new Lane(new ArrayList<Note>()));
|
||||
}
|
||||
|
||||
//LoadSongData("MiChi - ONE-315959669",lanes);
|
||||
|
||||
@ -95,7 +100,7 @@ public class LLSIG implements KeyListener{
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame f = new JFrame();
|
||||
f.setSize(640, 640);
|
||||
f.setSize(WINDOW_SIZE);
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
game = new LLSIG(f);
|
||||
}
|
||||
@ -107,7 +112,22 @@ public class LLSIG implements KeyListener{
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
LLSIG.game.lanes.get(0).addNote(new Note(NoteType.NORMAL,musicPlayer.getPlayPosition()));
|
||||
int lane = -1;
|
||||
switch (e.getKeyCode()) {
|
||||
case KeyEvent.VK_A:{lane=0;}break;
|
||||
case KeyEvent.VK_S:{lane=1;}break;
|
||||
case KeyEvent.VK_D:{lane=2;}break;
|
||||
case KeyEvent.VK_F:{lane=3;}break;
|
||||
case KeyEvent.VK_SPACE:{lane=4;}break;
|
||||
case KeyEvent.VK_J:{lane=5;}break;
|
||||
case KeyEvent.VK_K:{lane=6;}break;
|
||||
case KeyEvent.VK_L:{lane=7;}break;
|
||||
case KeyEvent.VK_SEMICOLON:{lane=8;}break;
|
||||
case KeyEvent.VK_P:{if (musicPlayer.isPaused()) {musicPlayer.resume();} else {musicPlayer.pause();}}break;
|
||||
}
|
||||
if (lane!=-1) {
|
||||
LLSIG.game.lanes.get(lane).addNote(new Note(NoteType.NORMAL,musicPlayer.getPlayPosition()));
|
||||
}
|
||||
//System.out.println("Pressed "+e.getKeyChar()+" on frame "+musicPlayer.getPlayPosition());
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,9 @@ public class Player {
|
||||
public void pause() {
|
||||
jlpp.pause();
|
||||
}
|
||||
public boolean isPaused() {
|
||||
return jlpp.isPaused();
|
||||
}
|
||||
public void resume() {
|
||||
new Thread() {
|
||||
public void run() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user