User prompt
Please fix the bug: 'TypeError: LK.getHighScore is not a function. (In 'LK.getHighScore()', 'LK.getHighScore' is undefined)' in or related to this line: 'var highScore = Math.max(score, LK.getHighScore());' Line Number: 146
User prompt
Show high score when you die.
User prompt
You should die, Skor, when you die.
User prompt
Make a background of people looking.
User prompt
Make the plane bigger!
User prompt
And the bullets are a little slow.
User prompt
The blocks can go very much faster.
User prompt
The blocks may go a little fast.
User prompt
The blocks can move from left to right, and from right to left.
Initial prompt
Penri shooter
/**** * Classes ****/ // Block class var Block = Container.expand(function () { var self = Container.call(this); var blockGraphics = self.attachAsset('block', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.horizontalSpeed = Math.random() < 0.5 ? -2 : 2; // Random initial horizontal direction self.update = function () { self.y += self.speed; self.x += self.horizontalSpeed; if (self.x < 0 || self.x > 2048) { self.horizontalSpeed *= -1; // Reverse direction when hitting screen edges } if (self.y > 2732 + 50) { self.destroy(); blocks.splice(blocks.indexOf(self), 1); } }; }); // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -15; self.update = function () { self.y += self.speed; if (self.y < -50) { self.destroy(); bullets.splice(bullets.indexOf(self), 1); } }; }); //<Assets used in the game will automatically appear here> // Plane class var Plane = Container.expand(function () { var self = Container.call(this); var planeGraphics = self.attachAsset('plane', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); self.shoot = function () { var bullet = new Bullet(); bullet.x = self.x; bullet.y = self.y - planeGraphics.height / 2; game.addChild(bullet); bullets.push(bullet); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var plane = new Plane(); plane.x = 2048 / 2; plane.y = 2732 - 200; game.addChild(plane); var bullets = []; var blocks = []; var hearts = 3; var score = 0; var scoreTxt = new Text2('Score: 0', { size: 100, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var heartsTxt = new Text2('Hearts: 3', { size: 100, fill: "#ffffff" }); heartsTxt.anchor.set(0.5, 0); LK.gui.topRight.addChild(heartsTxt); game.down = function (x, y, obj) { plane.x = x; plane.y = y; }; game.move = function (x, y, obj) { plane.x = x; plane.y = y; }; game.update = function () { if (LK.ticks % 60 === 0) { plane.shoot(); } if (LK.ticks % 120 === 0) { var block = new Block(); block.x = Math.random() * 2048; block.y = -50; game.addChild(block); blocks.push(block); } bullets.forEach(function (bullet) { blocks.forEach(function (block) { if (bullet.intersects(block)) { bullet.destroy(); block.destroy(); bullets.splice(bullets.indexOf(bullet), 1); blocks.splice(blocks.indexOf(block), 1); score += 10; scoreTxt.setText('Score: ' + score); } }); }); blocks.forEach(function (block) { if (plane.intersects(block)) { block.destroy(); blocks.splice(blocks.indexOf(block), 1); hearts -= 1; heartsTxt.setText('Hearts: ' + hearts); if (hearts <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } }); };
===================================================================
--- original.js
+++ change.js
@@ -43,9 +43,11 @@
var Plane = Container.expand(function () {
var self = Container.call(this);
var planeGraphics = self.attachAsset('plane', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5
});
self.shoot = function () {
var bullet = new Bullet();
bullet.x = self.x;