Commit ba05a50b authored by Ghyselen's avatar Ghyselen

Merge gitlab.crans.org:genie_logiciel_2015/the_dungeon_project

parents f566545c 45a761dd
......@@ -13,13 +13,31 @@ To run
################### HOW TO PLAY ###################
1)Launch the game. 2)On the main panel, you may : 2.1) single player : starts the game in a single player mode 2.2) multi player : TODO 2.3) configuration : you may configure the keys used to play the game 2.4) IGP : stands for "in game programming" : you may configure your own A.I. for the game 2.5) exit : leaves the game
1)Launch the game.
3)Once you are in game : For now, the basic configuration is : Move left : left_arrow Move right : right_arrow Move up : up_arrow Move down : down_arrow Attack : a Spell : s Back to main : escape
2)On the main panel, you may :
2.1) single player : starts the game in a single player mode
2.2) multi player : enables to create/join a multi player mode
2.3) configuration : you may configure the keys used to play the game
2.4) IGP : stands for "in game programming" : you may configure your own A.I. for your game allies
2.5) exit : leaves the game : be careful configuration keys are not registered
3)Default commands:
-Move left : left_arrow
-Move right : right_arrow
-Move up : up_arrow
-Move down : down_arrow
-Attack : a
-Ability1 : z
-Ability1 : e
-Ability1 : r
-Back to main : escape
################### HOW TO DOCUMENT ###################
To document the project, you need the package doxygen. It will create a HTML documentation from the code. To have inheritance graphs, please install graphivz.
To document the project, you need the package doxygen.
It will create a HTML documentation from the code.
To have inheritance graphs, please install graphivz.
English versions :
......@@ -37,26 +55,6 @@ Without graphivz
make doc-html2-fr
################### HOW TO PLAY ###################
1)Launch the game.
2)On the main panel, you may :
2.1) single player : starts the game in a single player mode
2.2) multi player : TODO
2.3) configuration : you may configure the keys used to play the game
2.4) IGP : stands for "in game programming" : you may configure your own A.I. for the game
2.5) exit : leaves the game
3)Once you are in game :
For now, the basic configuration is :
Move left : left_arrow
Move right : right_arrow
Move up : up_arrow
Move down : down_arrow
Attack : a
Spell : s
Back to main : escape
################### PRINCIPLE OF THE GAME ###################
TODO
......@@ -87,6 +85,4 @@ The following people were the developers :
-Ringeade Clément
-Toussaint Etienne
-Thomas Colin
-Ursu Bogdan
TODO : missing names to fill because not registered
-Ursu Bogdan
\ No newline at end of file
package graphics.graphical_abstraction.panel.menu;
import graphics.guiSkeleton.GUIColorsAndFonts;
import graphics.guiSkeleton.GraphicsMaster;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.MenuPanel;
import graphics.ingame_input_listener.Input;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by dupriez on 01/01/16.
*/
public interface GameOverPanelAbstraction extends MenuPanelAbstraction {
/*What to do when it have been pressed*/
public void returnButtonAction();
}
package graphics.graphical_abstraction.panel.menu;
/**
* Created by dupriez on 14/11/15.
*/
public class GameOverPanelAbstractionController extends MenuPanelAbstractionController {
private GameOverPanelAbstraction gameOverPanel;
public GameOverPanelAbstractionController(GameOverPanelAbstraction gameOverPanel){
this.menuPanel = gameOverPanel;
this.gameOverPanel = gameOverPanel;
}
public void returnButtonPressed(){
this.gameOverPanel.returnButtonAction();
}
}
package graphics.guiSkeleton.guiPanel.menuPanel;
import graphics.graphical_abstraction.GraphicsMasterAbstraction;
import graphics.graphical_abstraction.panel.menu.GameOverPanelAbstraction;
import graphics.graphical_abstraction.panel.menu.GameOverPanelAbstractionController;
import graphics.graphical_abstraction.panel.menu.MainMenuPanelAbstraction;
import graphics.guiSkeleton.GUIColorsAndFonts;
import graphics.guiSkeleton.GraphicsMaster;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker;
......@@ -14,7 +17,9 @@ import java.awt.event.ActionListener;
/**
* Created by dupriez on 01/01/16.
*/
public class GameOverPanel extends MenuPanel {
public class GameOverPanel extends MenuPanel implements GameOverPanelAbstraction {
GameOverPanelAbstractionController controller = new GameOverPanelAbstractionController(this);
public GameOverPanel(GraphicsMaster graphicsMaster) {
super(graphicsMaster);
......@@ -31,7 +36,7 @@ public class GameOverPanel extends MenuPanel {
private ActionListener returnButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MAIN_MENU);
controller.returnButtonPressed();
}
};
......@@ -59,4 +64,9 @@ public class GameOverPanel extends MenuPanel {
public void keyTypedHandler(Input e) {
}
@Override
public void returnButtonAction() {
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MAIN_MENU);
}
}
......@@ -24,27 +24,23 @@ public class MainMenuPanel extends MenuPanel implements MainMenuPanelAbstraction
setTitlePanel("The Dungeon Project");
addToCentralColumn(ButtonMaker.makeButton("single player", singlePlayerButtonListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("multi player", multiPlayerButtonListener),1,1);
//addToCentralColumn(ButtonMaker.makeButtonWithImage("src/graphics/guiSkeleton/guiPanel/interfaceElements/singlePlayerButton.png", "src/graphics/guiSkeleton/guiPanel/interfaceElements/singlePlayerPressedButton.png",singlePlayerButtonListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("multi player", multiPlayerButtonListener), 1, 1);
addToCentralColumn(ButtonMaker.makeButton("configuration", configurationButtonListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("IGP", IGPButtonListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("exit", exitButtonListener),1,1);
// setBottomPanel("V1.0 - ENS team");
}
private ActionListener singlePlayerButtonListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
controller.singlePlayerButtonPressed();
//DummyLocalCore.getInstance().startGameSinglePlayer();
}
};
private ActionListener multiPlayerButtonListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
//DummyLocalCore.getInstance().startGameMultiplayerPlayer();
controller.multiPlayerButtonPressed();
}
};
......@@ -89,7 +85,6 @@ public class MainMenuPanel extends MenuPanel implements MainMenuPanelAbstraction
@Override
public void initialise() {
// underlyingMainMenuPanel.setPreferredSize(new Dimension(getSize().width, getSize().height));
// System.out.println("Dimensions= "+getSize().width+", "+getSize().height);
// setSize(new Dimension(getSize().width, getSize().height));
......
......@@ -2,7 +2,8 @@ package graphics.guiSkeleton.guiPanel.menuPanel.configuration;
import graphics.ingame_input_listener.InputConfiguration;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
/**
......@@ -10,7 +11,7 @@ import java.util.ArrayList;
*/
public class InputChangeFrame extends Frame implements ActionListener{
private ArrayList<Button> b= new ArrayList<Button>();
private ArrayList<Button> b= new ArrayList<>();
public static void main(String string) {
InputChangeFrame myWindow = new InputChangeFrame(string);
......@@ -20,13 +21,93 @@ public class InputChangeFrame extends Frame implements ActionListener{
public InputChangeFrame(String title) {
super(title);
setLayout(new GridLayout(13, 2));
String alphabet="abcdefghijklmnopqrstuvwxyz";
for (int i=0;i<alphabet.length();i++) {
b.add(new Button(Character.toString(alphabet.charAt(i))));
String simpleKeyboard="abcdefghijklmnopqrstuvwxyz0123456789+-*(_)=,;:!^$/";
Button button;
int LayoutHeight=simpleKeyboard.length()/2;
int LayoutWidth=3;
setLayout(new GridLayout(LayoutHeight,LayoutWidth));
//Adding monoalphabetic keyBoard input
for (int i=0;i<simpleKeyboard.length();i++) {
b.add(new Button(Character.toString(simpleKeyboard.charAt(i))));
b.get(i).addActionListener(this);
add(b.get(i));
}
//Adding arrow inputs
button=new Button("Right arrow");
button.addActionListener(this);
add(button);
button=new Button("Left arrow");
button.addActionListener(this);
add(button);
button=new Button("Up arrow");
button.addActionListener(this);
add(button);
button=new Button("Down arrow");
button.addActionListener(this);
add(button);
//Adding Fi inputs
button=new Button("F1");
button.addActionListener(this);
add(button);
button=new Button("F2");
button.addActionListener(this);
add(button);
button=new Button("F3");
button.addActionListener(this);
add(button);
button=new Button("F4");
button.addActionListener(this);
add(button);
button=new Button("F5");
button.addActionListener(this);
add(button);
button=new Button("F6");
button.addActionListener(this);
add(button);
button=new Button("F7");
button.addActionListener(this);
add(button);
button=new Button("F8");
button.addActionListener(this);
add(button);
button=new Button("F9");
button.addActionListener(this);
add(button);
button=new Button("F10");
button.addActionListener(this);
add(button);
button=new Button("F11");
button.addActionListener(this);
add(button);
button=new Button("F12");
button.addActionListener(this);
add(button);
//Adding other inputs
button=new Button("Escape");
button.addActionListener(this);
add(button);
button=new Button("Ctrl");
button.addActionListener(this);
add(button);
button=new Button("Caps lock");
button.addActionListener(this);
add(button);
button=new Button("Shift");
button.addActionListener(this);
add(button);
button=new Button("Back space");
button.addActionListener(this);
add(button);
button=new Button("Alt");
button.addActionListener(this);
add(button);
button=new Button("Tab");
button.addActionListener(this);
add(button);
button=new Button("Enter");
button.addActionListener(this);
add(button);
}
public void actionPerformed(ActionEvent e) {
......
......@@ -25,4 +25,16 @@ public class ButtonMaker {
return button;
}
public static JButton makeButtonWithImage(String unPressed,String Pressed, ActionListener buttonAction){
JButton button = new JButton(new ImageIcon(unPressed));
button.setPressedIcon(new ImageIcon(Pressed));
//button.setBorder(new EmptyBorder(1,0,0,0));
button.setOpaque(true);
button.setVisible(true);
button.setFocusable(true);
//button.setFocusPainted(false);
button.addActionListener(buttonAction);
return button;
}
}
......@@ -6,9 +6,11 @@ import java.awt.event.KeyEvent;
* Created by etouss on 09/11/2015.
*/
public class InputConfiguration {
/** Each action that can be performed in the game
/**
* Each action that can be performed in the game
* is firstly linked with some input which is
* converted to a formal one from the Input enum */
* converted to a formal one from the Input enum
*/
// initial keys that may be changed in the game
private static int attack = KeyEvent.VK_A;
......@@ -25,53 +27,48 @@ public class InputConfiguration {
private static int left = KeyEvent.VK_LEFT;
//keys special for terminal version
private static char left_arrow='4';
private static char right_arrow='6';
private static char up_arrow='8';
private static char down_arrow='2';
private static char escape_terminal='p';
public static void ChangeKey(Input input, int j) {
switch(input){
case ATTACK:
attack=j;break;
case ABILITY_1:
ability1 =j;break;
case ABILITY_2:
ability2=j;break;
case ABILITY_3:
ability3=j;break;
case ESCAPE:
escape=j;break;
case UP_ARROW:
up=j;break;
case DOWN_ARROW:
down=j;break;
case RIGHT_ARROW:
right=j;break;
case LEFT_ARROW:
left=j;break;
default:
throw new IllegalStateException("Unknown input"+ input);
}
}
private static char left_arrow = '4';
private static char right_arrow = '6';
private static char up_arrow = '8';
private static char down_arrow = '2';
private static char escape_terminal = 'p';
/**
* @param e : a key pressed
* @return the formal name linked with this input
*/
public static Input GetInput(KeyEvent e){
int event=e.getKeyCode();
if (event==attack){return Input.ATTACK;}
if (event== ability1){return Input.ABILITY_1;}
if (event==ability2){return Input.ABILITY_2;}
if (event== ability3){return Input.ABILITY_3;}
if (event==escape){return Input.ESCAPE;}
if (event==up){return Input.UP_ARROW;}
if (event==down){return Input.DOWN_ARROW;}
if (event==right){return Input.RIGHT_ARROW;}
if (event==left){return Input.LEFT_ARROW;}
if (event==space){return Input.SPACE;}
public static Input GetInput(KeyEvent e) {
int event = e.getKeyCode();
if (event == attack) {
return Input.ATTACK;
}
if (event == ability1) {
return Input.ABILITY_1;
}
if (event == ability2) {
return Input.ABILITY_2;
}
if (event == ability3) {
return Input.ABILITY_3;
}
if (event == escape) {
return Input.ESCAPE;
}
if (event == up) {
return Input.UP_ARROW;
}
if (event == down) {
return Input.DOWN_ARROW;
}
if (event == right) {
return Input.RIGHT_ARROW;
}
if (event == left) {
return Input.LEFT_ARROW;
}
if (event == space) {
return Input.SPACE;
}
return Input.NONE;
}
......@@ -80,7 +77,7 @@ public class InputConfiguration {
* @return the string of the character whose code is j
* and a blank if j is not the code of a usual keyboard character
*/
private static String GetString(int j){
private static String GetString(int j) {
switch (j) {
case KeyEvent.VK_A:
return "a";
......@@ -135,13 +132,103 @@ public class InputConfiguration {
case KeyEvent.VK_Z:
return "z";
case KeyEvent.VK_UP:
return "up_arrow";
return "Up arrow";
case KeyEvent.VK_DOWN:
return "down_arrow";
return "Down arrow";
case KeyEvent.VK_LEFT:
return "left_arrow";
return "Left arrow";
case KeyEvent.VK_RIGHT:
return "right_arrow";
return "Right arrow";
case KeyEvent.VK_NUMPAD0:
return "0";
case KeyEvent.VK_NUMPAD1:
return "1";
case KeyEvent.VK_NUMPAD2:
return "2";
case KeyEvent.VK_NUMPAD3:
return "3";
case KeyEvent.VK_NUMPAD4:
return "4";
case KeyEvent.VK_NUMPAD5:
return "5";
case KeyEvent.VK_NUMPAD6:
return "6";
case KeyEvent.VK_NUMPAD7:
return "7";
case KeyEvent.VK_NUMPAD8:
return "8";
case KeyEvent.VK_NUMPAD9:
return "9";
case KeyEvent.VK_F1:
return "F1";
case KeyEvent.VK_F2:
return "F2";
case KeyEvent.VK_F3:
return "F3";
case KeyEvent.VK_F4:
return "F4";
case KeyEvent.VK_F5:
return "F5";
case KeyEvent.VK_F6:
return "F6";
case KeyEvent.VK_F7:
return "F7";
case KeyEvent.VK_F8:
return "F8";
case KeyEvent.VK_F9:
return "F9";
case KeyEvent.VK_F10:
return "F10";
case KeyEvent.VK_F11:
return "F11";
case KeyEvent.VK_F12:
return "F12";
case KeyEvent.VK_ADD:
return "+";
case KeyEvent.VK_MINUS:
return "-";
case KeyEvent.VK_MULTIPLY:
return "*";
case KeyEvent.VK_LEFT_PARENTHESIS:
return "(";
case KeyEvent.VK_UNDERSCORE:
return "_";
case KeyEvent.VK_RIGHT_PARENTHESIS:
return ")";
case KeyEvent.VK_EQUALS:
return "=";
case KeyEvent.VK_COMMA:
return ",";
case KeyEvent.VK_SEMICOLON:
return ";";
case KeyEvent.VK_COLON:
return ":";
case KeyEvent.VK_EXCLAMATION_MARK:
return "!";
case KeyEvent.VK_CIRCUMFLEX:
return "^";
case KeyEvent.VK_DOLLAR:
return "$";
case KeyEvent.VK_SEPARATOR:
return "/";
case KeyEvent.VK_ENTER:
return "Enter";
case KeyEvent.VK_CAPS_LOCK:
return "Caps lock";
case KeyEvent.VK_ESCAPE:
return "Escape";
case KeyEvent.VK_ALT:
return "Alt";
case KeyEvent.VK_CONTROL:
return "Ctrl";
case KeyEvent.VK_SPACE:
return "Space";
case KeyEvent.VK_SHIFT:
return "Shift";
case KeyEvent.VK_TAB:
return "Tab";
case KeyEvent.VK_BACK_SPACE:
return "Back space";
default:
throw new IllegalStateException("Unknown int : " + j);
}
......@@ -152,7 +239,7 @@ public class InputConfiguration {
* @return the character whose code is j
* and a blank if j is not the code of a usual keyboard character
*/
private static char GetChar(int j){
private static char GetChar(int j) {
switch (j) {
case KeyEvent.VK_A:
return 'a';
......@@ -212,68 +299,271 @@ public class InputConfiguration {
}
/**
*
* @param string a one character string representing a keyboard input
* @return the int linked to the keyEvent linked with the input underlying the string
*/
public static int GetIntFromString(String string){
if (string.equals("a")){return KeyEvent.VK_A;}
if (string.equals("b")){return KeyEvent.VK_B;}
if (string.equals("c")){return KeyEvent.VK_C;}
if (string.equals("d")){return KeyEvent.VK_D;}
if (string.equals("e")){return KeyEvent.VK_E;}
if (string.equals("f")){return KeyEvent.VK_F;}
if (string.equals("g")){return KeyEvent.VK_G;}
if (string.equals("j")){return KeyEvent.VK_J;}
if (string.equals("k")){return KeyEvent.VK_K;}
if (string.equals("l")){return KeyEvent.VK_L;}
if (string.equals("m")){return KeyEvent.VK_M;}
if (string.equals("n")){return KeyEvent.VK_N;}
if (string.equals("m")){return KeyEvent.VK_M;}
if (string.equals("n")){return KeyEvent.VK_N;}
if (string.equals("o")){return KeyEvent.VK_O;}
if (string.equals("p")){return KeyEvent.VK_P;}
if (string.equals("q")){return KeyEvent.VK_Q;}
if (string.equals("r")){return KeyEvent.VK_R;}
if (string.equals("s")){return KeyEvent.VK_S;}
if (string.equals("t")){return KeyEvent.VK_T;}
if (string.equals("u")){return KeyEvent.VK_U;}
if (string.equals("v")){return KeyEvent.VK_V;}
if (string.equals("w")){return KeyEvent.VK_W;}
if (string.equals("x")){return KeyEvent.VK_X;}
if (string.equals("y")){return KeyEvent.VK_Y;}
if (string.equals("z")){return KeyEvent.VK_Z;}
throw new IllegalStateException("Unknown input : "+ string);
public static int GetIntFromString(String string) {
if (string.equals("a")) {
return KeyEvent.VK_A;
}
if (string.equals("b")) {
return KeyEvent.VK_B;
}
if (string.equals("c")) {
return KeyEvent.VK_C;
}
if (string.equals("d")) {
return KeyEvent.VK_D;
}
if (string.equals("e")) {
return KeyEvent.VK_E;
}
if (string.equals("f")) {
return KeyEvent.VK_F;
}
if (string.equals("g")) {
return KeyEvent.VK_G;
}
if (string.equals("j")) {
return KeyEvent.VK_J;
}
if (string.equals("k")) {
return KeyEvent.VK_K;
}
if (string.equals("l")) {
return KeyEvent.VK_L;
}
if (string.equals("m")) {
return KeyEvent.VK_M;
}