Selected tile changes with scroll whell

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent 194f82e374
commit dc048c8fd7
  1. 8
      Java/scripts/md5
  2. 4
      src/sig/DrawLoop.java
  3. 10
      src/sig/engine/MouseScrollValue.java
  4. 9
      src/sig/engine/Object.java
  5. 2
      src/sig/engine/Panel.java
  6. 13
      src/sig/objects/LevelRenderer.java
  7. 2
      utils/filelist
  8. 8
      utils/md5

@ -1,4 +1,4 @@
build.sh:55f0208b07ba384f45009d6f92fe88fe *-
clean.sh:96ce35f2d2dcb555421e00a6afda23ca *-
commit.sh:5e4448db9ad48e72ec3a1ff4f5763b41 *-
jar.sh:56f9b7c6dc8e85f28ffefe9ce82b1f07 *-
build.sh:55f0208b07ba384f45009d6f92fe88fe -
clean.sh:96ce35f2d2dcb555421e00a6afda23ca -
commit.sh:5e4448db9ad48e72ec3a1ff4f5763b41 -
jar.sh:56f9b7c6dc8e85f28ffefe9ce82b1f07 -

@ -18,6 +18,10 @@ public class DrawLoop {
for (int i=0;i<RabiClone.OBJ.size();i++) {
RabiClone.OBJ.get(i).draw(p);
}
for (int i=0;i<RabiClone.OBJ.size();i++) {
RabiClone.OBJ.get(i).drawOverlay(p);
}
}
public static void Draw_Sprite(double x, double y, Sprite sprite){

@ -0,0 +1,10 @@
package sig.engine;
public enum MouseScrollValue {
UP(), //-1 is up
DOWN() /*1 is down*/;
public static MouseScrollValue getValue(int value) {
return value==-1?UP:DOWN;
}
}

@ -66,8 +66,11 @@ public abstract class Object implements GameEntity{
return panel.MOUSE.getOrDefault(mb,false);
}
protected boolean MouseScrolled(int scrolled) {
//-1 is UP, 1 is DOWN
return true;
/**
*
* @param scrolled -1 is UP, 1 is DOWN
* @return
*/
protected void MouseScrolled(MouseScrollValue scrolled) {
}
}

@ -107,7 +107,7 @@ public class Panel extends JPanel implements Runnable,KeyListener {
public void mouseWheelMoved(MouseWheelEvent e) {
for(int i=0; i<RabiClone.OBJ.size();i++){
Object current_obj = RabiClone.OBJ.get(i);
current_obj.MouseScrolled(e.getWheelRotation());
current_obj.MouseScrolled(MouseScrollValue.getValue(e.getWheelRotation()));
}
}
});

@ -4,6 +4,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import sig.RabiClone;
import sig.engine.MouseScrollValue;
import sig.engine.Object;
import sig.engine.Panel;
import sig.engine.Sprite;
@ -11,6 +12,8 @@ import sig.map.Tile;
public class LevelRenderer extends Object{
Tile selectedTile = Tile.WALL;
public LevelRenderer(Panel panel) {
super(panel);
this.setSprite(Sprite.TILE_SHEET);
@ -34,9 +37,13 @@ public class LevelRenderer extends Object{
}
@Override
protected boolean MouseScrolled(int scrolled) {
//System.out.println("Scrolled");
return true;
protected void MouseScrolled(MouseScrollValue scrolled) {
int up = scrolled==MouseScrollValue.UP?1:0;
int down = scrolled==MouseScrollValue.DOWN?1:0;
int tempIndex = selectedTile.ordinal()+down-up;
int selectedIndex = tempIndex<0?Tile.values().length-Math.abs(tempIndex):tempIndex%Tile.values().length;
selectedTile = Tile.values()[selectedIndex];
//System.out.println(selectedTile);
}
@Override

@ -1,5 +1,5 @@
.coauthors
.updateDirectories
define.sh
main.sh
search.sh
.updateDirectories

@ -1,4 +1,4 @@
.updateDirectories:0ede00461e947494545e694040787b3f *-
define.sh:883c4033be11b6d1268b852beada5463 *-
main.sh:663ac9bb9ee46eb8cd1d717e8eb5e486 *-
search.sh:2a471ffc3daa12f96157e613873f589d *-
define.sh:883c4033be11b6d1268b852beada5463 -
main.sh:663ac9bb9ee46eb8cd1d717e8eb5e486 -
search.sh:2a471ffc3daa12f96157e613873f589d -
.updateDirectories:0ede00461e947494545e694040787b3f -

Loading…
Cancel
Save