Improved kitty mechanics
Update .gitignore, nibblepoker-contributors.js, and kiki-ronron-01.ogg
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -39,4 +39,4 @@ tools/items/mc-art-viewer/nbt.js
|
||||
# Temporary
|
||||
articles/*.txt
|
||||
commons/strings/_*/
|
||||
*.ogg
|
||||
meow*.ogg
|
||||
|
@@ -1,27 +1,63 @@
|
||||
const rootSoundDirectory = "/resources/NibblePoker/sounds/"
|
||||
|
||||
const kittySoundData = {
|
||||
"kitty-kiki" : [
|
||||
"meow-test-01.ogg",
|
||||
],
|
||||
"kitty-maki" : [
|
||||
"meow-test-02.ogg",
|
||||
],
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
for (const [eId, sounds] of Object.entries(kittySoundData)) {
|
||||
const eHovered = document.getElementById(eId);
|
||||
|
||||
if(eHovered !== null) {
|
||||
eHovered.addEventListener('mouseover', function() {
|
||||
const randomIndex = Math.floor(Math.random() * sounds.length);
|
||||
const audio= new Audio(rootSoundDirectory + sounds[randomIndex]);
|
||||
audio.volume = 0.1;
|
||||
try {
|
||||
audio.play();
|
||||
} catch(DOMException) {}
|
||||
});
|
||||
{
|
||||
const rootSoundDirectory = "/resources/NibblePoker/sounds/"
|
||||
|
||||
class CatData {
|
||||
constructor(meows, purrs) {
|
||||
this.meowSounds = meows;
|
||||
this.purrSounds = purrs;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const kittyData = {
|
||||
"kitty-kiki": new CatData(
|
||||
["meow-test-01.ogg"],
|
||||
["kiki-ronron-01.ogg"]
|
||||
),
|
||||
"kitty-maki": new CatData(
|
||||
["meow-test-02.ogg"],
|
||||
[]
|
||||
),
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
for(const [eId, catData] of Object.entries(kittyData)) {
|
||||
const eHovered = document.getElementById(eId);
|
||||
|
||||
const audioPurr = (catData.purrSounds.length > 0) ? new Audio() : null;
|
||||
|
||||
if(eHovered !== null) {
|
||||
eHovered.addEventListener('mouseover', function() {
|
||||
// Playing the meow sound
|
||||
if(catData.meowSounds.length > 0) {
|
||||
const meowIndex = Math.floor(Math.random() * catData.meowSounds.length);
|
||||
const audioMeow = new Audio(rootSoundDirectory + catData.meowSounds[meowIndex]);
|
||||
audioMeow.volume = 0.1;
|
||||
try {
|
||||
audioMeow.play();
|
||||
} catch(DOMException) {
|
||||
}
|
||||
}
|
||||
|
||||
// Playing the purr sound
|
||||
if(audioPurr !== null) {
|
||||
const purrIndex = Math.floor(Math.random() * catData.purrSounds.length);
|
||||
audioPurr.src = rootSoundDirectory + catData.purrSounds[purrIndex];
|
||||
audioPurr.volume = 0.075;
|
||||
try {
|
||||
audioPurr.load();
|
||||
audioPurr.play();
|
||||
} catch(DOMException) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
eHovered.addEventListener('mouseout', function() {
|
||||
// Stopping the purring sound
|
||||
if(audioPurr !== null) {
|
||||
audioPurr.pause();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
BIN
resources/NibblePoker/sounds/kiki-ronron-01.ogg
Normal file
BIN
resources/NibblePoker/sounds/kiki-ronron-01.ogg
Normal file
Binary file not shown.
Reference in New Issue
Block a user