Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.GridLayout;
- import java.awt.Rectangle;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.io.Serializable;
- import java.util.ArrayList;
- import javax.sound.sampled.AudioFormat;
- import javax.sound.sampled.AudioInputStream;
- import javax.sound.sampled.AudioSystem;
- import javax.sound.sampled.Clip;
- import javax.sound.sampled.DataLine;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JFileChooser;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JTextArea;
- import javax.swing.WindowConstants;
- import javax.swing.Timer;
- public class ICS4U1_BeatGame {
- public static void main(String[] args) {
- MyUtil.importSongs();
- MenuFrame frame = new MenuFrame("M U S I C G A M E");
- }
- }
- class MenuFrame extends JFrame implements ActionListener, KeyListener{
- private JPanel menu, menuButtons;
- private Container c;
- private JButton buttonArray[];
- private String buttons[] = {"Load Game", "Create BeatMap", "Instructions"};
- private ImageIcon programIcon;
- private JFileChooser fc;
- private BeatMap mapIn;
- private GamePanel gamePanel;
- private JPanel keys;
- private JButton keyButtons[];
- private String keyText[] = {"d", "f", "space", "j", "k"};
- private Timer playerTimer;
- private long playerStartTime, playerCurrentTime, playerNoteTime, playerSongTime;
- private int playerNoteKey;
- private Note playerNote;
- private int score, bestScore;
- private boolean donePlaying;
- private JTextArea scoreInfo;
- public MenuFrame(String s) {
- setTitle(s);
- fc = new JFileChooser();
- mapIn = new BeatMap();
- programIcon = new ImageIcon("programIcon.png");//this is the thumbnail for the program (design one if you want)
- setIconImage(programIcon.getImage());
- buttonArray = new JButton[buttons.length];
- c = getContentPane();
- gamePanel = new GamePanel();
- scoreInfo = new JTextArea();
- scoreInfo.setEditable(false);
- keys = new JPanel();
- keyButtons = new JButton[keyText.length];
- for (int i = 0; i < keyText.length; i++) {
- keyButtons[i] = new JButton(keyText[i]);
- keyButtons[i].setBackground(new Color(246,246,246));
- keyButtons[i].setFont(new Font("Helvetica Nue", Font.PLAIN, 12));
- keyButtons[i].setBorderPainted(false);
- keyButtons[i].addKeyListener(this);
- keys.add(keyButtons[i]);
- }
- keys.addKeyListener(this);
- menu = new JPanel(new FlowLayout(FlowLayout.CENTER, 20,170));
- menuButtons = new JPanel();
- menuButtons.setLayout(new GridLayout(3,1,10,10));
- for (int i = 0; i < buttons.length; i++) {
- buttonArray[i] = new JButton(buttons[i]);
- buttonArray[i].setBackground(new Color(246,246,246));
- buttonArray[i].setFont(new Font("Helvetica Nue", Font.PLAIN, 12));
- buttonArray[i].setBorderPainted(false);
- buttonArray[i].addActionListener(this);
- menuButtons.add(buttonArray[i]);
- }
- menu.add(menuButtons);
- menu.setBackground(new Color(156,149,131));
- menuButtons.setBackground(new Color(156,149,131));
- c.add(menu, BorderLayout.CENTER);
- setSize(300,500);
- setResizable(false);
- setVisible(true);
- setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE);
- }
- public void actionPerformed(ActionEvent e) {
- if (e.getSource() == playerTimer) {
- }else {
- JButton b = (JButton) e.getSource();
- if (b == buttonArray[1]) {
- //stop initial menu music
- MapCreator creator = new MapCreator("Map Creator");
- } else if (b == buttonArray[0]) {
- try{
- int returnVal = fc.showOpenDialog(this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- openMethod(file);
- //menu.setVisible(false);
- remove(menu);
- updateHighscore(score);
- scoreInfo.setText(" High Score: " + bestScore + " Current Score: " + score);
- c.add(scoreInfo, BorderLayout.NORTH);
- c.add(gamePanel, BorderLayout.CENTER);
- c.add(keys, BorderLayout.SOUTH);
- keys.setFocusable(true);
- keys.requestFocusInWindow();
- revalidate();
- playerTimer = new Timer(10,this);
- playerStartTime = System.nanoTime()/10000000;
- playerTimer.start();
- score = 0;
- donePlaying = false;
- }
- }catch(Exception ex){
- System.out.print("Error" + ex);
- }
- } else if (b == buttonArray[2]) {
- InstructionFrame instruc = new InstructionFrame("Instructions");
- }
- }
- }
- public void openMethod(File filePath){
- FileInputStream fileIn = null;
- ObjectInputStream objectIn = null;
- try{
- fileIn = new FileInputStream(filePath);
- objectIn = new ObjectInputStream(fileIn);
- mapIn = (BeatMap)(objectIn.readObject());
- gamePanel.setMap(mapIn);
- objectIn.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public void paint(Graphics g) {
- super.paint(g);
- g.setColor(new Color(246,246,246));
- g.setFont(new Font("Helvetica Nue", Font.PLAIN, 12));
- g.drawString("M U S I C G A M E", 87, 140);
- //Rectangle
- g.fillRect(222, 473, 3, 20);
- //Leaves
- g.fillArc(222,470, 20,15, -180, -230 );
- g.fillArc(206, 470, 20, 15, 0, 230 );
- }
- public void keyTyped(KeyEvent e) {}
- public void keyPressed(KeyEvent e) {
- playerCurrentTime = System.nanoTime()/10000000 - 430;
- playerNoteTime = playerCurrentTime - playerStartTime;
- System.out.println("Player Current Time: " + playerNoteTime);
- if (e.getKeyCode() == 68){
- keyButtons[0].setBackground(Color.yellow);
- playerNoteKey = 1;
- }
- if (e.getKeyCode() == 70) {
- keyButtons[1].setBackground(Color.yellow);
- playerNoteKey = 2;
- }
- if (e.getKeyCode() == 32) {
- keyButtons[2].setBackground(Color.yellow);
- playerNoteKey = 3;
- }
- if (e.getKeyCode() == 74) {
- keyButtons[3].setBackground(Color.yellow);
- playerNoteKey = 4;
- }
- if (e.getKeyCode() == 75) {
- keyButtons[4].setBackground(Color.yellow);
- playerNoteKey = 5;
- }
- playerNote = mapIn.getNextNote();
- if (playerNote != null) {
- if (playerNote.compareNote(playerNoteTime, playerNoteKey) == 1) {
- score += playerNote.calcScore(50, playerNoteTime);
- scoreInfo.setText(" High Score: " + bestScore + " Current Score: " + score);
- }
- }
- try {
- if (playerNoteTime> MyUtil.clip.getMicrosecondLength()/10000) {
- System.out.println(MyUtil.clip.getMicrosecondLength()/10000);
- donePlaying = true;
- System.out.println("song is over");
- updateHighscore(score);
- scoreInfo.setText(" High Score: " + bestScore + " Current Score: " + score);
- }
- }
- catch(Exception ex) {}
- }
- public void keyReleased(KeyEvent e) {
- if (e.getKeyCode() == 68){
- keyButtons[0].setBackground(new Color(246, 246, 246));
- }
- if (e.getKeyCode() == 70) {
- keyButtons[1].setBackground(new Color(246, 246, 246));
- }
- if (e.getKeyCode() == 32) {
- keyButtons[2].setBackground(new Color(246, 246, 246));
- }
- if (e.getKeyCode() == 74) {
- keyButtons[3].setBackground(new Color(246, 246, 246));
- }
- if (e.getKeyCode() == 75) {
- keyButtons[4].setBackground(new Color(246, 246, 246));
- }
- }
- public void paintComponent(Graphics gr) {
- super.paintComponents(gr);
- gr.setColor(Color.black);
- gr.drawString("Highscore: " + bestScore + " Your Score: " + score, 20, 30);
- }
- public void updateHighscore (int score) {
- File myFile = new File("a.out");
- FileReader fr;
- BufferedReader reader;
- String lineIn="0";
- try {
- fr = new FileReader(myFile);
- reader = new BufferedReader(fr);
- lineIn = reader.readLine();
- reader.close();
- fr.close();
- }
- catch (Exception e) {
- System.out.println(e);
- }
- bestScore = Integer.parseInt(lineIn);
- if (bestScore < score) {
- System.out.println("New High Score!");
- BufferedWriter bw;
- try {
- bw=new BufferedWriter(new FileWriter ("a.out"));
- bw.write("" + score);
- bw.close();
- } catch (Exception e) {
- System.out.println(e);
- }
- }
- }
- }
- class InstructionFrame extends JFrame {
- private JTextArea ins;
- private Container c;
- public InstructionFrame(String s) {
- setTitle(s);
- setResizable(false);
- setSize(300,500);
- setVisible(true);
- c=getContentPane();
- ins = new JTextArea();
- ins.setEditable(false);
- ins.setText("INSTRUCTIONS\n\nCreate your own beatmap by importing .wav files\nor load a pre-existing map.\n" +
- "Begin to press the keys (d, f, spacebar, j, and k)\nonce the song starts to play.\n" +
- "Try to match your presses with the descending keys.\n" +
- "Press any key once more after the game to see\nyour highscore update.\n" +
- "");
- c.add(ins, BorderLayout.CENTER);
- }
- }
- class MapCreator extends JFrame implements ActionListener, KeyListener{
- private JButton btn_open = new JButton("Open Song");
- private JButton btn_save = new JButton("Save");
- private JButton btn_start = new JButton("Start Recording");
- private Container c;
- private JPanel control, side, main, creator;
- private JLabel selectedSong;
- private int currentSong;
- private JFileChooser fc;
- private SongSelect selector;
- private long startTime, currentTime, noteTime, songTime;
- private BeatMap map1;
- private boolean isRecording = false;
- private int noteKey;
- private Timer songTimer;
- private JButton keys[];
- private String keyText[] = {"d", "f", "space", "j", "k"};
- public MapCreator(String s, int currentSong) {
- this.currentSong = currentSong;
- fc = new JFileChooser();
- control = new JPanel();
- main = new JPanel();
- creator = new JPanel();
- side = new JPanel();
- selectedSong = new JLabel();
- c = getContentPane();
- control.setLayout(new GridLayout(3,1,10,10));
- creator.setLayout(new GridLayout(1, 5, 20,10));
- main.setLayout(new FlowLayout(FlowLayout.CENTER, 20,100));
- side.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 150));
- songTimer = new Timer(10, this);
- btn_open.setBackground(new Color(246,246,246));
- btn_open.setFont(new Font("Helvetica Nue", Font.PLAIN, 12));
- btn_open.setBorderPainted(false);
- btn_open.addActionListener(this);
- control.add(btn_open);
- btn_save.setBackground(new Color(246,246,246));
- btn_save.setFont(new Font("Helvetica Nue", Font.PLAIN, 12));
- btn_save.setBorderPainted(false);
- btn_save.addActionListener(this);
- control.add(btn_save);
- btn_start.setBackground(new Color(246,246,246));
- btn_start.setFont(new Font("Helvetica Nue", Font.PLAIN, 12));
- btn_start.setBorderPainted(false);
- btn_start.addActionListener(this);
- control.add(btn_start);
- keys = new JButton[keyText.length];
- for (int i = 0; i < keyText.length; i++) {
- keys[i] = new JButton(keyText[i]);
- keys[i].setBackground(new Color(246,246,246));
- keys[i].setFont(new Font("Helvetica Nue", Font.PLAIN, 12));
- keys[i].setBorderPainted(false);
- main.add(keys[i]);
- }
- if (currentSong == -1) {
- selectedSong.setText("Selected song: ");
- }else {
- selectedSong.setText("Selected song: " + MyUtil.currentSong(currentSong).getName());
- }
- main.add(selectedSong);
- side.add(control);
- creator.add(main);
- main.addKeyListener(this);
- btn_save.addKeyListener(this);
- btn_open.addKeyListener(this);
- btn_start.addKeyListener(this);
- main.setFocusable(true);
- c.add(side, BorderLayout.EAST);
- c.add(creator, BorderLayout.CENTER);
- setTitle(s);
- setResizable(false);
- setSize(600,300);
- setVisible(true);
- //setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE);
- }
- public MapCreator(String s) {
- this(s, -1);
- }
- public void actionPerformed (ActionEvent e) {
- if (isRecording) {
- currentTime = System.nanoTime()/10000000;
- if (currentTime - startTime > songTime) {
- isRecording = false;
- System.out.println("Song is over");
- songTimer.stop();
- }
- return;
- }
- JButton b = (JButton) e.getSource();
- if (b == btn_open) {
- selector = new SongSelect("Song Select");
- this.dispose();
- } else if (b == btn_save) {
- try{
- int returnVal = fc.showSaveDialog(this); // need to import javax.swing.filechooser.*;
- if (returnVal == JFileChooser.APPROVE_OPTION) { // if user did not click cancel and picked file name
- File file = fc.getSelectedFile(); // picked name
- saveMethod(file);
- }
- }catch(Exception ex){
- System.out.print("Error" + ex);
- }
- }
- else if (b == btn_start) {
- if (currentSong != -1) {
- System.out.println("Recording started");
- songTime = MyUtil.playSong(currentSong);
- System.out.println("Song time: " + songTime);
- map1 = new BeatMap(currentSong);
- startTime = System.nanoTime()/10000000;
- songTimer.start();
- isRecording = true;
- main.setFocusable(true);
- btn_start.setFocusable(false);
- }
- }
- }
- public void keyPressed(KeyEvent ev) {
- if (isRecording) {
- noteTime = currentTime - startTime;
- currentTime = System.nanoTime()/10000000;
- if (currentTime - startTime > songTime)
- isRecording = false;
- }
- if (ev.getKeyCode() == 68){
- noteKey = 1;
- keys[0].setBackground(Color.yellow);
- }
- if (ev.getKeyCode() == 70) {
- noteKey = 2;
- keys[1].setBackground(Color.yellow);
- }
- if (ev.getKeyCode() == 32) {
- noteKey = 3;
- keys[2].setBackground(Color.yellow);
- }
- if (ev.getKeyCode() == 74) {
- noteKey = 4;
- keys[3].setBackground(Color.yellow);
- }
- if (ev.getKeyCode() == 75) {
- noteKey = 5;
- keys[4].setBackground(Color.yellow);
- }
- if (noteKey != -1 && isRecording) {
- map1.addNote(noteTime, noteKey);
- System.out.println("Added note");
- System.out.println("Time: " + noteTime);
- System.out.println("Note:" + noteKey);
- }
- }
- public void keyReleased(KeyEvent ev) {
- if (isRecording) {
- int n = ev.getKeyCode();
- switch(n) {
- case 68: // d
- noteKey = 1;
- keys[0].setBackground(new Color(246, 246, 246));
- break;
- case 70: // f
- noteKey = 2;
- keys[1].setBackground(new Color(246, 246, 246));
- break;
- case 32: // spacebar
- noteKey = 3;
- keys[2].setBackground(new Color(246, 246, 246));
- break;
- case 74: // j
- noteKey = 4;
- keys[3].setBackground(new Color(246, 246, 246));
- break;
- case 75: // k
- noteKey = 5;
- keys[4].setBackground(new Color(246, 246, 246));
- break;
- default:
- noteKey = -1;
- break;
- }
- }else {
- System.out.println("Recording is over");
- }
- }
- public void keyTyped(KeyEvent ev) {
- }
- public void saveMethod(File filePath){
- FileOutputStream fout = null;
- ObjectOutputStream oos = null;
- try {
- fout = new FileOutputStream(filePath);
- oos = new ObjectOutputStream(fout);
- oos.writeObject(map1);
- fout.close();
- oos.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- }
- class SongSelect extends JFrame implements ActionListener {
- private Container c;
- private JPanel songSelect, southPanel, base;
- private JButton[] btnArr;
- private JButton selectSong, clearSong;
- private int currentSong;
- public SongSelect(String s) {
- songSelect = new JPanel();
- southPanel = new JPanel();
- base = new JPanel();
- selectSong = new JButton("Select Song");
- selectSong.setBackground(new Color(246,246,246));
- selectSong.setFont(new Font("Helvetica Nue", Font.PLAIN, 12));
- selectSong.setBorderPainted(false);
- selectSong.addActionListener(this);
- clearSong = new JButton("Clear Song");
- clearSong.setBackground(new Color(246,246,246));
- clearSong.setFont(new Font("Helvetica Nue", Font.PLAIN, 12));
- clearSong.setBorderPainted(false);
- clearSong.addActionListener(this);
- c = getContentPane();
- southPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
- southPanel.add(selectSong);
- southPanel.add(clearSong);
- songSelect.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 150));
- btnArr = new JButton[MyUtil.songArr.size()];
- for (int i = 0; i < btnArr.length; i++) {
- btnArr[i] = new JButton(MyUtil.songArr.get(i).getName());
- songSelect.add(btnArr[i]);
- btnArr[i].setBackground(new Color(246,246,246));
- btnArr[i].setFont(new Font("Helvetica Nue", Font.PLAIN, 12));
- btnArr[i].setBorderPainted(false);
- btnArr[i].addActionListener(this);
- }
- c.add(songSelect, BorderLayout.CENTER);
- c.add(southPanel, BorderLayout.SOUTH);
- setTitle(s);
- setResizable(false);
- setSize(600,300);
- setVisible(true);
- //setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- }
- public void actionPerformed(ActionEvent e) {
- //System.out.println("Action performed");
- JButton b = (JButton)e.getSource();
- if (b == clearSong) {
- try {
- MyUtil.clearSong();
- }catch(Exception ex) {}
- }else if(b == selectSong) {
- try {
- MyUtil.clearSong();
- }catch(Exception ex) {}
- MapCreator creator = new MapCreator("Map Creator", currentSong);
- this.dispose();
- }
- for (int i = 0; i < btnArr.length; i++) {
- if (btnArr[i] == e.getSource()) {
- try {
- MyUtil.clearSong();
- }catch(Exception ex) {}
- MyUtil.playSong(i);
- currentSong = i;
- }
- }
- }
- }
- class MyUtil {
- static ArrayList<Song> songArr = new ArrayList<Song>();
- static File songFolder = new File("Songs");
- static AudioInputStream stream;
- static AudioFormat format;
- static DataLine.Info info;
- static Clip clip;
- public static void importSongs() {
- File[] files = songFolder.listFiles();
- for (int i = 0; i < files.length; i++) {
- songArr.add(new Song(files[i], files[i].getName(), i));
- System.out.println("Adding new song: " + files[i].getName());
- }
- }
- public static long playSong(int i) {
- try {
- stream = AudioSystem.getAudioInputStream(songArr.get(i).getSongFile());
- format = stream.getFormat();
- info = new DataLine.Info(Clip.class, format);
- clip = (Clip) AudioSystem.getLine(info);
- clip.open(stream);
- clip.start();
- }catch(Exception e) {
- e.printStackTrace();
- }
- return clip.getMicrosecondLength()/10000;
- }
- public static void clearSong() {
- clip.close();
- }
- public static Song currentSong(int i) {
- return songArr.get(i);
- }
- }
- class Song implements Serializable{
- private File songFile;
- private String name;
- private int songNum;
- public Song(File file, String name, int songNum) {
- songFile = file;
- this.name = name;
- this.songNum = songNum;
- }
- public Song(String name) {
- this(new File(""), name, 0);
- }
- public String getName() {
- return name;
- }
- public File getSongFile() {
- return songFile;
- }
- public int getSongNum() {
- return songNum;
- }
- }
- class BeatMap implements Serializable {
- private ArrayList<Note> notes;
- private Song song;
- public BeatMap(){}
- public BeatMap(int i) {
- notes = new ArrayList<Note>();
- song = MyUtil.currentSong(i);
- addNote(0, 3);
- }
- public void addNote(long noteTime, int noteKey) {
- notes.add(new Note(noteTime, noteKey));
- }
- public ArrayList<Note> getAllNotes() {
- return notes;
- }
- public int getNumNotes() {
- return notes.size();
- }
- public Song getSong(){
- return song;
- }
- public Note getNextNote() {
- for (int i = 0; i < notes.size(); i++) {
- if (notes.get(i).hasPlayed == false) {
- System.out.print(notes.get(i).noteKey);
- notes.get(i).canPlay = true;
- return (notes.get(i));
- }
- }
- return null; //itll never reach this right
- }
- }
- class Note implements Serializable {
- private long noteTime;
- public int noteKey;
- public int moveY;
- private boolean onScreen;
- public boolean hasPlayed, canPlay;
- public Note(long noteTime, int noteKey) {
- this.noteTime = noteTime;
- this.noteKey = noteKey;
- moveY = (int)(noteTime*-1); //the spacing messes up the accuracy of the bars
- onScreen = true;
- hasPlayed = false;
- canPlay = false;
- }
- public int calcScore(int range, long pNoteTime) {
- if (range <= 1 || Math.abs(pNoteTime - noteTime) > range) {
- return 1;
- }
- else {
- return range + calcScore(range/2, pNoteTime);
- }
- }
- //compares the player's key presses to the created map for accuracy and returns score
- public int compareNote(long pNoteTime, int pNoteKey) {
- if (pNoteKey == noteKey) {
- System.out.println("Player note time: " + pNoteTime);
- System.out.println("Note time: " + noteTime);
- if (canPlay == true && Math.abs(pNoteTime - noteTime) < 100) {
- System.out.println(canPlay);
- canPlay = false;
- hasPlayed = true;
- System.out.println("good!");
- return 1;
- } else {
- System.out.println("bad");
- return 0;
- }
- } else {
- System.out.println("bad");
- return 0;
- }
- }
- public void draw(Graphics g, long currentTime){
- if (moveY + currentTime > 450 && onScreen) {
- //System.out.println("NoteTime: " + noteTime);
- onScreen = false;
- hasPlayed = true;
- }
- if (noteKey == 1) {
- g.fillRect(18, (int) (moveY + currentTime), 35, 5); ///lol this is not the right spacing
- } else if (noteKey == 2) {
- g.fillRect(64, (int) (moveY + currentTime) , 35, 5);
- } else if(noteKey == 3) {
- g.fillRect(109, (int) (moveY + currentTime), 60, 5);
- } else if (noteKey == 4){
- g.fillRect(178, (int) (moveY + currentTime), 35, 5);
- } else if (noteKey == 5) {
- g.fillRect(222, (int) (moveY + currentTime), 35, 5);
- }
- }
- }
- class GamePanel extends JPanel implements ActionListener{
- BeatMap map1;
- Timer gameTimer;
- public long startTime, currentTime;
- private boolean songPlaying;
- public GamePanel() {}
- public void setMap(BeatMap m){
- map1 = m;
- gameTimer = new Timer(10,this); //every tick (tick = 0.01s)
- gameTimer.start();
- startTime = System.nanoTime()/10000000;
- songPlaying = false;
- //MyUtil.playSong(m.getSong().getSongNum());
- }
- public void actionPerformed(ActionEvent e) {
- currentTime = (System.nanoTime()/10000000) - startTime;
- //System.out.println("Current Time: " + currentTime);
- if (e.getSource() == gameTimer) {
- if (currentTime > 430 && !songPlaying) {
- MyUtil.playSong(map1.getSong().getSongNum());
- songPlaying = true;
- }
- for (int i = 0; i < map1.getNumNotes(); i++) {
- //map1.getAllNotes().get(i).moveY += 1; //lol also not the right speed
- //map1.getAllNotes().get(i).updatePos(currentTime);
- }
- repaint();
- }
- }
- public void paintComponent(Graphics g){
- super.paintComponent(g);
- for (int i = 0; i < map1.getAllNotes().size(); i++) {
- map1.getAllNotes().get(i).draw(g, currentTime);
- }
- repaint();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement