From a9a5bc0189d316de863bbdc8c3a425706b6ade84 Mon Sep 17 00:00:00 2001 From: mafaldo Date: Sun, 11 Feb 2018 12:21:15 +0100 Subject: add pan, add zoom, add weapon --- src/main/java/Subconscious.java | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/main/java/Subconscious.java') 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) {} -- cgit v1.2.1