1
0
Fork 0

Add Help Menu

This commit is contained in:
MrDev023 2017-01-21 05:09:32 +01:00
parent e4992123a8
commit 2be7f5ceb2
3 changed files with 91 additions and 64 deletions

View file

@ -34,6 +34,7 @@ public class MainGame extends Game{
private MainWorld world;
private MainInterfaces interfaces;
public int[] scores;
public final int helpKey = GLFW.GLFW_KEY_H;
@Override
public void init() {

View file

@ -4,10 +4,13 @@ import globalgamejam.Main;
import globalgamejam.game.MainGame;
import globalgamejam.gui.GUI;
import globalgamejam.gui.GUILabel;
import globalgamejam.input.Input;
import java.awt.*;
import java.util.ArrayList;
import org.lwjgl.glfw.GLFW;
/**
* Created by trexr on 20/01/2017.
*/
@ -19,35 +22,55 @@ public class MainInterfaces {
private ArrayList<GUI> guis;
private GUILabel p1,p2;
private ArrayList<GUI> guisHelp;
private GUILabel helpLabel;
public MainInterfaces(MainGame game){
this.game = game;
guis = new ArrayList<GUI>();
guisHelp = new ArrayList<GUI>();
init();
}
public void init(){
p1 = new GUILabel("Player 1 : ", Main.WIDTH/4 - 50,10, Color.RED,"Arial",16);
p2 = new GUILabel("Player 2 : ", Main.WIDTH/4 * 3 - 50,10, Color.WHITE,"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.BLACK,"Arial",16);
guis.add(p1);
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(){
p1.setText("Player 1 : " + this.game.scores[0]);
p1.setX((Main.WIDTH-SIZE_OF_DETAILS)/4 - p1.getWitdh()/2);
p2.setText("Player 2 : " + this.game.scores[1]);
p2.setX((Main.WIDTH-SIZE_OF_DETAILS)/4*3 - p2.getWitdh()/2);
for(GUI g : guis)g.update();
if(Input.isKey(this.game.helpKey)){
for(GUI g : guisHelp)g.update();
}else{
p1.setText("Player 1 : " + this.game.scores[0]);
p1.setX((Main.WIDTH-SIZE_OF_DETAILS)/4 - p1.getWitdh()/2);
p2.setText("Player 2 : " + this.game.scores[1]);
p2.setX((Main.WIDTH-SIZE_OF_DETAILS)/4*3 - p2.getWitdh()/2);
for(GUI g : guis)g.update();
}
}
public void render(){
for(GUI g : guis)g.render();
if(Input.isKey(this.game.helpKey)){
for(GUI g : guisHelp)g.render();
}else{
for(GUI g : guis)g.render();
}
}
public void destroy(){
for(GUI g : guis)g.destroy();
guis.clear();
for(GUI g : guisHelp)g.destroy();
guisHelp.clear();
}
}

View file

@ -55,69 +55,72 @@ public class MainWorld {
}
public void update(){
//Player 1
float xDep = 0, yDep = 0;
if(Input.isKey(GLFW.GLFW_KEY_W)){
yDep = 10;
}
if(Input.isKey(GLFW.GLFW_KEY_S)){
yDep = -10;
}
if(Input.isKey(GLFW.GLFW_KEY_A)){
xDep = -10;
}
if(Input.isKey(GLFW.GLFW_KEY_D)){
xDep = 10;
}
if(xDep != 0.0 && yDep != 0.0){
xDep *= Math.cos(Math.PI / 4);
yDep *= Math.cos(Math.PI / 4);
}
player1.move(xDep, yDep);
if(Input.isKey(GLFW.GLFW_KEY_Q)){
player1.rotate(-5);
}
if(Input.isKey(GLFW.GLFW_KEY_E)){
player1.rotate(5);
}
if(!Input.isKey(this.game.helpKey)){
//Player 1
float xDep = 0, yDep = 0;
if(Input.isKey(GLFW.GLFW_KEY_W)){
yDep = 10;
}
if(Input.isKey(GLFW.GLFW_KEY_S)){
yDep = -10;
}
if(Input.isKey(GLFW.GLFW_KEY_A)){
xDep = -10;
}
if(Input.isKey(GLFW.GLFW_KEY_D)){
xDep = 10;
}
if(xDep != 0.0 && yDep != 0.0){
xDep *= Math.cos(Math.PI / 4);
yDep *= Math.cos(Math.PI / 4);
}
player1.move(xDep, yDep);
if(Input.isKey(GLFW.GLFW_KEY_Q)){
player1.rotate(-5);
}
if(Input.isKey(GLFW.GLFW_KEY_E)){
player1.rotate(5);
}
//Player 2
xDep = 0;
yDep = 0;
if(Input.isKey(GLFW.GLFW_KEY_I)){
yDep = 10;
}
if(Input.isKey(GLFW.GLFW_KEY_K)){
yDep = -10;
}
if(Input.isKey(GLFW.GLFW_KEY_J)){
xDep = -10;
}
if(Input.isKey(GLFW.GLFW_KEY_L)){
xDep = 10;
}
//Player 2
xDep = 0;
yDep = 0;
if(Input.isKey(GLFW.GLFW_KEY_I)){
yDep = 10;
}
if(Input.isKey(GLFW.GLFW_KEY_K)){
yDep = -10;
}
if(Input.isKey(GLFW.GLFW_KEY_J)){
xDep = -10;
}
if(Input.isKey(GLFW.GLFW_KEY_L)){
xDep = 10;
}
if(xDep != 0.0 && yDep != 0.0){
xDep *= Math.cos(Math.PI / 4);
yDep *= Math.cos(Math.PI / 4);
}
if(xDep != 0.0 && yDep != 0.0){
xDep *= Math.cos(Math.PI / 4);
yDep *= Math.cos(Math.PI / 4);
}
player2.move(xDep, yDep);
if(Input.isKey(GLFW.GLFW_KEY_U)){
player2.rotate(-5);
}
if(Input.isKey(GLFW.GLFW_KEY_O)){
player2.rotate(5);
}
player2.move(xDep, yDep);
if(Input.isKey(GLFW.GLFW_KEY_U)){
player2.rotate(-5);
}
if(Input.isKey(GLFW.GLFW_KEY_O)){
player2.rotate(5);
}
}
}
public void render(){
for(Tile t : tiles)t.render();
if(!Input.isKey(this.game.helpKey)){
for(Tile t : tiles)t.render();
}
}
public void destroy(){