mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
add option for camera centering
This commit is contained in:
parent
6c20de1b8a
commit
b60a80b10d
3 changed files with 27 additions and 4 deletions
|
|
@ -68,6 +68,8 @@ class CameraController extends Object {
|
||||||
var hasYInput:Bool = false;
|
var hasYInput:Bool = false;
|
||||||
var dt:Float;
|
var dt:Float;
|
||||||
|
|
||||||
|
var wasLastGamepadInput:Bool = false;
|
||||||
|
|
||||||
public function new(marble:Marble) {
|
public function new(marble:Marble) {
|
||||||
super();
|
super();
|
||||||
this.marble = marble;
|
this.marble = marble;
|
||||||
|
|
@ -135,6 +137,10 @@ class CameraController extends Object {
|
||||||
var factor = isTouch ? Util.lerp(1 / 25, 1 / 15,
|
var factor = isTouch ? Util.lerp(1 / 25, 1 / 15,
|
||||||
Settings.controlsSettings.cameraSensitivity) : Util.lerp(1 / 2500, 1 / 100, Settings.controlsSettings.cameraSensitivity);
|
Settings.controlsSettings.cameraSensitivity) : Util.lerp(1 / 2500, 1 / 100, Settings.controlsSettings.cameraSensitivity);
|
||||||
|
|
||||||
|
if (!Settings.controlsSettings.alwaysFreeLook && !Key.isDown(Settings.controlsSettings.freelook) && !isTouch) {
|
||||||
|
deltaposY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// CameraPitch += deltaposY * factor;
|
// CameraPitch += deltaposY * factor;
|
||||||
// CameraYaw += deltaposX * factor;
|
// CameraYaw += deltaposX * factor;
|
||||||
|
|
||||||
|
|
@ -155,6 +161,11 @@ class CameraController extends Object {
|
||||||
hasYInput = true;
|
hasYInput = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isTouch)
|
||||||
|
wasLastGamepadInput = false;
|
||||||
|
else
|
||||||
|
wasLastGamepadInput = true;
|
||||||
|
|
||||||
// var rotX = deltaposX * 0.001 * Settings.controlsSettings.cameraSensitivity * Math.PI * 2;
|
// var rotX = deltaposX * 0.001 * Settings.controlsSettings.cameraSensitivity * Math.PI * 2;
|
||||||
// var rotY = deltaposY * 0.001 * Settings.controlsSettings.cameraSensitivity * Math.PI * 2;
|
// var rotY = deltaposY * 0.001 * Settings.controlsSettings.cameraSensitivity * Math.PI * 2;
|
||||||
// CameraYaw -= rotX;
|
// CameraYaw -= rotX;
|
||||||
|
|
@ -221,6 +232,10 @@ class CameraController extends Object {
|
||||||
var gamepadX = applyNonlinearScale(rescaleDeadZone(Gamepad.getAxis(Settings.gamepadSettings.cameraXAxis), 0.25));
|
var gamepadX = applyNonlinearScale(rescaleDeadZone(Gamepad.getAxis(Settings.gamepadSettings.cameraXAxis), 0.25));
|
||||||
var gamepadY = applyNonlinearScale(rescaleDeadZone(Gamepad.getAxis(Settings.gamepadSettings.cameraYAxis), 0.25));
|
var gamepadY = applyNonlinearScale(rescaleDeadZone(Gamepad.getAxis(Settings.gamepadSettings.cameraYAxis), 0.25));
|
||||||
|
|
||||||
|
if (gamepadX != 0.0 || gamepadY != 0.0) {
|
||||||
|
wasLastGamepadInput = true;
|
||||||
|
}
|
||||||
|
|
||||||
var cameraPitchDelta = (Key.isDown(Settings.controlsSettings.camBackward) ? 1 : 0)
|
var cameraPitchDelta = (Key.isDown(Settings.controlsSettings.camBackward) ? 1 : 0)
|
||||||
- (Key.isDown(Settings.controlsSettings.camForward) ? 1 : 0)
|
- (Key.isDown(Settings.controlsSettings.camForward) ? 1 : 0)
|
||||||
+ gamepadY;
|
+ gamepadY;
|
||||||
|
|
@ -258,10 +273,7 @@ class CameraController extends Object {
|
||||||
deltaX = deltaNew;
|
deltaX = deltaNew;
|
||||||
|
|
||||||
// Center the pitch
|
// Center the pitch
|
||||||
if (!Settings.controlsSettings.alwaysFreeLook
|
if (Settings.controlsSettings.controllerVerticalCenter && !(hasXInput || hasYInput) && deltaY == 0.0 && wasLastGamepadInput) {
|
||||||
&& !Key.isDown(Settings.controlsSettings.freelook)
|
|
||||||
&& !(hasXInput || hasYInput)
|
|
||||||
&& deltaY == 0.0) {
|
|
||||||
var rescaledY = deltaY;
|
var rescaledY = deltaY;
|
||||||
if (rescaledY <= 0.0)
|
if (rescaledY <= 0.0)
|
||||||
rescaledY = 0.4 - rescaledY * -0.75;
|
rescaledY = 0.4 - rescaledY * -0.75;
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ typedef ControlsSettings = {
|
||||||
var powerup:Int;
|
var powerup:Int;
|
||||||
var freelook:Int;
|
var freelook:Int;
|
||||||
var alwaysFreeLook:Bool;
|
var alwaysFreeLook:Bool;
|
||||||
|
var controllerVerticalCenter:Bool;
|
||||||
var cameraSensitivity:Float;
|
var cameraSensitivity:Float;
|
||||||
var invertYAxis:Bool;
|
var invertYAxis:Bool;
|
||||||
var respawn:Int;
|
var respawn:Int;
|
||||||
|
|
@ -150,6 +151,7 @@ class Settings {
|
||||||
powerup: Key.MOUSE_LEFT,
|
powerup: Key.MOUSE_LEFT,
|
||||||
freelook: Key.MOUSE_MIDDLE,
|
freelook: Key.MOUSE_MIDDLE,
|
||||||
alwaysFreeLook: true,
|
alwaysFreeLook: true,
|
||||||
|
controllerVerticalCenter: true,
|
||||||
cameraSensitivity: 0.6,
|
cameraSensitivity: 0.6,
|
||||||
invertYAxis: false,
|
invertYAxis: false,
|
||||||
respawn: Key.BACKSPACE,
|
respawn: Key.BACKSPACE,
|
||||||
|
|
@ -362,6 +364,8 @@ class Settings {
|
||||||
#if js
|
#if js
|
||||||
if (optionsSettings.reflectionDetail == null)
|
if (optionsSettings.reflectionDetail == null)
|
||||||
optionsSettings.reflectionDetail = 2;
|
optionsSettings.reflectionDetail = 2;
|
||||||
|
if (controlsSettings.controllerVerticalCenter == null)
|
||||||
|
controlsSettings.controllerVerticalCenter = true;
|
||||||
#end
|
#end
|
||||||
if (optionsSettings.maxPixelRatio == 0 #if js || optionsSettings.maxPixelRatio == null #end)
|
if (optionsSettings.maxPixelRatio == 0 #if js || optionsSettings.maxPixelRatio == null #end)
|
||||||
optionsSettings.maxPixelRatio = 1;
|
optionsSettings.maxPixelRatio = 1;
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,13 @@ class InputOptionsGui extends GuiImage {
|
||||||
|
|
||||||
flOpt.setCurrentOption(Settings.controlsSettings.alwaysFreeLook ? 1 : 0);
|
flOpt.setCurrentOption(Settings.controlsSettings.alwaysFreeLook ? 1 : 0);
|
||||||
|
|
||||||
|
var clOpt = optionCollection.addOption(1, "Camera Recentering", ["Disabled", "Enabled"], (idx) -> {
|
||||||
|
Settings.controlsSettings.controllerVerticalCenter = (idx == 1);
|
||||||
|
return true;
|
||||||
|
}, 0.5, 118);
|
||||||
|
|
||||||
|
clOpt.setCurrentOption(Settings.controlsSettings.controllerVerticalCenter ? 1 : 0);
|
||||||
|
|
||||||
var msOpt = optionCollection.addOption(1, "Mouse Sensitivity", numberRange(10, 100, 5), (idx) -> {
|
var msOpt = optionCollection.addOption(1, "Mouse Sensitivity", numberRange(10, 100, 5), (idx) -> {
|
||||||
Settings.controlsSettings.cameraSensitivity = cast(0.2 + (idx / 18.0) * (3 - 0.2));
|
Settings.controlsSettings.cameraSensitivity = cast(0.2 + (idx / 18.0) * (3 - 0.2));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue