User prompt
make space pirates fire missiles at truck
User prompt
make background black, add red, blue, and yellow stars
User prompt
make background white
User prompt
need more space pirates
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'if (bullets[i].intersects(spaceDOTs[j])) {' Line Number: 146
User prompt
truck should bullets at the space pirates for a one shot kill, spaceDOTs need 3 shots to kill. include health bat above spaceDOT
User prompt
space pirates should come in waves, starting with 3 and increasing by 2 every wave
User prompt
delete cargo
User prompt
cargo should be attached to truck
User prompt
cargo should stay right behind the truck
User prompt
truck and cargo should follow curser
User prompt
cargo should stick to the truck and not detatch
User prompt
cargo should be attached to the back of the truck
Initial prompt
Space Trucker
/**** * Classes ****/ // Cargo class var Cargo = Container.expand(function () { var self = Container.call(this); var cargoGraphics = self.attachAsset('cargo', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Cargo logic }; }); // Space DOT class var SpaceDOT = Container.expand(function () { var self = Container.call(this); var dotGraphics = self.attachAsset('spaceDOT', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = -self.height; } }; }); // Space Pirate class var SpacePirate = Container.expand(function () { var self = Container.call(this); var pirateGraphics = self.attachAsset('spacePirate', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = -self.height; } }; }); //<Assets used in the game will automatically appear here> // Truck class var Truck = Container.expand(function () { var self = Container.call(this); var truckGraphics = self.attachAsset('truck', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { // Truck movement logic }; self.move = function (x, y, obj) { self.x = x; self.y = y; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize truck var truck = game.addChild(new Truck()); truck.x = 2048 / 2; truck.y = 2732 - 200; // Initialize cargo var cargo = game.addChild(new Cargo()); cargo.x = truck.x; cargo.y = truck.y - 100; // Initialize space pirates var spacePirates = []; for (var i = 0; i < 5; i++) { var pirate = new SpacePirate(); pirate.x = Math.random() * 2048; pirate.y = Math.random() * -2732; spacePirates.push(pirate); game.addChild(pirate); } // Initialize space DOTs var spaceDOTs = []; for (var i = 0; i < 5; i++) { var dot = new SpaceDOT(); dot.x = Math.random() * 2048; dot.y = Math.random() * -2732; spaceDOTs.push(dot); game.addChild(dot); } // Handle truck movement game.move = function (x, y, obj) { truck.move(x, y, obj); cargo.x = truck.x; cargo.y = truck.y - truck.height; }; // Update game logic game.update = function () { // Update space pirates for (var i = 0; i < spacePirates.length; i++) { spacePirates[i].update(); if (truck.intersects(spacePirates[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Update space DOTs for (var i = 0; i < spaceDOTs.length; i++) { spaceDOTs[i].update(); if (truck.intersects(spaceDOTs[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } };
===================================================================
--- original.js
+++ change.js
@@ -99,9 +99,9 @@
// Handle truck movement
game.move = function (x, y, obj) {
truck.move(x, y, obj);
cargo.x = truck.x;
- cargo.y = truck.y + truck.height;
+ cargo.y = truck.y - truck.height;
};
// Update game logic
game.update = function () {
// Update space pirates