var Knife = Container.expand(function () { var self = Container.call(this); self.angleTo = function (other) { var dx = other.x - self.x; var dy = other.y - self.y; return Math.atan2(dy, dx); }; var knifeGraphics = self.createAsset('knife', 'Knife Graphics', .5, 0); self.speed = 50; self.stuck = false; self.falling = false; self.spinDirection = Math.random() < 0.5 ? -1 : 1; self.move = function () { if (!self.stuck && !self.falling) { self.y -= self.speed; } }; self.fall = function () { if (self.falling) { if (!self.fallInitiated) { knifeGraphics.anchor.x = .5; knifeGraphics.anchor.y = .5; self.x += knifeGraphics.width / 2; self.y += knifeGraphics.height / 2; self.fallInitiated = true; } self.y += self.speed; self.rotation += self.spinDirection * 0.1; } }; self.hit = function (knives) { for (var i = 0; i < knives.length; i++) { if (knives[i] !== self && knives[i].stuck) { var angleDiff = Math.abs((knives[i].hitAngle - self.hitAngle) % (2 * Math.PI)); if (angleDiff < Math.PI / 18) { return true; } } } return false; }; }); var Target = Container.expand(function () { var self = Container.call(this); var targetGraphics = self.createAsset('target', 'Target Graphics', .5, .5); self.rotationSpeed = 0.01; self.rotate = function () { self.rotation += self.rotationSpeed; }; self.hit = function () {}; }); var Game = Container.expand(function () { var self = Container.call(this); var background = self.createAsset('background', 'Background Graphics', 0, 0); background.width = 2048; background.height = 2732; var knives = []; var targets = []; var score = 0; var lives = 3; var scoreTxt = new Text2('Score: ' + score.toString() + ', Lives: ' + lives.toString(), { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); var knife = self.addChild(new Knife()); knife.x = 2048 / 2; knife.y = 2732 - 200; var target = self.addChild(new Target()); target.x = 2048 / 2; target.y = 2732 / 2; stage.on('down', function (obj) { var newKnife = new Knife(); newKnife.x = knife.x; newKnife.y = knife.y; newKnife.speed = 10; knives.push(newKnife); self.addChild(newKnife); }); LK.on('tick', function () { target.rotate(); for (var i = 0; i < knives.length; i++) { knives[i].move(); knives[i].fall(); } for (var i = 0; i < knives.length; i++) { if (Math.abs(knives[i].y - target.y) <= target.height / 2 && !knives[i].stuck) { knives[i].stuck = true; knives[i].hitAngle = target.rotation - Math.PI / 2; if (knives[i].hit(knives)) { knives[i].falling = true; lives -= 1; scoreTxt.setText('Score: ' + score.toString() + ', Lives: ' + lives.toString()); } else { target.hit(); score += 1; scoreTxt.setText('Score: ' + score.toString() + ', Lives: ' + lives.toString()); } } if (knives[i].stuck && !knives[i].falling) { knives[i].rotation = target.rotation - knives[i].hitAngle - Math.PI / 2; knives[i].x = target.x + Math.cos(target.rotation - knives[i].hitAngle) * target.width / 2; knives[i].y = target.y + Math.sin(target.rotation - knives[i].hitAngle) * target.height / 2; } } for (var i = knives.length - 1; i >= 0; i--) { if (knives[i].y < -50) { knives[i].destroy(); knives.splice(i, 1); } if (lives <= 0) { LK.showGameOver(); } } }); });
===================================================================
--- original.js
+++ change.js
@@ -5,9 +5,9 @@
var dy = other.y - self.y;
return Math.atan2(dy, dx);
};
var knifeGraphics = self.createAsset('knife', 'Knife Graphics', .5, 0);
- self.speed = 30;
+ self.speed = 50;
self.stuck = false;
self.falling = false;
self.spinDirection = Math.random() < 0.5 ? -1 : 1;
self.move = function () {
Cartoon flat dart board. Single Game Texture. In-Game asset. 2d. White background. High contrast. No shadows.
Cartoon knife pointing up. Symmetrical. Vertical. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single cartoon extra life heart. No drop shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.