User prompt
que el jefe tenga 3 fases con distintos ataques
User prompt
que el fondo tenga estrellas
User prompt
mejor 1
User prompt
cada 2
User prompt
que el ataque prinsipal sea autonomo y se active cada 3 segundoos
User prompt
que el ataque especial sea activado por un clic quintuple rapido
User prompt
que el paersonage tenga un ataque con una recarga de 20 seg que sea una bonba de plasma ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
que luego de 10 ordas haya un jefe final ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
que hallan mas tipos de aliens
User prompt
que hayan mas tipos de aliens minimo 3 ademas de distintas combinaciones en cada orda
User prompt
que los aliens tengan 2 sprite de movimiento
User prompt
que las naves enemigas se mueven de izq a der mientras bajan
User prompt
que las animaciones del enemigo sean 2 sprites distintos
User prompt
que los enemigos tengan 2 animaciones ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
que los enemigos bayan bajando
User prompt
que no alla un boton si no que al picar la pantalla dispare
User prompt
que el boton sea un sirculo
User prompt
que haya un boton rojo que sea para disparar
User prompt
que el disparo no sea automatico que haya un boton para disparar
Code edit (1 edits merged)
Please save this source code
User prompt
Space Invader
Initial prompt
recrea el juego space in vader
/**** * Classes ****/ var AlienBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('alienBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.update = function () { self.y += self.speed; }; return self; }); var AlienType1 = Container.expand(function () { var self = Container.call(this, 'alienMove1', 'alienMove2', 10, 0.0005, 1); return self; }); var AlienType2 = Container.expand(function () { var self = Container.call(this, 'alienType2Move1', 'alienType2Move2', 20, 0.001, 1.2); return self; }); var AlienType3 = Container.expand(function () { var self = Container.call(this, 'alienType3Move1', 'alienType3Move2', 30, 0.0015, 0.8); return self; }); var BaseAlien = Container.expand(function (sprite1Name, sprite2Name, points, shootChance, speed) { var self = Container.call(this); // Create both movement sprites var alienMove1 = self.attachAsset(sprite1Name, { anchorX: 0.5, anchorY: 0.5 }); var alienMove2 = self.attachAsset(sprite2Name, { anchorX: 0.5, anchorY: 0.5 }); // Initially show first movement sprite, hide second alienMove2.visible = false; self.speed = speed || 1; self.points = points || 10; self.dropDistance = 40; self.shootChance = shootChance || 0.0005; self.animationTimer = 0; self.animationDuration = 20; // Switch sprites every 20 ticks for smoother movement animation self.currentSprite = 1; // Track which sprite is currently visible self.update = function () { // Move alien down continuously self.y += 0.3; // Move alien horizontally self.x += alienDirection * alienSpeed; // Handle movement sprite animation self.animationTimer++; if (self.animationTimer >= self.animationDuration) { self.animationTimer = 0; // Switch between movement sprites if (self.currentSprite === 1) { alienMove1.visible = false; alienMove2.visible = true; self.currentSprite = 2; } else { alienMove1.visible = true; alienMove2.visible = false; self.currentSprite = 1; } } // Random shooting if (Math.random() < self.shootChance) { createAlienBullet(self.x, self.y); } }; return self; }); var PlayerBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('playerBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -12; self.update = function () { self.y += self.speed; }; return self; }); var PlayerShip = Container.expand(function () { var self = Container.call(this); var shipGraphics = self.attachAsset('playerShip', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.shootCooldown = 0; self.shootRate = 15; // Fire every 15 ticks self.moveLeft = function () { self.x -= self.speed; if (self.x < 60) self.x = 60; }; self.moveRight = function () { self.x += self.speed; if (self.x > 1988) self.x = 1988; }; self.shoot = function () { if (self.shootCooldown <= 0) { self.shootCooldown = self.shootRate; createPlayerBullet(); LK.getSound('shoot').play(); } }; self.update = function () { // Player ship update without automatic shooting }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000033 }); /**** * Game Code ****/ var player; var aliens = []; var playerBullets = []; var alienBullets = []; var alienDirection = 1; // 1 for right, -1 for left var alienSpeed = 0.5; var waveNumber = 1; var aliensPerRow = 8; var alienRows = 5; var alienSpacingX = 200; var alienSpacingY = 100; var dragNode = null; // Score display var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Wave display var waveTxt = new Text2('Wave: 1', { size: 60, fill: 0xFFFFFF }); waveTxt.anchor.set(1, 0); LK.gui.topRight.addChild(waveTxt); // Initialize player player = game.addChild(new PlayerShip()); player.x = 1024; player.y = 2600; function createPlayerBullet() { var bullet = new PlayerBullet(); bullet.x = player.x; bullet.y = player.y - 50; bullet.lastY = bullet.y; playerBullets.push(bullet); game.addChild(bullet); } function createAlienBullet(x, y) { var bullet = new AlienBullet(); bullet.x = x; bullet.y = y + 40; bullet.lastY = bullet.y; alienBullets.push(bullet); game.addChild(bullet); } function spawnWave() { aliens = []; var startX = (2048 - (aliensPerRow - 1) * alienSpacingX) / 2; var startY = 200; for (var row = 0; row < alienRows; row++) { for (var col = 0; col < aliensPerRow; col++) { var alien; // Create different alien types based on row and wave pattern if (waveNumber % 3 === 1) { // Wave pattern 1: Type 1 top, Type 2 middle, Type 3 bottom if (row < 2) { alien = new AlienType1(); } else if (row < 4) { alien = new AlienType2(); } else { alien = new AlienType3(); } } else if (waveNumber % 3 === 2) { // Wave pattern 2: Type 3 top, Type 1 middle, Type 2 bottom if (row < 2) { alien = new AlienType3(); } else if (row < 4) { alien = new AlienType1(); } else { alien = new AlienType2(); } } else { // Wave pattern 3: Mixed types alternating if ((row + col) % 3 === 0) { alien = new AlienType1(); } else if ((row + col) % 3 === 1) { alien = new AlienType2(); } else { alien = new AlienType3(); } } alien.x = startX + col * alienSpacingX; alien.y = startY + row * alienSpacingY; alien.lastY = alien.y; alien.lastIntersectingPlayer = false; aliens.push(alien); game.addChild(alien); } } alienSpeed += 0.2; // Increase speed each wave waveTxt.setText('Wave: ' + waveNumber); } function checkAlienBounds() { var shouldChangeDirection = false; // Check if any alien hits the edge for (var i = 0; i < aliens.length; i++) { var alien = aliens[i]; if (alien.x <= 50 || alien.x >= 1998) { shouldChangeDirection = true; break; } } if (shouldChangeDirection) { alienDirection *= -1; } } function handleMove(x, y, obj) { if (dragNode) { dragNode.x = x; if (dragNode.x < 60) dragNode.x = 60; if (dragNode.x > 1988) dragNode.x = 1988; } } game.move = handleMove; game.down = function (x, y, obj) { dragNode = player; handleMove(x, y, obj); player.shoot(); }; game.up = function (x, y, obj) { dragNode = null; }; // Initialize first wave spawnWave(); game.update = function () { // Update player shoot cooldown if (player.shootCooldown > 0) { player.shootCooldown--; } // Update player bullets for (var i = playerBullets.length - 1; i >= 0; i--) { var bullet = playerBullets[i]; // Remove bullets that go off screen if (bullet.lastY >= -20 && bullet.y < -20) { bullet.destroy(); playerBullets.splice(i, 1); continue; } // Check collision with aliens var hit = false; for (var j = aliens.length - 1; j >= 0; j--) { var alien = aliens[j]; if (bullet.intersects(alien)) { // Destroy alien and bullet LK.setScore(LK.getScore() + alien.points); scoreTxt.setText('Score: ' + LK.getScore()); LK.getSound('alienHit').play(); LK.effects.flashObject(alien, 0xffff00, 200); alien.destroy(); aliens.splice(j, 1); bullet.destroy(); playerBullets.splice(i, 1); hit = true; break; } } if (!hit) { bullet.lastY = bullet.y; } } // Update alien bullets for (var i = alienBullets.length - 1; i >= 0; i--) { var bullet = alienBullets[i]; // Remove bullets that go off screen if (bullet.lastY <= 2752 && bullet.y > 2752) { bullet.destroy(); alienBullets.splice(i, 1); continue; } // Check collision with player if (bullet.intersects(player)) { LK.getSound('playerHit').play(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } bullet.lastY = bullet.y; } // Check if aliens reach bottom for (var i = 0; i < aliens.length; i++) { var alien = aliens[i]; if (alien.lastY < 2400 && alien.y >= 2400) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } alien.lastY = alien.y; } // Check alien boundaries for direction change checkAlienBounds(); // Check if all aliens destroyed if (aliens.length === 0) { waveNumber++; spawnWave(); } };
===================================================================
--- original.js
+++ change.js
@@ -1,23 +1,48 @@
/****
* Classes
****/
-var Alien = Container.expand(function () {
+var AlienBullet = Container.expand(function () {
var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('alienBullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 8;
+ self.update = function () {
+ self.y += self.speed;
+ };
+ return self;
+});
+var AlienType1 = Container.expand(function () {
+ var self = Container.call(this, 'alienMove1', 'alienMove2', 10, 0.0005, 1);
+ return self;
+});
+var AlienType2 = Container.expand(function () {
+ var self = Container.call(this, 'alienType2Move1', 'alienType2Move2', 20, 0.001, 1.2);
+ return self;
+});
+var AlienType3 = Container.expand(function () {
+ var self = Container.call(this, 'alienType3Move1', 'alienType3Move2', 30, 0.0015, 0.8);
+ return self;
+});
+var BaseAlien = Container.expand(function (sprite1Name, sprite2Name, points, shootChance, speed) {
+ var self = Container.call(this);
// Create both movement sprites
- var alienMove1 = self.attachAsset('alienMove1', {
+ var alienMove1 = self.attachAsset(sprite1Name, {
anchorX: 0.5,
anchorY: 0.5
});
- var alienMove2 = self.attachAsset('alienMove2', {
+ var alienMove2 = self.attachAsset(sprite2Name, {
anchorX: 0.5,
anchorY: 0.5
});
// Initially show first movement sprite, hide second
alienMove2.visible = false;
- self.speed = 1;
+ self.speed = speed || 1;
+ self.points = points || 10;
self.dropDistance = 40;
- self.shootChance = 0.0005; // Small chance to shoot each frame
+ self.shootChance = shootChance || 0.0005;
self.animationTimer = 0;
self.animationDuration = 20; // Switch sprites every 20 ticks for smoother movement animation
self.currentSprite = 1; // Track which sprite is currently visible
self.update = function () {
@@ -46,20 +71,8 @@
}
};
return self;
});
-var AlienBullet = Container.expand(function () {
- var self = Container.call(this);
- var bulletGraphics = self.attachAsset('alienBullet', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 8;
- self.update = function () {
- self.y += self.speed;
- };
- return self;
-});
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('playerBullet', {
anchorX: 0.5,
@@ -162,9 +175,38 @@
var startX = (2048 - (aliensPerRow - 1) * alienSpacingX) / 2;
var startY = 200;
for (var row = 0; row < alienRows; row++) {
for (var col = 0; col < aliensPerRow; col++) {
- var alien = new Alien();
+ var alien;
+ // Create different alien types based on row and wave pattern
+ if (waveNumber % 3 === 1) {
+ // Wave pattern 1: Type 1 top, Type 2 middle, Type 3 bottom
+ if (row < 2) {
+ alien = new AlienType1();
+ } else if (row < 4) {
+ alien = new AlienType2();
+ } else {
+ alien = new AlienType3();
+ }
+ } else if (waveNumber % 3 === 2) {
+ // Wave pattern 2: Type 3 top, Type 1 middle, Type 2 bottom
+ if (row < 2) {
+ alien = new AlienType3();
+ } else if (row < 4) {
+ alien = new AlienType1();
+ } else {
+ alien = new AlienType2();
+ }
+ } else {
+ // Wave pattern 3: Mixed types alternating
+ if ((row + col) % 3 === 0) {
+ alien = new AlienType1();
+ } else if ((row + col) % 3 === 1) {
+ alien = new AlienType2();
+ } else {
+ alien = new AlienType3();
+ }
+ }
alien.x = startX + col * alienSpacingX;
alien.y = startY + row * alienSpacingY;
alien.lastY = alien.y;
alien.lastIntersectingPlayer = false;
@@ -226,9 +268,9 @@
for (var j = aliens.length - 1; j >= 0; j--) {
var alien = aliens[j];
if (bullet.intersects(alien)) {
// Destroy alien and bullet
- LK.setScore(LK.getScore() + 10);
+ LK.setScore(LK.getScore() + alien.points);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('alienHit').play();
LK.effects.flashObject(alien, 0xffff00, 200);
alien.destroy();