Add mouse-based movement (#1037)

* Add mouse-based movement

* Rename keybind to 'Follow Mouse'
This commit is contained in:
Joshua Fan
2019-11-11 13:00:35 -06:00
committed by Anuken
parent 8d19c8b7af
commit dcdec7f55f
3 changed files with 7 additions and 0 deletions

View File

@@ -593,6 +593,11 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
movement.x += xa * speed;
}
if(Core.input.keyDown(Binding.mouse_move)){
movement.x += Mathf.clamp((Core.input.mouseX() - Core.graphics.getWidth() / 2) * 0.005f, -1, 1) * speed;
movement.y += Mathf.clamp((Core.input.mouseY() - Core.graphics.getHeight() / 2) * 0.005f, -1, 1) * speed;
}
Vector2 vec = Core.input.mouseWorld(control.input.getMouseX(), control.input.getMouseY());
pointerX = vec.x;
pointerY = vec.y;

View File

@@ -9,6 +9,7 @@ import io.anuke.arc.input.KeyCode;
public enum Binding implements KeyBind{
move_x(new Axis(KeyCode.A, KeyCode.D), "general"),
move_y(new Axis(KeyCode.S, KeyCode.W)),
mouse_move(KeyCode.MOUSE_BACK),
select(KeyCode.MOUSE_LEFT),
deselect(KeyCode.MOUSE_RIGHT),
break_block(KeyCode.MOUSE_RIGHT),