User prompt
Haz que el multiplicador de monedas valga 50 monedas y que solo dure 3 partidas ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Haz que en la tienda se pueda comprar un potenciador de monedas ×2 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Haz que puedas saltar al agua y perder de esa manera
User prompt
Arregla esto: el sonido splash no suena
User prompt
Arregla esto: la rana "Double jump" no hace doble salto
User prompt
Elimina la rana "high Jumper" de la tienda
User prompt
Ahora haz que las piedras dezaparescan mientras la rana está encima
User prompt
Arregla esto: las otras ranas no pueden saltar
User prompt
Haz que solo la rana con la habilidad "Big jump" pueda saltar lejos y que las otras ranas no puedan saltar lejos
User prompt
Haz que solo te lleve al siguiente nivel cuando solo haya una roca
User prompt
Soluciona este problema: cuando paso por algunas piedras derrepente me lleva al siguiente nivel sin hacer que todas las rocas desaparezcan
User prompt
Añade que cuando ya no hallan rocas pases al siguiente nivel y que cada vez que pases al siguiente nivel aparezcan más peces y los otros tipos de rocas
User prompt
Ahora en el menú añade un botón abajo del de empezar el juego que diga "store" para abrir una tienda en la que puedas comprar ranas con abilidades como doble salto más velocidad etc. Y que puedas comprar esas ranas con las monedas
User prompt
Ahora añade un menú que te salga al iniciar el juego en el que este el título del juego "froggy river rush" y abajo del título este el botón para empezar "play"
User prompt
Y ahora añade este objetivo: Llega lo más lejos posible sin caer al agua. Hay monedas para coleccionar que se pueden usar para desbloquear diferentes ranas con habilidades especiales (más salto, velocidad, doble salto, etc.). ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Froggy River Rush
Initial prompt
Necesito hacer un juego que se trate de esto: Eres una rana que debe cruzar un río saltando sobre piedras flotantes. Cada piedra se hunde unos segundos después de que la pisas, así que debes moverte rápido. Algunas piedras se mueven, otras son resbaladizas, y hay enemigos como peces que saltan y pueden derribarte.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.collect = function () {
if (self.collected) return;
self.collected = true;
LK.getSound('coinCollect').play();
// Add coin to storage
var currentCoins = storage.coins || 0;
storage.coins = currentCoins + 1;
// Update coin display
coinsTxt.setText('Coins: ' + storage.coins);
self.destroy();
};
return self;
});
var Fish = Container.expand(function () {
var self = Container.call(this);
var fishGraphics = self.attachAsset('fish', {
anchorX: 0.5,
anchorY: 0.5
});
self.jumpSpeed = -8;
self.gravity = 0.4;
self.velocityY = self.jumpSpeed;
self.startY = 0;
self.jump = function () {
self.velocityY = self.jumpSpeed;
LK.getSound('fishJump').play();
};
self.update = function () {
self.velocityY += self.gravity;
self.y += self.velocityY;
if (self.y > self.startY + 100) {
self.destroy();
}
};
return self;
});
var Frog = Container.expand(function (frogType) {
var self = Container.call(this);
self.frogType = frogType || 'normal';
var frogGraphics = self.attachAsset('frog', {
anchorX: 0.5,
anchorY: 0.5
});
self.isJumping = false;
self.currentStone = null;
self.jumpSpeed = 8;
self.targetX = 0;
self.targetY = 0;
self.doubleJumpUsed = false;
// Apply frog abilities based on type
if (self.frogType === 'fast') {
self.jumpSpeed = 12;
frogGraphics.tint = 0xff6b6b;
} else if (self.frogType === 'jumper') {
self.jumpSpeed = 10;
frogGraphics.tint = 0x4ecdc4;
} else if (self.frogType === 'double') {
frogGraphics.tint = 0xffe66d;
}
self.jumpTo = function (stone) {
if (self.isJumping) return;
self.isJumping = true;
self.targetX = stone.x;
self.targetY = stone.y - 50;
if (self.currentStone) {
self.currentStone.startSinking();
}
self.currentStone = stone;
LK.getSound('jump').play();
var jumpDistance = Math.sqrt(Math.pow(self.targetX - self.x, 2) + Math.pow(self.targetY - self.y, 2));
var jumpDuration = jumpDistance / self.jumpSpeed * 16.67; // Convert to ms
tween(self, {
x: self.targetX,
y: self.targetY
}, {
duration: jumpDuration,
easing: tween.easeOut,
onFinish: function onFinish() {
self.isJumping = false;
if (self.frogType === 'double') {
self.doubleJumpUsed = false;
}
if (stone.stoneType === 'slippery') {
var slipAmount = (Math.random() - 0.5) * 40;
self.x += slipAmount;
}
}
});
};
self.doubleJump = function (stone) {
if (self.frogType !== 'double' || self.doubleJumpUsed || !self.isJumping) return;
self.doubleJumpUsed = true;
self.jumpTo(stone);
};
return self;
});
var Stone = Container.expand(function (stoneType) {
var self = Container.call(this);
self.stoneType = stoneType || 'regular';
self.sinkTimer = 0;
self.maxSinkTime = 180; // 3 seconds at 60fps
self.isOccupied = false;
self.originalY = 0;
self.moveSpeed = 0;
var assetName = 'stone';
if (self.stoneType === 'moving') {
assetName = 'movingStone';
self.moveSpeed = Math.random() * 2 - 1; // -1 to 1
} else if (self.stoneType === 'slippery') {
assetName = 'slipperyStone';
}
var stoneGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.startSinking = function () {
self.isOccupied = true;
self.sinkTimer = 0;
};
self.update = function () {
if (self.isOccupied) {
self.sinkTimer++;
var sinkProgress = self.sinkTimer / self.maxSinkTime;
self.y = self.originalY + sinkProgress * 50;
self.alpha = 1 - sinkProgress * 0.7;
if (self.sinkTimer >= self.maxSinkTime) {
self.destroy();
return;
}
}
if (self.stoneType === 'moving') {
self.x += self.moveSpeed;
if (self.x < 60 || self.x > 1988) {
self.moveSpeed *= -1;
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0077BE
});
/****
* Game Code
****/
var waterBackground = game.addChild(LK.getAsset('water', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
var stones = [];
var fishes = [];
var coins = [];
var currentFrogType = storage.selectedFrog || 'normal';
var frog = game.addChild(new Frog(currentFrogType));
var level = 1;
var crossingCount = 0;
var fishSpawnTimer = 0;
var coinSpawnTimer = 0;
var maxDistance = 0;
var startY = 2650;
// Score display
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
scoreTxt.x = 120;
scoreTxt.y = 50;
LK.gui.topLeft.addChild(scoreTxt);
// Level display
var levelTxt = new Text2('Level: 1', {
size: 50,
fill: 0xFFFFFF
});
levelTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(levelTxt);
// Coins display
var coinsTxt = new Text2('Coins: ' + (storage.coins || 0), {
size: 50,
fill: 0xffd700
});
coinsTxt.anchor.set(0, 0);
coinsTxt.x = 120;
coinsTxt.y = 120;
LK.gui.topLeft.addChild(coinsTxt);
// Distance display
var distanceTxt = new Text2('Distance: 0m', {
size: 50,
fill: 0xFFFFFF
});
distanceTxt.anchor.set(1, 0);
distanceTxt.x = -20;
distanceTxt.y = 60;
LK.gui.topRight.addChild(distanceTxt);
function createStoneRow(y, count) {
var stoneSpacing = 2048 / (count + 1);
for (var i = 0; i < count; i++) {
var stoneType = 'regular';
var rand = Math.random();
if (level > 2 && rand < 0.2) {
stoneType = 'moving';
} else if (level > 3 && rand < 0.4) {
stoneType = 'slippery';
}
var stone = new Stone(stoneType);
stone.x = stoneSpacing * (i + 1) + (Math.random() - 0.5) * 100;
stone.y = y;
stone.originalY = y;
stones.push(stone);
game.addChild(stone);
// Spawn coin randomly on some stones
if (Math.random() < 0.3) {
var coin = new Coin();
coin.x = stone.x;
coin.y = stone.y - 40;
coins.push(coin);
game.addChild(coin);
}
}
}
function initializeLevel() {
// Clear existing stones
for (var i = stones.length - 1; i >= 0; i--) {
stones[i].destroy();
}
stones = [];
// Create stone rows
var rows = 6 + level;
var rowSpacing = 2200 / rows;
for (var row = 0; row < rows; row++) {
var y = 2600 - row * rowSpacing;
var stoneCount = 3 + Math.floor(Math.random() * 3);
createStoneRow(y, stoneCount);
}
// Position frog at start
frog.x = 1024;
frog.y = 2650;
frog.currentStone = null;
frog.isJumping = false;
}
function spawnFish() {
if (Math.random() < 0.3) {
var fish = new Fish();
fish.x = Math.random() * 1800 + 124;
fish.y = Math.random() * 1800 + 400;
fish.startY = fish.y;
fish.jump();
fishes.push(fish);
game.addChild(fish);
}
}
function checkWinCondition() {
if (frog.y < 400) {
crossingCount++;
LK.setScore(LK.getScore() + 100 + level * 20);
level++;
levelTxt.setText('Level: ' + level);
// Clear existing coins
for (var i = coins.length - 1; i >= 0; i--) {
coins[i].destroy();
}
coins = [];
initializeLevel();
}
}
function checkGameOver() {
// Check if frog fell in water
if (frog.y > 2650 && !frog.isJumping) {
LK.getSound('splash').play();
LK.showGameOver();
return;
}
// Check fish collision
for (var i = fishes.length - 1; i >= 0; i--) {
var fish = fishes[i];
if (frog.intersects(fish)) {
LK.getSound('splash').play();
LK.showGameOver();
return;
}
}
}
// Initialize first level
initializeLevel();
game.down = function (x, y, obj) {
if (frog.isJumping && frog.frogType !== 'double') return;
var nearestStone = null;
var nearestDistance = Infinity;
for (var i = 0; i < stones.length; i++) {
var stone = stones[i];
var distance = Math.sqrt(Math.pow(x - stone.x, 2) + Math.pow(y - stone.y, 2));
if (distance < 150 && distance < nearestDistance) {
nearestDistance = distance;
nearestStone = stone;
}
}
if (nearestStone && !nearestStone.isOccupied) {
if (frog.isJumping && frog.frogType === 'double') {
frog.doubleJump(nearestStone);
} else {
frog.jumpTo(nearestStone);
}
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
}
};
game.update = function () {
// Clean up destroyed stones
for (var i = stones.length - 1; i >= 0; i--) {
if (stones[i].destroyed) {
stones.splice(i, 1);
}
}
// Clean up destroyed fish
for (var i = fishes.length - 1; i >= 0; i--) {
if (fishes[i].destroyed) {
fishes.splice(i, 1);
}
}
// Clean up destroyed coins
for (var i = coins.length - 1; i >= 0; i--) {
if (coins[i].destroyed) {
coins.splice(i, 1);
}
}
// Check coin collection
for (var i = coins.length - 1; i >= 0; i--) {
var coin = coins[i];
if (frog.intersects(coin) && !coin.collected) {
coin.collect();
coins.splice(i, 1);
}
}
// Update distance traveled
var currentDistance = Math.max(0, Math.floor((startY - frog.y) / 10));
if (currentDistance > maxDistance) {
maxDistance = currentDistance;
storage.maxDistance = maxDistance;
}
distanceTxt.setText('Distance: ' + currentDistance + 'm');
// Spawn fish periodically
fishSpawnTimer++;
if (fishSpawnTimer > 120 - level * 10) {
fishSpawnTimer = 0;
spawnFish();
}
checkWinCondition();
checkGameOver();
}; ===================================================================
--- original.js
+++ change.js
@@ -1,12 +1,33 @@
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
+var Coin = Container.expand(function () {
+ var self = Container.call(this);
+ var coinGraphics = self.attachAsset('coin', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.collected = false;
+ self.collect = function () {
+ if (self.collected) return;
+ self.collected = true;
+ LK.getSound('coinCollect').play();
+ // Add coin to storage
+ var currentCoins = storage.coins || 0;
+ storage.coins = currentCoins + 1;
+ // Update coin display
+ coinsTxt.setText('Coins: ' + storage.coins);
+ self.destroy();
+ };
+ return self;
+});
var Fish = Container.expand(function () {
var self = Container.call(this);
var fishGraphics = self.attachAsset('fish', {
anchorX: 0.5,
@@ -28,10 +49,11 @@
}
};
return self;
});
-var Frog = Container.expand(function () {
+var Frog = Container.expand(function (frogType) {
var self = Container.call(this);
+ self.frogType = frogType || 'normal';
var frogGraphics = self.attachAsset('frog', {
anchorX: 0.5,
anchorY: 0.5
});
@@ -39,8 +61,19 @@
self.currentStone = null;
self.jumpSpeed = 8;
self.targetX = 0;
self.targetY = 0;
+ self.doubleJumpUsed = false;
+ // Apply frog abilities based on type
+ if (self.frogType === 'fast') {
+ self.jumpSpeed = 12;
+ frogGraphics.tint = 0xff6b6b;
+ } else if (self.frogType === 'jumper') {
+ self.jumpSpeed = 10;
+ frogGraphics.tint = 0x4ecdc4;
+ } else if (self.frogType === 'double') {
+ frogGraphics.tint = 0xffe66d;
+ }
self.jumpTo = function (stone) {
if (self.isJumping) return;
self.isJumping = true;
self.targetX = stone.x;
@@ -59,15 +92,23 @@
duration: jumpDuration,
easing: tween.easeOut,
onFinish: function onFinish() {
self.isJumping = false;
+ if (self.frogType === 'double') {
+ self.doubleJumpUsed = false;
+ }
if (stone.stoneType === 'slippery') {
var slipAmount = (Math.random() - 0.5) * 40;
self.x += slipAmount;
}
}
});
};
+ self.doubleJump = function (stone) {
+ if (self.frogType !== 'double' || self.doubleJumpUsed || !self.isJumping) return;
+ self.doubleJumpUsed = true;
+ self.jumpTo(stone);
+ };
return self;
});
var Stone = Container.expand(function (stoneType) {
var self = Container.call(this);
@@ -130,12 +171,17 @@
y: 0
}));
var stones = [];
var fishes = [];
-var frog = game.addChild(new Frog());
+var coins = [];
+var currentFrogType = storage.selectedFrog || 'normal';
+var frog = game.addChild(new Frog(currentFrogType));
var level = 1;
var crossingCount = 0;
var fishSpawnTimer = 0;
+var coinSpawnTimer = 0;
+var maxDistance = 0;
+var startY = 2650;
// Score display
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
@@ -150,8 +196,26 @@
fill: 0xFFFFFF
});
levelTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(levelTxt);
+// Coins display
+var coinsTxt = new Text2('Coins: ' + (storage.coins || 0), {
+ size: 50,
+ fill: 0xffd700
+});
+coinsTxt.anchor.set(0, 0);
+coinsTxt.x = 120;
+coinsTxt.y = 120;
+LK.gui.topLeft.addChild(coinsTxt);
+// Distance display
+var distanceTxt = new Text2('Distance: 0m', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+distanceTxt.anchor.set(1, 0);
+distanceTxt.x = -20;
+distanceTxt.y = 60;
+LK.gui.topRight.addChild(distanceTxt);
function createStoneRow(y, count) {
var stoneSpacing = 2048 / (count + 1);
for (var i = 0; i < count; i++) {
var stoneType = 'regular';
@@ -166,8 +230,16 @@
stone.y = y;
stone.originalY = y;
stones.push(stone);
game.addChild(stone);
+ // Spawn coin randomly on some stones
+ if (Math.random() < 0.3) {
+ var coin = new Coin();
+ coin.x = stone.x;
+ coin.y = stone.y - 40;
+ coins.push(coin);
+ game.addChild(coin);
+ }
}
}
function initializeLevel() {
// Clear existing stones
@@ -205,8 +277,13 @@
crossingCount++;
LK.setScore(LK.getScore() + 100 + level * 20);
level++;
levelTxt.setText('Level: ' + level);
+ // Clear existing coins
+ for (var i = coins.length - 1; i >= 0; i--) {
+ coins[i].destroy();
+ }
+ coins = [];
initializeLevel();
}
}
function checkGameOver() {
@@ -228,9 +305,9 @@
}
// Initialize first level
initializeLevel();
game.down = function (x, y, obj) {
- if (frog.isJumping) return;
+ if (frog.isJumping && frog.frogType !== 'double') return;
var nearestStone = null;
var nearestDistance = Infinity;
for (var i = 0; i < stones.length; i++) {
var stone = stones[i];
@@ -240,9 +317,13 @@
nearestStone = stone;
}
}
if (nearestStone && !nearestStone.isOccupied) {
- frog.jumpTo(nearestStone);
+ if (frog.isJumping && frog.frogType === 'double') {
+ frog.doubleJump(nearestStone);
+ } else {
+ frog.jumpTo(nearestStone);
+ }
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
}
};
@@ -258,8 +339,29 @@
if (fishes[i].destroyed) {
fishes.splice(i, 1);
}
}
+ // Clean up destroyed coins
+ for (var i = coins.length - 1; i >= 0; i--) {
+ if (coins[i].destroyed) {
+ coins.splice(i, 1);
+ }
+ }
+ // Check coin collection
+ for (var i = coins.length - 1; i >= 0; i--) {
+ var coin = coins[i];
+ if (frog.intersects(coin) && !coin.collected) {
+ coin.collect();
+ coins.splice(i, 1);
+ }
+ }
+ // Update distance traveled
+ var currentDistance = Math.max(0, Math.floor((startY - frog.y) / 10));
+ if (currentDistance > maxDistance) {
+ maxDistance = currentDistance;
+ storage.maxDistance = maxDistance;
+ }
+ distanceTxt.setText('Distance: ' + currentDistance + 'm');
// Spawn fish periodically
fishSpawnTimer++;
if (fishSpawnTimer > 120 - level * 10) {
fishSpawnTimer = 0;