31
0
1mo
User prompt
Add ANOTHER enemy jet called the Dogfighter (Shoots bombs in front of it instead of the back)
User prompt
My bombs won't phase the enemy jets!
User prompt
Add a new asset fot the bombers, also make a unique one, don't just buff every jet!
User prompt
Add a new enemy called the Stealth Bomber (Rare but incredibly fast)
User prompt
Add enemy bombers
User prompt
Make powerups
User prompt
Make the enemy encyclopedia open in mobile when you tap twice in 0.3sec
User prompt
Create a encyclopedia of every enemy
User prompt
My bombs don't do damage to enemy ships
User prompt
Enemy bombs don't do damage
User prompt
The defenses don't do damage when i collide
User prompt
Please fix the bug: 'ReferenceError: defenses is not defined' in or related to this line: 'defenses.push(defense);' Line Number: 170
User prompt
Please fix the bug: 'ReferenceError: bullets is not defined' in or related to this line: 'bullets.push(bullet);' Line Number: 77
User prompt
Please fix the bug: 'ReferenceError: Bullet is not defined' in or related to this line: 'var bullet = new Bullet();' Line Number: 58
User prompt
Add enemy ships that shoot at the player
User prompt
Make it activatable using mobile
User prompt
The button won't work
User prompt
Please fix the bug: 'Uncaught TypeError: LK.showLore is not a function' in or related to this line: 'LK.showLore();' Line Number: 54
Initial prompt
Add a lore button
/**** * Classes ****/ // Class for bombs dropped by Viggen var Bomb = Container.expand(function () { var self = Container.call(this); var bombGraphics = self.attachAsset('bomb', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); // Class for enemy bullets var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -5; self.update = function () { self.y += self.speed; if (self.y < 0) { self.destroy(); } }; }); // Class for enemy defenses var Defense = Container.expand(function () { var self = Container.call(this); var defenseGraphics = self.attachAsset('defense', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = -100; } }; }); // Class for Dogfighter enemy jets var Dogfighter = Container.expand(function () { var self = Container.call(this); var dogfighterGraphics = self.attachAsset('enemyShip', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 7; // Faster than regular enemy ships self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = -100; } }; self.shoot = function () { var bullet = new Bullet(); bullet.x = self.x; bullet.y = self.y; bullets.push(bullet); game.addChild(bullet); }; }); // Class for enemy bombers var EnemyBomber = Container.expand(function () { var self = Container.call(this); var bomberGraphics = self.attachAsset('enemyShip', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = -100; } }; self.dropBomb = function () { var bomb = new Bomb(); bomb.x = self.x; bomb.y = self.y; bombs.push(bomb); game.addChild(bomb); }; }); // Class for the enemy encyclopedia var EnemyEncyclopedia = Container.expand(function () { var self = Container.call(this); self.update = function () { // Update logic for EnemyEncyclopedia }; self.down = function (x, y, obj) { // Add double tap event listener if (this.lastTap) { var diff = Date.now() - this.lastTap; if (diff < 300) { // Show enemy details when double tapped console.log("Enemy Details: "); enemyShips.forEach(function (enemyShip, index) { console.log("Enemy " + (index + 1) + ": " + "Position - x: " + enemyShip.x + ", y: " + enemyShip.y); }); } } this.lastTap = Date.now(); }; }); // Class for enemy ships var EnemyShip = Container.expand(function () { var self = Container.call(this); var enemyShipGraphics = self.attachAsset('enemyShip', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = -100; } }; self.shoot = function () { var bullet = new Bullet(); bullet.x = self.x; bullet.y = self.y; bullets.push(bullet); game.addChild(bullet); }; }); // Class for the lore button var LoreButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Update logic for LoreButton }; self.down = function (x, y, obj) { // Show lore when button is pressed console.log("Lore: In the midst of the Cold War, a lone Viggen pilot embarks on a daring mission deep into Soviet territory. Outnumbered and outgunned, the pilot must rely on skill and cunning to survive. This is their story."); }; }); // Class for powerups var Powerup = Container.expand(function () { var self = Container.call(this); var powerupGraphics = self.attachAsset('powerup', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); // Class for stealth bombers var StealthBomber = Container.expand(function () { var self = Container.call(this); var stealthBomberGraphics = self.attachAsset('stealthBomber', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; // Incredibly fast speed self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = -100; } }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Class for the player's aircraft var Viggen = Container.expand(function () { var self = Container.call(this); var viggenGraphics = self.attachAsset('viggen', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Update logic for Viggen }; 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 player Viggen var viggen = game.addChild(new Viggen()); viggen.x = 1024; viggen.y = 2400; // Initialize lore button var loreButton = game.addChild(new LoreButton()); loreButton.x = 1800; loreButton.y = 100; // Initialize enemy encyclopedia var enemyEncyclopedia = game.addChild(new EnemyEncyclopedia()); enemyEncyclopedia.x = 1800; enemyEncyclopedia.y = 200; // Initialize bullets array var bullets = []; // Initialize defenses array var defenses = []; // Initialize enemy ships var enemyShips = []; for (var i = 0; i < 5; i++) { var enemyShip = new EnemyShip(); enemyShip.x = Math.random() * 2048; enemyShip.y = Math.random() * -1000; enemyShips.push(enemyShip); game.addChild(enemyShip); } // Initialize enemy bombers var enemyBombers = []; for (var i = 0; i < 3; i++) { var enemyBomber = new EnemyBomber(); enemyBomber.x = Math.random() * 2048; enemyBomber.y = Math.random() * -1000; enemyBombers.push(enemyBomber); game.addChild(enemyBomber); } // Initialize Dogfighters var dogfighters = []; for (var i = 0; i < 2; i++) { var dogfighter = new Dogfighter(); dogfighter.x = Math.random() * 2048; dogfighter.y = Math.random() * -1000; dogfighters.push(dogfighter); game.addChild(dogfighter); } // Initialize stealth bombers var stealthBombers = []; for (var i = 0; i < 1; i++) { // Rare occurrence var stealthBomber = new StealthBomber(); stealthBomber.x = Math.random() * 2048; stealthBomber.y = Math.random() * -1000; stealthBombers.push(stealthBomber); game.addChild(stealthBomber); } // Initialize powerups array var powerups = []; // Initialize bombs var bombs = []; // Handle game move events game.move = function (x, y, obj) { var game_position = game.toLocal(obj.global); viggen.move(game_position.x, game_position.y, obj); }; // Handle game update events game.update = function () { // Update enemy ships enemyShips.forEach(function (enemyShip) { enemyShip.update(); if (viggen.intersects(enemyShip)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } // Make enemy ships shoot at the player every 2 seconds if (LK.ticks % 120 === 0) { enemyShip.shoot(); } }); // Update Dogfighters dogfighters.forEach(function (dogfighter) { dogfighter.update(); if (viggen.intersects(dogfighter)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } // Make Dogfighters shoot bombs in front every 1.5 seconds if (LK.ticks % 90 === 0) { dogfighter.shoot(); } }); // Update enemy bombers enemyBombers.forEach(function (enemyBomber) { enemyBomber.update(); if (viggen.intersects(enemyBomber)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } // Make enemy bombers drop bombs every 3 seconds if (LK.ticks % 180 === 0) { enemyBomber.dropBomb(); } }); // Update stealth bombers stealthBombers.forEach(function (stealthBomber) { stealthBomber.update(); if (viggen.intersects(stealthBomber)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }); // Check for collision between player's aircraft and enemy bullets bullets.forEach(function (bullet) { if (viggen.intersects(bullet)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }); // Check for collision between player's aircraft and enemy defenses defenses.forEach(function (defense) { if (viggen.intersects(defense)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }); // Spawn new defenses every 2 seconds if (LK.ticks % 120 === 0) { var defense = new Defense(); defense.x = Math.random() * 2048; defense.y = Math.random() * -1000; defenses.push(defense); game.addChild(defense); } // Update bombs bombs.forEach(function (bomb, index) { bomb.update(); defenses.forEach(function (defense) { if (bomb.intersects(defense)) { defense.destroy(); bomb.destroy(); defenses.splice(defenses.indexOf(defense), 1); bombs.splice(index, 1); } }); // Check for collision between player's bombs and enemy ships enemyShips.forEach(function (enemyShip) { if (bomb.intersects(enemyShip)) { enemyShip.destroy(); bomb.destroy(); enemyShips.splice(enemyShips.indexOf(enemyShip), 1); bombs.splice(index, 1); } }); // Check for collision between player's bombs and enemy bombers enemyBombers.forEach(function (enemyBomber) { if (bomb.intersects(enemyBomber)) { enemyBomber.destroy(); bomb.destroy(); enemyBombers.splice(enemyBombers.indexOf(enemyBomber), 1); bombs.splice(index, 1); } }); // Check for collision between player's bombs and stealth bombers stealthBombers.forEach(function (stealthBomber) { if (bomb.intersects(stealthBomber)) { stealthBomber.destroy(); bomb.destroy(); stealthBombers.splice(stealthBombers.indexOf(stealthBomber), 1); bombs.splice(index, 1); } }); }); // Update powerups powerups.forEach(function (powerup, index) { powerup.update(); if (viggen.intersects(powerup)) { // Apply powerup effect console.log("Powerup collected!"); powerup.destroy(); powerups.splice(index, 1); } }); // Spawn powerups every 5 seconds if (LK.ticks % 300 === 0) { var powerup = new Powerup(); powerup.x = Math.random() * 2048; powerup.y = Math.random() * -1000; powerups.push(powerup); game.addChild(powerup); } // Drop bombs if (LK.ticks % 60 === 0) { var bomb = new Bomb(); bomb.x = viggen.x; bomb.y = viggen.y; bombs.push(bomb); game.addChild(bomb); } };
===================================================================
--- original.js
+++ change.js
@@ -45,8 +45,30 @@
self.y = -100;
}
};
});
+// Class for Dogfighter enemy jets
+var Dogfighter = Container.expand(function () {
+ var self = Container.call(this);
+ var dogfighterGraphics = self.attachAsset('enemyShip', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 7; // Faster than regular enemy ships
+ self.update = function () {
+ self.y += self.speed;
+ if (self.y > 2732) {
+ self.y = -100;
+ }
+ };
+ self.shoot = function () {
+ var bullet = new Bullet();
+ bullet.x = self.x;
+ bullet.y = self.y;
+ bullets.push(bullet);
+ game.addChild(bullet);
+ };
+});
// Class for enemy bombers
var EnemyBomber = Container.expand(function () {
var self = Container.call(this);
var bomberGraphics = self.attachAsset('enemyShip', {
@@ -218,8 +240,17 @@
enemyBomber.y = Math.random() * -1000;
enemyBombers.push(enemyBomber);
game.addChild(enemyBomber);
}
+// Initialize Dogfighters
+var dogfighters = [];
+for (var i = 0; i < 2; i++) {
+ var dogfighter = new Dogfighter();
+ dogfighter.x = Math.random() * 2048;
+ dogfighter.y = Math.random() * -1000;
+ dogfighters.push(dogfighter);
+ game.addChild(dogfighter);
+}
// Initialize stealth bombers
var stealthBombers = [];
for (var i = 0; i < 1; i++) {
// Rare occurrence
@@ -251,8 +282,20 @@
if (LK.ticks % 120 === 0) {
enemyShip.shoot();
}
});
+ // Update Dogfighters
+ dogfighters.forEach(function (dogfighter) {
+ dogfighter.update();
+ if (viggen.intersects(dogfighter)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ // Make Dogfighters shoot bombs in front every 1.5 seconds
+ if (LK.ticks % 90 === 0) {
+ dogfighter.shoot();
+ }
+ });
// Update enemy bombers
enemyBombers.forEach(function (enemyBomber) {
enemyBomber.update();
if (viggen.intersects(enemyBomber)) {
Pixel art of a Saab Viggen, the Swedish fighter jet.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A anti-air missile. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A Soviet fighter jet, facing down. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
supply crate. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows