Skip to content

Commit 4b61605

Browse files
committed
added music
minor bug fixes added click sfx gonna add more later yeah
1 parent 0b79882 commit 4b61605

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

Brokemon.wav

15.3 MB
Binary file not shown.

click.mp3

11.9 KB
Binary file not shown.

index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<head>
3+
<script src="https://kit.fontawesome.com/19a43ba50e.js" crossorigin="anonymous"></script>
34
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
45
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.13.2/themes/smoothness/jquery-ui.css">
56
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js"></script>
@@ -9,6 +10,7 @@
910
<title>Brokemon Beta 01.4.0</title>
1011
</head>
1112
<body>
13+
<button id="mute-btn" onclick="toggleMusic()" style="color: white;"><i class="fa-solid fa-volume-high fa-3x"></i></button>
1214
<h1>Brokemon</h1>
1315
<h2>Your HP: <span id="player-hp">100</span> <span id="playerBoost" class="boost">x1</span></h2>
1416
<h3>Defense: <span class="defense" id="player-defense">0</span></h3>
@@ -17,7 +19,7 @@ <h3>Defense: <span class="defense" id="enemy-defense">0</span></h3>
1719
<div id="info">
1820
<span id="top-bar">| Select your moves.</span>
1921
<br>
20-
<span id="bottom-bar">|</span>
22+
<span id="bottom-bar">| WARNING: Music will start playing once you select all 4</span>
2123
</div>
2224
<div id="actions">
2325
<button class="move" id="button-1" disabled="true"></button>

index.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ let moveNames = [];
1111
let selectableMoves = [];
1212
let movePool = [];
1313
let movesChosen = 1;
14+
let click = new Audio("click.mp3")
15+
let music = new Audio("Brokemon.wav")
16+
let musicPlaying = false;
1417
let isFirefox = navigator.userAgent.match(/firefox|fxios/i)
1518
let isSafari = navigator.userAgent.match(/safari/i);
1619

@@ -43,12 +46,21 @@ $('#button-2').prop("disabled", true);
4346
$('#button-3').prop("disabled", true);
4447
$('#button-4').prop("disabled", true);
4548

49+
function toggleMusic() {
50+
if (musicPlaying) {
51+
if (music.paused) {
52+
music.play()
53+
} else {
54+
music.pause()
55+
}
56+
}
57+
}
58+
4659
function setDifficulty() {
4760
let diffBoost = $("#enemy-boost-input").val();
4861
let diffHp = $("#enemy-hp-input").val();
4962
diffBoost = Math.max(0, Math.min(100000, Math.round(diffBoost)))
5063
diffHp = Math.max(1, Math.min(10000000, Math.round(diffHp)))
51-
console.log(diffBoost + diffHp)
5264
window.location.replace(`index.html?hp=${diffHp}&boost=${diffBoost}`)
5365
}
5466

@@ -179,24 +191,30 @@ class Move {
179191
}
180192

181193
addToMoves() {
194+
click.play();
182195
$(`#button-${movesChosen}`).html(this.name);
183196
$(`#button-${movesChosen}`).attr("onclick", `${this.useFunction}`)
184197
movesChosen += 1;
185198
$(`#add-${this.codeName}`).remove();
186199
if (movesChosen === 5) {
187200
$("#moveSelector").remove();
201+
music.play()
202+
music.loop = true;
203+
musicPlaying = true;
188204
loop1();
189205
}
190206
}
191207

192208
useMove(user) {
193209
switch (user) {
194210
case "player":
211+
click.play();
195212
let pDamageDealt = this.dmg * playerExtraDmg;
196213
let randomDamageBoost = Math.random() / 5
197214
randomDamageBoost += 0.9
198215
pDamageDealt *= randomDamageBoost
199216
if (this.dmg > 0) {
217+
console.log("indeedee")
200218
pDamageDealt -= enemyDef
201219
pDamageDealt = Math.max(pDamageDealt, (pDamageDealt + enemyDef) / 2)
202220
}
@@ -265,8 +283,10 @@ class Move {
265283
let eRandomDamageBoost = Math.random() / 5
266284
eRandomDamageBoost += 0.9
267285
eDamageDealt *= eRandomDamageBoost
286+
if (this.dmg > 0) {
268287
eDamageDealt -= playerDef;
269-
eDamageDealt = Math.max(eDamageDealt, (eDamageDealt + playerDef) / 2)
288+
eDamageDealt = Math.max(eDamageDealt, (eDamageDealt + playerDef) / 2);
289+
};
270290
playerHp -= eDamageDealt;
271291
enemyHp += this.heal * enemyExtraDmg;
272292
enemyHp = Math.min(enemyHp, enemyMaxHp);

styles.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,22 @@ button:disabled {
7878
margin: 0.5vw;
7979
}
8080

81+
#mute-btn {
82+
width: 60px;
83+
height: 60px;
84+
float: right;
85+
border: 0;
86+
background-color:rgb(10, 10, 25);
87+
}
88+
89+
.fa-solid {
90+
text-align: center;
91+
opacity: 1;
92+
}
93+
8194
textarea {
8295
border-radius: 10px;
96+
resize: none;
8397
}
8498

8599
#difficulty-builder {

0 commit comments

Comments
 (0)