Commit e0a2fe0c authored by Huot Mathieu's avatar Huot Mathieu

bug input configuration fixed

parent aa39d7e3
......@@ -10,16 +10,16 @@ import java.util.ArrayList;
* Created by zobi on 02/01/16.
*/
public class InputChangeFrame extends Frame implements ActionListener{
public class ConfigurationFrame extends Frame implements ActionListener{
private ArrayList<Button> b= new ArrayList<>();
public static void main(String string) {
InputChangeFrame myWindow = new InputChangeFrame(string);
myWindow.setSize(600, 600);
myWindow.setVisible(true);
public static void InputConfigurationFrame(String title) {
ConfigurationFrame configFrame = new ConfigurationFrame(title);
configFrame.setSize(600, 600);
configFrame.setVisible(true);
}
public InputChangeFrame(String title) {
public ConfigurationFrame(String title) {
super(title);
String simpleKeyboard="abcdefghijklmnopqrstuvwxyz0123456789+-*(_)=,;:!^$/";
Button button;
......@@ -36,77 +36,101 @@ public class InputChangeFrame extends Frame implements ActionListener{
//Adding arrow inputs
button=new Button("Right arrow");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("Left arrow");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("Up arrow");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("Down arrow");
button.addActionListener(this);
b.add(button);
add(button);
//Adding Fi inputs
button=new Button("F1");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F2");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F3");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F4");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F5");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F6");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F7");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F8");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F9");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F10");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F11");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("F12");
button.addActionListener(this);
b.add(button);
add(button);
//Adding other inputs
button=new Button("Escape");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("Ctrl");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("Caps lock");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("Shift");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("Back space");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("Alt");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("Tab");
button.addActionListener(this);
b.add(button);
add(button);
button=new Button("Enter");
button.addActionListener(this);
b.add(button);
add(button);
}
......
......@@ -53,14 +53,14 @@ public class ConfigurationPanel extends MenuPanel {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.UP_ARROW;
InputChangeFrame.main("Move Up: current control: "+(InputConfiguration.GetFormalInputString(Input.UP_ARROW)));
ConfigurationFrame.InputConfigurationFrame("Move Up: current control: " + (InputConfiguration.GetFormalInputString(Input.UP_ARROW)));
}
};
private ActionListener configDownListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.DOWN_ARROW;
InputChangeFrame.main("Move Down: current control: "+(InputConfiguration.GetFormalInputString(Input.DOWN_ARROW)));
ConfigurationFrame.InputConfigurationFrame("Move Down: current control: " + (InputConfiguration.GetFormalInputString(Input.DOWN_ARROW)));
}
};
......@@ -68,41 +68,41 @@ public class ConfigurationPanel extends MenuPanel {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.LEFT_ARROW;
InputChangeFrame.main("Move Left: current control: "+(InputConfiguration.GetFormalInputString(Input.LEFT_ARROW)));
ConfigurationFrame.InputConfigurationFrame("Move Left: current control: " + (InputConfiguration.GetFormalInputString(Input.LEFT_ARROW)));
}
};
private ActionListener configRightListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.RIGHT_ARROW;
InputChangeFrame.main("Move Right: current control: "+(InputConfiguration.GetFormalInputString(Input.RIGHT_ARROW)));
ConfigurationFrame.InputConfigurationFrame("Move Right: current control: " + (InputConfiguration.GetFormalInputString(Input.RIGHT_ARROW)));
}
};
private ActionListener configAttackListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.ATTACK;
InputChangeFrame.main("Attack: current control: "+(InputConfiguration.GetFormalInputString(Input.ATTACK)));
ConfigurationFrame.InputConfigurationFrame("Attack: current control: " + (InputConfiguration.GetFormalInputString(Input.ATTACK)));
}
};
private ActionListener configAbility1Listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.ABILITY_1;
InputChangeFrame.main("First Ability: current control: "+(InputConfiguration.GetFormalInputString(Input.ABILITY_1)));
ConfigurationFrame.InputConfigurationFrame("First Ability: current control: " + (InputConfiguration.GetFormalInputString(Input.ABILITY_1)));
}
};
private ActionListener configAbility2Listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.ABILITY_2;
InputChangeFrame.main("Second Ability: current control: "+(InputConfiguration.GetFormalInputString(Input.ABILITY_2)));}
ConfigurationFrame.InputConfigurationFrame("Second Ability: current control: " + (InputConfiguration.GetFormalInputString(Input.ABILITY_2)));}
};
private ActionListener configAbility3Listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.ABILITY_3;
InputChangeFrame.main("Third Ability: current control: "+(InputConfiguration.GetFormalInputString(Input.ABILITY_3)));
ConfigurationFrame.InputConfigurationFrame("Third Ability: current control: " + (InputConfiguration.GetFormalInputString(Input.ABILITY_3)));
}
};
private ActionListener backButtonListener = new ActionListener() {
......
......@@ -5,7 +5,7 @@ import graphics.graphical_abstraction.GraphicsMasterAbstraction;
/**
* Created by dupriez on 10/11/15.
*
* The class that contains the main method calling the "launchGUI" method from GraphicsMaster
* The class that contains the InputConfigurationFrame method calling the "launchGUI" method from GraphicsMaster
* It's just a starter
*/
public class Igniter_Main_Term {
......
......@@ -9,13 +9,13 @@ import java.util.Random;
import map_generation.map.RoomBuilder.RoomType;
import map_generation.tiles.TileBuilder;
/**
*
*
* This class contains methods that generates simple map to help for tests
*
*/
public class SurfacesMapGeneration implements Serializable{
/**
*
*
*/
private static final long serialVersionUID = 5179076009464463054L;
......@@ -28,15 +28,15 @@ public class SurfacesMapGeneration implements Serializable{
}
return tilebs;
}
private static RoomBuilder defineStartPosition(RoomBuilder[] rooms) {
Random r = new Random();
int idRoom=r.nextInt(rooms.length);
rooms[idRoom].setType(RoomType.START);
return rooms[idRoom];
}
private static void defineStairsPosition(MapBuilder map,int height,int width,RoomBuilder[] rooms, RoomBuilder startingRoom) {
private static void defineStairsPosition(MapBuilder map,int height,int width,RoomBuilder[] rooms, RoomBuilder startingRoom) {
// This method chooses, once the structure of the map is done and the start position of the player is choosed, where the stairs should be
// First I do a BFS (Breadth First Search) starting at the start position of the player that I put in distanceToStart
MapPoint startPosition = new MapPoint(startingRoom.getSurface().j1, startingRoom.getSurface().i1);
......@@ -85,7 +85,7 @@ public class SurfacesMapGeneration implements Serializable{
list.add(newList.get(k));
}
}
// Now it's time to find the position of the stairs
Random r = new Random();
boolean bb=true;
......@@ -98,18 +98,18 @@ public class SurfacesMapGeneration implements Serializable{
posY = rooms[idRoom].getSurface().j1;
if (3*distanceToStart[posY][posX]>2*max_dist){
rooms[idRoom].setType(RoomType.END);
bb=false; // If the distance from the start position to the stairs position is large enough I choose it (compared to the farest point the player can reach)
bb=false; // If the distance from the start position to the stairs position is large enough I choose it (compared to the farest point the player can reach)
}
}
}
public static int distanceBetweenTwoSurface(Surface surface1,Surface surface2) {
// Method that computes the distance between two rooms
int dY=Math.max(surface1.j1-surface2.j2+2,0)+Math.max(surface2.j1-surface1.j2+2,0);
int dX=Math.max(surface1.i1-surface2.i2+2,0)+Math.max(surface2.i1-surface1.i2+2,0);
return (dY>0 && dX>0)?dX+dY+4:dX+dY; // There's an extra to the distance between rooms that aren't facing each other horizontally or vertically (to avoid corridors with corners in the MST when possible)
}
public static LinkedList<Surface> creationCorridor(Surface room1,Surface room2) {
// This method creates a corridor between two rooms
int dNorth=Math.max(room2.j1-room1.j2-1,0);
......@@ -164,12 +164,12 @@ public class SurfacesMapGeneration implements Serializable{
Surface corridor2 = new Surface(room1.i2, yTarget-1, xTarget, yTarget);
corridors.addLast(corridor2);
}
}
return(corridors);
}
}
private static void addCorridorsByMST(RoomBuilder[] rooms, MapBuilder map) {
// Considering the graph made by the rooms with edges corresponding to the distance between any two of them
// I find the MST (Math.minimum SpamMath.ming Tree) of this graph in order to create a first set of corridors that connects all the rooms
......@@ -215,9 +215,9 @@ public class SurfacesMapGeneration implements Serializable{
}
}
}
public static Map roomsRandomGeneration(int meanRoomSize, int numberOfRooms) {
// This is for the moment the main method to create a map
// This is for the moment the InputConfigurationFrame method to create a map
// It first creates the map attributes and then calls the MapBuilder to build the map with those
int heightMap=(meanRoomSize+6)*(int)Math.sqrt(numberOfRooms);
int widthMap=(meanRoomSize+6)*(int)Math.sqrt(numberOfRooms);
......@@ -226,7 +226,7 @@ public class SurfacesMapGeneration implements Serializable{
RoomBuilder[] rooms = new RoomBuilder[numberOfRooms];
int numberOfRoomsCreated=0;
int nbIteration=0;
// Creation of the rooms
while (numberOfRoomsCreated<numberOfRooms) {
nbIteration++;
......@@ -260,17 +260,17 @@ public class SurfacesMapGeneration implements Serializable{
addCorridorsByMST(rooms, map); // Creation of the set of corridors
RoomBuilder startRoom=defineStartPosition(rooms);
defineStairsPosition(map,heightMap,widthMap,rooms,startRoom);
map.setHeight(heightMap);
map.setWidth(widthMap);
for (RoomBuilder room : rooms) {
room.setRandomlySpecial(0.3);
}
return map.build();
}
public static Map simpleRoom(int size) {
// This is a very simple model of a map that contains only one squared room of side size
MapBuilder map = new MapBuilder();
......@@ -285,5 +285,5 @@ public class SurfacesMapGeneration implements Serializable{
defineStairsPosition(map,size,size,rooms,startRoom);
return(map.build());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment