User prompt
Only the road gets moved not the buildings
User prompt
Make it lower
User prompt
Make a road rectangle
User prompt
Add more buildings
User prompt
Make an animation of building being reconstructed by making a fade in effect
User prompt
Make a sound when it explodes
User prompt
Make a little road with cars driving on it
User prompt
Please fix the bug: 'Timeout.tick error: LK.effects.shakeScreen is not a function' in or related to this line: 'LK.effects.shakeScreen(500);' Line Number: 26
User prompt
Make it shake the screen when it explodes
User prompt
It didnt flasht eh screen
User prompt
Add a animation of buildings being reconstructed
User prompt
Make the bomb wait for 1 second, And then explodes
User prompt
The bomb isnt shown, Which makes it unused
User prompt
When all buildings are destroyed, add new ones, Also add a explosion effect
Initial prompt
Demolishin'
/**** * Classes ****/ // Bomb class var Bomb = Container.expand(function () { var self = Container.call(this); var bombGraphics = self.attachAsset('bomb', { anchorX: 0.5, anchorY: 0.5 }); self.explode = function () { // Create explosion effect var explosion = new Explosion(); explosion.x = self.x; explosion.y = self.y; game.addChild(explosion); explosion.init(); // Flash the screen LK.effects.flashScreen(0xff0000, 500); // Damage nearby buildings for (var i = 0; i < buildings.length; i++) { if (self.intersects(buildings[i])) { buildings[i].takeDamage(50); } } LK.getSound('explosion').play(); self.destroy(); }; }); //<Assets used in the game will automatically appear here> // Building class var Building = Container.expand(function () { var self = Container.call(this); var buildingGraphics = self.attachAsset('building', { anchorX: 0.5, anchorY: 0.5 }); // Create reconstruction animation var reconstruction = new BuildingReconstruction(); reconstruction.x = self.x; reconstruction.y = self.y; game.addChild(reconstruction); reconstruction.init(); self.health = 100; self.update = function () { if (self.health <= 0) { self.destroy(); } }; self.takeDamage = function (damage) { self.health -= damage; }; }); // BuildingReconstruction class var BuildingReconstruction = Container.expand(function () { var self = Container.call(this); self.init = function () { // Create reconstruction effect with fade in self.alpha = 0; LK.effects.flashObject(self, 0x00ff00, 500); var fadeInInterval = LK.setInterval(function () { if (self.alpha < 1) { self.alpha += 0.02; } else { LK.clearInterval(fadeInInterval); } }, 20); }; }); // Explosion class var Explosion = Container.expand(function () { var self = Container.call(this); self.init = function () { // Create explosion effect LK.effects.flashObject(self, 0xff0000, 500); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize road var road = game.addChild(LK.getAsset('road', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 })); // Initialize buildings array var buildings = []; // Create buildings for (var i = 0; i < 10; i++) { var building = new Building(); building.x = 200 * (i + 1); building.y = 1366; buildings.push(building); game.addChild(building); } // Initialize bombs array var bombs = []; // Handle touch down event to place bombs game.down = function (x, y, obj) { var bomb = new Bomb(); bomb.x = x; bomb.y = y; bombs.push(bomb); game.addChild(bomb); LK.setTimeout(function () { bomb.explode(); }, 1000); }; // Update game state game.update = function () { for (var i = buildings.length - 1; i >= 0; i--) { buildings[i].update(); if (buildings[i].health <= 0) { buildings.splice(i, 1); } } for (var j = bombs.length - 1; j >= 0; j--) { if (bombs[j].destroyed) { bombs.splice(j, 1); } } // Add new buildings when all are destroyed if (buildings.length === 0) { LK.setTimeout(function () { for (var i = 0; i < 10; i++) { var building = new Building(); building.x = 200 * (i + 1); building.y = 1366; buildings.push(building); game.addChild(building); } }, 1000); } };
===================================================================
--- original.js
+++ change.js
@@ -85,8 +85,15 @@
/****
* Game Code
****/
+// Initialize road
+var road = game.addChild(LK.getAsset('road', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1366
+}));
// Initialize buildings array
var buildings = [];
// Create buildings
for (var i = 0; i < 10; i++) {