User prompt
No,me refiero a que cada gena tenga su color
User prompt
Haz que la gema normal cambie de color ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz que en vez de cambiar de color,cambie el tono,más poder más fuerte el azul ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Axel's Gem Quest
Initial prompt
Eres un ajolote azul llamado axel,todo bien pero a alguien se le cayó unas gemas mágicas,encuentras antes de que tu enemigo,una piraña los tenga y se vuelva muy poderoso,TU tienes que recolectarlas,volverte poderoso y vencer
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Axel = Container.expand(function () { var self = Container.call(this); var axelGraphics = self.attachAsset('axel', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.powerLevel = 0; self.maxPowerLevel = 10; self.targetX = 0; self.targetY = 0; self.isMoving = false; self.collectGem = function (gem) { self.powerLevel++; LK.setScore(LK.getScore() + 10); // Visual power-up effect tween(axelGraphics, { scaleX: 1.3, scaleY: 1.3 }, { duration: 200, onFinish: function onFinish() { tween(axelGraphics, { scaleX: 1, scaleY: 1 }, { duration: 200 }); } }); // Change color based on power level var powerTint = 0x4A90E2 + self.powerLevel * 0x111111; axelGraphics.tint = powerTint; LK.getSound('collectGem').play(); }; self.collectPowerGem = function () { self.powerLevel += 3; LK.setScore(LK.getScore() + 50); // Special power-up effect LK.effects.flashObject(self, 0xF39C12, 500); LK.getSound('powerUp').play(); }; self.update = function () { if (self.isMoving) { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 5) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } else { self.isMoving = false; } } }; return self; }); var Bubble = Container.expand(function () { var self = Container.call(this); var bubbleGraphics = self.attachAsset('bubble', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2 + Math.random() * 3; self.sway = Math.random() * 0.02; self.swayOffset = Math.random() * Math.PI * 2; self.update = function () { self.y -= self.speed; self.x += Math.sin(LK.ticks * self.sway + self.swayOffset) * 1; // Fade out as it rises if (self.y < -50) { self.alpha -= 0.02; if (self.alpha <= 0) { self.destroy(); } } }; return self; }); var Gem = Container.expand(function () { var self = Container.call(this); var gemGraphics = self.attachAsset('gem', { anchorX: 0.5, anchorY: 0.5 }); self.floatOffset = Math.random() * Math.PI * 2; self.floatSpeed = 0.02; self.initialY = 0; self.update = function () { // Floating animation self.y = self.initialY + Math.sin(LK.ticks * self.floatSpeed + self.floatOffset) * 10; // Gentle rotation gemGraphics.rotation += 0.01; }; return self; }); var Piranha = Container.expand(function () { var self = Container.call(this); var piranhaGraphics = self.attachAsset('piranha', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.powerLevel = 0; self.targetGem = null; self.aggressionLevel = 1; self.collectGem = function (gem) { self.powerLevel++; self.speed += 0.5; self.aggressionLevel += 0.1; // Visual effect tween(piranhaGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 150, onFinish: function onFinish() { tween(piranhaGraphics, { scaleX: 1, scaleY: 1 }, { duration: 150 }); } }); // Change color to show increased power var powerTint = 0xE74C3C + self.powerLevel * 0x110000; piranhaGraphics.tint = powerTint; }; self.findNearestGem = function (gems) { var nearest = null; var minDistance = Infinity; for (var i = 0; i < gems.length; i++) { var gem = gems[i]; var dx = gem.x - self.x; var dy = gem.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < minDistance) { minDistance = distance; nearest = gem; } } return nearest; }; self.update = function () { if (self.targetGem) { var dx = self.targetGem.x - self.x; var dy = self.targetGem.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 5) { self.x += dx / distance * self.speed * self.aggressionLevel; self.y += dy / distance * self.speed * self.aggressionLevel; } } }; return self; }); var PowerGem = Container.expand(function () { var self = Container.call(this); var powerGemGraphics = self.attachAsset('powerGem', { anchorX: 0.5, anchorY: 0.5 }); self.floatOffset = Math.random() * Math.PI * 2; self.floatSpeed = 0.03; self.initialY = 0; self.update = function () { // More pronounced floating animation self.y = self.initialY + Math.sin(LK.ticks * self.floatSpeed + self.floatOffset) * 15; // Faster rotation powerGemGraphics.rotation += 0.03; // Pulsing effect var scale = 1 + Math.sin(LK.ticks * 0.05) * 0.1; powerGemGraphics.scaleX = scale; powerGemGraphics.scaleY = scale; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1E3A8A }); /**** * Game Code ****/ game.setBackgroundColor(0x0F4C75); // Game state variables var gameState = 'playing'; // 'playing', 'finalBattle', 'gameOver' var gems = []; var powerGems = []; var bubbles = []; var axel; var piranha; var gemSpawnTimer = 0; var powerGemSpawnTimer = 0; var bubbleSpawnTimer = 0; var finalBattleTriggered = false; // UI Elements var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var powerTxt = new Text2('Power: 0', { size: 60, fill: 0xF39C12 }); powerTxt.anchor.set(0, 0); powerTxt.x = 100; powerTxt.y = 150; LK.gui.topLeft.addChild(powerTxt); // Initialize game entities axel = game.addChild(new Axel()); axel.x = 1024; axel.y = 2000; piranha = game.addChild(new Piranha()); piranha.x = 1024; piranha.y = 500; // Spawn initial gems function spawnGem() { var gem = new Gem(); gem.x = 200 + Math.random() * 1648; gem.y = 300 + Math.random() * 1800; gem.initialY = gem.y; gems.push(gem); game.addChild(gem); } function spawnPowerGem() { var powerGem = new PowerGem(); powerGem.x = 300 + Math.random() * 1448; powerGem.y = 400 + Math.random() * 1600; powerGem.initialY = powerGem.y; powerGems.push(powerGem); game.addChild(powerGem); } function spawnBubble() { var bubble = new Bubble(); bubble.x = Math.random() * 2048; bubble.y = 2732 + 50; bubble.alpha = 0.6; bubbles.push(bubble); game.addChild(bubble); } // Initial spawns for (var i = 0; i < 5; i++) { spawnGem(); } // Game movement controls game.move = function (x, y, obj) { if (gameState === 'playing') { axel.targetX = x; axel.targetY = y; axel.isMoving = true; } }; game.down = function (x, y, obj) { if (gameState === 'playing') { axel.targetX = x; axel.targetY = y; axel.isMoving = true; } }; // Start background music LK.playMusic('underwaterBg'); // Main game loop game.update = function () { if (gameState === 'playing') { // Update timers gemSpawnTimer++; powerGemSpawnTimer++; bubbleSpawnTimer++; // Spawn gems periodically if (gemSpawnTimer >= 180) { // Every 3 seconds spawnGem(); gemSpawnTimer = 0; } // Spawn power gems less frequently if (powerGemSpawnTimer >= 600) { // Every 10 seconds spawnPowerGem(); powerGemSpawnTimer = 0; } // Spawn bubbles for ambiance if (bubbleSpawnTimer >= 60) { // Every second spawnBubble(); bubbleSpawnTimer = 0; } // Update piranha AI piranha.targetGem = piranha.findNearestGem(gems.concat(powerGems)); // Check gem collection by axel for (var i = gems.length - 1; i >= 0; i--) { var gem = gems[i]; if (axel.intersects(gem)) { axel.collectGem(gem); gem.destroy(); gems.splice(i, 1); continue; } // Check piranha collection if (piranha.intersects(gem)) { piranha.collectGem(gem); gem.destroy(); gems.splice(i, 1); } } // Check power gem collection for (var j = powerGems.length - 1; j >= 0; j--) { var powerGem = powerGems[j]; if (axel.intersects(powerGem)) { axel.collectPowerGem(); powerGem.destroy(); powerGems.splice(j, 1); continue; } // Check piranha collection if (piranha.intersects(powerGem)) { piranha.collectGem(powerGem); piranha.collectGem(powerGem); // Double power for piranha powerGem.destroy(); powerGems.splice(j, 1); } } // Clean up bubbles for (var k = bubbles.length - 1; k >= 0; k--) { var bubble = bubbles[k]; if (bubble.alpha <= 0) { bubble.destroy(); bubbles.splice(k, 1); } } // Update UI scoreTxt.setText('Score: ' + LK.getScore()); powerTxt.setText('Power: ' + axel.powerLevel); // Check for final battle trigger if (axel.powerLevel >= 10 && !finalBattleTriggered) { finalBattleTriggered = true; gameState = 'finalBattle'; // Clear remaining gems for (var g = 0; g < gems.length; g++) { gems[g].destroy(); } gems = []; for (var pg = 0; pg < powerGems.length; pg++) { powerGems[pg].destroy(); } powerGems = []; // Make piranha aggressive and move toward axel piranha.speed = 6; piranha.targetGem = null; // Flash screen to indicate battle start LK.effects.flashScreen(0xF39C12, 1000); } // Final battle logic if (gameState === 'finalBattle') { // Piranha chases axel var dx = axel.x - piranha.x; var dy = axel.y - piranha.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 5) { piranha.x += dx / distance * piranha.speed; piranha.y += dy / distance * piranha.speed; } // Check collision for battle outcome if (axel.intersects(piranha)) { if (axel.powerLevel >= piranha.powerLevel) { // Player wins LK.showYouWin(); } else { // Player loses LK.getSound('defeat').play(); LK.showGameOver(); } } } } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,391 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Axel = Container.expand(function () {
+ var self = Container.call(this);
+ var axelGraphics = self.attachAsset('axel', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 8;
+ self.powerLevel = 0;
+ self.maxPowerLevel = 10;
+ self.targetX = 0;
+ self.targetY = 0;
+ self.isMoving = false;
+ self.collectGem = function (gem) {
+ self.powerLevel++;
+ LK.setScore(LK.getScore() + 10);
+ // Visual power-up effect
+ tween(axelGraphics, {
+ scaleX: 1.3,
+ scaleY: 1.3
+ }, {
+ duration: 200,
+ onFinish: function onFinish() {
+ tween(axelGraphics, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200
+ });
+ }
+ });
+ // Change color based on power level
+ var powerTint = 0x4A90E2 + self.powerLevel * 0x111111;
+ axelGraphics.tint = powerTint;
+ LK.getSound('collectGem').play();
+ };
+ self.collectPowerGem = function () {
+ self.powerLevel += 3;
+ LK.setScore(LK.getScore() + 50);
+ // Special power-up effect
+ LK.effects.flashObject(self, 0xF39C12, 500);
+ LK.getSound('powerUp').play();
+ };
+ self.update = function () {
+ if (self.isMoving) {
+ var dx = self.targetX - self.x;
+ var dy = self.targetY - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 5) {
+ self.x += dx / distance * self.speed;
+ self.y += dy / distance * self.speed;
+ } else {
+ self.isMoving = false;
+ }
+ }
+ };
+ return self;
+});
+var Bubble = Container.expand(function () {
+ var self = Container.call(this);
+ var bubbleGraphics = self.attachAsset('bubble', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 2 + Math.random() * 3;
+ self.sway = Math.random() * 0.02;
+ self.swayOffset = Math.random() * Math.PI * 2;
+ self.update = function () {
+ self.y -= self.speed;
+ self.x += Math.sin(LK.ticks * self.sway + self.swayOffset) * 1;
+ // Fade out as it rises
+ if (self.y < -50) {
+ self.alpha -= 0.02;
+ if (self.alpha <= 0) {
+ self.destroy();
+ }
+ }
+ };
+ return self;
+});
+var Gem = Container.expand(function () {
+ var self = Container.call(this);
+ var gemGraphics = self.attachAsset('gem', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.floatOffset = Math.random() * Math.PI * 2;
+ self.floatSpeed = 0.02;
+ self.initialY = 0;
+ self.update = function () {
+ // Floating animation
+ self.y = self.initialY + Math.sin(LK.ticks * self.floatSpeed + self.floatOffset) * 10;
+ // Gentle rotation
+ gemGraphics.rotation += 0.01;
+ };
+ return self;
+});
+var Piranha = Container.expand(function () {
+ var self = Container.call(this);
+ var piranhaGraphics = self.attachAsset('piranha', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 4;
+ self.powerLevel = 0;
+ self.targetGem = null;
+ self.aggressionLevel = 1;
+ self.collectGem = function (gem) {
+ self.powerLevel++;
+ self.speed += 0.5;
+ self.aggressionLevel += 0.1;
+ // Visual effect
+ tween(piranhaGraphics, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 150,
+ onFinish: function onFinish() {
+ tween(piranhaGraphics, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 150
+ });
+ }
+ });
+ // Change color to show increased power
+ var powerTint = 0xE74C3C + self.powerLevel * 0x110000;
+ piranhaGraphics.tint = powerTint;
+ };
+ self.findNearestGem = function (gems) {
+ var nearest = null;
+ var minDistance = Infinity;
+ for (var i = 0; i < gems.length; i++) {
+ var gem = gems[i];
+ var dx = gem.x - self.x;
+ var dy = gem.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < minDistance) {
+ minDistance = distance;
+ nearest = gem;
+ }
+ }
+ return nearest;
+ };
+ self.update = function () {
+ if (self.targetGem) {
+ var dx = self.targetGem.x - self.x;
+ var dy = self.targetGem.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 5) {
+ self.x += dx / distance * self.speed * self.aggressionLevel;
+ self.y += dy / distance * self.speed * self.aggressionLevel;
+ }
+ }
+ };
+ return self;
+});
+var PowerGem = Container.expand(function () {
+ var self = Container.call(this);
+ var powerGemGraphics = self.attachAsset('powerGem', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.floatOffset = Math.random() * Math.PI * 2;
+ self.floatSpeed = 0.03;
+ self.initialY = 0;
+ self.update = function () {
+ // More pronounced floating animation
+ self.y = self.initialY + Math.sin(LK.ticks * self.floatSpeed + self.floatOffset) * 15;
+ // Faster rotation
+ powerGemGraphics.rotation += 0.03;
+ // Pulsing effect
+ var scale = 1 + Math.sin(LK.ticks * 0.05) * 0.1;
+ powerGemGraphics.scaleX = scale;
+ powerGemGraphics.scaleY = scale;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1E3A8A
+});
+
+/****
+* Game Code
+****/
+game.setBackgroundColor(0x0F4C75);
+// Game state variables
+var gameState = 'playing'; // 'playing', 'finalBattle', 'gameOver'
+var gems = [];
+var powerGems = [];
+var bubbles = [];
+var axel;
+var piranha;
+var gemSpawnTimer = 0;
+var powerGemSpawnTimer = 0;
+var bubbleSpawnTimer = 0;
+var finalBattleTriggered = false;
+// UI Elements
+var scoreTxt = new Text2('Score: 0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+var powerTxt = new Text2('Power: 0', {
+ size: 60,
+ fill: 0xF39C12
+});
+powerTxt.anchor.set(0, 0);
+powerTxt.x = 100;
+powerTxt.y = 150;
+LK.gui.topLeft.addChild(powerTxt);
+// Initialize game entities
+axel = game.addChild(new Axel());
+axel.x = 1024;
+axel.y = 2000;
+piranha = game.addChild(new Piranha());
+piranha.x = 1024;
+piranha.y = 500;
+// Spawn initial gems
+function spawnGem() {
+ var gem = new Gem();
+ gem.x = 200 + Math.random() * 1648;
+ gem.y = 300 + Math.random() * 1800;
+ gem.initialY = gem.y;
+ gems.push(gem);
+ game.addChild(gem);
+}
+function spawnPowerGem() {
+ var powerGem = new PowerGem();
+ powerGem.x = 300 + Math.random() * 1448;
+ powerGem.y = 400 + Math.random() * 1600;
+ powerGem.initialY = powerGem.y;
+ powerGems.push(powerGem);
+ game.addChild(powerGem);
+}
+function spawnBubble() {
+ var bubble = new Bubble();
+ bubble.x = Math.random() * 2048;
+ bubble.y = 2732 + 50;
+ bubble.alpha = 0.6;
+ bubbles.push(bubble);
+ game.addChild(bubble);
+}
+// Initial spawns
+for (var i = 0; i < 5; i++) {
+ spawnGem();
+}
+// Game movement controls
+game.move = function (x, y, obj) {
+ if (gameState === 'playing') {
+ axel.targetX = x;
+ axel.targetY = y;
+ axel.isMoving = true;
+ }
+};
+game.down = function (x, y, obj) {
+ if (gameState === 'playing') {
+ axel.targetX = x;
+ axel.targetY = y;
+ axel.isMoving = true;
+ }
+};
+// Start background music
+LK.playMusic('underwaterBg');
+// Main game loop
+game.update = function () {
+ if (gameState === 'playing') {
+ // Update timers
+ gemSpawnTimer++;
+ powerGemSpawnTimer++;
+ bubbleSpawnTimer++;
+ // Spawn gems periodically
+ if (gemSpawnTimer >= 180) {
+ // Every 3 seconds
+ spawnGem();
+ gemSpawnTimer = 0;
+ }
+ // Spawn power gems less frequently
+ if (powerGemSpawnTimer >= 600) {
+ // Every 10 seconds
+ spawnPowerGem();
+ powerGemSpawnTimer = 0;
+ }
+ // Spawn bubbles for ambiance
+ if (bubbleSpawnTimer >= 60) {
+ // Every second
+ spawnBubble();
+ bubbleSpawnTimer = 0;
+ }
+ // Update piranha AI
+ piranha.targetGem = piranha.findNearestGem(gems.concat(powerGems));
+ // Check gem collection by axel
+ for (var i = gems.length - 1; i >= 0; i--) {
+ var gem = gems[i];
+ if (axel.intersects(gem)) {
+ axel.collectGem(gem);
+ gem.destroy();
+ gems.splice(i, 1);
+ continue;
+ }
+ // Check piranha collection
+ if (piranha.intersects(gem)) {
+ piranha.collectGem(gem);
+ gem.destroy();
+ gems.splice(i, 1);
+ }
+ }
+ // Check power gem collection
+ for (var j = powerGems.length - 1; j >= 0; j--) {
+ var powerGem = powerGems[j];
+ if (axel.intersects(powerGem)) {
+ axel.collectPowerGem();
+ powerGem.destroy();
+ powerGems.splice(j, 1);
+ continue;
+ }
+ // Check piranha collection
+ if (piranha.intersects(powerGem)) {
+ piranha.collectGem(powerGem);
+ piranha.collectGem(powerGem); // Double power for piranha
+ powerGem.destroy();
+ powerGems.splice(j, 1);
+ }
+ }
+ // Clean up bubbles
+ for (var k = bubbles.length - 1; k >= 0; k--) {
+ var bubble = bubbles[k];
+ if (bubble.alpha <= 0) {
+ bubble.destroy();
+ bubbles.splice(k, 1);
+ }
+ }
+ // Update UI
+ scoreTxt.setText('Score: ' + LK.getScore());
+ powerTxt.setText('Power: ' + axel.powerLevel);
+ // Check for final battle trigger
+ if (axel.powerLevel >= 10 && !finalBattleTriggered) {
+ finalBattleTriggered = true;
+ gameState = 'finalBattle';
+ // Clear remaining gems
+ for (var g = 0; g < gems.length; g++) {
+ gems[g].destroy();
+ }
+ gems = [];
+ for (var pg = 0; pg < powerGems.length; pg++) {
+ powerGems[pg].destroy();
+ }
+ powerGems = [];
+ // Make piranha aggressive and move toward axel
+ piranha.speed = 6;
+ piranha.targetGem = null;
+ // Flash screen to indicate battle start
+ LK.effects.flashScreen(0xF39C12, 1000);
+ }
+ // Final battle logic
+ if (gameState === 'finalBattle') {
+ // Piranha chases axel
+ var dx = axel.x - piranha.x;
+ var dy = axel.y - piranha.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 5) {
+ piranha.x += dx / distance * piranha.speed;
+ piranha.y += dy / distance * piranha.speed;
+ }
+ // Check collision for battle outcome
+ if (axel.intersects(piranha)) {
+ if (axel.powerLevel >= piranha.powerLevel) {
+ // Player wins
+ LK.showYouWin();
+ } else {
+ // Player loses
+ LK.getSound('defeat').play();
+ LK.showGameOver();
+ }
+ }
+ }
+ }
+};
\ No newline at end of file
Un ajolote azul. In-Game asset. 2d. High contrast. No shadows
Piraña. In-Game asset. 2d. High contrast. No shadows
Gema. In-Game asset. 2d. High contrast. No shadows
Gema. In-Game asset. 2d. High contrast. No shadows
Gema. In-Game asset. 2d. High contrast. No shadows
Gema. In-Game asset. 2d. High contrast. No shadows
Gema. In-Game asset. 2d. High contrast. No shadows
Burbuja. In-Game asset. 2d. High contrast. No shadows
Gema verde. In-Game asset. 2d. High contrast. No shadows