Difficulty Toegevoegt
This commit is contained in:
@@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import model.SongHandler;
|
import model.SongHandler;
|
||||||
|
import model.objects.DifficultyButton;
|
||||||
import model.objects.MenuButton;
|
import model.objects.MenuButton;
|
||||||
import audio.Song;
|
import audio.Song;
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
@@ -19,6 +20,7 @@ import control.joystick.JoystickEvent;
|
|||||||
|
|
||||||
public class MenuState extends GameState {
|
public class MenuState extends GameState {
|
||||||
private ArrayList<MenuButton> buttons;
|
private ArrayList<MenuButton> buttons;
|
||||||
|
private ArrayList<DifficultyButton> buttons2;
|
||||||
private int selected, oldselected;
|
private int selected, oldselected;
|
||||||
private List<Song> songs;
|
private List<Song> songs;
|
||||||
private Polygon triangle;
|
private Polygon triangle;
|
||||||
@@ -26,9 +28,12 @@ public class MenuState extends GameState {
|
|||||||
private int animationcounter;
|
private int animationcounter;
|
||||||
private boolean subscreen, startanimation;
|
private boolean subscreen, startanimation;
|
||||||
|
|
||||||
|
private int z;
|
||||||
|
|
||||||
public MenuState(GameStateManager gsm, SongHandler sh) {
|
public MenuState(GameStateManager gsm, SongHandler sh) {
|
||||||
super(gsm, sh);
|
super(gsm, sh);
|
||||||
buttons = new ArrayList<MenuButton>();
|
buttons = new ArrayList<MenuButton>();
|
||||||
|
buttons2 = new ArrayList<DifficultyButton>();
|
||||||
this.songs = sh.getSongs();
|
this.songs = sh.getSongs();
|
||||||
startanimation = true;
|
startanimation = true;
|
||||||
subscreen = false;
|
subscreen = false;
|
||||||
@@ -40,6 +45,11 @@ public class MenuState extends GameState {
|
|||||||
buttons.add(new MenuButton(-600, 450, 1.7, 30, Color.WHITE,selectedToSong(selected+2)));
|
buttons.add(new MenuButton(-600, 450, 1.7, 30, Color.WHITE,selectedToSong(selected+2)));
|
||||||
buttons.get(2).setSelected(true);
|
buttons.get(2).setSelected(true);
|
||||||
|
|
||||||
|
buttons2.add(new DifficultyButton(600 ,"Beginner", Color.BLUE));
|
||||||
|
buttons2.add(new DifficultyButton(700 ,"Easy", Color.GREEN));
|
||||||
|
buttons2.add(new DifficultyButton(800 ,"Normal", Color.orange));
|
||||||
|
buttons2.add(new DifficultyButton(900 ,"Hard", Color.RED));
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
@@ -63,6 +73,7 @@ public class MenuState extends GameState {
|
|||||||
if(selected != oldselected){
|
if(selected != oldselected){
|
||||||
for(int i = 0; i < buttons.size(); i++){
|
for(int i = 0; i < buttons.size(); i++){
|
||||||
buttons.get(i).setSong(selectedToSong(selected+(i-2)));
|
buttons.get(i).setSong(selectedToSong(selected+(i-2)));
|
||||||
|
z=i;
|
||||||
}
|
}
|
||||||
oldselected = selected;
|
oldselected = selected;
|
||||||
}
|
}
|
||||||
@@ -95,10 +106,23 @@ public class MenuState extends GameState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(subscreen) {
|
if(subscreen) {
|
||||||
g2.setColor(Color.ORANGE);
|
|
||||||
g2.fillPolygon(triangle);
|
|
||||||
g2.setColor(Color.BLACK);
|
g2.setColor(Color.BLACK);
|
||||||
// g2.drawString(songs.getTitle(), 30, 60);
|
g2.fillRect(0,0,1280,1024);
|
||||||
|
g2.setColor(Color.ORANGE);
|
||||||
|
g2.fillRect(0, 0, 1280, 1024/8);
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
g2.drawString(selectedToSong(selected).getTitle(), 30, 60);
|
||||||
|
|
||||||
|
g2.setColor(Color.WHITE);
|
||||||
|
g2.drawString("Overall Highscore: " + "", 30, 200);
|
||||||
|
g2.drawString("Daily Highscore: " + "", 30, 300);
|
||||||
|
g2.drawString("Beats per Minute: " + selectedToSong(selected).getBPM(), 30, 400);
|
||||||
|
|
||||||
|
for(DifficultyButton b : buttons2){
|
||||||
|
b.draw(g2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package model.objects;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
|
||||||
|
public class DifficultyButton {
|
||||||
|
|
||||||
|
private int x = 900;
|
||||||
|
private int y;
|
||||||
|
private String str;
|
||||||
|
private Color color;
|
||||||
|
|
||||||
|
|
||||||
|
public DifficultyButton(int y, String str, Color color) {
|
||||||
|
this.y = y;
|
||||||
|
this.str = str;
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(Graphics2D g2) {
|
||||||
|
g2.setColor(Color.WHITE);
|
||||||
|
g2.fillRect(x, y, 300, 75);
|
||||||
|
g2.setColor(Color.ORANGE);
|
||||||
|
g2.drawRect(x, y, 300, 75);
|
||||||
|
g2.drawRect(x-2, y-2, 304, 79);
|
||||||
|
|
||||||
|
g2.setColor(color);
|
||||||
|
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 50);
|
||||||
|
g2.setFont(textFont2);
|
||||||
|
|
||||||
|
g2.drawString(str, x+5, y+50);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user