User prompt
Reduce the power of tornado to destroy on at least 2 signals but no more than 3 signals.
User prompt
Sharks start to orbit each other every 10-20 seconds and intertwine to create a vortex that transforms into a tornado as it goes upwards, and that hits the signal, it also knocks down 2 or 3 pieces, which fall off with the red signal fall effect and disappear at the bottom of the screen
User prompt
Sharks start to orbit each other every 10-20 seconds and intertwine to create a vortex that transforms into a tornado as it goes upwards, and along the vertical line that hits the signal, it also knocks down 2 or 3 pieces, which fall off with the red signal fall effect and disappear at the bottom of the screen
User prompt
Change coin spawning logic to only load coins between the 'MEMECOIN' word and the center height of the screen
User prompt
Coins can only be loaded under the word memecoin and at the height between the center of the screen.
User prompt
Until all the letters of the memecoin are collected after all the coins, the word should not flash ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Set the distance between score and memecoin text as the same as between high score and score texts
User prompt
Change memecoin text color from dark gray to a lighter gray
User prompt
More lightgrey
User prompt
Change the memecoin original text a lighter grey
User prompt
180 units was too much, try it only 100 units
User prompt
Do it
User prompt
Move shark and shark2 positions down by 321 units
User prompt
Move shark and shark2 positions down by 300 units
User prompt
The signal upward movement should be countinously and not directly
User prompt
Move shark and shark2 positions down by 200 units
User prompt
Move down the sharks by 200 units
User prompt
This signal upward movement is too fast. Slow down it to the half
User prompt
If one of the sharks touch a red signal, then the red signal moving up by 100-1000 units and Change color to green during upward movement
User prompt
If one of the sharks touch a red signal, then the red signal moving up by 100-1000 units and Change color to green during upward movement
User prompt
Set the distance between score and memecoin text as the same as between high score and score texts
User prompt
If the player picks up a coin, in the text 'MEMECOIN', recolor a letter to golden yellow in order from left to right ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
If the player has collected all 8 types of memecoins, write 'MEMECOIN' under the scoreboard in golden illuminated letters: 'MEMECOIN' After each coin collected, write out a letter from the word MEMECOIN IN ORDER FROM LEFT TO RIGHT and leave the earned letters displayed.
User prompt
Move all signals loading up that signals never touch sharks
User prompt
Please fix the bug: 'ReferenceError: timeTxt is not defined' in or related to this line: 'timeTxt.setText('TIME: ' + Math.floor(gameTime));' Line Number: 993
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var BonusText = Container.expand(function (amount, type) { var self = Container.call(this); // Create bonus text display var bonusAmount = amount || 100; var bonusText = new Text2('+' + bonusAmount + ' BONUS', { size: 100, fill: 0xFFD700 // Gold color }); bonusText.anchor.set(0.5, 0.5); self.addChild(bonusText); // Start animation self.animate = function () { // Initial state self.alpha = 0; self.scale.set(0.5); // Animation sequence - fade in with scale up tween(self, { alpha: 1, scaleX: 1.2, scaleY: 1.2 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { // Pulse effect tween(bonusText, { tint: 0xFFFFFF // Flash to white }, { duration: 200, easing: tween.easeIn, onFinish: function onFinish() { tween(bonusText, { tint: 0xFFD700 // Back to gold }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { // Fade out with float up tween(self, { alpha: 0, y: self.y - 100 }, { duration: 800, easing: tween.linear, onFinish: function onFinish() { self.active = false; } }); } }); } }); } }); }; self.active = true; return self; }); var Memecoin = Container.expand(function (type) { var self = Container.call(this); self.type = type || 'regular'; var assetId; if (self.type === 'dogmeme') { assetId = 'dogmeme'; } else if (self.type === 'shib') { assetId = 'shib'; } else if (self.type === 'pepe') { assetId = 'pepe'; } else if (self.type === 'loki') { assetId = 'loki'; } else if (self.type === 'volt') { assetId = 'volt'; } else if (self.type === 'cat') { assetId = 'cat'; } else if (self.type === 'president') { assetId = 'president'; } else { assetId = 'memecoin'; } var coinGraphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); self.speed = 6; self.active = true; self.collected = false; self.value = self.type === 'dogmeme' ? 100 : self.type === 'shib' ? 150 : self.type === 'pepe' ? 200 : self.type === 'loki' ? 250 : self.type === 'volt' ? 300 : self.type === 'cat' ? 350 : self.type === 'president' ? 400 : 50; // President worth more points than cat self.update = function () { if (!self.active) { return; } self.x -= self.speed; // Rotate coin counterclockwise (negative value for opposite direction) coinGraphics.rotation -= 0.03; // Remove when off screen if (self.x < -100) { self.active = false; } }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.vx = 0; self.vy = 0; self.gravity = 0.5; self.jumpPower = -25; // Increased jump power from -15 to -25 self.isJumping = false; self.isDead = false; self.lastWasIntersecting = false; self.jump = function () { // Find if player is standing on a green signal var standingOnGreenSignal = signals.some(function (s) { return player && s.type === 'green' && player.intersects(s) && Math.abs(player.y - (s.y - 275)) < 10; }); if (!self.isDead && (self.vy === 0 || standingOnGreenSignal)) { self.vy = self.jumpPower; self.isJumping = true; LK.getSound('jump').play(); } }; self.update = function () { if (self.isDead) { return; } // Store last position for collision detection self.lastY = self.y; // Apply gravity self.vy += self.gravity; // Apply movement self.y += self.vy; // Track if player is jumping or falling self.isJumping = self.vy !== 0; // Ground collision detection if (self.y > 2732 - playerGraphics.height / 2) { // Bottom of screen self.y = 2732 - playerGraphics.height / 2; self.vy = 0; self.isJumping = false; } }; return self; }); var Shark = Container.expand(function () { var self = Container.call(this); var sharkGraphics = self.attachAsset('shark', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.direction = 1; self.centerY = 2732 - sharkGraphics.height / 2; self.update = function () { // Keep shark at constant y position self.y = self.centerY; // Check if player exists and has fallen to shark's height level if (player && player.y > 2732 - 350) { // Shark hunts player - move toward player position self.direction = player.x > self.x ? 1 : -1; self.speed = 8; // Increase speed when hunting // Set correct shark orientation based on direction sharkGraphics.scale.x = self.direction; } else { // Normal back-and-forth movement when player isn't at shark level self.speed = 5; // Check if this is the second shark (compare to the global shark2 reference) if (this === shark2) { // Second shark moves in opposite pattern to first shark (alternating pattern) // Start swimming from right to left if (self.x <= 200 && self.direction === -1) { self.direction = 1; sharkGraphics.scale.x = 1; } else if (self.x >= 1900 && self.direction === 1) { self.direction = -1; sharkGraphics.scale.x = -1; } } else { // First shark patrols from left to right first if (self.x >= 1800 && self.direction === 1) { self.direction = -1; sharkGraphics.scale.x = -1; } else if (self.x <= 200 && self.direction === -1) { self.direction = 1; sharkGraphics.scale.x = 1; } } } // Apply movement self.x += self.speed * self.direction; }; return self; }); var Signal = Container.expand(function (type) { var self = Container.call(this); self.type = type || 'green'; var assetId = self.type === 'green' ? 'greenSignal' : 'redSignal'; // Generate random width variation factor between 0.7 and 1.3 var widthVariation = 0.7 + Math.random() * 0.6; var signalGraphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5, scaleX: 1 / 1.2 * widthVariation, scaleY: 1 / 1.2 }); // Rotate signal by 90 degrees to the left signalGraphics.rotation = -Math.PI / 2; // -90 degrees in radians self.speed = 3.5; self.active = true; self.shineTimer = 0; self.isShining = false; // Store the width variation for calculations self.widthVariation = widthVariation; // Create shine effect self.startShine = function () { if (!self.isShining) { self.isShining = true; var baseColor = self.type === 'green' ? 0xFFFFFF : 0xFFFFFF; // Shine effect with tween tween(signalGraphics, { alpha: 0.8 }, { duration: 300, easing: tween.easeIn, onFinish: function onFinish() { tween(signalGraphics, { alpha: 1 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { self.isShining = false; } }); } }); } }; // Turn green signal golden when touched by player // Create shimmer animation with color tint alternation self.startShimmerAnimation = function (targetGraphics) { self.shimmerAnimationActive = true; // Golden to bright white shimmer function shimmerCycle() { if (!self.shimmerAnimationActive) { return; } // Shimmer to bright white tween(targetGraphics, { tint: 0xFFFFFF // Bright white }, { duration: 600, easing: tween.easeInOut, onFinish: function onFinish() { if (!self.shimmerAnimationActive) { return; } // Return to gold tween(targetGraphics, { tint: 0xFFD700 // Gold color }, { duration: 600, easing: tween.easeInOut, onFinish: function onFinish() { if (self.shimmerAnimationActive) { // Continue animation cycle shimmerCycle(); } } }); } }); } // Start shimmer cycle shimmerCycle(); }; self.turnGolden = function () { if (self.type === 'green' && !self.isGolden) { self.isGolden = true; var goldenSignalGraphics = LK.getAsset('goldenSignal', { anchorX: 0.5, anchorY: 0.5, scaleX: 1 / 1.2, scaleY: 1 / 1.2 }); // Match the rotation of the current signal goldenSignalGraphics.rotation = signalGraphics.rotation; // Animation sequence for golden transformation tween(signalGraphics, { alpha: 0 }, { duration: 300, easing: tween.easeInOut, onFinish: function onFinish() { // Replace the green signal with golden one self.removeChild(signalGraphics); self.addChild(goldenSignalGraphics); // Start with small scale and expand goldenSignalGraphics.scale.set(0.5, 0.5); goldenSignalGraphics.alpha = 0.7; // Grow and fade in tween(goldenSignalGraphics, { scaleX: 1 / 1.2, scaleY: 1 / 1.2, alpha: 1 }, { duration: 400, easing: tween.easeOut, onFinish: function onFinish() { // Start shimmer animation after the initial grow animation self.startShimmerAnimation(goldenSignalGraphics); } }); } }); } }; self.falling = false; self.fallSpeed = 0; self.update = function () { if (!self.active) { // Clean up shimmer animation if it's running if (self.shimmerAnimationActive) { self.shimmerAnimationActive = false; } return; } // Handle falling behavior for red signals if (self.falling) { self.fallSpeed += 0.5; // Gravity effect self.y += self.fallSpeed; // Rotate while falling self.children[0].rotation += 0.05; // Deactivate when off bottom of screen if (self.y > 2732 + 100) { self.active = false; } return; // Skip normal behavior when falling } self.x -= self.speed; // Add random shine effect occasionally self.shineTimer++; if (self.shineTimer > 60 && Math.random() < 0.05) { self.startShine(); self.shineTimer = 0; } // Check for overlapping signals (only for active signals on screen) for (var i = 0; i < signals.length; i++) { var otherSignal = signals[i]; // Skip self and inactive signals if (otherSignal !== self && otherSignal.active) { // Check if signals are close to each other var xDistance = Math.abs(self.x - otherSignal.x); var yDistance = Math.abs(self.y - otherSignal.y); // If signals are overlapping or very close (within 20px) if (xDistance < 20 && yDistance < 20) { // Move this signal to avoid overlap if (self.type === 'green') { self.y -= 30; // Move green signals upward } else { self.y += 30; // Move red signals downward } // Trigger shine effect to show adjustment self.startShine(); } } } // Remove when off screen only if player is not jumping/falling // Make sure we keep signals visible while player is falling if (self.x < -200) { // Only deactivate if player doesn't exist or if player is not jumping/falling if (!player || !player.isJumping && player.vy <= 0) { self.active = false; } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x00142A }); /**** * Game Code ****/ // Game variables var player; var signals = []; var memecoins = []; var shark; var shark2; var isGameActive = true; var gameSpeed = 1; var lastSignalTime = 0; var lastCoinTime = 0; var score = 0; var scoreIncrement = 0.1; var distanceTraveled = 0; var gameTime = 0; var lastTimeUpdate = 0; var coinRound = { regular: false, dogmeme: false, shib: false, pepe: false, loki: false, volt: false, cat: false, president: false }; // UI elements var scoreTxt; var highScoreTxt; var timeTxt; // Initialize UI function initUI() { // High score text var highScore = storage.highScore || 0; highScoreTxt = new Text2('HIGH SCORE: ' + Math.floor(highScore), { size: 50, fill: 0xFFD700 }); highScoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(highScoreTxt); highScoreTxt.y = 0; // Score text scoreTxt = new Text2('SCORE: 0', { size: 70, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.y = 60; // Time counter var timeTxt = new Text2('TIME: 0', { size: 50, fill: 0xFFFFFF }); timeTxt.anchor.set(1, 0); // Right-aligned LK.gui.topRight.addChild(timeTxt); timeTxt.x = -20; // 20px from right edge timeTxt.y = 20; // 20px from top } // Initialize game world function initGame() { isGameActive = true; score = 0; distanceTraveled = 0; gameSpeed = 1; gameTime = 0; lastTimeUpdate = Date.now(); // Reset coin round tracking coinRound = { regular: false, dogmeme: false, shib: false, pepe: false, loki: false, volt: false, cat: false, president: false }; // Create player at top left, ready to fall player = new Player(); player.x = 200; player.y = 100; player.vy = 5; // Start with downward velocity game.addChild(player); // Create sharks shark = new Shark(); shark.y = 2732 - 100; game.addChild(shark); // Create second shark with opposite direction compared to first shark shark2 = new Shark(); shark2.x = 1500; // Position second shark on the right side shark2.y = 2732 - 100; shark2.direction = -1; // Start with opposite direction to make sharks swim alternately // Set correct orientation based on direction shark2.children[0].scale.x = -1; game.addChild(shark2); // Clear signals and coins clearEntities(); // Create initial signals that have already reached the left side var recentHeights = []; var heightThreshold = 100; // Further increased threshold to force more staggering for (var i = 0; i < 44; i++) { var signalType = Math.random() < 0.5 ? 'green' : 'red'; // For signals that are lower than the previous, make them red // For signals that are higher than the previous, make them green var lastY = 1500; if (signals.length > 0) { lastY = signals[signals.length - 1].y; } var newY; var willBeHigher = Math.random() < 0.5; if (willBeHigher) { // More pronounced ascent with increased height differences var heightDiff = 100 + Math.random() * 120; newY = lastY - heightDiff; signalType = 'green'; } else { // More pronounced descent with increased height differences var heightDiff = 100 + Math.random() * 120; newY = lastY + heightDiff; signalType = 'red'; } // Check if this height is too similar to recent heights var isTooSimilar = recentHeights.length > 0 && recentHeights.some(function (height) { return Math.abs(newY - height) < heightThreshold; }); // If too similar, adjust the height with smaller offsets to maintain gradual changes if (isTooSimilar) { if (signalType === 'green') { newY -= 60 + Math.random() * 40; // Reduced offset for more gradual separation } else { newY += 60 + Math.random() * 40; // Reduced offset for more gradual separation } } // Ensure signal stays within playable area newY = Math.max(800, Math.min(2200, newY)); // Store this height for future comparison recentHeights.push(newY); if (recentHeights.length > 10) { recentHeights.shift(); // Keep only last 10 heights } var signal = new Signal(signalType); // Position signals already at the left side of the screen signal.x = -150 + i * 50; // Distribute signals across the left edge signal.y = newY; signals.push(signal); // Make sure signals are placed behind the player if (player) { var playerIndex = game.getChildIndex(player); game.addChildAt(signal, playerIndex); } else { game.addChild(signal); } } // Start game music LK.playMusic('gameMusic'); } // Clear all entities function clearEntities() { for (var i = signals.length - 1; i >= 0; i--) { signals[i].destroy(); signals.splice(i, 1); } for (var i = memecoins.length - 1; i >= 0; i--) { memecoins[i].destroy(); memecoins.splice(i, 1); } } // Spawn signals function spawnSignal() { var currentTime = Date.now(); // Spawn signals at intervals that maintain consistent spacing regardless of score // At higher scores (1000+), we need to keep a minimum time between signals var baseInterval = 300; var minInterval = 150; var adjustedInterval = score > 1000 ? Math.max(minInterval, baseInterval / gameSpeed) : baseInterval / gameSpeed; if (currentTime - lastSignalTime > adjustedInterval) { // This ensures spacing remains consistent even at high scores var signal; var lastSignalY = 1500; // Default Y position if no signals exist // Get the Y position of the last signal to compare with if (signals.length > 0) { var lastSignal = signals[signals.length - 1]; lastSignalY = lastSignal.y; } // Calculate a new Y position var newY; var willBeHigher = Math.random() < 0.30; // 30% chance to go higher, 70% chance for red signals // Count consecutive red signals var redSignalCount = 0; // Find the last signal of each type for height comparison var lastGreenY = null; var lastRedY = null; // Track recent signal heights to prevent repetition var recentHeights = []; var heightThreshold = 100; // Further increased threshold to force more staggering // Collect the last few signal heights for comparison for (var i = signals.length - 1; i >= Math.max(0, signals.length - 15); i--) { recentHeights.push(signals[i].y); } // Find the last green and red signal Y positions for (var i = signals.length - 1; i >= 0; i--) { if (signals[i].type === 'green' && lastGreenY === null) { lastGreenY = signals[i].y; } if (signals[i].type === 'red' && lastRedY === null) { lastRedY = signals[i].y; } if (lastGreenY !== null && lastRedY !== null) { break; } } for (var i = signals.length - 1; i >= Math.max(0, signals.length - 5); i--) { if (signals[i] && signals[i].type === 'red') { redSignalCount++; } else { break; } } // Force green signal if we've had 5 reds in a row if (redSignalCount >= 5) { // Force green signal (must be higher) but with more gradual ascent newY = lastSignalY - (60 + Math.random() * 80); signal = new Signal('green'); } else if (willBeHigher) { // This signal will be higher (ascending) // More gradual height difference for green signals var heightDiff = 50 + Math.random() * 70; // Further reduced for more gradual ascent if (lastGreenY !== null && Math.abs(lastSignalY - heightDiff - lastGreenY) > 150) { // Limit the maximum height change between signals of same color heightDiff = Math.min(heightDiff, 150); } newY = lastSignalY - heightDiff; // Higher signals must be green signal = new Signal('green'); } else { // This signal will be lower (descending) // More gradual height difference for red signals var heightDiff = 50 + Math.random() * 70; // Further reduced for more gradual descent if (lastRedY !== null && Math.abs(lastSignalY + heightDiff - lastRedY) > 150) { // Limit the maximum height change between signals of same color heightDiff = Math.min(heightDiff, 150); } newY = lastSignalY + heightDiff; // Check if we would have too many consecutive red signals var wouldBeConsecutiveReds = redSignalCount + 1; if (wouldBeConsecutiveReds >= 5) { // Force this to be a green signal instead with gradual ascent newY = lastSignalY - (60 + Math.random() * 80); signal = new Signal('green'); } else { // Lower signals must be red signal = new Signal('red'); } } // Ensure signal stays within playable area newY = Math.max(800, Math.min(2200, newY)); // Additional check for signals that might be about to overlap (within 25px) var potentialOverlap = signals.filter(function (s) { // Only check signals that are still on screen or about to enter return s.active && s.x > -200 && s.x < 2300 && Math.abs(s.y - newY) < 25; }); // If there's potential overlap, adjust the Y position with smaller offsets if (potentialOverlap.length > 0) { if (signal.type === 'green') { newY -= 60 + Math.random() * 30; // Move green signals higher with smaller offset } else { newY += 60 + Math.random() * 30; // Move red signals lower with smaller offset } // Re-check playable area boundaries newY = Math.max(800, Math.min(2200, newY)); } // Add height variation to signals and prevent consecutive similar heights if (signal.type === 'green') { // Green signals with cascading heights - increased variations var greenOffset = Math.random() * 80 + 30; // Increased base offset for green signals // Check if this height is too similar to recent heights var isTooSimilar = recentHeights.some(function (height) { return Math.abs(newY - greenOffset - height) < heightThreshold; }); // If too similar, use larger offset to ensure more staggering if (isTooSimilar) { greenOffset += 70 + Math.random() * 50; // Larger offset for more staggering } newY -= greenOffset; } else if (signal.type === 'red') { // Red signals with cascading heights - increased variations var redOffset = Math.random() * 80 + 30; // Increased base offset for red signals // Check if this height is too similar to recent heights var isTooSimilar = recentHeights.some(function (height) { return Math.abs(newY + redOffset - height) < heightThreshold; }); // If too similar, use larger offset to ensure more staggering if (isTooSimilar) { redOffset += 70 + Math.random() * 50; // Larger offset for more staggering } newY += redOffset; } signal.x = 2048 + 150; signal.y = newY; signals.push(signal); // Add signal behind the player to ensure correct display order if (player) { var playerIndex = game.getChildIndex(player); game.addChildAt(signal, playerIndex); } else { game.addChild(signal); } lastSignalTime = currentTime; } } // Spawn memecoins function spawnMemecoin() { var currentTime = Date.now(); // Spawn coins less frequently than signals - increased interval from 6000 to 12000 if (currentTime - lastCoinTime > 12000 / gameSpeed) { // Find green signals that are still on screen (or about to enter) var greenSignals = signals.filter(function (signal) { return signal.type === 'green' && signal.x > -200 && signal.x < 2300; }); // Only spawn coin if we have green signals if (greenSignals.length > 0) { // Pick a random green signal var randomGreenSignal = greenSignals[Math.floor(Math.random() * greenSignals.length)]; // Check if we completed a round of all coin types var roundComplete = coinRound.regular && coinRound.dogmeme && coinRound.shib; if (roundComplete) { // Reset the round if all coin types have appeared coinRound = { regular: false, dogmeme: false, shib: false, pepe: false, loki: false, volt: false, cat: false, president: false }; } // Determine which coin types are still needed in current round var availableTypes = []; if (!coinRound.regular) { availableTypes.push('regular'); } if (!coinRound.dogmeme) { availableTypes.push('dogmeme'); } if (!coinRound.shib) { availableTypes.push('shib'); } if (!coinRound.pepe) { availableTypes.push('pepe'); } if (!coinRound.loki) { availableTypes.push('loki'); } if (!coinRound.volt) { availableTypes.push('volt'); } if (!coinRound.cat) { availableTypes.push('cat'); } if (!coinRound.president) { availableTypes.push('president'); } // Select a random coin type from available types var coinType = availableTypes[Math.floor(Math.random() * availableTypes.length)]; // Mark this type as spawned in current round coinRound[coinType] = true; var coin = new Memecoin(coinType); coin.x = 2048 + 150; // Position coin above the green signal (50-150px higher) coin.y = randomGreenSignal.y - randomGreenSignal.width / 2 - 100 - Math.random() * 100; memecoins.push(coin); // Add coin behind the player to ensure correct display order if (player) { var playerIndex = game.getChildIndex(player); game.addChildAt(coin, playerIndex); } else { game.addChild(coin); } lastCoinTime = currentTime; } } } // Check collisions between player and signals/coins/shark function checkCollisions() { if (!isGameActive) { return; } // Check signal collisions for (var i = 0; i < signals.length; i++) { var signal = signals[i]; if (signal.active && player.intersects(signal)) { // Store previous intersection state var wasIntersecting = player.lastWasIntersecting; player.lastWasIntersecting = true; // Only handle collision if this is a new intersection if (!wasIntersecting) { // Handle red signal falling when touched anywhere if (signal.type === 'red' && !signal.falling) { // Make red signal fall signal.falling = true; signal.fallSpeed = 2; // Trigger laser shine effect when starting to fall signal.startShine(); continue; // Skip other collision handling for this signal } // Check if player is above the signal and falling down // The signal is rotated 90 degrees left, so we need to detect its height properly // Signal's height is now its width because of the rotation var signalHeight = 50 / 1.2; // Original height divided by scale factor var signalWidth = 500 / 1.2; // Original width divided by scale factor var playerHeight = 150; // Player height // Calculate where the top of the signal is considering rotation if (player.y < signal.y - signalWidth / 2 && player.vy > 0) { if (signal.type === 'green') { // Land on green signals but don't automatically jump // Position player properly on top of the signal player.y = signal.y - signalWidth / 2 - playerHeight / 2; player.vy = 0; player.isJumping = false; // Trigger laser shine effect on green signal when landing signal.startShine(); // Turn the green signal golden when touched signal.turnGolden(); } else if (signal.type === 'red') { // Pass through red signals, ignore collision // Don't land on red signals, continue falling player.vy += player.gravity; player.isJumping = true; // Trigger laser shine effect on red signal when passing through signal.startShine(); } } } } else if (signal.active) { // If not intersecting this signal, reset lastWasIntersecting player.lastWasIntersecting = false; } } // Check memecoin collisions for (var i = 0; i < memecoins.length; i++) { var coin = memecoins[i]; // Track previous intersection state to prevent multiple collections in one frame if (!coin.lastWasIntersecting) { coin.lastWasIntersecting = false; } // Only collect if active, not already collected, and this is a new intersection if (coin.active && !coin.collected && player.intersects(coin) && !coin.lastWasIntersecting) { // Collect coin coin.collected = true; coin.lastWasIntersecting = true; // Add points based on coin type score += coin.value; scoreTxt.setText('SCORE: ' + Math.floor(score)); // Flash coin with different colors based on type var flashColor; if (coin.type === 'dogmeme') { flashColor = 0xFFA500; // Orange } else if (coin.type === 'shib') { flashColor = 0x00FF00; // Green } else if (coin.type === 'pepe') { flashColor = 0x00FF80; // Mint Green } else if (coin.type === 'loki') { flashColor = 0x00FFFF; // Cyan } else if (coin.type === 'volt') { flashColor = 0xFFFF00; // Yellow } else if (coin.type === 'cat') { flashColor = 0xFF00FF; // Magenta } else if (coin.type === 'president') { flashColor = 0x0000FF; // Blue } else { flashColor = 0xFFFFFF; // White } LK.effects.flashObject(coin, flashColor, 300); LK.getSound('coinCollect').play(); // Show bonus text for memecoin pickup (+100 BONUS) if (coin.type === 'memecoin') { // Create bonus text in top third of screen var bonusText = new BonusText(100); bonusText.x = 2048 / 2; bonusText.y = 2732 / 3; game.addChild(bonusText); bonusText.animate(); // Add extra 100 points for memecoin score += 100; scoreTxt.setText('SCORE: ' + Math.floor(score)); } tween(coin, { alpha: 0, scaleX: coin.type === 'president' ? 8 : coin.type === 'cat' ? 7 : coin.type === 'volt' ? 6 : coin.type === 'loki' ? 5 : coin.type === 'pepe' ? 4 : coin.type === 'shib' ? 3 : 2, // Biggest effect for president, then cat, then volt, then loki, then pepe, then shib scaleY: coin.type === 'president' ? 8 : coin.type === 'cat' ? 7 : coin.type === 'volt' ? 6 : coin.type === 'loki' ? 5 : coin.type === 'pepe' ? 4 : coin.type === 'shib' ? 3 : 2 // Biggest effect for president, then cat, then volt, then loki, then pepe, then shib }, { duration: coin.type === 'president' ? 1000 : coin.type === 'cat' ? 900 : coin.type === 'volt' ? 800 : coin.type === 'loki' ? 700 : coin.type === 'pepe' ? 600 : coin.type === 'shib' ? 500 : 300, // Longest animation for president, then cat, then volt, then loki, then pepe, then shib onFinish: function onFinish() { coin.active = false; } }); } else if (!player.intersects(coin)) { // Reset intersection state when player is no longer intersecting the coin coin.lastWasIntersecting = false; } } // Check shark collisions if (player.y > 2732 - player.height && player.intersects(shark) || player.y > 2732 - player.height && player.intersects(shark2)) { // Game over if player touches either shark gameOver(); } } // Clean up inactive entities function cleanupEntities() { // Remove inactive signals for (var i = signals.length - 1; i >= 0; i--) { // Only remove signals if player is not jumping or falling if (!signals[i].active) { // Add extra conditions to ensure we don't remove signals that player might need to land on if (!player || !player.isJumping && player.vy <= 0) { signals[i].destroy(); signals.splice(i, 1); } } } // Remove inactive coins for (var i = memecoins.length - 1; i >= 0; i--) { if (!memecoins[i].active) { memecoins[i].destroy(); memecoins.splice(i, 1); } } // Remove inactive bonus texts for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof BonusText && !game.children[i].active) { game.children[i].destroy(); } } } // Game over function gameOver() { isGameActive = false; player.isDead = true; // Play crash sound LK.getSound('crash').play(); // Flash screen red LK.effects.flashScreen(0xFF0000, 500); // Update high score var highScore = storage.highScore || 0; if (score > highScore) { storage.highScore = score; highScoreTxt.setText('HIGH SCORE: ' + Math.floor(score)); } // Show game over after a short delay LK.setTimeout(function () { LK.showGameOver(); }, 800); } // Input handling game.down = function (x, y, obj) { // Jump when tapping/clicking player.jump(); }; // Main game update loop game.update = function () { if (!isGameActive) { return; } // Update timer var currentTime = Date.now(); var elapsed = (currentTime - lastTimeUpdate) / 1000; // Convert to seconds gameTime += elapsed; timeTxt.setText('TIME: ' + Math.floor(gameTime)); lastTimeUpdate = currentTime; // Update score based on distance distanceTraveled += gameSpeed; score += scoreIncrement * gameSpeed; // Update score display occasionally to avoid text updates every frame if (Math.floor(score) % 5 === 0) { scoreTxt.setText('SCORE: ' + Math.floor(score)); } // Increase game speed gradually gameSpeed = 1 + distanceTraveled / 10000; // Spawn entities spawnSignal(); spawnMemecoin(); // Check collisions checkCollisions(); // Remove inactive entities cleanupEntities(); // Check if player fell off screen if (player.y > 2732 + 200) { gameOver(); } }; // Initialize UI and game initUI(); initGame(); // Track signal status globally game.onEntityDestroyed = function (entity) { // Keep track of destroyed entities if needed if (entity instanceof Signal && player) { // Keep signals around longer if player is falling or jumping if (player.isJumping || player.vy > 0) { // Return false to prevent deletion when player might need to land return false; } } return true; };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var BonusText = Container.expand(function (amount, type) {
var self = Container.call(this);
// Create bonus text display
var bonusAmount = amount || 100;
var bonusText = new Text2('+' + bonusAmount + ' BONUS', {
size: 100,
fill: 0xFFD700 // Gold color
});
bonusText.anchor.set(0.5, 0.5);
self.addChild(bonusText);
// Start animation
self.animate = function () {
// Initial state
self.alpha = 0;
self.scale.set(0.5);
// Animation sequence - fade in with scale up
tween(self, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
// Pulse effect
tween(bonusText, {
tint: 0xFFFFFF // Flash to white
}, {
duration: 200,
easing: tween.easeIn,
onFinish: function onFinish() {
tween(bonusText, {
tint: 0xFFD700 // Back to gold
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
// Fade out with float up
tween(self, {
alpha: 0,
y: self.y - 100
}, {
duration: 800,
easing: tween.linear,
onFinish: function onFinish() {
self.active = false;
}
});
}
});
}
});
}
});
};
self.active = true;
return self;
});
var Memecoin = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'regular';
var assetId;
if (self.type === 'dogmeme') {
assetId = 'dogmeme';
} else if (self.type === 'shib') {
assetId = 'shib';
} else if (self.type === 'pepe') {
assetId = 'pepe';
} else if (self.type === 'loki') {
assetId = 'loki';
} else if (self.type === 'volt') {
assetId = 'volt';
} else if (self.type === 'cat') {
assetId = 'cat';
} else if (self.type === 'president') {
assetId = 'president';
} else {
assetId = 'memecoin';
}
var coinGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 6;
self.active = true;
self.collected = false;
self.value = self.type === 'dogmeme' ? 100 : self.type === 'shib' ? 150 : self.type === 'pepe' ? 200 : self.type === 'loki' ? 250 : self.type === 'volt' ? 300 : self.type === 'cat' ? 350 : self.type === 'president' ? 400 : 50; // President worth more points than cat
self.update = function () {
if (!self.active) {
return;
}
self.x -= self.speed;
// Rotate coin counterclockwise (negative value for opposite direction)
coinGraphics.rotation -= 0.03;
// Remove when off screen
if (self.x < -100) {
self.active = false;
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.vx = 0;
self.vy = 0;
self.gravity = 0.5;
self.jumpPower = -25; // Increased jump power from -15 to -25
self.isJumping = false;
self.isDead = false;
self.lastWasIntersecting = false;
self.jump = function () {
// Find if player is standing on a green signal
var standingOnGreenSignal = signals.some(function (s) {
return player && s.type === 'green' && player.intersects(s) && Math.abs(player.y - (s.y - 275)) < 10;
});
if (!self.isDead && (self.vy === 0 || standingOnGreenSignal)) {
self.vy = self.jumpPower;
self.isJumping = true;
LK.getSound('jump').play();
}
};
self.update = function () {
if (self.isDead) {
return;
}
// Store last position for collision detection
self.lastY = self.y;
// Apply gravity
self.vy += self.gravity;
// Apply movement
self.y += self.vy;
// Track if player is jumping or falling
self.isJumping = self.vy !== 0;
// Ground collision detection
if (self.y > 2732 - playerGraphics.height / 2) {
// Bottom of screen
self.y = 2732 - playerGraphics.height / 2;
self.vy = 0;
self.isJumping = false;
}
};
return self;
});
var Shark = Container.expand(function () {
var self = Container.call(this);
var sharkGraphics = self.attachAsset('shark', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.direction = 1;
self.centerY = 2732 - sharkGraphics.height / 2;
self.update = function () {
// Keep shark at constant y position
self.y = self.centerY;
// Check if player exists and has fallen to shark's height level
if (player && player.y > 2732 - 350) {
// Shark hunts player - move toward player position
self.direction = player.x > self.x ? 1 : -1;
self.speed = 8; // Increase speed when hunting
// Set correct shark orientation based on direction
sharkGraphics.scale.x = self.direction;
} else {
// Normal back-and-forth movement when player isn't at shark level
self.speed = 5;
// Check if this is the second shark (compare to the global shark2 reference)
if (this === shark2) {
// Second shark moves in opposite pattern to first shark (alternating pattern)
// Start swimming from right to left
if (self.x <= 200 && self.direction === -1) {
self.direction = 1;
sharkGraphics.scale.x = 1;
} else if (self.x >= 1900 && self.direction === 1) {
self.direction = -1;
sharkGraphics.scale.x = -1;
}
} else {
// First shark patrols from left to right first
if (self.x >= 1800 && self.direction === 1) {
self.direction = -1;
sharkGraphics.scale.x = -1;
} else if (self.x <= 200 && self.direction === -1) {
self.direction = 1;
sharkGraphics.scale.x = 1;
}
}
}
// Apply movement
self.x += self.speed * self.direction;
};
return self;
});
var Signal = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'green';
var assetId = self.type === 'green' ? 'greenSignal' : 'redSignal';
// Generate random width variation factor between 0.7 and 1.3
var widthVariation = 0.7 + Math.random() * 0.6;
var signalGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1 / 1.2 * widthVariation,
scaleY: 1 / 1.2
});
// Rotate signal by 90 degrees to the left
signalGraphics.rotation = -Math.PI / 2; // -90 degrees in radians
self.speed = 3.5;
self.active = true;
self.shineTimer = 0;
self.isShining = false;
// Store the width variation for calculations
self.widthVariation = widthVariation;
// Create shine effect
self.startShine = function () {
if (!self.isShining) {
self.isShining = true;
var baseColor = self.type === 'green' ? 0xFFFFFF : 0xFFFFFF;
// Shine effect with tween
tween(signalGraphics, {
alpha: 0.8
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
tween(signalGraphics, {
alpha: 1
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
self.isShining = false;
}
});
}
});
}
};
// Turn green signal golden when touched by player
// Create shimmer animation with color tint alternation
self.startShimmerAnimation = function (targetGraphics) {
self.shimmerAnimationActive = true;
// Golden to bright white shimmer
function shimmerCycle() {
if (!self.shimmerAnimationActive) {
return;
}
// Shimmer to bright white
tween(targetGraphics, {
tint: 0xFFFFFF // Bright white
}, {
duration: 600,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (!self.shimmerAnimationActive) {
return;
}
// Return to gold
tween(targetGraphics, {
tint: 0xFFD700 // Gold color
}, {
duration: 600,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (self.shimmerAnimationActive) {
// Continue animation cycle
shimmerCycle();
}
}
});
}
});
}
// Start shimmer cycle
shimmerCycle();
};
self.turnGolden = function () {
if (self.type === 'green' && !self.isGolden) {
self.isGolden = true;
var goldenSignalGraphics = LK.getAsset('goldenSignal', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1 / 1.2,
scaleY: 1 / 1.2
});
// Match the rotation of the current signal
goldenSignalGraphics.rotation = signalGraphics.rotation;
// Animation sequence for golden transformation
tween(signalGraphics, {
alpha: 0
}, {
duration: 300,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Replace the green signal with golden one
self.removeChild(signalGraphics);
self.addChild(goldenSignalGraphics);
// Start with small scale and expand
goldenSignalGraphics.scale.set(0.5, 0.5);
goldenSignalGraphics.alpha = 0.7;
// Grow and fade in
tween(goldenSignalGraphics, {
scaleX: 1 / 1.2,
scaleY: 1 / 1.2,
alpha: 1
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
// Start shimmer animation after the initial grow animation
self.startShimmerAnimation(goldenSignalGraphics);
}
});
}
});
}
};
self.falling = false;
self.fallSpeed = 0;
self.update = function () {
if (!self.active) {
// Clean up shimmer animation if it's running
if (self.shimmerAnimationActive) {
self.shimmerAnimationActive = false;
}
return;
}
// Handle falling behavior for red signals
if (self.falling) {
self.fallSpeed += 0.5; // Gravity effect
self.y += self.fallSpeed;
// Rotate while falling
self.children[0].rotation += 0.05;
// Deactivate when off bottom of screen
if (self.y > 2732 + 100) {
self.active = false;
}
return; // Skip normal behavior when falling
}
self.x -= self.speed;
// Add random shine effect occasionally
self.shineTimer++;
if (self.shineTimer > 60 && Math.random() < 0.05) {
self.startShine();
self.shineTimer = 0;
}
// Check for overlapping signals (only for active signals on screen)
for (var i = 0; i < signals.length; i++) {
var otherSignal = signals[i];
// Skip self and inactive signals
if (otherSignal !== self && otherSignal.active) {
// Check if signals are close to each other
var xDistance = Math.abs(self.x - otherSignal.x);
var yDistance = Math.abs(self.y - otherSignal.y);
// If signals are overlapping or very close (within 20px)
if (xDistance < 20 && yDistance < 20) {
// Move this signal to avoid overlap
if (self.type === 'green') {
self.y -= 30; // Move green signals upward
} else {
self.y += 30; // Move red signals downward
}
// Trigger shine effect to show adjustment
self.startShine();
}
}
}
// Remove when off screen only if player is not jumping/falling
// Make sure we keep signals visible while player is falling
if (self.x < -200) {
// Only deactivate if player doesn't exist or if player is not jumping/falling
if (!player || !player.isJumping && player.vy <= 0) {
self.active = false;
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x00142A
});
/****
* Game Code
****/
// Game variables
var player;
var signals = [];
var memecoins = [];
var shark;
var shark2;
var isGameActive = true;
var gameSpeed = 1;
var lastSignalTime = 0;
var lastCoinTime = 0;
var score = 0;
var scoreIncrement = 0.1;
var distanceTraveled = 0;
var gameTime = 0;
var lastTimeUpdate = 0;
var coinRound = {
regular: false,
dogmeme: false,
shib: false,
pepe: false,
loki: false,
volt: false,
cat: false,
president: false
};
// UI elements
var scoreTxt;
var highScoreTxt;
var timeTxt;
// Initialize UI
function initUI() {
// High score text
var highScore = storage.highScore || 0;
highScoreTxt = new Text2('HIGH SCORE: ' + Math.floor(highScore), {
size: 50,
fill: 0xFFD700
});
highScoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(highScoreTxt);
highScoreTxt.y = 0;
// Score text
scoreTxt = new Text2('SCORE: 0', {
size: 70,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 60;
// Time counter
var timeTxt = new Text2('TIME: 0', {
size: 50,
fill: 0xFFFFFF
});
timeTxt.anchor.set(1, 0); // Right-aligned
LK.gui.topRight.addChild(timeTxt);
timeTxt.x = -20; // 20px from right edge
timeTxt.y = 20; // 20px from top
}
// Initialize game world
function initGame() {
isGameActive = true;
score = 0;
distanceTraveled = 0;
gameSpeed = 1;
gameTime = 0;
lastTimeUpdate = Date.now();
// Reset coin round tracking
coinRound = {
regular: false,
dogmeme: false,
shib: false,
pepe: false,
loki: false,
volt: false,
cat: false,
president: false
};
// Create player at top left, ready to fall
player = new Player();
player.x = 200;
player.y = 100;
player.vy = 5; // Start with downward velocity
game.addChild(player);
// Create sharks
shark = new Shark();
shark.y = 2732 - 100;
game.addChild(shark);
// Create second shark with opposite direction compared to first shark
shark2 = new Shark();
shark2.x = 1500; // Position second shark on the right side
shark2.y = 2732 - 100;
shark2.direction = -1; // Start with opposite direction to make sharks swim alternately
// Set correct orientation based on direction
shark2.children[0].scale.x = -1;
game.addChild(shark2);
// Clear signals and coins
clearEntities();
// Create initial signals that have already reached the left side
var recentHeights = [];
var heightThreshold = 100; // Further increased threshold to force more staggering
for (var i = 0; i < 44; i++) {
var signalType = Math.random() < 0.5 ? 'green' : 'red';
// For signals that are lower than the previous, make them red
// For signals that are higher than the previous, make them green
var lastY = 1500;
if (signals.length > 0) {
lastY = signals[signals.length - 1].y;
}
var newY;
var willBeHigher = Math.random() < 0.5;
if (willBeHigher) {
// More pronounced ascent with increased height differences
var heightDiff = 100 + Math.random() * 120;
newY = lastY - heightDiff;
signalType = 'green';
} else {
// More pronounced descent with increased height differences
var heightDiff = 100 + Math.random() * 120;
newY = lastY + heightDiff;
signalType = 'red';
}
// Check if this height is too similar to recent heights
var isTooSimilar = recentHeights.length > 0 && recentHeights.some(function (height) {
return Math.abs(newY - height) < heightThreshold;
});
// If too similar, adjust the height with smaller offsets to maintain gradual changes
if (isTooSimilar) {
if (signalType === 'green') {
newY -= 60 + Math.random() * 40; // Reduced offset for more gradual separation
} else {
newY += 60 + Math.random() * 40; // Reduced offset for more gradual separation
}
}
// Ensure signal stays within playable area
newY = Math.max(800, Math.min(2200, newY));
// Store this height for future comparison
recentHeights.push(newY);
if (recentHeights.length > 10) {
recentHeights.shift(); // Keep only last 10 heights
}
var signal = new Signal(signalType);
// Position signals already at the left side of the screen
signal.x = -150 + i * 50; // Distribute signals across the left edge
signal.y = newY;
signals.push(signal);
// Make sure signals are placed behind the player
if (player) {
var playerIndex = game.getChildIndex(player);
game.addChildAt(signal, playerIndex);
} else {
game.addChild(signal);
}
}
// Start game music
LK.playMusic('gameMusic');
}
// Clear all entities
function clearEntities() {
for (var i = signals.length - 1; i >= 0; i--) {
signals[i].destroy();
signals.splice(i, 1);
}
for (var i = memecoins.length - 1; i >= 0; i--) {
memecoins[i].destroy();
memecoins.splice(i, 1);
}
}
// Spawn signals
function spawnSignal() {
var currentTime = Date.now();
// Spawn signals at intervals that maintain consistent spacing regardless of score
// At higher scores (1000+), we need to keep a minimum time between signals
var baseInterval = 300;
var minInterval = 150;
var adjustedInterval = score > 1000 ? Math.max(minInterval, baseInterval / gameSpeed) : baseInterval / gameSpeed;
if (currentTime - lastSignalTime > adjustedInterval) {
// This ensures spacing remains consistent even at high scores
var signal;
var lastSignalY = 1500; // Default Y position if no signals exist
// Get the Y position of the last signal to compare with
if (signals.length > 0) {
var lastSignal = signals[signals.length - 1];
lastSignalY = lastSignal.y;
}
// Calculate a new Y position
var newY;
var willBeHigher = Math.random() < 0.30; // 30% chance to go higher, 70% chance for red signals
// Count consecutive red signals
var redSignalCount = 0;
// Find the last signal of each type for height comparison
var lastGreenY = null;
var lastRedY = null;
// Track recent signal heights to prevent repetition
var recentHeights = [];
var heightThreshold = 100; // Further increased threshold to force more staggering
// Collect the last few signal heights for comparison
for (var i = signals.length - 1; i >= Math.max(0, signals.length - 15); i--) {
recentHeights.push(signals[i].y);
}
// Find the last green and red signal Y positions
for (var i = signals.length - 1; i >= 0; i--) {
if (signals[i].type === 'green' && lastGreenY === null) {
lastGreenY = signals[i].y;
}
if (signals[i].type === 'red' && lastRedY === null) {
lastRedY = signals[i].y;
}
if (lastGreenY !== null && lastRedY !== null) {
break;
}
}
for (var i = signals.length - 1; i >= Math.max(0, signals.length - 5); i--) {
if (signals[i] && signals[i].type === 'red') {
redSignalCount++;
} else {
break;
}
}
// Force green signal if we've had 5 reds in a row
if (redSignalCount >= 5) {
// Force green signal (must be higher) but with more gradual ascent
newY = lastSignalY - (60 + Math.random() * 80);
signal = new Signal('green');
} else if (willBeHigher) {
// This signal will be higher (ascending)
// More gradual height difference for green signals
var heightDiff = 50 + Math.random() * 70; // Further reduced for more gradual ascent
if (lastGreenY !== null && Math.abs(lastSignalY - heightDiff - lastGreenY) > 150) {
// Limit the maximum height change between signals of same color
heightDiff = Math.min(heightDiff, 150);
}
newY = lastSignalY - heightDiff;
// Higher signals must be green
signal = new Signal('green');
} else {
// This signal will be lower (descending)
// More gradual height difference for red signals
var heightDiff = 50 + Math.random() * 70; // Further reduced for more gradual descent
if (lastRedY !== null && Math.abs(lastSignalY + heightDiff - lastRedY) > 150) {
// Limit the maximum height change between signals of same color
heightDiff = Math.min(heightDiff, 150);
}
newY = lastSignalY + heightDiff;
// Check if we would have too many consecutive red signals
var wouldBeConsecutiveReds = redSignalCount + 1;
if (wouldBeConsecutiveReds >= 5) {
// Force this to be a green signal instead with gradual ascent
newY = lastSignalY - (60 + Math.random() * 80);
signal = new Signal('green');
} else {
// Lower signals must be red
signal = new Signal('red');
}
}
// Ensure signal stays within playable area
newY = Math.max(800, Math.min(2200, newY));
// Additional check for signals that might be about to overlap (within 25px)
var potentialOverlap = signals.filter(function (s) {
// Only check signals that are still on screen or about to enter
return s.active && s.x > -200 && s.x < 2300 && Math.abs(s.y - newY) < 25;
});
// If there's potential overlap, adjust the Y position with smaller offsets
if (potentialOverlap.length > 0) {
if (signal.type === 'green') {
newY -= 60 + Math.random() * 30; // Move green signals higher with smaller offset
} else {
newY += 60 + Math.random() * 30; // Move red signals lower with smaller offset
}
// Re-check playable area boundaries
newY = Math.max(800, Math.min(2200, newY));
}
// Add height variation to signals and prevent consecutive similar heights
if (signal.type === 'green') {
// Green signals with cascading heights - increased variations
var greenOffset = Math.random() * 80 + 30; // Increased base offset for green signals
// Check if this height is too similar to recent heights
var isTooSimilar = recentHeights.some(function (height) {
return Math.abs(newY - greenOffset - height) < heightThreshold;
});
// If too similar, use larger offset to ensure more staggering
if (isTooSimilar) {
greenOffset += 70 + Math.random() * 50; // Larger offset for more staggering
}
newY -= greenOffset;
} else if (signal.type === 'red') {
// Red signals with cascading heights - increased variations
var redOffset = Math.random() * 80 + 30; // Increased base offset for red signals
// Check if this height is too similar to recent heights
var isTooSimilar = recentHeights.some(function (height) {
return Math.abs(newY + redOffset - height) < heightThreshold;
});
// If too similar, use larger offset to ensure more staggering
if (isTooSimilar) {
redOffset += 70 + Math.random() * 50; // Larger offset for more staggering
}
newY += redOffset;
}
signal.x = 2048 + 150;
signal.y = newY;
signals.push(signal);
// Add signal behind the player to ensure correct display order
if (player) {
var playerIndex = game.getChildIndex(player);
game.addChildAt(signal, playerIndex);
} else {
game.addChild(signal);
}
lastSignalTime = currentTime;
}
}
// Spawn memecoins
function spawnMemecoin() {
var currentTime = Date.now();
// Spawn coins less frequently than signals - increased interval from 6000 to 12000
if (currentTime - lastCoinTime > 12000 / gameSpeed) {
// Find green signals that are still on screen (or about to enter)
var greenSignals = signals.filter(function (signal) {
return signal.type === 'green' && signal.x > -200 && signal.x < 2300;
});
// Only spawn coin if we have green signals
if (greenSignals.length > 0) {
// Pick a random green signal
var randomGreenSignal = greenSignals[Math.floor(Math.random() * greenSignals.length)];
// Check if we completed a round of all coin types
var roundComplete = coinRound.regular && coinRound.dogmeme && coinRound.shib;
if (roundComplete) {
// Reset the round if all coin types have appeared
coinRound = {
regular: false,
dogmeme: false,
shib: false,
pepe: false,
loki: false,
volt: false,
cat: false,
president: false
};
}
// Determine which coin types are still needed in current round
var availableTypes = [];
if (!coinRound.regular) {
availableTypes.push('regular');
}
if (!coinRound.dogmeme) {
availableTypes.push('dogmeme');
}
if (!coinRound.shib) {
availableTypes.push('shib');
}
if (!coinRound.pepe) {
availableTypes.push('pepe');
}
if (!coinRound.loki) {
availableTypes.push('loki');
}
if (!coinRound.volt) {
availableTypes.push('volt');
}
if (!coinRound.cat) {
availableTypes.push('cat');
}
if (!coinRound.president) {
availableTypes.push('president');
}
// Select a random coin type from available types
var coinType = availableTypes[Math.floor(Math.random() * availableTypes.length)];
// Mark this type as spawned in current round
coinRound[coinType] = true;
var coin = new Memecoin(coinType);
coin.x = 2048 + 150;
// Position coin above the green signal (50-150px higher)
coin.y = randomGreenSignal.y - randomGreenSignal.width / 2 - 100 - Math.random() * 100;
memecoins.push(coin);
// Add coin behind the player to ensure correct display order
if (player) {
var playerIndex = game.getChildIndex(player);
game.addChildAt(coin, playerIndex);
} else {
game.addChild(coin);
}
lastCoinTime = currentTime;
}
}
}
// Check collisions between player and signals/coins/shark
function checkCollisions() {
if (!isGameActive) {
return;
}
// Check signal collisions
for (var i = 0; i < signals.length; i++) {
var signal = signals[i];
if (signal.active && player.intersects(signal)) {
// Store previous intersection state
var wasIntersecting = player.lastWasIntersecting;
player.lastWasIntersecting = true;
// Only handle collision if this is a new intersection
if (!wasIntersecting) {
// Handle red signal falling when touched anywhere
if (signal.type === 'red' && !signal.falling) {
// Make red signal fall
signal.falling = true;
signal.fallSpeed = 2;
// Trigger laser shine effect when starting to fall
signal.startShine();
continue; // Skip other collision handling for this signal
}
// Check if player is above the signal and falling down
// The signal is rotated 90 degrees left, so we need to detect its height properly
// Signal's height is now its width because of the rotation
var signalHeight = 50 / 1.2; // Original height divided by scale factor
var signalWidth = 500 / 1.2; // Original width divided by scale factor
var playerHeight = 150; // Player height
// Calculate where the top of the signal is considering rotation
if (player.y < signal.y - signalWidth / 2 && player.vy > 0) {
if (signal.type === 'green') {
// Land on green signals but don't automatically jump
// Position player properly on top of the signal
player.y = signal.y - signalWidth / 2 - playerHeight / 2;
player.vy = 0;
player.isJumping = false;
// Trigger laser shine effect on green signal when landing
signal.startShine();
// Turn the green signal golden when touched
signal.turnGolden();
} else if (signal.type === 'red') {
// Pass through red signals, ignore collision
// Don't land on red signals, continue falling
player.vy += player.gravity;
player.isJumping = true;
// Trigger laser shine effect on red signal when passing through
signal.startShine();
}
}
}
} else if (signal.active) {
// If not intersecting this signal, reset lastWasIntersecting
player.lastWasIntersecting = false;
}
}
// Check memecoin collisions
for (var i = 0; i < memecoins.length; i++) {
var coin = memecoins[i];
// Track previous intersection state to prevent multiple collections in one frame
if (!coin.lastWasIntersecting) {
coin.lastWasIntersecting = false;
}
// Only collect if active, not already collected, and this is a new intersection
if (coin.active && !coin.collected && player.intersects(coin) && !coin.lastWasIntersecting) {
// Collect coin
coin.collected = true;
coin.lastWasIntersecting = true;
// Add points based on coin type
score += coin.value;
scoreTxt.setText('SCORE: ' + Math.floor(score));
// Flash coin with different colors based on type
var flashColor;
if (coin.type === 'dogmeme') {
flashColor = 0xFFA500; // Orange
} else if (coin.type === 'shib') {
flashColor = 0x00FF00; // Green
} else if (coin.type === 'pepe') {
flashColor = 0x00FF80; // Mint Green
} else if (coin.type === 'loki') {
flashColor = 0x00FFFF; // Cyan
} else if (coin.type === 'volt') {
flashColor = 0xFFFF00; // Yellow
} else if (coin.type === 'cat') {
flashColor = 0xFF00FF; // Magenta
} else if (coin.type === 'president') {
flashColor = 0x0000FF; // Blue
} else {
flashColor = 0xFFFFFF; // White
}
LK.effects.flashObject(coin, flashColor, 300);
LK.getSound('coinCollect').play();
// Show bonus text for memecoin pickup (+100 BONUS)
if (coin.type === 'memecoin') {
// Create bonus text in top third of screen
var bonusText = new BonusText(100);
bonusText.x = 2048 / 2;
bonusText.y = 2732 / 3;
game.addChild(bonusText);
bonusText.animate();
// Add extra 100 points for memecoin
score += 100;
scoreTxt.setText('SCORE: ' + Math.floor(score));
}
tween(coin, {
alpha: 0,
scaleX: coin.type === 'president' ? 8 : coin.type === 'cat' ? 7 : coin.type === 'volt' ? 6 : coin.type === 'loki' ? 5 : coin.type === 'pepe' ? 4 : coin.type === 'shib' ? 3 : 2,
// Biggest effect for president, then cat, then volt, then loki, then pepe, then shib
scaleY: coin.type === 'president' ? 8 : coin.type === 'cat' ? 7 : coin.type === 'volt' ? 6 : coin.type === 'loki' ? 5 : coin.type === 'pepe' ? 4 : coin.type === 'shib' ? 3 : 2 // Biggest effect for president, then cat, then volt, then loki, then pepe, then shib
}, {
duration: coin.type === 'president' ? 1000 : coin.type === 'cat' ? 900 : coin.type === 'volt' ? 800 : coin.type === 'loki' ? 700 : coin.type === 'pepe' ? 600 : coin.type === 'shib' ? 500 : 300,
// Longest animation for president, then cat, then volt, then loki, then pepe, then shib
onFinish: function onFinish() {
coin.active = false;
}
});
} else if (!player.intersects(coin)) {
// Reset intersection state when player is no longer intersecting the coin
coin.lastWasIntersecting = false;
}
}
// Check shark collisions
if (player.y > 2732 - player.height && player.intersects(shark) || player.y > 2732 - player.height && player.intersects(shark2)) {
// Game over if player touches either shark
gameOver();
}
}
// Clean up inactive entities
function cleanupEntities() {
// Remove inactive signals
for (var i = signals.length - 1; i >= 0; i--) {
// Only remove signals if player is not jumping or falling
if (!signals[i].active) {
// Add extra conditions to ensure we don't remove signals that player might need to land on
if (!player || !player.isJumping && player.vy <= 0) {
signals[i].destroy();
signals.splice(i, 1);
}
}
}
// Remove inactive coins
for (var i = memecoins.length - 1; i >= 0; i--) {
if (!memecoins[i].active) {
memecoins[i].destroy();
memecoins.splice(i, 1);
}
}
// Remove inactive bonus texts
for (var i = game.children.length - 1; i >= 0; i--) {
if (game.children[i] instanceof BonusText && !game.children[i].active) {
game.children[i].destroy();
}
}
}
// Game over
function gameOver() {
isGameActive = false;
player.isDead = true;
// Play crash sound
LK.getSound('crash').play();
// Flash screen red
LK.effects.flashScreen(0xFF0000, 500);
// Update high score
var highScore = storage.highScore || 0;
if (score > highScore) {
storage.highScore = score;
highScoreTxt.setText('HIGH SCORE: ' + Math.floor(score));
}
// Show game over after a short delay
LK.setTimeout(function () {
LK.showGameOver();
}, 800);
}
// Input handling
game.down = function (x, y, obj) {
// Jump when tapping/clicking
player.jump();
};
// Main game update loop
game.update = function () {
if (!isGameActive) {
return;
}
// Update timer
var currentTime = Date.now();
var elapsed = (currentTime - lastTimeUpdate) / 1000; // Convert to seconds
gameTime += elapsed;
timeTxt.setText('TIME: ' + Math.floor(gameTime));
lastTimeUpdate = currentTime;
// Update score based on distance
distanceTraveled += gameSpeed;
score += scoreIncrement * gameSpeed;
// Update score display occasionally to avoid text updates every frame
if (Math.floor(score) % 5 === 0) {
scoreTxt.setText('SCORE: ' + Math.floor(score));
}
// Increase game speed gradually
gameSpeed = 1 + distanceTraveled / 10000;
// Spawn entities
spawnSignal();
spawnMemecoin();
// Check collisions
checkCollisions();
// Remove inactive entities
cleanupEntities();
// Check if player fell off screen
if (player.y > 2732 + 200) {
gameOver();
}
};
// Initialize UI and game
initUI();
initGame();
// Track signal status globally
game.onEntityDestroyed = function (entity) {
// Keep track of destroyed entities if needed
if (entity instanceof Signal && player) {
// Keep signals around longer if player is falling or jumping
if (player.isJumping || player.vy > 0) {
// Return false to prevent deletion when player might need to land
return false;
}
}
return true;
};
Grey shark, sideview. In-Game asset. 2d. High contrast. No shadows
Golden Dogecoin
Golden memecoin with sunglasses
shiba inu golden memecoin
Golden memecoin with Pepe
Golden coin with Floki
Golden coin with volt
Golden coin with cute catface
Golden coin with Trump and 'WILL FIX IT' Text
Lightning line. In-Game asset. 2d. High contrast. No shadows