User prompt
Add many stone on other place
User prompt
Hero's plane are not moving
User prompt
Please fix the bug: 'ReferenceError: dragNode is not defined' in or related to this line: 'if (dragNode) {' Line Number: 157
User prompt
And produce the big stone on the background for the protection
User prompt
Black colour and stars on background
User prompt
And plz change background
User prompt
Also add movement on enemy plane and he attacked on hero plane with bullet
User prompt
I want to move my plain
Initial prompt
A war
/**** * Classes ****/ // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); // EnemyBullet class var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.shoot = function () { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y - 50; game.addChild(bullet); heroBullets.push(bullet); }; }); // HeroBullet class var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('heroBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -15; self.update = function () { self.y += self.speed; if (self.y < 0) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Black background }); /**** * Game Code ****/ // Add stars to the background for (var i = 0; i < 200; i++) { var star = LK.getAsset('star', { anchorX: 0.5, anchorY: 0.5, scaleX: Math.random() * 0.5, scaleY: Math.random() * 0.5, x: Math.random() * 2048, y: Math.random() * 2732 }); game.addChild(star); } // Add big stone to the game for protection var bigStone = LK.getAsset('bigStone', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(bigStone); // Initialize assets used in this game. // Assets will be automatically created and loaded by the LK engine based on their usage in the code. var hero = new Hero(); hero.x = 2048 / 2; hero.y = 2732 - 150; game.addChild(hero); var enemies = []; var heroBullets = []; var enemyBullets = []; game.down = function (x, y, obj) { hero.shoot(); }; game.update = function () { // Update hero bullets for (var i = heroBullets.length - 1; i >= 0; i--) { heroBullets[i].update(); for (var j = enemies.length - 1; j >= 0; j--) { if (heroBullets[i].intersects(enemies[j])) { enemies[j].destroy(); heroBullets[i].destroy(); enemies.splice(j, 1); heroBullets.splice(i, 1); break; } } } // Update enemies for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].update(); if (enemies[i].intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } // Enemy shoots bullet if (LK.ticks % 120 == 0) { var bullet = new EnemyBullet(); bullet.x = enemies[i].x; bullet.y = enemies[i].y + 50; game.addChild(bullet); enemyBullets.push(bullet); } } // Update enemy bullets for (var i = enemyBullets.length - 1; i >= 0; i--) { enemyBullets[i].update(); if (enemyBullets[i].intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Spawn enemies if (LK.ticks % 60 == 0) { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = -50; game.addChild(enemy); enemies.push(enemy); } // Move hero if (dragNode) { hero.x = dragNode.x; hero.y = dragNode.y; } };
===================================================================
--- original.js
+++ change.js
@@ -84,8 +84,16 @@
y: Math.random() * 2732
});
game.addChild(star);
}
+// Add big stone to the game for protection
+var bigStone = LK.getAsset('bigStone', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2
+});
+game.addChild(bigStone);
// Initialize assets used in this game.
// Assets will be automatically created and loaded by the LK engine based on their usage in the code.
var hero = new Hero();
hero.x = 2048 / 2;
Fighter plane. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Sharpe bullet of plane. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Little stars. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Mountain rock. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Dangerous fight plane. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.