diff options
author | mafaldo <mafaldo@heavyhammer.home> | 2018-02-11 12:21:15 +0100 |
---|---|---|
committer | mafaldo <mafaldo@heavyhammer.home> | 2018-02-11 12:21:15 +0100 |
commit | a9a5bc0189d316de863bbdc8c3a425706b6ade84 (patch) | |
tree | e92db501cfa040cad315b535cb326abb3f086348 /src/main/java/Subconscious.java | |
parent | tiles bound to actors, remove Player and Enemy (diff) | |
download | Subconscious-old-a9a5bc0189d316de863bbdc8c3a425706b6ade84.tar.gz Subconscious-old-a9a5bc0189d316de863bbdc8c3a425706b6ade84.zip |
add pan, add zoom, add weapon
Diffstat (limited to '')
-rw-r--r-- | src/main/java/Subconscious.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/main/java/Subconscious.java b/src/main/java/Subconscious.java index d462385..cbb17dc 100644 --- a/src/main/java/Subconscious.java +++ b/src/main/java/Subconscious.java @@ -7,6 +7,8 @@ import java.awt.Dimension; import java.awt.event.MouseListener; import java.awt.event.MouseEvent; +import java.awt.event.MouseWheelListener; +import java.awt.event.MouseWheelEvent; import java.awt.event.KeyListener; import java.awt.event.KeyEvent; import java.awt.event.ComponentListener; @@ -20,7 +22,8 @@ import java.awt.Toolkit; public class Subconscious extends JPanel - implements Runnable, MouseListener, KeyListener, ComponentListener { + implements Runnable, MouseListener, KeyListener, + ComponentListener, MouseWheelListener { public static final String TITLE = "Subconscious"; public static final long RENDER_PERIOD_MS = 10; @@ -46,6 +49,7 @@ public class Subconscious addMouseListener(this); addKeyListener(this); addComponentListener(this); + addMouseWheelListener(this); setFocusable(true); requestFocus(); @@ -146,6 +150,37 @@ public class Subconscious if (keyCode == KeyEvent.VK_Q && e.isControlDown()) { running = false; } + + if (keyCode == KeyEvent.VK_DOWN) { + currentScene.pan(0, -10); + //rerender + dbImage = null; + } + + if (keyCode == KeyEvent.VK_UP) { + currentScene.pan(0, 10); + //rerender + dbImage = null; + } + + if (keyCode == KeyEvent.VK_LEFT) { + currentScene.pan(10, 0); + //rerender + dbImage = null; + } + + if (keyCode == KeyEvent.VK_RIGHT) { + currentScene.pan(-10, 0); + //rerender + dbImage = null; + } + } + + @Override public void mouseWheelMoved(MouseWheelEvent e) { + int value = e.getWheelRotation(); + currentScene.zoom(value*-3); + //rerender + dbImage = null; } @Override public void componentHidden(ComponentEvent e) {} |