Code edit (9 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.showYouFinished is not a function' in or related to this line: 'LK.showYouFinished();' Line Number: 96
Code edit (1 edits merged)
Please save this source code
Initial prompt
Bed Shooters
/**** * Classes ****/ // 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 < 0) { self.destroy(); } }; }); // 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(); } }; }); //<Assets used in the game will automatically appear here> // 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.update = function () { // Hero update logic }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 102 //Init game with black background }); /**** * Game Code ****/ // Initialize variables var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2500; var enemies = []; var bullets = []; // Function to spawn enemies function spawnEnemy() { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = 0; enemies.push(enemy); game.addChild(enemy); } // Function to shoot bullets function shootBullet() { var bullet = new Bullet(); bullet.x = hero.x; bullet.y = hero.y; bullets.push(bullet); game.addChild(bullet); } // Game update loop game.update = function () { // Update hero hero.update(); // 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(); } } // Update bullets for (var j = bullets.length - 1; j >= 0; j--) { bullets[j].update(); for (var k = enemies.length - 1; k >= 0; k--) { if (bullets[j].intersects(enemies[k])) { bullets[j].destroy(); enemies[k].destroy(); bullets.splice(j, 1); enemies.splice(k, 1); break; } } } // Spawn enemies periodically if (LK.ticks % 60 == 0) { spawnEnemy(); } }; // Handle touch events for hero movement game.down = function (x, y, obj) { hero.x = x; hero.y = y; }; game.move = function (x, y, obj) { hero.x = x; hero.y = y; }; game.up = function (x, y, obj) { shootBullet(); };
===================================================================
--- original.js
+++ change.js
@@ -48,9 +48,9 @@
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 102 //Init game with black background
});
/****
* Game Code
@@ -65,9 +65,9 @@
function spawnEnemy() {
var enemy = new Enemy();
enemy.x = Math.random() * 2048;
enemy.y = 0;
- enemies.push(theft);
+ enemies.push(enemy);
game.addChild(enemy);
}
// Function to shoot bullets
function shootBullet() {
the bullet is of 1 inch and is of m4 rifle.. Single Game Texture. In-Game asset. 3d. Blank background. High contrast. No shadows.
Hero is ironman and sitting on bed facing backward. Single Game Texture. In-Game asset. 3d. Blank background. High contrast. No shadows.
zombie green single. Single Game Texture. In-Game asset. 3d. Blank background. High contrast. No shadows.