From 62cf2938130609cbc461b0da59f2338a00f3b2e5 Mon Sep 17 00:00:00 2001 From: Lindsey McDowell Date: Tue, 27 Nov 2018 20:58:18 -0800 Subject: [PATCH 1/3] Menu.js jsdocs --- client/js/menu.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/client/js/menu.js b/client/js/menu.js index 5c320f9..5e96707 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) => { @@ -10,7 +15,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; From f37bfd5fc5aa577d28dac380f51595018332ee0b Mon Sep 17 00:00:00 2001 From: sugarsyntax Date: Thu, 29 Nov 2018 16:11:29 -0800 Subject: [PATCH 2/3] Add Docstrings --- client/js/gameLoopTools/playerUtilities.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/client/js/gameLoopTools/playerUtilities.js b/client/js/gameLoopTools/playerUtilities.js index 66e1f94..d0a042e 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 + * @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; @@ -28,6 +44,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, From 0d602c1e0efd3e907f9812345d8934fa721016ae Mon Sep 17 00:00:00 2001 From: sugarsyntax Date: Thu, 29 Nov 2018 17:52:30 -0800 Subject: [PATCH 3/3] Add doc strings --- client/js/gameLoopTools/playerUtilities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/js/gameLoopTools/playerUtilities.js b/client/js/gameLoopTools/playerUtilities.js index 43522aa..6370fa4 100644 --- a/client/js/gameLoopTools/playerUtilities.js +++ b/client/js/gameLoopTools/playerUtilities.js @@ -22,7 +22,7 @@ playerUtilities.update = (player) => { /** * Determines the device the user is on and moves character accordingly - * @param {Object} player + * @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 */