Skip to content
Merged

Dev #14

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions GameSounds/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<head>
<title>Play Sounds</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
<div class="inventory ring">Ring</div>
<div class="inventory page">Page</div>
<div class="inventory sell">Sell</div>

<script src="soundPlayer.js"></script>

</body>

</html>
37 changes: 37 additions & 0 deletions GameSounds/soundPlayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const inventoryItems = document.querySelectorAll(".inventory");
console.log(inventoryItems);
for(let i=0; i<inventoryItems.length; i++) {
inventoryItems[i].addEventListener("click", function(){
let inventory = this.innerHTML;
let lowerInventory = inventory.toLowerCase();
makeSound(lowerInventory);
addStyle(lowerInventory);
})
}

function addStyle(name) {
let activeElement =
document.querySelector("."+name);
activeElement.classList.add("active");
setTimeout(function(){
activeElement.classList.remove("active");
},300)
}

function makeSound(name){
console.log(name);
switch(name){
case "ring":
let sound1 = new Audio("sounds/"+name+".wav");
sound1.play();
break;
case "page":
let sound2 = new Audio("sounds/"+name+".wav");
sound2.play();
break;
case "sell":
let sound3 = new Audio("sounds/"+name+".wav");
sound3.play();
break;
}
}
Binary file added GameSounds/sounds/page.wav
Binary file not shown.
Binary file added GameSounds/sounds/ring.wav
Binary file not shown.
Binary file added GameSounds/sounds/sell.wav
Binary file not shown.
15 changes: 15 additions & 0 deletions GameSounds/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
body { padding:0; margin:10px; vertical-align:top; background:#ffffff; font-family:Tahoma;}

.inventory {
width: 100px;
height: 100px;
color: black;
text-align: center;
border: 2px solid black;
display: inline-block;
margin: 10px;
}

.active {
border: 2px solid red;
}
14 changes: 14 additions & 0 deletions GameSounds/todo_soundPlayer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<title>Sound Player To Do</title>
</head>

<body>
To Do List:

<ul>
<li>Add images into the DIVs</li>
<li>OR add images below and make them clickable too</li>
</ul>
</body>
</html>
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ If there's anything that you think could be improved due to misunderstanding, th
# The 1000 Things
Structure of the repo Things are as *folder > main js file*, along with the supporting HTML and CSS files.

(6) Name Changer > namechange.js <br>
(5) Message Changer > messageChanger.js <br>
(4) Time of Day > timeOfDay.js <br>
(3) VAT Calculator > vat-script.js <br>
(2) Date and Time > myYearAndDate.js <br>
(7) Game Sounds > soundPlayer.js<br>
(6) Name Changer > namechange.js<br>
(5) Message Changer > messageChanger.js<br>
(4) Time of Day > timeOfDay.js<br>
(3) VAT Calculator > vat-script.js<br>
(2) Date and Time > myYearAndDate.js<br>
(1) Date and Time > myDayFunction.js

**994 to go...**
**Only 993 to go... o_O**

# Courses and Sources
**[https://www.sololearn.com/Course/JavaScript/](https://www.sololearn.com/Course/JavaScript/)**
Expand Down