generated from sigonasr2/JavaProjectTemplate
parent
7bb0ce71e1
commit
683d056992
@ -5,6 +5,7 @@ import sig.engine.Color;
|
||||
import sig.engine.Font;
|
||||
import sig.engine.Key;
|
||||
import sig.engine.Mouse;
|
||||
import sig.engine.MouseScrollValue;
|
||||
import sig.engine.Panel;
|
||||
import sig.engine.Point;
|
||||
import sig.engine.Sprite;
|
||||
@ -58,6 +59,13 @@ public class JavaProjectTemplate {
|
||||
if (Mouse.isPressed(2)) { //If middle click is pressed, reset the player position.
|
||||
pl.x=pl.y=200;
|
||||
}
|
||||
|
||||
if (Mouse.mouseWheel==MouseScrollValue.UP) {
|
||||
System.out.println("Scroll up!");
|
||||
}
|
||||
if (Mouse.mouseWheel==MouseScrollValue.DOWN) {
|
||||
System.out.println("Scroll down!");
|
||||
}
|
||||
}
|
||||
|
||||
public void drawGame() {
|
||||
|
||||
@ -9,6 +9,7 @@ public class Mouse {
|
||||
public static HashMap<Integer,Boolean> pressMap=new HashMap<>();
|
||||
public static HashMap<Integer,Boolean> releaseMap=new HashMap<>();
|
||||
public static Point<Integer> mousePosition = new Point<Integer>(0,0);
|
||||
public static MouseScrollValue mouseWheel = MouseScrollValue.NONE;
|
||||
public static Point<Integer> GetPos(){
|
||||
return new Point<Integer>(x,y);
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
package sig.engine;
|
||||
|
||||
public enum MouseScrollValue {
|
||||
UP(), //-1 is up
|
||||
DOWN() /*1 is down*/;
|
||||
UP, //-1 is up
|
||||
DOWN, /*1 is down*/
|
||||
NONE /*Means no scrolling occurring.*/;
|
||||
|
||||
public static MouseScrollValue getValue(int value) {
|
||||
return value==-1?UP:DOWN;
|
||||
|
||||
@ -49,7 +49,6 @@ public class Panel extends JPanel implements Runnable,KeyListener {
|
||||
public double nanaX = 0;
|
||||
public double nanaY = 0;
|
||||
public int button = 0;
|
||||
private MouseScrollValue scrollWheel=null;
|
||||
public static final int UPDATE_LOOP_FRAMERATE = 244;
|
||||
public static final long UPDATE_LOOP_NANOTIME = (long)((1d/UPDATE_LOOP_FRAMERATE)*1000000000l);
|
||||
public static final double UPDATE_MULT = 1d / UPDATE_LOOP_FRAMERATE;
|
||||
@ -101,6 +100,7 @@ public class Panel extends JPanel implements Runnable,KeyListener {
|
||||
Mouse.releaseMap.clear();
|
||||
Key.KEYS_PRESS.clear();
|
||||
Key.KEYS_RELEASE.clear();
|
||||
Mouse.mouseWheel=MouseScrollValue.NONE;
|
||||
dt -= UPDATE_LOOP_NANOTIME;
|
||||
TIME += UPDATE_LOOP_NANOTIME;
|
||||
}
|
||||
@ -181,7 +181,7 @@ public class Panel extends JPanel implements Runnable,KeyListener {
|
||||
//-1 is UP, 1 is DOWN
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
scrollWheel=MouseScrollValue.getValue(e.getWheelRotation());
|
||||
Mouse.mouseWheel=MouseScrollValue.getValue(e.getWheelRotation());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user