diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2023-05-14 17:34:40 -0400 | 
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2023-05-14 17:34:40 -0400 | 
| commit | 4a1f4a98116b5c59efe0606375b833a722a0d281 (patch) | |
| tree | f993765d0022da440199fb109633b0e0113082eb /src/main | |
| parent | 6e2ff44c33226e6d03810ae5fae9645605d3e89d (diff) | |
| download | NPEhero-4a1f4a98116b5c59efe0606375b833a722a0d281.tar.gz NPEhero-4a1f4a98116b5c59efe0606375b833a722a0d281.tar.bz2 NPEhero-4a1f4a98116b5c59efe0606375b833a722a0d281.zip  | |
add levelselector gui, move some files around
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/JFXaudioPlayer.java | 29 | ||||
| -rw-r--r-- | src/main/KeyDetection.java | 27 | ||||
| -rw-r--r-- | src/main/Level.java | 25 | ||||
| -rw-r--r-- | src/main/LevelController.java | 1 | ||||
| -rw-r--r-- | src/main/NoteTest.java | 35 | ||||
| -rw-r--r-- | src/main/SettingsController.java | 7 | ||||
| -rw-r--r-- | src/main/SongPlayer.java | 97 | ||||
| -rw-r--r-- | src/main/focusTest.java | 46 | 
8 files changed, 33 insertions, 234 deletions
diff --git a/src/main/JFXaudioPlayer.java b/src/main/JFXaudioPlayer.java deleted file mode 100644 index 9207c59..0000000 --- a/src/main/JFXaudioPlayer.java +++ /dev/null @@ -1,29 +0,0 @@ -package main; - -import java.io.File; -import java.io.IOException; - -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.media.Media; -import javafx.scene.media.MediaPlayer; -import javafx.stage.Stage; - -public class JFXaudioPlayer extends Application{ -     -    public static void main(String[] args)  -    { -        launch(args); -    } -         -    @Override -    public void start(Stage primaryStage)  -    { -        // primaryStage.show(); -        String musicFile = "EXAMPLE.mp3";     // For example -        Media sound = new Media(new File(musicFile).toURI().toString()); -        MediaPlayer mediaPlayer = new MediaPlayer(sound); -        mediaPlayer.play(); -    } -}
\ No newline at end of file diff --git a/src/main/KeyDetection.java b/src/main/KeyDetection.java deleted file mode 100644 index 7887405..0000000 --- a/src/main/KeyDetection.java +++ /dev/null @@ -1,27 +0,0 @@ -/*Name:	 - *Date: - *Period: - *Teacher: - *Description: - */ -package main; - -import javax.swing.*; -import java.awt.event.ActionEvent; - -public class KeyDetection extends AbstractAction -{ -    long timeStart = System.currentTimeMillis(); -    private char key; -    public KeyDetection(char ch){ -        key = ch; -    } -     -    public void actionPerformed(ActionEvent e) -    { -        // TODO Auto-generated method stub -        int time = (int)((System.currentTimeMillis()-timeStart)); -        System.out.println(key + ": " + time); -    } -     -} diff --git a/src/main/Level.java b/src/main/Level.java new file mode 100644 index 0000000..52047fd --- /dev/null +++ b/src/main/Level.java @@ -0,0 +1,25 @@ +package main; + +import java.io.File; +import java.util.ArrayList; + +import javafx.scene.image.Image; +import javafx.scene.paint.Color; + +public class Level  +{ +    private Color[] colors; +    private Image background; +    private Image preview; +    private String text; +    private String desc; +    //private ArrayList<String>(); + +    //google "varargs" to see how this works +    public void setColors(Color... newColors) +    { +        colors = newColors; +    } + +    //INCOMPLETE +} diff --git a/src/main/LevelController.java b/src/main/LevelController.java new file mode 100644 index 0000000..daf7ae3 --- /dev/null +++ b/src/main/LevelController.java @@ -0,0 +1 @@ +//coming soon
\ No newline at end of file diff --git a/src/main/NoteTest.java b/src/main/NoteTest.java deleted file mode 100644 index 34d9c8c..0000000 --- a/src/main/NoteTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/*Name:	 - *Date: - *Period: - *Teacher: - *Description: - */ -package main; -import java.awt.*; - -public class NoteTest -{ -    private boolean failed = false; -    private int lane; -    private final int NOTESPEED = 1; -    private int yPos = SongPlayer.HEIGHT; -     -    public void gameTick() { -        if (!failed) { -            if (yPos > 0) { -                yPos -= NOTESPEED; -            }             -            else { -                failed = true; -            } -        }     -    } -     -    public boolean getFailed() { -        return failed; -    } -     -    public int getY() { -        return yPos; -    } -} diff --git a/src/main/SettingsController.java b/src/main/SettingsController.java new file mode 100644 index 0000000..79fb560 --- /dev/null +++ b/src/main/SettingsController.java @@ -0,0 +1,7 @@ +// coming soon +// needs to have getters and setters for: +// - sfx vol +// - music vol +// - full screen  +// +// perhaps use public variables instead of getters and setters
\ No newline at end of file diff --git a/src/main/SongPlayer.java b/src/main/SongPlayer.java deleted file mode 100644 index caf1ab7..0000000 --- a/src/main/SongPlayer.java +++ /dev/null @@ -1,97 +0,0 @@ -/*Name:	 - *Date: - *Period: - *Teacher: - *Description: - */ -package main; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - - -public class SongPlayer -{ -    public static final int HEIGHT = 650; -    public static final int LENGTH = 400; -     -     -    private final int BLENGTH = LENGTH/6; -    private final int BHEIGHT = HEIGHT/20; -    JFrame frame = new JFrame("Guitar Hero");      //creates the frame -     -     -    JButton d = new JButton("D");       //creates the four button lanes -    JButton f = new JButton("F"); -    JButton h = new JButton("H"); -    JButton j = new JButton("J"); - -     -    public void createAndShowGui() { -         -        d.setBounds(1*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);      //makes the button bounds for each button -        f.setBounds(2*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);      -        h.setBounds(3*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);       -        j.setBounds(4*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);      - -         -        frame.add(d);                           //adds the buttons to the frame -        frame.add(f); -        frame.add(h); -        frame.add(j); -         -        frame.setSize(LENGTH, HEIGHT);          //sets the size of the frame -        frame.setLayout(null);                  //???     -        frame.setVisible(true);                 //makes the frame visible -         -        KeyDetection dAction = new KeyDetection('d');                                                   //creates an action for each char -        d.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('d'), "dPress");    //Input map and Action map setting -        d.getActionMap().put("dPress", dAction); -        d.setFocusable(false);                                                                          //makes it so you can't highlight the button -         -        KeyDetection fAction = new KeyDetection('f'); -        f.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('f'), "fPress"); -        f.getActionMap().put("fPress", fAction); -        f.setFocusable(false); -         -        KeyDetection hAction = new KeyDetection('h'); -        h.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('h'), "hPress"); -        h.getActionMap().put("hPress", hAction); -        h.setFocusable(false); - -        KeyDetection jAction = new KeyDetection('j'); -        j.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('j'), "jPress"); -        j.getActionMap().put("jPress", jAction); -        j.setFocusable(false); -    } -     -    public void loop() { -        JButton note = new JButton(); -        JButton test = new JButton(); -        test.setBounds(200, 200, 100, 100); -        note.setBounds(BLENGTH, 0, BLENGTH, BHEIGHT); -        frame.add(note); -        frame.add(test); -         -        NoteTest a = new NoteTest(); -        while (!a.getFailed()) { -            if (!a.getFailed()) { -                a.gameTick(); -                note.setBounds(BLENGTH, HEIGHT-a.getY(), BLENGTH, BHEIGHT); //moves the note down every frame -                System.out.println(a.getFailed()); -                //the computer runs too fast normally, force it to run at a certain fps -                try { -                    Thread.sleep(2); -                } catch (InterruptedException e) -                { -                    // TODO Auto-generated catch block -                    e.printStackTrace(); -                } -            } -            if (a.getFailed()) { -                frame.remove(note); //removes the note once its off the screen -            } -        } -    } -} diff --git a/src/main/focusTest.java b/src/main/focusTest.java deleted file mode 100644 index 28e61a3..0000000 --- a/src/main/focusTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package main; - -import javafx.application.Application; -import javafx.geometry.Pos; -import javafx.scene.Scene; -import javafx.scene.control.ToggleButton; -import javafx.scene.layout.HBox; -import javafx.scene.layout.VBox; -import javafx.stage.Stage; - -public class focusTest extends Application { -     -    public static void main(String[] args)  -    { -        launch(args); -    } - -    @Override -    public void start(Stage primaryStage) throws Exception  -    { -        VBox root = new VBox(); -        root.setAlignment(Pos.CENTER); -        root.setSpacing(20); -        Scene sc = new Scene(root, 500, 500); -        primaryStage.setScene(sc); -        primaryStage.show(); - - -        ToggleButton btn1 = new ToggleButton("Button 1"); -        ToggleButton btn2 = new ToggleButton("Button 2"); -        ToggleButton btn3 = new ToggleButton("Button 3"); -        ToggleButton btn4 = new ToggleButton("Button 4"); - -        HBox hb1 = new HBox(); -        hb1.setAlignment(Pos.CENTER); -        hb1.getChildren().addAll(btn1, btn2); - -        HBox hb2 = new HBox(); -        hb2.setAlignment(Pos.CENTER); -        hb2.getChildren().addAll(btn3, btn4); - -        root.getChildren().addAll(hb1, hb2); - -        hb1.requestFocus(); -    } -}  | 
