-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audio Manager #1
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
@@ -2,7 +2,10 @@ import WZManager from './wzmanager'; | |||
|
|||
const AudioManager = {}; | |||
|
|||
AudioManager.playBGM = async function(name) { | |||
var musicVolume = 1; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
const concurrentAudio = audio.cloneNode(); | ||
concurrentAudio.volume = volume; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 @@ | |||
{ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
@@ -5,3 +5,33 @@ | |||
* `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. | |||
|
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@@ -257,8 +258,8 @@ class MapleCharacter { | |||
const twoChars = /.{1,2}/g; | |||
const [hat, faceAcc, ...equips] = this.equips; | |||
|
|||
const hatVslot = !hat? '' : hat.info.vslot.nValue; | |||
const hatParts = !hat? [] : getParts(hat).filter(isDrawable); | |||
const hatVslot = !hat ? '' : hat.info.vslot.nValue; |
There was a problem hiding this comment.
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 () { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@@ -111,7 +111,7 @@ UILogin.doUpdate = function(msPerTick, camera) { | |||
this.loginButton.stance = 'normal'; | |||
|
|||
if (this.activeButton === this.loginButton) { | |||
UICommon.playMouseHoverAudio(); | |||
UICommon.playMouseHoverAudio(1); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Sorry for the mistakes, it's my first contribution to a public git. |
@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! |
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