Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jgss-gabriel-sousa committed Apr 11, 2024
1 parent 4108567 commit 5e71345
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions scripts/population.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ function popDeaths(){

homelessDeathChance = Math.round(homelessDeathChance);

let popDeath = rand(0,100) < homelessDeathChance;
const popDeathChance = rand(0, 100) < homelessDeathChance;
let popDeath = 0;

if(popDeath){
if(popDeathChance){
popDeath = Math.ceil((rand(0,homelessDeathChance)/100)*homelessPops);
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/sound.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { rand } from "./funcs.js"

var audio = new Audio();
export let audio = new Audio();
const NUMBER_OF_SONGS = 7;

export function soundStart(){
Expand All @@ -23,7 +23,7 @@ export function soundtrack(){
;
});

audio.addEventListener('ended', soundtrack);
audio.addEventListener('ended', setTimeout(soundtrack, rand(500,4000)));

}, 1000);
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/ui/options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { game } from "../../data/gameData.js";
import { audio } from "../sound.js";

export function gameOptionsUI(){
const volumeValue = localStorage.getItem("mv-volume");
Expand All @@ -22,6 +23,7 @@ export function gameOptionsUI(){
const volumeEl = document.querySelector("#volume input");
volumeEl.addEventListener("change", () => {
localStorage.setItem("mv-volume", volumeEl.value);
audio.volume = volumeEl.value;
});
}

Expand Down

0 comments on commit 5e71345

Please sign in to comment.