@moderrkowo/jsgl
Version:
Client-side JavaScript library for creating web 2D games. Focusing at objective game.
50 lines (49 loc) • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Input = void 0;
var Vector2_1 = require("./structs/Vector2");
var Input = /** @class */ (function () {
function Input() {
// Mouse
this.isMousePrimaryButtonDown = false;
/**
* The current mouse scroll wheel delta. Positive number is up, negative is down and zero is for none.
* @property
*/
this.mouseScrollDelta = new Vector2_1.Vector2();
/**
* The current integer mouse position on canvas pixel coordinate.
* @property
*/
this.mouseClientPosition = new Vector2_1.Vector2();
/**
* The current integer mouse position on world grid coordinate.
* @property
*/
this.mouseWorldPosition = new Vector2_1.Vector2();
/**
* The current decimal mouse position on world grid coordinate.
* @property
*/
this.mousePreciseWorldPosition = new Vector2_1.Vector2();
/**
* The current integer mouse position on canvas grid coordinate.
*/
this.mouseLocalPosition = new Vector2_1.Vector2();
/**
* The current decimal mouse position on canvas grid coordinate.
*/
this.mousePreciseLocalPosition = new Vector2_1.Vector2();
// Keyboard
this.keysUp = new Set();
this.keysDown = new Set();
}
Input.prototype.isKeyDown = function (keyCode) {
return this.keysDown.has(keyCode.toLowerCase().replace('key', ''));
};
Input.prototype.isKeyUp = function (keyCode) {
return this.keysUp.has(keyCode.toLowerCase().replace('key', ''));
};
return Input;
}());
exports.Input = Input;