You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.9 KiB
Plaintext
71 lines
1.9 KiB
Plaintext
2 years ago
|
package Main;
|
||
|
|
||
|
import org.newdawn.slick.Animation;
|
||
|
import org.newdawn.slick.Color;
|
||
|
import org.newdawn.slick.GameContainer;
|
||
|
import org.newdawn.slick.Graphics;
|
||
|
import org.newdawn.slick.Image;
|
||
|
import org.newdawn.slick.Input;
|
||
|
import org.newdawn.slick.SlickException;
|
||
|
import org.newdawn.slick.SpriteSheet;
|
||
|
|
||
|
public class Menu {
|
||
|
|
||
|
Image menu;
|
||
|
State state;
|
||
|
String selectedOption;
|
||
|
int selectedString;
|
||
|
SpriteSheet shocking;
|
||
|
Animation selected;
|
||
|
|
||
|
|
||
|
public void init(GameContainer gc, State state) throws SlickException{
|
||
|
this.state= state;
|
||
|
|
||
|
selectedString = 0;
|
||
|
menu = new Image ("Main/menu.png");
|
||
|
shocking = new SpriteSheet("Main/shock.png", 75, 45);
|
||
|
selected = new Animation(shocking,0,0,3,0,true,250,true);//Auswahl im Menu
|
||
|
}
|
||
|
|
||
|
public void render(GameContainer gc, Graphics g)throws SlickException{
|
||
|
g.setColor(Color.magenta);
|
||
|
|
||
|
|
||
|
|
||
|
if(state.currentState == "menu"){
|
||
|
menu.draw(0, 0);
|
||
|
g.scale(2, 2);
|
||
|
|
||
|
switch(selectedString){
|
||
|
case 0: selected.draw(100, 70);break;
|
||
|
case 1: selected.draw(100, 130);break;
|
||
|
case 2: selected.draw(100, 190);break;
|
||
|
|
||
|
}//Menu auswahl punkte
|
||
|
g.drawString("Start Game", 150, 80);
|
||
|
g.drawString("Options Game", 150, 140);
|
||
|
g.drawString("Exit Game", 150, 200);
|
||
|
g.scale(0.5f, 0.5f);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void update(GameContainer gc, float _delta)throws SlickException{
|
||
|
|
||
|
switch(state.stateId){
|
||
|
case 0: case 1:break;
|
||
|
case 4: switch(selectedString){
|
||
|
case 0: selectedOption = "Start Game";selectedString = 0;break;
|
||
|
case 1: selectedOption = "Options";selectedString = 1;break;
|
||
|
case 2: selectedOption = "Exit Game";selectedString = 2;break;
|
||
|
}
|
||
|
if(gc.getInput().isKeyPressed(Input.KEY_UP)&& selectedString >0)
|
||
|
selectedString--;
|
||
|
if(gc.getInput().isKeyPressed(Input.KEY_DOWN)&& selectedString <2)
|
||
|
selectedString++;
|
||
|
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|