changed ball and bar for a sprite

This commit is contained in:
2021-11-16 22:01:43 +01:00
parent e0ebef2a27
commit bc3ef31728
17 changed files with 77 additions and 24 deletions

26
assets/js/Resources.js Normal file
View File

@ -0,0 +1,26 @@
class Resources {
constructor() {
this.total = 0;
this.loading = 0;
this.resources = {};
this.load('ball');
this.load('bar');
}
load(res) {
let _this = this;
this.total++;
this.loading++;
this.resources[res] = new Image();
this.resources[res].onload = function () {
_this.loading--;
}
this.resources[res].src = 'assets/imgs/' + res + '.png';
}
get(res) {
return this.resources[res];
}
};