mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-27 13:11:42 +00:00
camera controls stuff
This commit is contained in:
parent
80291f02f3
commit
0f4ccde6dc
4 changed files with 35 additions and 8 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import src.Settings;
|
||||||
|
import hxd.Key;
|
||||||
import src.Util;
|
import src.Util;
|
||||||
import h3d.Quat;
|
import h3d.Quat;
|
||||||
#if hl
|
#if hl
|
||||||
|
|
@ -100,6 +102,9 @@ class CameraController extends Object {
|
||||||
var window = Window.getInstance();
|
var window = Window.getInstance();
|
||||||
var deltaposX = (window.width / 2) - mouseX;
|
var deltaposX = (window.width / 2) - mouseX;
|
||||||
var deltaposY = (window.height / 2) - mouseY;
|
var deltaposY = (window.height / 2) - mouseY;
|
||||||
|
if (!Settings.controlsSettings.alwaysFreeLook && !Key.isDown(Settings.controlsSettings.freelook)) {
|
||||||
|
deltaposY = 0;
|
||||||
|
}
|
||||||
var rotX = deltaposX * 0.001 * CameraSensitivity * Math.PI * 2;
|
var rotX = deltaposX * 0.001 * CameraSensitivity * Math.PI * 2;
|
||||||
var rotY = deltaposY * 0.001 * CameraSensitivity * Math.PI * 2;
|
var rotY = deltaposY * 0.001 * CameraSensitivity * Math.PI * 2;
|
||||||
CameraYaw -= rotX;
|
CameraYaw -= rotX;
|
||||||
|
|
@ -123,6 +128,21 @@ class CameraController extends Object {
|
||||||
// camera.position.add(cameraVerticalTranslation);
|
// camera.position.add(cameraVerticalTranslation);
|
||||||
var camera = level.scene.camera;
|
var camera = level.scene.camera;
|
||||||
|
|
||||||
|
if (Key.isDown(Settings.controlsSettings.camForward)) {
|
||||||
|
CameraPitch += 0.75 * 5 * dt;
|
||||||
|
}
|
||||||
|
if (Key.isDown(Settings.controlsSettings.camBackward)) {
|
||||||
|
CameraPitch -= 0.75 * 5 * dt;
|
||||||
|
}
|
||||||
|
if (Key.isDown(Settings.controlsSettings.camLeft)) {
|
||||||
|
CameraYaw -= 0.75 * 5 * dt;
|
||||||
|
}
|
||||||
|
if (Key.isDown(Settings.controlsSettings.camRight)) {
|
||||||
|
CameraYaw += 0.75 * 5 * dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
CameraPitch = Util.clamp(CameraPitch, -Math.PI / 2, Math.PI / 2);
|
||||||
|
|
||||||
function getRotQuat(v1:Vector, v2:Vector) {
|
function getRotQuat(v1:Vector, v2:Vector) {
|
||||||
function orthogonal(v:Vector) {
|
function orthogonal(v:Vector) {
|
||||||
var x = Math.abs(v.x);
|
var x = Math.abs(v.x);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import src.Settings;
|
||||||
import h3d.scene.Mesh;
|
import h3d.scene.Mesh;
|
||||||
import h3d.col.Bounds;
|
import h3d.col.Bounds;
|
||||||
import collision.CollisionEntity;
|
import collision.CollisionEntity;
|
||||||
|
|
@ -811,22 +812,22 @@ class Marble extends GameObject {
|
||||||
var move = new Move();
|
var move = new Move();
|
||||||
move.d = new Vector();
|
move.d = new Vector();
|
||||||
if (this.controllable && this.mode != Finish) {
|
if (this.controllable && this.mode != Finish) {
|
||||||
if (Key.isDown(Key.W)) {
|
if (Key.isDown(Settings.controlsSettings.forward)) {
|
||||||
move.d.x -= 1;
|
move.d.x -= 1;
|
||||||
}
|
}
|
||||||
if (Key.isDown(Key.S)) {
|
if (Key.isDown(Settings.controlsSettings.backward)) {
|
||||||
move.d.x += 1;
|
move.d.x += 1;
|
||||||
}
|
}
|
||||||
if (Key.isDown(Key.A)) {
|
if (Key.isDown(Settings.controlsSettings.left)) {
|
||||||
move.d.y += 1;
|
move.d.y += 1;
|
||||||
}
|
}
|
||||||
if (Key.isDown(Key.D)) {
|
if (Key.isDown(Settings.controlsSettings.right)) {
|
||||||
move.d.y -= 1;
|
move.d.y -= 1;
|
||||||
}
|
}
|
||||||
if (Key.isDown(Key.SPACE)) {
|
if (Key.isDown(Settings.controlsSettings.jump)) {
|
||||||
move.jump = true;
|
move.jump = true;
|
||||||
}
|
}
|
||||||
if (Key.isDown(Key.MOUSE_LEFT)) {
|
if (Key.isDown(Settings.controlsSettings.powerup)) {
|
||||||
move.powerup = true;
|
move.powerup = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ typedef ControlsSettings = {
|
||||||
var jump:Int;
|
var jump:Int;
|
||||||
var powerup:Int;
|
var powerup:Int;
|
||||||
var freelook:Int;
|
var freelook:Int;
|
||||||
|
var alwaysFreeLook:Bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Settings {
|
class Settings {
|
||||||
|
|
@ -49,7 +50,7 @@ class Settings {
|
||||||
colorDepth: 1,
|
colorDepth: 1,
|
||||||
shadows: false,
|
shadows: false,
|
||||||
musicVolume: 0,
|
musicVolume: 0,
|
||||||
soundVolume: 0
|
soundVolume: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static var controlsSettings:ControlsSettings = {
|
public static var controlsSettings:ControlsSettings = {
|
||||||
|
|
@ -63,7 +64,8 @@ class Settings {
|
||||||
camRight: Key.RIGHT,
|
camRight: Key.RIGHT,
|
||||||
jump: Key.SPACE,
|
jump: Key.SPACE,
|
||||||
powerup: Key.MOUSE_LEFT,
|
powerup: Key.MOUSE_LEFT,
|
||||||
freelook: Key.MOUSE_RIGHT
|
freelook: Key.MOUSE_RIGHT,
|
||||||
|
alwaysFreeLook: true
|
||||||
};
|
};
|
||||||
|
|
||||||
public static function applySettings() {
|
public static function applySettings() {
|
||||||
|
|
|
||||||
|
|
@ -583,6 +583,10 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
|
||||||
alwaysFreelook.position = new Vector(365, 269);
|
alwaysFreelook.position = new Vector(365, 269);
|
||||||
alwaysFreelook.extent = new Vector(43, 53);
|
alwaysFreelook.extent = new Vector(43, 53);
|
||||||
alwaysFreelook.buttonType = Toggle;
|
alwaysFreelook.buttonType = Toggle;
|
||||||
|
alwaysFreelook.pressed = Settings.controlsSettings.alwaysFreeLook;
|
||||||
|
alwaysFreelook.pressedAction = (sender) -> {
|
||||||
|
Settings.controlsSettings.alwaysFreeLook = !Settings.controlsSettings.alwaysFreeLook;
|
||||||
|
}
|
||||||
mouseControlsPane.addChild(alwaysFreelook);
|
mouseControlsPane.addChild(alwaysFreelook);
|
||||||
|
|
||||||
var mouseSensitivity = new GuiSlider(ResourceLoader.getImage("data/ui/options/cntrl_mous_knb.png").toTile());
|
var mouseSensitivity = new GuiSlider(ResourceLoader.getImage("data/ui/options/cntrl_mous_knb.png").toTile());
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue