Feature/help state
Conflicts: image/Images.java
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
import model.SongHandler;
|
||||
import model.gameState.GameOverState;
|
||||
import model.gameState.GameState;
|
||||
import model.gameState.HelpState;
|
||||
import model.gameState.MenuState;
|
||||
import model.gameState.PlayState;
|
||||
import model.gameState.PreGameState;
|
||||
@@ -29,6 +30,7 @@ public class GameStateManager {
|
||||
public enum State {
|
||||
TITLE_STATE,
|
||||
MENU_STATE,
|
||||
HELP_STATE,
|
||||
PLAY_STATE,
|
||||
GAMEOVER_STATE,
|
||||
PRE_GAME_STATE
|
||||
@@ -38,6 +40,7 @@ public class GameStateManager {
|
||||
gamestates = new ArrayList<GameState>();
|
||||
gamestates.add(new TitleState(this, sh, sql));
|
||||
gamestates.add(new MenuState(this, sh, sql));
|
||||
gamestates.add(new HelpState(this, sh, sql));
|
||||
gamestates.add(new PlayState(this, sh, sql));
|
||||
gamestates.add(new GameOverState(this, sh, sql));
|
||||
gamestates.add(new PreGameState(this,sh, sql));
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ public class Images {
|
||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/kast.png"))));
|
||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/gameover.png"))));
|
||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/screenshot.png"))));
|
||||
|
||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/help.png"))));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class Images {
|
||||
}
|
||||
|
||||
public enum ImageType {
|
||||
pulse,cursor,pressstart,colorstrike,background,aanwijzers,kast,gameover, screenshot
|
||||
pulse,cursor,pressstart,colorstrike,background,aanwijzers,kast,gameover, screenshot, help
|
||||
}
|
||||
|
||||
public static BufferedImage readImage(File f) {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 112 KiB |
+15
-15
@@ -36,21 +36,21 @@ public class Window extends JFrame {
|
||||
setSize(WIDTH, HEIGHT);
|
||||
|
||||
//Create Events
|
||||
Window.ON_RASP = ON_RASP;
|
||||
if(ON_RASP){ //Only on the raspberry pi
|
||||
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
|
||||
|
||||
if (!devices[0].isFullScreenSupported ()){
|
||||
throw new UnsupportedOperationException ("Fullscreen mode is unsupported.");
|
||||
}else{
|
||||
devices[0].setFullScreenWindow(this);
|
||||
}
|
||||
//Remove cursor
|
||||
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
|
||||
this.setCursor(blankCursor);
|
||||
}
|
||||
// Window.ON_RASP = ON_RASP;
|
||||
// if(ON_RASP){ //Only on the raspberry pi
|
||||
// GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
// GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
|
||||
//
|
||||
// if (!devices[0].isFullScreenSupported ()){
|
||||
// throw new UnsupportedOperationException ("Fullscreen mode is unsupported.");
|
||||
// }else{
|
||||
// devices[0].setFullScreenWindow(this);
|
||||
// }
|
||||
// //Remove cursor
|
||||
// BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||
// Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
|
||||
// this.setCursor(blankCursor);
|
||||
// }
|
||||
|
||||
ButtonHandler bth = new ButtonHandler();
|
||||
JoystickHandler jsh = new JoystickHandler();
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package model.gameState;
|
||||
|
||||
import image.Images;
|
||||
import image.Images.ImageType;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.VolatileImage;
|
||||
|
||||
import model.GameModel;
|
||||
import model.SongHandler;
|
||||
import control.GameStateManager;
|
||||
import control.GameStateManager.State;
|
||||
import control.button.ButtonEvent;
|
||||
import control.joystick.JoystickEvent;
|
||||
import data.io.SQLConnector;
|
||||
|
||||
public class HelpState extends GameState {
|
||||
|
||||
BufferedImage help = Images.getImage(ImageType.help);
|
||||
VolatileImage background;
|
||||
Font textFontSmall = new Font("OCR A Extended", Font.BOLD, 15);
|
||||
|
||||
|
||||
int index = 0;
|
||||
int frame;
|
||||
|
||||
|
||||
public HelpState(GameStateManager gsm, SongHandler sh, SQLConnector sql){
|
||||
super(gsm, sh, sql);
|
||||
createBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
sh.play();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float factor) {
|
||||
|
||||
frame++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2) {
|
||||
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonPressed(ButtonEvent e) {
|
||||
|
||||
if(e.getButton().getButtonID() == 2) {
|
||||
gsm.setState(State.MENU_STATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonReleased(ButtonEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoystickMoved(JoystickEvent e) {
|
||||
}
|
||||
|
||||
public void createBackground() {
|
||||
background = Images.initVolatileImage(1280, 1024, Transparency.OPAQUE);
|
||||
Graphics2D g2 = background.createGraphics();
|
||||
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHints(rh);
|
||||
|
||||
g2.drawImage(help, 0,0,1280,1024,null);
|
||||
|
||||
g2.setFont(textFontSmall);
|
||||
|
||||
//back
|
||||
g2.setColor(GameModel.colors[2]);
|
||||
g2.fillOval(80, 965, 30, 30);
|
||||
g2.drawString("Back", 115, 985);
|
||||
|
||||
g2.dispose();
|
||||
background.createGraphics();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,6 +49,8 @@ public class MenuState extends GameState {
|
||||
int yPosDiffButton = 900;
|
||||
private int difSelect=0, oldDifSelect = -1;
|
||||
Font textFont = new Font("OCR A Extended", Font.BOLD, 50);
|
||||
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 35);
|
||||
Font textFont3 = new Font("OCR A Extended", Font.BOLD, 20);
|
||||
Font textFontSmall = new Font("OCR A Extended", Font.BOLD, 15);
|
||||
BufferedImage aanwijzers = Images.getImage(ImageType.aanwijzers);
|
||||
int index = 0;
|
||||
@@ -195,7 +197,9 @@ public class MenuState extends GameState {
|
||||
selected = 0;
|
||||
sh.set(songs.indexOf(selectedToSong(selected)));
|
||||
sh.play();
|
||||
}
|
||||
}else if(e.getButton().getButtonID() == 3){
|
||||
gsm.setState(control.GameStateManager.State.HELP_STATE);
|
||||
}
|
||||
}
|
||||
|
||||
if(e.getButton().getButtonID() == 0)
|
||||
@@ -327,12 +331,17 @@ public class MenuState extends GameState {
|
||||
g2.drawString("Main Menu", 32, 60);
|
||||
|
||||
g2.setFont(textFontSmall);
|
||||
|
||||
|
||||
//select
|
||||
g2.setColor(GameModel.colors[0]);
|
||||
g2.fillOval(20, 860, 30, 30);
|
||||
g2.drawString("Play", 55, 880);
|
||||
|
||||
//help
|
||||
g2.setColor(GameModel.colors[3]);
|
||||
g2.fillOval(20, 900, 30, 30);
|
||||
g2.drawString("Play", 55, 920);
|
||||
|
||||
g2.drawString("Help", 55, 920);
|
||||
|
||||
//letters
|
||||
g2.setColor(GameModel.colors[1]);
|
||||
g2.fillOval(20, 940, 30, 30);
|
||||
@@ -380,8 +389,10 @@ public class MenuState extends GameState {
|
||||
g2.setFont(textFont);
|
||||
g2.drawString(selectedToSong(selected).getTitle(), 30, 60);
|
||||
|
||||
g2.setFont(textFont3);
|
||||
g2.setColor(Color.WHITE);
|
||||
g2.drawString("Author: " + selectedToSong(selected).getAuthor(), 30, 200);
|
||||
g2.drawString("Author: " + selectedToSong(selected).getAuthor(), 30, 100);
|
||||
g2.setFont(textFont);
|
||||
|
||||
boolean highscoresFound = true;
|
||||
int HIGHSCORES_TO_DISPLAY = 5;
|
||||
@@ -399,6 +410,7 @@ public class MenuState extends GameState {
|
||||
}
|
||||
else
|
||||
g2.drawString("Daily Highscore", 30, 300);
|
||||
g2.setFont(textFont2);
|
||||
|
||||
if(highscoresFound)
|
||||
{
|
||||
@@ -408,7 +420,7 @@ public class MenuState extends GameState {
|
||||
{
|
||||
Highscore hi = highscores.get(i);
|
||||
|
||||
g2.drawString(hi.getName() + " - " + hi.getScore(), 30, 400 + i*100);
|
||||
g2.drawString(hi.getName() + " - " + hi.getScore(), 30, 350 + i*100);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user