User prompt
Venus health is 95%
User prompt
I cant see mars and venus health
User prompt
Earth:100% Health Mars:85% Health Venus:95%
User prompt
The start game stays there even after the game starts.
User prompt
I cant see the planet selection location
User prompt
Add a planet selection location. (New 2 planets. Venus, Mars)
User prompt
Add moon its deal %50 health
Code edit (1 edits merged)
Please save this source code
User prompt
Planet Destroyer
Initial prompt
Make a planet destroy game, let it be a world, let's destroy it with a few things
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Bomb = Container.expand(function () { var self = Container.call(this); var bombGraphics = self.attachAsset('bomb', { anchorX: 0.5, anchorY: 0.5 }); self.timer = 120; // 2 seconds at 60fps self.active = false; self.activate = function () { self.active = true; }; self.update = function () { if (!self.active) return; self.timer--; if (self.timer <= 0) { self.active = false; onBombExplode(self.x, self.y); } }; return self; }); var Explosion = Container.expand(function () { var self = Container.call(this); var explosionGraphics = self.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5 }); self.lifetime = 60; // 1 second self.maxLifetime = 60; self.update = function () { self.lifetime--; var alpha = self.lifetime / self.maxLifetime; explosionGraphics.alpha = alpha; if (self.lifetime <= 0) { self.destroy(); var index = explosions.indexOf(self); if (index > -1) explosions.splice(index, 1); } }; return self; }); var Meteor = Container.expand(function () { var self = Container.call(this); var meteorGraphics = self.attachAsset('meteor', { anchorX: 0.5, anchorY: 0.5 }); self.targetX = 0; self.targetY = 0; self.speed = 8; self.active = false; self.launch = function (targetX, targetY) { self.targetX = targetX; self.targetY = targetY; self.active = true; var angle = Math.atan2(targetY - self.y, targetX - self.x); self.velocityX = Math.cos(angle) * self.speed; self.velocityY = Math.sin(angle) * self.speed; }; self.update = function () { if (!self.active) return; self.x += self.velocityX; self.y += self.velocityY; var distance = Math.sqrt(Math.pow(self.targetX - self.x, 2) + Math.pow(self.targetY - self.y, 2)); if (distance < 30) { self.active = false; onMeteorHit(self.x, self.y); } }; return self; }); var Moon = Container.expand(function () { var self = Container.call(this); var moonGraphics = self.attachAsset('moon', { anchorX: 0.5, anchorY: 0.5 }); self.targetX = 0; self.targetY = 0; self.speed = 6; self.active = false; self.launch = function (targetX, targetY) { self.targetX = targetX; self.targetY = targetY; self.active = true; var angle = Math.atan2(targetY - self.y, targetX - self.x); self.velocityX = Math.cos(angle) * self.speed; self.velocityY = Math.sin(angle) * self.speed; }; self.update = function () { if (!self.active) return; self.x += self.velocityX; self.y += self.velocityY; var distance = Math.sqrt(Math.pow(self.targetX - self.x, 2) + Math.pow(self.targetY - self.y, 2)); if (distance < 40) { self.active = false; onMoonHit(self.x, self.y); } }; return self; }); var Planet = Container.expand(function () { var self = Container.call(this); var planetGraphics = self.attachAsset('planet', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.maxHealth = 100; self.destructionZones = []; self.takeDamage = function (amount, x, y) { self.health -= amount; if (self.health < 0) self.health = 0; // Add destruction zone var destructionZone = { x: x - self.x, y: y - self.y, size: amount * 2 }; self.destructionZones.push(destructionZone); // Update planet appearance based on health var healthPercent = self.health / self.maxHealth; if (healthPercent > 0.7) { planetGraphics.tint = 0x4CAF50; // Green } else if (healthPercent > 0.4) { planetGraphics.tint = 0xFFEB3B; // Yellow } else if (healthPercent > 0.1) { planetGraphics.tint = 0xFF5722; // Orange } else { planetGraphics.tint = 0x8D6E63; // Brown } return self.health <= 0; }; return self; }); var WeaponButton = Container.expand(function (weaponType) { var self = Container.call(this); var buttonGraphics = self.attachAsset('weaponButton', { anchorX: 0.5, anchorY: 0.5 }); self.weaponType = weaponType; self.selected = false; // Add weapon icon var iconAsset; switch (weaponType) { case 'meteor': iconAsset = 'meteor'; break; case 'bomb': iconAsset = 'bomb'; break; case 'laser': iconAsset = 'laser'; break; case 'blackhole': iconAsset = 'blackhole'; break; case 'moon': iconAsset = 'moon'; break; } var icon = self.attachAsset(iconAsset, { anchorX: 0.5, anchorY: 0.5, scaleX: 0.7, scaleY: 0.7 }); self.setSelected = function (selected) { self.selected = selected; if (selected) { buttonGraphics.tint = 0xFFFFFF; } else { buttonGraphics.tint = 0x888888; } }; self.down = function (x, y, obj) { selectWeapon(self.weaponType); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000011 }); /**** * Game Code ****/ var planet; var meteors = []; var moons = []; var bombs = []; var explosions = []; var weaponButtons = []; var selectedWeapon = 'meteor'; var score = 0; var planetDestroyed = false; // UI Elements var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0, 0); scoreTxt.x = 150; scoreTxt.y = 50; LK.gui.topLeft.addChild(scoreTxt); var healthTxt = new Text2('Planet Health: 100%', { size: 60, fill: 0xFFFFFF }); healthTxt.anchor.set(0.5, 0); LK.gui.top.addChild(healthTxt); // Create planet planet = game.addChild(new Planet()); planet.x = 2048 / 2; planet.y = 2732 / 2; // Create weapon selection buttons var weaponTypes = ['meteor', 'bomb', 'laser', 'blackhole', 'moon']; for (var i = 0; i < weaponTypes.length; i++) { var button = new WeaponButton(weaponTypes[i]); button.x = 150 + i * 140; button.y = 2732 - 150; weaponButtons.push(button); game.addChild(button); } // Select initial weapon selectWeapon('meteor'); function selectWeapon(weaponType) { selectedWeapon = weaponType; for (var i = 0; i < weaponButtons.length; i++) { weaponButtons[i].setSelected(weaponButtons[i].weaponType === weaponType); } } function onMeteorHit(x, y) { LK.getSound('meteorHit').play(); var destroyed = planet.takeDamage(15, x, y); score += 100; createExplosion(x, y); if (destroyed && !planetDestroyed) { planetDestroyed = true; LK.showYouWin(); } } function onMoonHit(x, y) { LK.getSound('moonHit').play(); var destroyed = planet.takeDamage(50, x, y); score += 500; createExplosion(x, y); if (destroyed && !planetDestroyed) { planetDestroyed = true; LK.showYouWin(); } } function onBombExplode(x, y) { LK.getSound('bombExplode').play(); var destroyed = planet.takeDamage(25, x, y); score += 200; createExplosion(x, y); // Create multiple smaller explosions for effect for (var i = 0; i < 3; i++) { var offsetX = (Math.random() - 0.5) * 100; var offsetY = (Math.random() - 0.5) * 100; createExplosion(x + offsetX, y + offsetY); } if (destroyed && !planetDestroyed) { planetDestroyed = true; LK.showYouWin(); } } function onLaserFire(startX, startY, endX, endY) { LK.getSound('laserFire').play(); var destroyed = planet.takeDamage(20, endX, endY); score += 150; createExplosion(endX, endY); if (destroyed && !planetDestroyed) { planetDestroyed = true; LK.showYouWin(); } } function onBlackholeActivate(x, y) { LK.getSound('blackholeActivate').play(); var destroyed = planet.takeDamage(30, x, y); score += 300; createExplosion(x, y); if (destroyed && !planetDestroyed) { planetDestroyed = true; LK.showYouWin(); } } function createExplosion(x, y) { var explosion = new Explosion(); explosion.x = x; explosion.y = y; explosions.push(explosion); game.addChild(explosion); } function isPlanetClick(x, y) { var distance = Math.sqrt(Math.pow(x - planet.x, 2) + Math.pow(y - planet.y, 2)); return distance < 200; } game.down = function (x, y, obj) { if (planetDestroyed) return; if (isPlanetClick(x, y)) { switch (selectedWeapon) { case 'meteor': var meteor = new Meteor(); meteor.x = Math.random() * 2048; meteor.y = -100; meteor.launch(x, y); meteors.push(meteor); game.addChild(meteor); break; case 'bomb': var bomb = new Bomb(); bomb.x = x; bomb.y = y; bomb.activate(); bombs.push(bomb); game.addChild(bomb); break; case 'laser': onLaserFire(x, 0, x, y); break; case 'blackhole': onBlackholeActivate(x, y); break; case 'moon': var moon = new Moon(); moon.x = Math.random() * 2048; moon.y = -100; moon.launch(x, y); moons.push(moon); game.addChild(moon); break; } } }; game.update = function () { if (planetDestroyed) return; // Update meteors for (var i = meteors.length - 1; i >= 0; i--) { var meteor = meteors[i]; if (!meteor.active) { meteor.destroy(); meteors.splice(i, 1); } } // Update moons for (var i = moons.length - 1; i >= 0; i--) { var moon = moons[i]; if (!moon.active) { moon.destroy(); moons.splice(i, 1); } } // Update bombs for (var i = bombs.length - 1; i >= 0; i--) { var bomb = bombs[i]; if (!bomb.active) { bomb.destroy(); bombs.splice(i, 1); } } // Update UI scoreTxt.setText('Score: ' + score); var healthPercent = Math.round(planet.health / planet.maxHealth * 100); healthTxt.setText('Planet Health: ' + healthPercent + '%'); LK.setScore(score); };
===================================================================
--- original.js
+++ change.js
@@ -76,8 +76,38 @@
}
};
return self;
});
+var Moon = Container.expand(function () {
+ var self = Container.call(this);
+ var moonGraphics = self.attachAsset('moon', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.targetX = 0;
+ self.targetY = 0;
+ self.speed = 6;
+ self.active = false;
+ self.launch = function (targetX, targetY) {
+ self.targetX = targetX;
+ self.targetY = targetY;
+ self.active = true;
+ var angle = Math.atan2(targetY - self.y, targetX - self.x);
+ self.velocityX = Math.cos(angle) * self.speed;
+ self.velocityY = Math.sin(angle) * self.speed;
+ };
+ self.update = function () {
+ if (!self.active) return;
+ self.x += self.velocityX;
+ self.y += self.velocityY;
+ var distance = Math.sqrt(Math.pow(self.targetX - self.x, 2) + Math.pow(self.targetY - self.y, 2));
+ if (distance < 40) {
+ self.active = false;
+ onMoonHit(self.x, self.y);
+ }
+ };
+ return self;
+});
var Planet = Container.expand(function () {
var self = Container.call(this);
var planetGraphics = self.attachAsset('planet', {
anchorX: 0.5,
@@ -133,8 +163,11 @@
break;
case 'blackhole':
iconAsset = 'blackhole';
break;
+ case 'moon':
+ iconAsset = 'moon';
+ break;
}
var icon = self.attachAsset(iconAsset, {
anchorX: 0.5,
anchorY: 0.5,
@@ -166,8 +199,9 @@
* Game Code
****/
var planet;
var meteors = [];
+var moons = [];
var bombs = [];
var explosions = [];
var weaponButtons = [];
var selectedWeapon = 'meteor';
@@ -192,9 +226,9 @@
planet = game.addChild(new Planet());
planet.x = 2048 / 2;
planet.y = 2732 / 2;
// Create weapon selection buttons
-var weaponTypes = ['meteor', 'bomb', 'laser', 'blackhole'];
+var weaponTypes = ['meteor', 'bomb', 'laser', 'blackhole', 'moon'];
for (var i = 0; i < weaponTypes.length; i++) {
var button = new WeaponButton(weaponTypes[i]);
button.x = 150 + i * 140;
button.y = 2732 - 150;
@@ -218,8 +252,18 @@
planetDestroyed = true;
LK.showYouWin();
}
}
+function onMoonHit(x, y) {
+ LK.getSound('moonHit').play();
+ var destroyed = planet.takeDamage(50, x, y);
+ score += 500;
+ createExplosion(x, y);
+ if (destroyed && !planetDestroyed) {
+ planetDestroyed = true;
+ LK.showYouWin();
+ }
+}
function onBombExplode(x, y) {
LK.getSound('bombExplode').play();
var destroyed = planet.takeDamage(25, x, y);
score += 200;
@@ -291,8 +335,16 @@
break;
case 'blackhole':
onBlackholeActivate(x, y);
break;
+ case 'moon':
+ var moon = new Moon();
+ moon.x = Math.random() * 2048;
+ moon.y = -100;
+ moon.launch(x, y);
+ moons.push(moon);
+ game.addChild(moon);
+ break;
}
}
};
game.update = function () {
@@ -304,8 +356,16 @@
meteor.destroy();
meteors.splice(i, 1);
}
}
+ // Update moons
+ for (var i = moons.length - 1; i >= 0; i--) {
+ var moon = moons[i];
+ if (!moon.active) {
+ moon.destroy();
+ moons.splice(i, 1);
+ }
+ }
// Update bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
if (!bomb.active) {
Earth. In-Game asset. 2d. High contrast. No shadows
Moon. In-Game asset. 2d. High contrast. No shadows
Meteor. In-Game asset. 2d. High contrast. No shadows
Explosion. In-Game asset. 2d. High contrast. No shadows
Black hole. In-Game asset. 2d. High contrast. No shadows
Laser only. In-Game asset. 2d. High contrast. No shadows
Bomb. In-Game asset. 2d. High contrast. No shadows
Mars. In-Game asset. 2d. High contrast. No shadows
Venus. In-Game asset. 2d. High contrast. No shadows
Jupiter. In-Game asset. 2d. High contrast. No shadows
Mercury. In-Game asset. 2d. High contrast. No shadows
Sun. In-Game asset. 2d. High contrast. No shadows
Saturn. In-Game asset. 2d. High contrast. No shadows
Just laser, but ice. In-Game asset. 2d. High contrast. No shadows
İce Explosion. In-Game asset. 2d. High contrast. No shadows
Uranus. In-Game asset. 2d. High contrast. No shadows
Fireball. In-Game asset. 2d. High contrast. No shadows
Planet of fire, volcano, magma, lava. In-Game asset. 2d. High contrast. No shadows