diff options
author | Pacien TRAN-GIRARD | 2016-05-11 22:45:02 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-05-11 22:45:02 +0200 |
commit | 48d8fc2efc91f5a02391fb1031e7a662509f5630 (patch) | |
tree | 4f78dffe979846421fbbccc9dc798a767dd6fb32 /test | |
parent | 33bc4cab3f2a00db14e6d055d6cd55781c9dd2b4 (diff) | |
download | xblast-48d8fc2efc91f5a02391fb1031e7a662509f5630.tar.gz |
Implement client
Diffstat (limited to 'test')
-rw-r--r-- | test/ch/epfl/xblast/simulation/GraphicalSimulation.java | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/test/ch/epfl/xblast/simulation/GraphicalSimulation.java b/test/ch/epfl/xblast/simulation/GraphicalSimulation.java index 9329cc7..1d15fe5 100644 --- a/test/ch/epfl/xblast/simulation/GraphicalSimulation.java +++ b/test/ch/epfl/xblast/simulation/GraphicalSimulation.java | |||
@@ -12,11 +12,7 @@ import ch.epfl.xblast.server.painter.BoardPainter; | |||
12 | 12 | ||
13 | import javax.swing.*; | 13 | import javax.swing.*; |
14 | import java.awt.*; | 14 | import java.awt.*; |
15 | import java.awt.event.KeyEvent; | ||
16 | import java.util.Collections; | ||
17 | import java.util.HashMap; | ||
18 | import java.util.List; | 15 | import java.util.List; |
19 | import java.util.Map; | ||
20 | import java.util.function.Consumer; | 16 | import java.util.function.Consumer; |
21 | 17 | ||
22 | /** | 18 | /** |
@@ -31,19 +27,6 @@ public class GraphicalSimulation extends Simulation { | |||
31 | private static final Consumer<PlayerAction> PLAYER_ACTION_CONSUMER = System.out::println; | 27 | private static final Consumer<PlayerAction> PLAYER_ACTION_CONSUMER = System.out::println; |
32 | private static final PlayerID MAIN_PLAYER = PlayerID.PLAYER_1; | 28 | private static final PlayerID MAIN_PLAYER = PlayerID.PLAYER_1; |
33 | 29 | ||
34 | private static Map<Integer, PlayerAction> buildPlayerActionMap() { | ||
35 | Map<Integer, PlayerAction> playerActionMap = new HashMap<>(); | ||
36 | |||
37 | playerActionMap.put(KeyEvent.VK_UP, PlayerAction.MOVE_N); | ||
38 | playerActionMap.put(KeyEvent.VK_RIGHT, PlayerAction.MOVE_E); | ||
39 | playerActionMap.put(KeyEvent.VK_DOWN, PlayerAction.MOVE_S); | ||
40 | playerActionMap.put(KeyEvent.VK_LEFT, PlayerAction.MOVE_W); | ||
41 | playerActionMap.put(KeyEvent.VK_SPACE, PlayerAction.DROP_BOMB); | ||
42 | playerActionMap.put(KeyEvent.VK_SHIFT, PlayerAction.STOP); | ||
43 | |||
44 | return Collections.unmodifiableMap(playerActionMap); | ||
45 | } | ||
46 | |||
47 | private static ch.epfl.xblast.client.GameState translateToClientData(GameState gs) { | 30 | private static ch.epfl.xblast.client.GameState translateToClientData(GameState gs) { |
48 | List<Byte> serializedGameState = GameStateSerializer.serialize(BOARD_PAINTER, gs); | 31 | List<Byte> serializedGameState = GameStateSerializer.serialize(BOARD_PAINTER, gs); |
49 | return GameStateDeserializer.deserialize(serializedGameState); | 32 | return GameStateDeserializer.deserialize(serializedGameState); |
@@ -61,7 +44,7 @@ public class GraphicalSimulation extends Simulation { | |||
61 | } | 44 | } |
62 | 45 | ||
63 | private void attachKeyboardHandler(Component comp) { | 46 | private void attachKeyboardHandler(Component comp) { |
64 | comp.addKeyListener(new KeyboardEventHandler(buildPlayerActionMap(), PLAYER_ACTION_CONSUMER)); | 47 | comp.addKeyListener(new KeyboardEventHandler(PLAYER_ACTION_CONSUMER)); |
65 | comp.requestFocusInWindow(); | 48 | comp.requestFocusInWindow(); |
66 | } | 49 | } |
67 | 50 | ||