User prompt
So when you reach 100 points you win
User prompt
So if the stone frog eats 3 lizards it will turn into the iron frog and if the Flycatcher frog If you eat 5 flies you will turn into a fly frog and both will be able to move to more space βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
So if you are the fly-frog you cannot transform into the stone frog and vice versa.
User prompt
So when you transform into an adult frog, lizards should appear on the cubes from time to time and if you eat two you will transform into the stone frog, but if you eat two more flies you will transform into the Flycatcher frog βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
So when you transform into the adult frog you can move through more space βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
So when you have 20 points the frog becomes an adult frog. βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
So the background is blue and waves should appear from time to time. βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Frog Evolution
Initial prompt
Create a game called frog evolution πΈ in this game the map is divided into cubes if you touch one your frog will move towards it sometimes flies appear on the cubes and you must move to the cubes Where the flies are
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Fly = Container.expand(function (gridX, gridY) { var self = Container.call(this); self.gridX = gridX; self.gridY = gridY; self.lifespan = 5000; // 5 seconds self.timeAlive = 0; var flyGraphics = self.attachAsset('fly', { anchorX: 0.5, anchorY: 0.5 }); // Buzzing animation function buzzAnimation() { if (self.parent) { tween(flyGraphics, { rotation: Math.random() * 0.3 - 0.15 }, { duration: 100 + Math.random() * 200, onFinish: buzzAnimation }); } } buzzAnimation(); self.update = function () { self.timeAlive += 16.67; // ~60fps if (self.timeAlive > self.lifespan) { self.remove(); } // Fade out near end of life if (self.timeAlive > self.lifespan * 0.7) { var fadeAmount = 1 - (self.timeAlive - self.lifespan * 0.7) / (self.lifespan * 0.3); flyGraphics.alpha = Math.max(0.3, fadeAmount); } }; self.remove = function () { var tile = grid[self.gridX][self.gridY]; tile.hasFly = false; var index = flies.indexOf(self); if (index > -1) { flies.splice(index, 1); } self.destroy(); }; self["catch"] = function () { LK.setScore(LK.getScore() + 10); scoreTxt.setText(LK.getScore()); if (LK.getScore() % 50 === 0) { frog.evolve(); } LK.getSound('catchFly').play(); self.remove(); }; return self; }); var Frog = Container.expand(function () { var self = Container.call(this); self.gridX = 0; self.gridY = 0; self.isMoving = false; self.evolutionLevel = 1; var frogGraphics = self.attachAsset('frog', { anchorX: 0.5, anchorY: 0.5 }); self.setGridPosition = function (gridX, gridY) { self.gridX = gridX; self.gridY = gridY; var worldPos = gridToWorld(gridX, gridY); self.x = worldPos.x; self.y = worldPos.y; }; self.moveToGrid = function (gridX, gridY, callback) { if (self.isMoving) return; self.isMoving = true; self.gridX = gridX; self.gridY = gridY; var worldPos = gridToWorld(gridX, gridY); // Animate hop tween(self, { y: worldPos.y - 60 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { x: worldPos.x, y: worldPos.y }, { duration: 200, easing: tween.easeIn, onFinish: function onFinish() { self.isMoving = false; if (callback) callback(); } }); } }); LK.getSound('hop').play(); }; self.evolve = function () { self.evolutionLevel++; var newColor = [0x228b22, 0x32cd32, 0x7fff00, 0xadff2f, 0x9acd32][Math.min(self.evolutionLevel - 1, 4)]; frogGraphics.tint = newColor; // Scale animation for evolution tween(frogGraphics, { scaleX: 1.3, scaleY: 1.3 }, { duration: 300, onFinish: function onFinish() { tween(frogGraphics, { scaleX: 1, scaleY: 1 }, { duration: 300 }); } }); }; return self; }); var GridTile = Container.expand(function (gridX, gridY) { var self = Container.call(this); self.gridX = gridX; self.gridY = gridY; self.hasFly = false; self.isValidMove = false; var tileGraphics = self.attachAsset('gridTile', { anchorX: 0.5, anchorY: 0.5 }); var validMoveGraphics = self.attachAsset('validMove', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); self.showValidMove = function (show) { self.isValidMove = show; tween(validMoveGraphics, { alpha: show ? 0.5 : 0 }, { duration: 200 }); }; self.down = function (x, y, obj) { if (self.isValidMove && !frog.isMoving) { moveFrogTo(self.gridX, self.gridY); } }; return self; }); var Wave = Container.expand(function () { var self = Container.call(this); self.rings = []; self.maxRadius = 300; self.speed = 2; // Create multiple concentric circles for wave effect for (var i = 0; i < 3; i++) { var ring = LK.getAsset('wave_ring_' + i, { width: 20, height: 20, color: 0x87ceeb, shape: 'ellipse' }); ring.alpha = 0.3 - i * 0.1; ring.scaleX = 0.1; ring.scaleY = 0.1; self.rings.push(ring); self.addChild(ring); } self.update = function () { var allFinished = true; for (var i = 0; i < self.rings.length; i++) { var ring = self.rings[i]; if (ring.scaleX < self.maxRadius / 10) { ring.scaleX += self.speed * 0.01; ring.scaleY += self.speed * 0.01; ring.alpha *= 0.995; allFinished = false; } } if (allFinished || self.rings[0].alpha < 0.01) { self.remove(); } }; self.remove = function () { var index = waves.indexOf(self); if (index > -1) { waves.splice(index, 1); } self.destroy(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x4169e1 }); /**** * Game Code ****/ var GRID_SIZE = 200; var GRID_WIDTH = 10; var GRID_HEIGHT = 12; var GRID_OFFSET_X = (2048 - GRID_WIDTH * GRID_SIZE) / 2; var GRID_OFFSET_Y = 300; var grid = []; var frog; var flies = []; var flySpawnTimer = 0; var flySpawnInterval = 3000; // 3 seconds initially var waves = []; var waveTimer = 0; var waveInterval = 2000; // Create waves every 2 seconds // Create score display var scoreTxt = new Text2('0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Helper functions function gridToWorld(gridX, gridY) { return { x: GRID_OFFSET_X + gridX * GRID_SIZE + GRID_SIZE / 2, y: GRID_OFFSET_Y + gridY * GRID_SIZE + GRID_SIZE / 2 }; } function isAdjacent(x1, y1, x2, y2) { var dx = Math.abs(x1 - x2); var dy = Math.abs(y1 - y2); return dx <= 1 && dy <= 1 && !(dx === 0 && dy === 0); } function clearValidMoves() { for (var x = 0; x < GRID_WIDTH; x++) { for (var y = 0; y < GRID_HEIGHT; y++) { grid[x][y].showValidMove(false); } } } function showValidMoves() { clearValidMoves(); for (var x = 0; x < GRID_WIDTH; x++) { for (var y = 0; y < GRID_HEIGHT; y++) { if (isAdjacent(frog.gridX, frog.gridY, x, y)) { grid[x][y].showValidMove(true); } } } } function moveFrogTo(gridX, gridY) { clearValidMoves(); frog.moveToGrid(gridX, gridY, function () { // Check if frog caught a fly var tile = grid[gridX][gridY]; if (tile.hasFly) { for (var i = 0; i < flies.length; i++) { if (flies[i].gridX === gridX && flies[i].gridY === gridY) { flies[i]["catch"](); break; } } } showValidMoves(); }); } function spawnFly() { var attempts = 0; var maxAttempts = 50; while (attempts < maxAttempts) { var x = Math.floor(Math.random() * GRID_WIDTH); var y = Math.floor(Math.random() * GRID_HEIGHT); if (!grid[x][y].hasFly && !(x === frog.gridX && y === frog.gridY)) { var fly = new Fly(x, y); var worldPos = gridToWorld(x, y); fly.x = worldPos.x; fly.y = worldPos.y - 20; // Hover above tile grid[x][y].hasFly = true; flies.push(fly); game.addChild(fly); break; } attempts++; } } // Initialize grid for (var x = 0; x < GRID_WIDTH; x++) { grid[x] = []; for (var y = 0; y < GRID_HEIGHT; y++) { var tile = new GridTile(x, y); var worldPos = gridToWorld(x, y); tile.x = worldPos.x; tile.y = worldPos.y; grid[x][y] = tile; game.addChild(tile); } } // Initialize frog frog = new Frog(); frog.setGridPosition(GRID_WIDTH / 2, GRID_HEIGHT - 2); game.addChild(frog); // Show initial valid moves showValidMoves(); // Spawn first fly spawnFly(); game.update = function () { // Update flies for (var i = flies.length - 1; i >= 0; i--) { if (flies[i].update) { flies[i].update(); } } // Update waves for (var i = waves.length - 1; i >= 0; i--) { if (waves[i].update) { waves[i].update(); } } // Spawn waves periodically waveTimer += 16.67; if (waveTimer >= waveInterval) { waveTimer = 0; var wave = new Wave(); // Random position on screen wave.x = Math.random() * 2048; wave.y = Math.random() * 2732; waves.push(wave); game.addChild(wave); // Vary wave spawn timing waveInterval = 1500 + Math.random() * 2000; } // Spawn flies periodically flySpawnTimer += 16.67; if (flySpawnTimer >= flySpawnInterval) { flySpawnTimer = 0; spawnFly(); // Increase difficulty - spawn flies faster as score increases if (LK.getScore() > 0) { flySpawnInterval = Math.max(1500, 3000 - LK.getScore() / 10 * 50); } } };
===================================================================
--- original.js
+++ change.js
@@ -155,14 +155,57 @@
}
};
return self;
});
+var Wave = Container.expand(function () {
+ var self = Container.call(this);
+ self.rings = [];
+ self.maxRadius = 300;
+ self.speed = 2;
+ // Create multiple concentric circles for wave effect
+ for (var i = 0; i < 3; i++) {
+ var ring = LK.getAsset('wave_ring_' + i, {
+ width: 20,
+ height: 20,
+ color: 0x87ceeb,
+ shape: 'ellipse'
+ });
+ ring.alpha = 0.3 - i * 0.1;
+ ring.scaleX = 0.1;
+ ring.scaleY = 0.1;
+ self.rings.push(ring);
+ self.addChild(ring);
+ }
+ self.update = function () {
+ var allFinished = true;
+ for (var i = 0; i < self.rings.length; i++) {
+ var ring = self.rings[i];
+ if (ring.scaleX < self.maxRadius / 10) {
+ ring.scaleX += self.speed * 0.01;
+ ring.scaleY += self.speed * 0.01;
+ ring.alpha *= 0.995;
+ allFinished = false;
+ }
+ }
+ if (allFinished || self.rings[0].alpha < 0.01) {
+ self.remove();
+ }
+ };
+ self.remove = function () {
+ var index = waves.indexOf(self);
+ if (index > -1) {
+ waves.splice(index, 1);
+ }
+ self.destroy();
+ };
+ return self;
+});
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x2d5016
+ backgroundColor: 0x4169e1
});
/****
* Game Code
@@ -176,8 +219,11 @@
var frog;
var flies = [];
var flySpawnTimer = 0;
var flySpawnInterval = 3000; // 3 seconds initially
+var waves = [];
+var waveTimer = 0;
+var waveInterval = 2000; // Create waves every 2 seconds
// Create score display
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
@@ -274,8 +320,27 @@
if (flies[i].update) {
flies[i].update();
}
}
+ // Update waves
+ for (var i = waves.length - 1; i >= 0; i--) {
+ if (waves[i].update) {
+ waves[i].update();
+ }
+ }
+ // Spawn waves periodically
+ waveTimer += 16.67;
+ if (waveTimer >= waveInterval) {
+ waveTimer = 0;
+ var wave = new Wave();
+ // Random position on screen
+ wave.x = Math.random() * 2048;
+ wave.y = Math.random() * 2732;
+ waves.push(wave);
+ game.addChild(wave);
+ // Vary wave spawn timing
+ waveInterval = 1500 + Math.random() * 2000;
+ }
// Spawn flies periodically
flySpawnTimer += 16.67;
if (flySpawnTimer >= flySpawnInterval) {
flySpawnTimer = 0;