Add mouse-based movement (#1037)
* Add mouse-based movement * Rename keybind to 'Follow Mouse'
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user