Skip to content

Commit

Permalink
fix: Make proper variables and remove unused code from Sprite class
Browse files Browse the repository at this point in the history
  • Loading branch information
johnedvard committed Sep 12, 2022
1 parent 011c411 commit 837d577
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 26 deletions.
18 changes: 0 additions & 18 deletions src/kontra.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,24 +587,6 @@ class Sprite extends GameObject {
} = {}) {
super.init({ image: t, width: e, height: i, ...s });
}
get animations() {
return this._a;
}
set animations(t) {
let e, i;
for (e in ((this._a = {}), t))
(this._a[e] = t[e].clone()), (i = i || this._a[e]);
(this.currentAnimation = i),
(this.width = this.width || i.width),
(this.height = this.height || i.height);
}
playAnimation(t) {
(this.currentAnimation = this.animations[t]),
this.currentAnimation.loop || this.currentAnimation.reset();
}
advance(t) {
super.advance(t), this.currentAnimation && this.currentAnimation.update(t);
}
draw() {
this.image &&
this.context.drawImage(
Expand Down
2 changes: 1 addition & 1 deletion src/sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { zzfxM } from './zzfxm';

let myAudioNode = null;
let isPlaying = false;
let audioContext = zzfxX;
let audioContext = window.zzfxX;

export const getIsPlaying = () => {
return isPlaying;
Expand Down
11 changes: 6 additions & 5 deletions src/zzfx.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// zzfxV - global volume
zzfxV = 0.3;
const zzfxV = 0.3;

// zzfxR - global sample rate
zzfxR = 44100;
const zzfxR = 44100;
window.zzfxR = zzfxR;

// zzfxX - the common audio context
zzfxX = new (window.AudioContext || webkitAudioContext)();
sfxContext = new (window.AudioContext || webkitAudioContext)();
window.zzfxX = new (window.AudioContext || webkitAudioContext)();
const sfxContext = new (window.AudioContext || webkitAudioContext)();
// zzfx() - the universal entry point -- returns a AudioBufferSourceNode
export const zzfx = (...t) => zzfxP(sfxContext, zzfxG(...t));

Expand All @@ -22,7 +23,7 @@ export const zzfxP = (ctx, ...t) => {
};

// zzfxG() - the sound generator -- returns an array of sample data
zzfxG = (
window.zzfxG = (
q = 1,
k = 0.05,
c = 220,
Expand Down
4 changes: 2 additions & 2 deletions src/zzfxm.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const zzfxM = (n, f, t, e = 125) => {
q = 0,
s = 1,
v = {},
w = ((zzfxR / e) * 60) >> 2;
w = ((window.zzfxR / e) * 60) >> 2;
for (; s; k++)
(R = [(s = a = d = m = 0)]),
t.map((e, d) => {
Expand Down Expand Up @@ -55,7 +55,7 @@ export const zzfxM = (n, f, t, e = 125) => {
v[[c, g]] ||
((l = [...n[c]]),
(l[2] *= 2 ** ((g - 12) / 12)),
g > 0 ? zzfxG(...l) : [])));
g > 0 ? window.zzfxG(...l) : [])));
}
m = G;
});
Expand Down

0 comments on commit 837d577

Please sign in to comment.