-
Notifications
You must be signed in to change notification settings - Fork 8
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
sound.ts added #13
sound.ts added #13
Conversation
✅ Deploy Preview for skyscraper-game ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Keep going
src/Components/Sound.ts
Outdated
this.audio.addEventListener('ended', () => { | ||
if (count > 1) { | ||
count--; | ||
this.audio.currentTime = 0; | ||
this.audio.play(); | ||
} | ||
}); |
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 move this function into private method decreaseCounter
src/Components/Sound.ts
Outdated
|
||
// usage: | ||
const tapBlockSound = new Sound('public/sound/tapBlock.wav'); | ||
const gameOverSound = new Sound('public/sound/gameOverSound.wav'); | ||
|
||
// To play the sounds: | ||
tapBlockSound.play(); | ||
gameOverSound.play(); | ||
|
||
|
||
tapBlockSound.setVolume(0.5); | ||
gameOverSound.repeat(2); |
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 remove this
src/Components/Sound.ts
Outdated
interface Sound { | ||
play(): void; // play sound | ||
stop(): void; // stop sound | ||
repeat(count: number): void; // repeat sound `count` times or infinity | ||
setVolume(value: number): void; // set volume of sound | ||
} |
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 remove comments from interface
Rename interface to ISound
src/Components/Sound.ts
Outdated
setVolume(value: number): void; // set volume of sound | ||
} | ||
|
||
class Sound implements Sound { |
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.
Change to
export default class Sound implements ISound {
repeat(count: number) { | ||
if (count === Infinity) { | ||
this.audio.loop = true; | ||
} else if (count > 0) { |
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.
Better:
if (count > 0) {
on it @corners2wall |
@Vidhanvyrs Good job!!! |
Thankyou 🙌 |
No description provided.