User prompt
when you get to -500 you lose the game
User prompt
Add a weapon that is a bomb. When you hit 5 enemies in a row a bomb goes off and clears the board
User prompt
When an enemy crosses the bottom threshold that is minus 5 points. Once I reach 150 points I win the game.
User prompt
Speed robotDogs up and send them in zigzags, also make them worth two points
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'if (bullets[k].intersects(robotDogs[n])) {' Line Number: 141
User prompt
Add Robot dogs
Initial prompt
CybWar
/**** * 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; }; }); // 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; }; }); //<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 }; }); // RobotDog class var RobotDog = Container.expand(function () { var self = Container.call(this); var robotDogGraphics = self.attachAsset('robotDog', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.direction = 1; self.update = function () { self.y += self.speed; self.x += self.direction * 5; if (self.x > 2048 - 75 || self.x < 75) { self.direction *= -1; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize hero var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 200; // Initialize arrays for bullets and enemies var bullets = []; var enemies = []; var robotDogs = []; // Score display var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Handle move events function handleMove(x, y, obj) { hero.x = x; hero.y = y; } game.move = handleMove; // Handle shooting game.down = function (x, y, obj) { var newBullet = new Bullet(); newBullet.x = hero.x; newBullet.y = hero.y; bullets.push(newBullet); game.addChild(newBullet); }; // Update game state game.update = function () { // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].update(); if (bullets[i].y < -50) { bullets[i].destroy(); bullets.splice(i, 1); } } // Update enemies for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); if (enemies[j].y > 2732 + 50) { enemies[j].destroy(); enemies.splice(j, 1); } } // Update robotDogs for (var m = robotDogs.length - 1; m >= 0; m--) { robotDogs[m].update(); if (robotDogs[m].y > 2732 + 50) { robotDogs[m].destroy(); robotDogs.splice(m, 1); } } // Check for collisions for (var k = bullets.length - 1; k >= 0; k--) { for (var l = enemies.length - 1; l >= 0; l--) { if (bullets[k].intersects(enemies[l])) { bullets[k].destroy(); enemies[l].destroy(); bullets.splice(k, 1); enemies.splice(l, 1); LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); break; } } for (var n = robotDogs.length - 1; n >= 0; n--) { if (bullets[k] && bullets[k].intersects(robotDogs[n])) { bullets[k].destroy(); robotDogs[n].destroy(); bullets.splice(k, 1); robotDogs.splice(n, 1); LK.setScore(LK.getScore() + 2); scoreTxt.setText(LK.getScore()); break; } } } // Spawn enemies if (LK.ticks % 60 == 0) { var newEnemy = new Enemy(); newEnemy.x = Math.random() * 2048; newEnemy.y = -50; enemies.push(newEnemy); game.addChild(newEnemy); } // Spawn robotDogs if (LK.ticks % 120 == 0) { var newRobotDog = new RobotDog(); newRobotDog.x = Math.random() * 2048; newRobotDog.y = -50; robotDogs.push(newRobotDog); game.addChild(newRobotDog); } };
===================================================================
--- original.js
+++ change.js
@@ -44,11 +44,16 @@
var robotDogGraphics = self.attachAsset('robotDog', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 7;
+ self.speed = 10;
+ self.direction = 1;
self.update = function () {
self.y += self.speed;
+ self.x += self.direction * 5;
+ if (self.x > 2048 - 75 || self.x < 75) {
+ self.direction *= -1;
+ }
};
});
/****
Large Bullet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Humanoid robots. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Badass marine with a green muscle T-shirt and a red bandana and a big cigar hanging from his mouth. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Rabid Robot Dog. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.