Feature/json
# Conflicts: # control/GameStateManager.java # image/Images.java # main/Window.java # model/gameState/MenuState.java
This commit is contained in:
@@ -2,6 +2,7 @@ package model.gameState;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import model.SongHandler;
|
||||
import control.GameStateManager;
|
||||
import control.button.ButtonEvent;
|
||||
import control.joystick.JoystickEvent;
|
||||
@@ -9,10 +10,11 @@ import control.joystick.JoystickEvent;
|
||||
public abstract class GameState {
|
||||
|
||||
protected GameStateManager gsm;
|
||||
protected SongHandler sh;
|
||||
|
||||
public GameState(GameStateManager gsm) {
|
||||
super();
|
||||
public GameState(GameStateManager gsm, SongHandler sh) {
|
||||
this.gsm = gsm;
|
||||
this.sh = sh;
|
||||
}
|
||||
|
||||
public abstract void init();
|
||||
|
||||
@@ -5,12 +5,12 @@ import image.Images.ImageType;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import model.SongHandler;
|
||||
import model.objects.MenuButton;
|
||||
import control.GameStateManager;
|
||||
import control.button.Button;
|
||||
import control.GameStateManager.State;
|
||||
import control.button.ButtonEvent;
|
||||
import control.joystick.Joystick;
|
||||
import control.joystick.JoystickEvent;
|
||||
@@ -25,11 +25,11 @@ public class MenuState extends GameState {
|
||||
int maxFrames = 2560;
|
||||
int animationcounter;
|
||||
|
||||
public MenuState(GameStateManager gsm) {
|
||||
super(gsm);
|
||||
public MenuState(GameStateManager gsm, SongHandler sh) {
|
||||
super(gsm, sh);
|
||||
buttons = new ArrayList<MenuButton>();
|
||||
buttons.add(new MenuButton(-600, 50,1.7,"Genre", 0, Color.green));
|
||||
buttons.add(new MenuButton(-600, 150, 1.7, "Most played", 10, new Color(60,60,255)));
|
||||
buttons.add(new MenuButton(-600, 50,1.7, "Quick play", 0, Color.green));
|
||||
buttons.add(new MenuButton(-600, 150, 1.7, "Pick song", 10, new Color(60,60,255)));
|
||||
buttons.add(new MenuButton(-600, 250, 1.7, "Best played", 20, Color.red));
|
||||
buttons.add(new MenuButton(-600, 350, 1.7, "Last played", 30, Color.yellow));
|
||||
}
|
||||
@@ -57,6 +57,13 @@ public class MenuState extends GameState {
|
||||
|
||||
@Override
|
||||
public void buttonPressed(ButtonEvent e) {
|
||||
if(e.getButton().getButtonID() == 1){
|
||||
for(MenuButton b:buttons){
|
||||
if(b.isSelected()){
|
||||
gsm.setState(State.PLAY_STATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void buttonReleased(ButtonEvent e) {
|
||||
@@ -95,7 +102,6 @@ public class MenuState extends GameState {
|
||||
}
|
||||
if(buttons.get(button).getX() >= -200){
|
||||
buttonInAnimation(button+1);
|
||||
System.out.println(buttons.get(button).getX());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package model.gameState;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Window;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import model.SongHandler;
|
||||
import control.GameStateManager;
|
||||
import control.button.ButtonEvent;
|
||||
import control.joystick.JoystickEvent;
|
||||
|
||||
public class PickSongState extends GameState {
|
||||
|
||||
public PickSongState(GameStateManager gsm, SongHandler sh) {
|
||||
super(gsm, sh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
sh.set(0);
|
||||
sh.play(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d) {
|
||||
g2d.drawImage(sh.getCurrentSong().getBackgroundImage(), null, 0, 0);
|
||||
g2d.drawImage(sh.getCurrentSong().getBannerImage(), null, 400, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonPressed(ButtonEvent e) {}
|
||||
|
||||
@Override
|
||||
public void buttonReleased(ButtonEvent e) {}
|
||||
|
||||
@Override
|
||||
public void onJoystickMoved(JoystickEvent e) {
|
||||
switch (e.getJoystick().getPos()) {
|
||||
case LEFT:
|
||||
sh.previous();
|
||||
sh.play(true);
|
||||
break;
|
||||
case RIGHT:
|
||||
sh.next();
|
||||
sh.play(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import model.GameModel;
|
||||
import model.SongHandler;
|
||||
import model.drawObjects.Bullet;
|
||||
import model.drawObjects.Enemy;
|
||||
import model.drawObjects.Player;
|
||||
@@ -34,8 +35,8 @@ public class PlayState extends GameState{
|
||||
public static int currentScore = 0;
|
||||
public static int lifePoints = 100;
|
||||
|
||||
public PlayState(GameStateManager gsm) {
|
||||
super(gsm);
|
||||
public PlayState(GameStateManager gsm, SongHandler sh) {
|
||||
super(gsm, sh);
|
||||
area = new PlayArea((int) borderRect.getX(),1024,1024,100);
|
||||
infoPanel = new InfoPanel(0, 0);
|
||||
enemys = new ArrayList<Enemy>();
|
||||
|
||||
@@ -8,9 +8,10 @@ import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import control.joystick.JoystickEvent;
|
||||
import model.SongHandler;
|
||||
import control.GameStateManager;
|
||||
import control.button.ButtonEvent;
|
||||
import control.joystick.JoystickEvent;
|
||||
|
||||
public class TitleState extends GameState {
|
||||
|
||||
@@ -23,8 +24,8 @@ public class TitleState extends GameState {
|
||||
int frame = 0;
|
||||
int maxFrames = 2560;
|
||||
|
||||
public TitleState(GameStateManager gsm) {
|
||||
super(gsm);
|
||||
public TitleState(GameStateManager gsm, SongHandler sh){
|
||||
super(gsm, sh);
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
@@ -63,7 +64,7 @@ public class TitleState extends GameState {
|
||||
Font textFont = new Font("OCR A Extended", Font.BOLD, 15);
|
||||
g2.setFont(textFont);
|
||||
g2.setColor(Color.WHITE);
|
||||
g2.drawString("©2015 Team Hamtaro", - 18*5, 500);
|
||||
g2.drawString("�2015 Team Hamtaro", - 18*5, 500);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user