Skip to content

Commit

Permalink
update joist
Browse files Browse the repository at this point in the history
  • Loading branch information
deebloo committed Feb 29, 2024
1 parent e0b11f8 commit 75dcd43
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 37 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
}
},
"dependencies": {
"@joist/di": "^3.0.8-next.1",
"@joist/element": "^3.0.8-next.1",
"@joist/di": "^3.1.0",
"@joist/element": "^3.1.0",
"tslib": "^2.5.2"
},
"devDependencies": {
Expand Down
61 changes: 34 additions & 27 deletions src/sfx.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
const stone_sounds = [
[1000.0, 137.20833333333331],
[2137.208333333333, 58.854166666666664],
[3196.0625, 86.60416666666666],
[4282.666666666667, 85.0],
[5367.666666666667, 86.8125],
] as const;

const capture_stone_sounds = [
[2507.1041666666665, 1074.6458333333333],
[6200.895833333333, 1485.9166666666667],
[10539.125, 1034.9375],
[14253.833333333332, 895.8541666666666],
] as const;

const capture_pile_sounds = [
[1000.0, 507.1041666666667],
[4581.75, 619.1458333333333],
[8686.8125, 852.3125],
[12574.0625, 679.7708333333334],
[16149.687499999998, 1148.8125],
[18298.5, 1145.3333333333333],
] as const;

export class Sfx {
#stones = new Audio();
#effects = new Audio();
Expand All @@ -13,15 +37,8 @@ export class Sfx {
}

placeStone() {
let sounds = [
[1000.0, 137.20833333333331],
[2137.208333333333, 58.854166666666664],
[3196.0625, 86.60416666666666],
[4282.666666666667, 85.0],
[5367.666666666667, 86.8125],
];

const [start, duration] = sounds[Math.floor(Math.random() * sounds.length)];
const [start, duration] =
stone_sounds[Math.floor(Math.random() * stone_sounds.length)];

return new Promise<void>((resolve) => {
this.#stones.currentTime = start / 1000;
Expand All @@ -36,33 +53,23 @@ export class Sfx {
}

captureStones(count: number) {
const single = [
[2507.1041666666665, 1074.6458333333333],
[6200.895833333333, 1485.9166666666667],
[10539.125, 1034.9375],
[14253.833333333332, 895.8541666666666],
];

const pile = [
[1000.0, 507.1041666666667],
[4581.75, 619.1458333333333],
[8686.8125, 852.3125],
[12574.0625, 679.7708333333334],
[16149.687499999998, 1148.8125],
[18298.5, 1145.3333333333333],
];

return new Promise<void>((resolve) => {
let start: number;
let duration: number;

if (count === 1) {
const sprite = single[Math.floor(Math.random() * single.length)];
const sprite =
capture_stone_sounds[
Math.floor(Math.random() * capture_stone_sounds.length)
];

start = sprite[0];
duration = sprite[1];
} else {
const sprite = pile[Math.floor(Math.random() * pile.length)];
const sprite =
capture_pile_sounds[
Math.floor(Math.random() * capture_pile_sounds.length)
];

start = sprite[0];
duration = sprite[1];
Expand Down

0 comments on commit 75dcd43

Please sign in to comment.