Skip to content

Audio Manager#1

Open
igorpwnd wants to merge 2 commits intojohncintron:masterfrom
igorpwnd:master
Open

Audio Manager#1
igorpwnd wants to merge 2 commits intojohncintron:masterfrom
igorpwnd:master

Conversation

@igorpwnd
Copy link

Most of my changes were at AudioManager.

I made 2 variables to control the sound volume, everytime that PLAY_AUDIO() is called, the sound volume is controled by one of those variables.

The rest of changes are identation and stuff from VSCODE

Copy link

@JoaoBGusmao JoaoBGusmao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not the project owner, but I did a small code review to help keeping the code beautiful as it is today

const AudioManager = {};

AudioManager.playBGM = async function(name) {
var musicVolume = 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not recommended to use var. Try using const instead

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct. Take a look at this style guide: https://github.com/airbnb/javascript.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an addendum, I don't recommend storing these variables at the module level. I prefer assigning these variables to the AudoManager object.


function PLAY_AUDIO(audio, vol) {
const concurrentAudio = audio.cloneNode();
concurrentAudio.volume = volume;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change volume to vol? It's a good practice to be explicit in what you want to do, and abbreviating names could bad for readability

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Also, the default parameter is there for a good reason.

@@ -0,0 +1,5 @@
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this VS config file here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I don't know. He is on my .gitignore. Gotta remove for the next commit

* `npm install`
* `npm run local` to start the application with inspectable client code.
* `npm run dev` to start the application with minified IIFE client code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my comment on the RZ thread. I don't think it should be part of the README.

}
};

AudioManager.setMusicVolume = async function (vol) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async is not necessary because you're not using await in the body of the function. Also, don't do type checking here; it's an antipattern and the caller is expected to pass a number.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I was trying to make some sort of validation


const hatVslot = !hat? '' : hat.info.vslot.nValue;
const hatParts = !hat? [] : getParts(hat).filter(isDrawable);
const hatVslot = !hat ? '' : hat.info.vslot.nValue;
Copy link
Owner

@johncintron johncintron Mar 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These ternaries are the only places where VS autoformat is acceptable. See the other comment about style.

const UICommon = {};

UICommon.initialize = async function() {
UICommon.initialize = async function () {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no whitespace between function and the parentheses.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johncintron according to airbnb styleguide, the space is correct:
space-before-function-paren


if (this.activeButton === this.loginButton) {
UICommon.playMouseHoverAudio();
UICommon.playMouseHoverAudio(1);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UICommon.playMouseHoverAudio doesn't take any arguments. Not sure why you're passing 1 to it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably forgot to remove, I was using during the test phase

@igorpwnd
Copy link
Author

Sorry for the mistakes, it's my first contribution to a public git.

@JoaoBGusmao
Copy link

@igorpwnd keep working on this pull request, and send it again to @johncintron. Once you're done with corrections quoted above, he can maybe accept your request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants