-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
destructured code and cleaned functions, which now import from sepera…
…te module
- Loading branch information
Will Irving
authored and
Will Irving
committed
May 24, 2021
1 parent
58dba53
commit 8dab8fa
Showing
7 changed files
with
151 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [["@babel/preset-env", { targets: { node: "current" } }]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
export const shuffleArr = (array) => { | ||
const newArray = [...array]; | ||
var currentIndex = newArray.length, | ||
temporaryValue, | ||
randomIndex; | ||
|
||
// While there remain elements to shuffleArr... | ||
while (0 !== currentIndex) { | ||
// Pick a remaining element... | ||
randomIndex = Math.floor(Math.random() * currentIndex); | ||
currentIndex -= 1; | ||
|
||
// And swap it with the current element. | ||
temporaryValue = newArray[currentIndex]; | ||
newArray[currentIndex] = newArray[randomIndex]; | ||
newArray[randomIndex] = temporaryValue; | ||
} | ||
|
||
return newArray; | ||
}; | ||
|
||
export const getRandom = (upperLimit) => { | ||
const arrayNum = [...Array(upperLimit)].map((_, i) => i); | ||
|
||
const ranNums = shuffleArr(arrayNum); | ||
|
||
return ranNums; | ||
}; | ||
|
||
export const loadSounds = (length) => { | ||
const soundArray = new Array(length); | ||
|
||
for (let i = 0; i < soundArray.length; i++) { | ||
const relPath = "./sounds/"; | ||
const fileType = ".mp3"; | ||
const srcLink = `${relPath}${i}${fileType}`; | ||
soundArray[i] = new Howl({ | ||
src: [`${srcLink}`], | ||
}); | ||
} | ||
|
||
return soundArray; | ||
}; | ||
|
||
export const makeImg = (name) => { | ||
const img = new Image(); | ||
const path = "./images/"; | ||
const fileType = ".png"; | ||
const imgStr = `${path}${name}${fileType}`; | ||
img.src = imgStr; | ||
return img; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.