Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Audio Manager #1

wants to merge 2 commits into from

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

@@ -2,7 +2,10 @@ import WZManager from './wzmanager';

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.

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

@@ -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.

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

@@ -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;
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

@@ -111,7 +111,7 @@ UILogin.doUpdate = function(msPerTick, camera) {
this.loginButton.stance = 'normal';

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.

None yet

3 participants