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