diff --git a/client/js/gameLoopTools/playerUtilities.js b/client/js/gameLoopTools/playerUtilities.js index 4abc30b..6370fa4 100644 --- a/client/js/gameLoopTools/playerUtilities.js +++ b/client/js/gameLoopTools/playerUtilities.js @@ -1,4 +1,10 @@ const playerUtilities = {}; + +/** + * Creates player avatar + * @param {Object} player - classless object + * @return {Object} - returns object with character classes + */ playerUtilities.create = (player) => { game.physics.enable(player.sprite, Phaser.Physics.ARCADE); player.sprite.body.collideWorldBounds = true; @@ -6,10 +12,20 @@ playerUtilities.create = (player) => { player.sprite.anchor.setTo(...spriteCenter); }; +/** + * + * @param {Object} player + */ playerUtilities.update = (player) => { playerUtilities.move(player, player.controlType); }; +/** + * Determines the device the user is on and moves character accordingly + * @param {Object} player - object representing the character + * @param {Number} type - defines whether play is using a keyboard, mouse or phone + * @returns {Number} - the type of device the user is playing on + */ playerUtilities.move = (player, type) => { let mouseType = type === 0; let keyboardType = type === 1; @@ -23,6 +39,12 @@ playerUtilities.move = (player, type) => { return type; }; + +/** +* Moves the player in the direction of keyboard press. +* @param {Object} player - The player object. +* @param {Number} playerSpeed - The current speed of the player. +*/ playerUtilities.mouseMovement = (player, playerSpeed) => { let movementVector = { x: game.input.x - player.x, diff --git a/client/js/menu.js b/client/js/menu.js index a9edd77..c82ff86 100644 --- a/client/js/menu.js +++ b/client/js/menu.js @@ -1,4 +1,9 @@ -// initialize menuState 1st so it functions as a namespace + /** + * Initializes the menuState 1st; declaring all the variables for width, height, etc.. so menuState will functions as a namespace. + * @function init + * @param {Object} data An object declaring the width, height, background, title, startButton, and startButtonDots + * @return {Object} + */ let menuState = {}; menuState = { init: (data) => { @@ -11,7 +16,15 @@ menuState = { menuState.startButton = data.menuState.startButton || config.menuState.startButton; menuState.startButtonDots = data.menuState.startButtonDots || config.menuState.startButtonDots; }, - + /** $pure + * Makes sure the background image fills the game display no matter the size of the background. + * @function getScaleValueToEnvelopeRect + * @param {Object} childWidth Background width + * @param {Object} childHeight Background height + * @param {Object} parentWidth The game display's width + * @param {Object} parentHeight The game display's height + * @return {Number} + */ getScaleValueToEnvelopeRect: (childWidth, childHeight, parentWidth, parentHeight) => { let xScale = parentWidth / childWidth; let yScale = parentHeight / childHeight;