| background: new ImageSource("background", null, ".jpg"), | background: new ImageSource("background", null, ".jpg"), | ||||
| wall: new ImageSource("wall"), | wall: new ImageSource("wall"), | ||||
| wall_overlap: new ImageSource("wall-overlap"), | wall_overlap: new ImageSource("wall-overlap"), | ||||
| powerup: new ImageSource("powerup"), | |||||
| }, | }, | ||||
| audio: { | audio: { | ||||
| var ext = ext || ".mp3"; | var ext = ext || ".mp3"; | ||||
| this.elems = []; | this.elems = []; | ||||
| for (var i = 0; i < 10; ++i) | |||||
| for (var i = 0; i < 10; ++i) { | |||||
| this.elems[i] = new Audio(commonPath+"/"+src+ext); | this.elems[i] = new Audio(commonPath+"/"+src+ext); | ||||
| this.elems[i].addEventListener("ended", function() { | |||||
| this.emit("ended"); | |||||
| }.bind(this)); | |||||
| } | |||||
| this.ready = false; | this.ready = false; | ||||
| this.index = 0; | this.index = 0; | ||||
| this.emit("load"); | this.emit("load"); | ||||
| }.bind(this)); | }.bind(this)); | ||||
| this.elems[0].addEventListener("ended", function() { | |||||
| this.emit("ended"); | |||||
| }.bind(this)); | |||||
| this.elems[0].onerror = function() { | this.elems[0].onerror = function() { | ||||
| console.error("Error with", src); | console.error("Error with", src); | ||||
| } | } |
| function PowerUp(game, x, y, type) { | function PowerUp(game, x, y, type) { | ||||
| makeEnt(this, game, 100); | makeEnt(this, game, 100); | ||||
| this.layer = 1; | this.layer = 1; | ||||
| this.img = assets.imgs.powerup; | |||||
| this.type = type; | this.type = type; | ||||
| this.pos.set({ x: x, y: y }); | this.pos.set({ x: x, y: y }); | ||||
| } | } | ||||
| PowerUp.prototype.draw = function(ctx) { | |||||
| ctx.fillStyle = "#33ee33"; | |||||
| ctx.strokeStyle = "#227722"; | |||||
| ctx.beginPath(); | |||||
| ctx.arc(15, 15, 15, 0, 2 * Math.PI); | |||||
| ctx.stroke(); | |||||
| ctx.fill(); | |||||
| PowerUp.prototype.draw = function() {} | |||||
| PowerUp.prototype.drawOverlay = function(ctx) { | |||||
| ctx.scale(0.3, 0.3); | |||||
| ctx.translate(-20, -5); | |||||
| this.img.draw(ctx); | |||||
| } | } | ||||
| PowerUp.prototype.update = function() { | PowerUp.prototype.update = function() { | ||||
| if (this.game.camera.x > this.pos.x + this.shape.width()) | if (this.game.camera.x > this.pos.x + this.shape.width()) |