Add Help Menu
This commit is contained in:
parent
e4992123a8
commit
2be7f5ceb2
3 changed files with 91 additions and 64 deletions
|
@ -34,6 +34,7 @@ public class MainGame extends Game{
|
||||||
private MainWorld world;
|
private MainWorld world;
|
||||||
private MainInterfaces interfaces;
|
private MainInterfaces interfaces;
|
||||||
public int[] scores;
|
public int[] scores;
|
||||||
|
public final int helpKey = GLFW.GLFW_KEY_H;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
|
@ -4,10 +4,13 @@ import globalgamejam.Main;
|
||||||
import globalgamejam.game.MainGame;
|
import globalgamejam.game.MainGame;
|
||||||
import globalgamejam.gui.GUI;
|
import globalgamejam.gui.GUI;
|
||||||
import globalgamejam.gui.GUILabel;
|
import globalgamejam.gui.GUILabel;
|
||||||
|
import globalgamejam.input.Input;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by trexr on 20/01/2017.
|
* Created by trexr on 20/01/2017.
|
||||||
*/
|
*/
|
||||||
|
@ -20,34 +23,54 @@ public class MainInterfaces {
|
||||||
|
|
||||||
private GUILabel p1,p2;
|
private GUILabel p1,p2;
|
||||||
|
|
||||||
|
private ArrayList<GUI> guisHelp;
|
||||||
|
private GUILabel helpLabel;
|
||||||
|
|
||||||
|
|
||||||
public MainInterfaces(MainGame game){
|
public MainInterfaces(MainGame game){
|
||||||
this.game = game;
|
this.game = game;
|
||||||
guis = new ArrayList<GUI>();
|
guis = new ArrayList<GUI>();
|
||||||
|
guisHelp = new ArrayList<GUI>();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
p1 = new GUILabel("Player 1 : ", Main.WIDTH/4 - 50,10, Color.RED,"Arial",16);
|
p1 = new GUILabel("Player 1 : ", Main.WIDTH/4 - 50,10, Color.BLACK,"Arial",16);
|
||||||
p2 = new GUILabel("Player 2 : ", Main.WIDTH/4 * 3 - 50,10, Color.WHITE,"Arial",16);
|
p2 = new GUILabel("Player 2 : ", Main.WIDTH/4 * 3 - 50,10, Color.BLACK,"Arial",16);
|
||||||
guis.add(p1);
|
guis.add(p1);
|
||||||
guis.add(p2);
|
guis.add(p2);
|
||||||
|
|
||||||
|
//Menu Help
|
||||||
|
helpLabel = new GUILabel("HELP",Main.WIDTH/2,10,Color.WHITE,"Arial",16);
|
||||||
|
helpLabel.setX(Main.WIDTH/2 - helpLabel.getWitdh()/2);
|
||||||
|
guisHelp.add(helpLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
|
if(Input.isKey(this.game.helpKey)){
|
||||||
|
for(GUI g : guisHelp)g.update();
|
||||||
|
}else{
|
||||||
p1.setText("Player 1 : " + this.game.scores[0]);
|
p1.setText("Player 1 : " + this.game.scores[0]);
|
||||||
p1.setX((Main.WIDTH-SIZE_OF_DETAILS)/4 - p1.getWitdh()/2);
|
p1.setX((Main.WIDTH-SIZE_OF_DETAILS)/4 - p1.getWitdh()/2);
|
||||||
p2.setText("Player 2 : " + this.game.scores[1]);
|
p2.setText("Player 2 : " + this.game.scores[1]);
|
||||||
p2.setX((Main.WIDTH-SIZE_OF_DETAILS)/4*3 - p2.getWitdh()/2);
|
p2.setX((Main.WIDTH-SIZE_OF_DETAILS)/4*3 - p2.getWitdh()/2);
|
||||||
for(GUI g : guis)g.update();
|
for(GUI g : guis)g.update();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void render(){
|
public void render(){
|
||||||
|
if(Input.isKey(this.game.helpKey)){
|
||||||
|
for(GUI g : guisHelp)g.render();
|
||||||
|
}else{
|
||||||
for(GUI g : guis)g.render();
|
for(GUI g : guis)g.render();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void destroy(){
|
public void destroy(){
|
||||||
|
for(GUI g : guis)g.destroy();
|
||||||
guis.clear();
|
guis.clear();
|
||||||
|
for(GUI g : guisHelp)g.destroy();
|
||||||
|
guisHelp.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class MainWorld {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
|
if(!Input.isKey(this.game.helpKey)){
|
||||||
//Player 1
|
//Player 1
|
||||||
float xDep = 0, yDep = 0;
|
float xDep = 0, yDep = 0;
|
||||||
if(Input.isKey(GLFW.GLFW_KEY_W)){
|
if(Input.isKey(GLFW.GLFW_KEY_W)){
|
||||||
|
@ -113,12 +114,14 @@ public class MainWorld {
|
||||||
if(Input.isKey(GLFW.GLFW_KEY_O)){
|
if(Input.isKey(GLFW.GLFW_KEY_O)){
|
||||||
player2.rotate(5);
|
player2.rotate(5);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(){
|
public void render(){
|
||||||
|
if(!Input.isKey(this.game.helpKey)){
|
||||||
for(Tile t : tiles)t.render();
|
for(Tile t : tiles)t.render();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void destroy(){
|
public void destroy(){
|
||||||
for(Tile t : tiles)t.destroy();
|
for(Tile t : tiles)t.destroy();
|
||||||
|
|
Reference in a new issue