Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'to')' in or related to this line: 'tween(scoreText).to({' Line Number: 898
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: tween.get is not a function' in or related to this line: 'tween.get(scoreText).to({' Line Number: 898
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'to')' in or related to this line: 'tween(scoreText).to({' Line Number: 898
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: tween.get is not a function' in or related to this line: 'tween.get(scoreText).to({' Line Number: 898
User prompt
Please fix the bug: 'TypeError: tween.to is not a function' in or related to this line: 'tween.to(scoreText, {' Line Number: 898
User prompt
Please fix the bug: 'TypeError: tween.get is not a function' in or related to this line: 'tween.get(scoreText).to({' Line Number: 898
User prompt
Please fix the bug: 'TypeError: tween.to is not a function' in or related to this line: 'tween.to(scoreText, {' Line Number: 898
User prompt
Please fix the bug: 'TypeError: tween.get is not a function' in or related to this line: 'tween.get(scoreText).to({' Line Number: 898
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 770
Code edit (1 edits merged)
Please save this source code
User prompt
delete input username area on code
User prompt
Create an ASCII-style infinite arcade game with the following flow and features: 🌟 START SCREEN: - First, show a centered screen with a square input box where the user can enter their username (max 10 characters). - The box should be outlined like: +----------+ | username | +----------+ - Below it, a [ START ] button should appear after text is entered. - Save the username and display it in the game and profile. 🕹 IN-GAME FEATURES: - The player controls a stick figure at the bottom using left/right arrows. - Show health as stars (★) directly above the character. - The player starts with 3★ health, max 5★. - Enemies fall randomly from top. Some examples: - "LOL", "UwU", "=====", "!!!", ":((", "RIP" - Decorative falling objects also appear but do nothing: - "<3", "⚔", "~*", "✿", "彡☆", etc. - Show current score at the top. 🛡 SHIELD RULES: - Only drop [SHIELD] once when score hits multiples of 100 (100, 200, 300...). - Do NOT drop [SHIELD] continuously or randomly. - Picking up a [SHIELD] adds +1★ (up to 5★). - Hitting an enemy removes -1★. - Game ends when health reaches 0. 💾 PROFILE SYSTEM: - Add a [PROFILE] screen that shows unlocked score milestones with checkboxes: - [✓] Score 10 - [✓] Score 25 - ... - [ ] Score 1000 - Display current username at the top of the profile screen. - Show [ BACK ] to return to game. 🎁 COSMETICS: - Add a small square border around the player (like a tag/skin frame) in-game. - This border should change every 500 score (e.g., default → stars → flames → cyber). - These are cosmetic only, don't affect gameplay. 🧠 NOTES: - Use only ASCII art. - No sound or plugins. - Ensure shields do not flood the screen and only drop per milestone.
User prompt
Create an infinite ASCII-style arcade game where: - The player controls a stick figure at the bottom of the screen using on-screen left/right controls. - Random objects fall from the top of the screen. These include: - Enemies like: "LOL", "UwU", "=====", "!!!" - Visual decorations: "<3", "⚔", "~*", "★彡", "✿", "☠", etc. (harmless) - Only the enemy words can hurt the player. 🛡 Shields: - The player starts with 3 health, displayed as stars (★) above the character. - Every time the score reaches a multiple of 100 (e.g., 100, 200, 300), spawn **one** [SHIELD] item only once. - After that, do not spawn any more shields until the next 100-point threshold is reached. - When the player touches a [SHIELD], restore +1 health (up to a max of 5 stars). - Shields should not flood the screen. They should only drop at those specific moments. ❤️ Health: - Getting hit by an enemy reduces 1 star. - Getting a shield adds 1 star (max 5). - Health is shown as ★★ directly above the player. 🌟 Other: - Score is shown at the top. - Falling speed of enemies increases gradually. - Use only ASCII visuals. No sound, no plugins. - Decorative ASCII objects can be added for visual flair, but only enemies affect the player. IMPORTANT: Shields should not spawn continuously or randomly — only once per 100-point milestone.
User prompt
Create an infinite ASCII-style arcade game where: - The player controls a stick figure at the bottom of the screen using on-screen left/right controls. - Random objects fall from the top of the screen. These include: - Enemies like: "LOL", "UwU", "=====", "!!!" - Visual decorations: "<3", "⚔", "~*", "★彡", "✿", "☠", and other harmless aesthetic items that are just for style - Only the enemy words can hurt the player. The player has 3 health at the start, and health is displayed as stars (★) directly **above the character** (e.g., `★★★`). - If the player touches an enemy, lose 1 health (remove one star). - Every 100 score, drop one "[SHIELD]" item from the top. If the player collects it, restore +1 health (up to 5 stars). - Shields do not fall randomly, only exactly once per 100 points. Make the falling speed of objects increase over time to make the game harder. Show the current score at the top of the screen. Make the visual style fun and chaotic with random harmless ASCII art mixed in, but only the defined enemy words can reduce health. Use only ASCII characters, no plugins, no sound, and ensure everything loops smoothly.
User prompt
Create an infinite ASCII-style game where: - The player controls a stick figure character at the bottom of the screen using on-screen left and right buttons. - Enemies fall from the top with random ASCII words like "LOL", "UwU", "=====", and similar. - If an enemy touches the player, the player loses 1 health. - Occasionally, "[SHIELD]" objects fall from the top. If the player collects a shield, they gain +1 health (up to a maximum of 5). Health is represented by stars (★) displayed **above the player character**. For example: - 3 health = `★★★` - 1 health = `★` When collecting a shield, add 1 star (up to 5). When hit by an enemy, remove 1 star. Display the player's score at the top of the screen. Make the falling speed of enemies slowly increase over time to add difficulty. Use only ASCII characters for visuals. No sound or plugin imports needed.
User prompt
Please fix the bug: 'powerups is not defined' in or related to this line: 'if (powerups) {' Line Number: 420
User prompt
Please fix the bug: 'leftBtn is not defined' in or related to this line: 'if (leftBtn) {' Line Number: 410
User prompt
Please fix the bug: 'healthText is not defined' in or related to this line: 'if (healthText) {' Line Number: 405
User prompt
Create an infinite ASCII arcade-style game where the player controls a stick figure at the bottom of the screen using left and right arrow buttons or on-screen controls. Enemies fall from the top of the screen using ASCII characters like "LOL", "UwU", "=====", and "!!!". If an enemy touches the player, the player loses 1 health. The player starts with 3 health. Sometimes, special items like "[SHIELD]" fall down. If the player collects a shield, they gain +1 health (up to a maximum of 5). The game gets harder over time by increasing the speed of falling objects. Display the player's score and current health at the top of the screen. Score increases over time and when dodging enemies. Keep the visuals minimalist using only ASCII characters. No sound or plugin support is needed. Make sure everything works smoothly in a loop without crashing or stopping. Optional: - Every 100 points, show a cosmetic reward like a new visual tag above the player's head.
User prompt
Add another blocks for funny on the game
Code edit (1 edits merged)
Please save this source code
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { milestones: [] }); /**** * Classes ****/ // On-screen left/right controls for mobile var AsciiButton = Container.expand(function () { var self = Container.call(this); self.txt = self.addChild(new Text2("", { size: 120, fill: 0xFFFFFF, font: "monospace" })); self.txt.anchor.set(0.5, 0.5); self.setLabel = function (label) { self.txt.setText(label); }; return self; }); // ASCII Obstacle var AsciiObstacle = Container.expand(function () { var self = Container.call(this); // Randomly choose an ASCII obstacle shape, now with more funny blocks! var shapes = ["#####", "=====", "-----", "|||||", "oOoOo", // funny bouncy "UwU", // cute face "0v0v0", // zigzag "><(((º>", // fish "LOL", // meme ":-)", // smiley "ZZZZZ", // sleepy "MOO", // cow "BEEP", // robot "!!!", // exclamation "T_T", // sad face "12345", // numbers "abcde" // letters ]; var ascii = shapes[Math.floor(Math.random() * shapes.length)]; var obsText = self.addChild(new Text2(ascii, { size: 90, fill: 0xFF5555, font: "monospace" })); obsText.anchor.set(0.5, 0.5); // For collision, define a bounding box self.getBounds = function () { return { x: self.x - 225, y: self.y - 45, width: 450, height: 90 }; }; // Move down at a variable speed (default 12, can be overridden) self.speed = 12; self.update = function () { if (typeof self.lastY === "undefined") { self.lastY = self.y; } self.y += self.speed; self.lastY = self.y; }; return self; }); // ASCII Player Character var AsciiPlayer = Container.expand(function () { var self = Container.call(this); // ASCII art for the player (simple stick figure) var asciiArt = [" O ", " /|\\ ", " / \\ "].join("\n"); var playerText = self.addChild(new Text2(asciiArt, { size: 90, fill: 0xFFFFFF, font: "monospace" })); playerText.anchor.set(0.5, 0.5); // Cosmetic tag above head (for rewards) self.tagText = self.addChild(new Text2("", { size: 60, fill: 0x00FF99, font: "monospace" })); self.tagText.anchor.set(0.5, 1); self.tagText.x = 0; self.tagText.y = -140; // NEW: Container for power-up effects self.effectsContainer = self.addChild(new Container()); // For collision, define a bounding box self.getBounds = function () { return { x: self.x - 90, y: self.y - 135, width: 180, height: 270 }; }; return self; }); // NEW: Power-up: Score Multiplier var ScoreMultiplierPowerup = Container.expand(function () { var self = Container.call(this); var multiplierText = self.addChild(new Text2("[x2 SCORE]", { size: 80, fill: 0xFF00FF, // Magenta color font: "monospace" })); multiplierText.anchor.set(0.5, 0.5); self.speed = 10; self.getBounds = function () { return { x: self.x - 120, y: self.y - 40, width: 240, height: 80 }; }; self.update = function () { if (typeof self.lastY === "undefined") { self.lastY = self.y; } self.y += self.speed; self.lastY = self.y; }; return self; }); // Power-up: Shield var ShieldPowerup = Container.expand(function () { var self = Container.call(this); var shieldText = self.addChild(new Text2("[SHIELD]", { size: 80, fill: 0x00FFFF, font: "monospace" })); shieldText.anchor.set(0.5, 0.5); self.speed = 10; self.getBounds = function () { return { x: self.x - 120, y: self.y - 40, width: 240, height: 80 }; }; self.update = function () { if (typeof self.lastY === "undefined") { self.lastY = self.y; } self.y += self.speed; self.lastY = self.y; }; return self; }); // NEW: Power-up: Speed Boost var SpeedBoostPowerup = Container.expand(function () { var self = Container.call(this); var speedBoostText = self.addChild(new Text2("[SPEED]", { size: 80, fill: 0xFFFF00, // Yellow color font: "monospace" })); speedBoostText.anchor.set(0.5, 0.5); self.speed = 10; self.getBounds = function () { return { x: self.x - 120, y: self.y - 40, width: 240, height: 80 }; }; self.update = function () { if (typeof self.lastY === "undefined") { self.lastY = self.y; } self.y += self.speed; self.lastY = self.y; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181818 }); /**** * Game Code ****/ // NEW: Dynamic background layers var backgroundText1, backgroundText2; var backgroundSpeed = 1; // Adjust for desired scroll speed function createBackgroundLayer(yPos) { var bgArt = ""; for (var i = 0; i < 20; i++) { for (var j = 0; j < 50; j++) { bgArt += String.fromCharCode(33 + Math.floor(Math.random() * 94)); } bgArt += "\n"; } var bgText = new Text2(bgArt, { size: 50, fill: 0x282828, font: "monospace" }); bgText.anchor.set(0.5, 0); bgText.x = 2048 / 2; bgText.y = yPos; game.addChild(bgText); return bgText; } // Initialize two background layers for seamless scrolling backgroundText1 = createBackgroundLayer(0); backgroundText2 = createBackgroundLayer(-2732); // Position above the first one // Game states var STATE_MENU = 0; var STATE_PLAY = 1; var STATE_PROFILE = 2; var gameState = STATE_MENU; // Main elements var player; var obstacles = []; var powerups = []; var score = 0; var currentScoreMultiplier = 1; // Track the current score multiplier var bestScore = storage.bestScore || 0; var milestones = storage.milestones || []; var milestoneThresholds = [10, 25, 50, 100, 200, 500, 1000]; // GUI elements var scoreText, bestText, menuTitle, startBtn, profileBtn, profilePanel, profileTitle, profileMilestones, backBtn; var healthText; var leftBtn; var rightBtn; // Game variables var health = 3; var maxHealth = 5; var combo = 0; var lastCosmetic = -1; var cosmeticTags = ["", "ASCII MAN", "ASCII PRO", "RUNNER", "ELITE", "ASCII KING", "GODMODE", "AMAZİNG", "777", "SHİT", "ADMİN"]; // Utility: collision detection (AABB) function intersects(a, b) { var ab = a.getBounds(); var bb = b.getBounds(); return ab.x < bb.x + bb.width && ab.x + ab.width > bb.x && ab.y < bb.y + bb.height && ab.y + ab.height > bb.y; } // --- MENU UI --- function showMenu() { gameState = STATE_MENU; clearGame(); clearProfile(); // Title menuTitle = new Text2("ASCII RUNNER", { size: 140, fill: 0xFFFFFF, font: "monospace" }); menuTitle.anchor.set(0.5, 0); menuTitle.x = 2048 / 2; menuTitle.y = 300; game.addChild(menuTitle); // Start Button (always enabled, no username required) startBtn = new Text2("[ START ]", { size: 110, fill: 0x00FF99, font: "monospace" }); startBtn.anchor.set(0.5, 0.5); startBtn.x = 2048 / 2; startBtn.y = 900; startBtn.alpha = 1; startBtn.down = function () { clearMenu(); startGame(); }; game.addChild(startBtn); // Profile Button profileBtn = new Text2("[ PROFILE ]", { size: 90, fill: 0xCCCCCC, font: "monospace" }); profileBtn.anchor.set(0.5, 0.5); profileBtn.x = 2048 / 2; profileBtn.y = 1600; game.addChild(profileBtn); // Best Score bestText = new Text2("Best: " + bestScore, { size: 80, fill: 0xAAAAAA, font: "monospace" }); bestText.anchor.set(0.5, 0.5); bestText.x = 2048 / 2; bestText.y = 1800; game.addChild(bestText); // Button handlers profileBtn.down = function () { showProfile(); }; } // --- PROFILE UI --- function showProfile() { gameState = STATE_PROFILE; clearMenu(); clearGame(); profilePanel = new Container(); // Username at top var uname = typeof username !== "undefined" && username ? username : storage.username || ""; var unameText = new Text2(uname, { size: 90, fill: 0x00FF99, font: "monospace" }); unameText.anchor.set(0.5, 0); unameText.x = 2048 / 2; unameText.y = 180; profilePanel.addChild(unameText); // Title profileTitle = new Text2("PROFILE", { size: 120, fill: 0xFFFFFF, font: "monospace" }); profileTitle.anchor.set(0.5, 0); profileTitle.x = 2048 / 2; profileTitle.y = 300; profilePanel.addChild(profileTitle); // Milestones var milestoneLines = []; for (var i = 0; i < milestoneThresholds.length; i++) { var th = milestoneThresholds[i]; var unlocked = milestones.indexOf(th) !== -1; milestoneLines.push((unlocked ? "[✓] " : "[ ] ") + "Score " + th); } profileMilestones = new Text2(milestoneLines.join("\n"), { size: 90, fill: 0xFFFF99, font: "monospace" }); profileMilestones.anchor.set(0.5, 0); profileMilestones.x = 2048 / 2; profileMilestones.y = 500; profilePanel.addChild(profileMilestones); // Back Button backBtn = new Text2("[ BACK ]", { size: 90, fill: 0x00FF99, font: "monospace" }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 2048 / 2; backBtn.y = 1800; profilePanel.addChild(backBtn); backBtn.down = function () { showMenu(); }; game.addChild(profilePanel); } // --- GAMEPLAY UI --- function startGame() { gameState = STATE_PLAY; clearMenu(); clearProfile(); clearGame(); score = 0; currentScoreMultiplier = 1; // Reset multiplier at start obstacles = []; powerups = []; health = 3; maxHealth = 5; combo = 0; lastCosmetic = -1; game._lastShieldScore = -1; // Reset shield drop tracker game._lastSpeedBoostScore = -1; // Reset speed boost drop tracker game._lastScoreMultiplierScore = -1; // Reset score multiplier drop tracker // Player player = new AsciiPlayer(); player.x = 2048 / 2; player.y = 2200; game.addChild(player); player.originalMoveSpeed = 180; // Store original player movement speed player.xMoveAmount = player.originalMoveSpeed; // Current horizontal move amount // Cosmetic border container player.borderBox = new Container(); player.addChild(player.borderBox); // Function to update border style player.updateBorder = function (score) { // Remove previous border if (player.borderBox.children.length > 0) { for (var i = 0; i < player.borderBox.children.length; i++) { player.borderBox.children[i].destroy(); } player.borderBox.removeChildren(); } // Choose border style by score var borderStyle = Math.floor(score / 100) % 6; // her 100 puanda değişir var borderArt = ""; var borderColor = 0xFFFFFF; if (score >= 100) { borderColor = Math.random() * 0xFFFFFF; // Rastgele renk (istediğin gibi değiştir) switch (borderStyle) { case 0: borderArt = "+-----+\n| |\n| |\n+-----+"; break; case 1: borderArt = "☆-----☆\n| |\n| |\n☆-----☆"; break; case 2: borderArt = "🔥-----🔥\n| |\n| |\n🔥-----🔥"; break; case 3: borderArt = "▓▓▓▓▓▓▓\n| |\n| |\n▓▓▓▓▓▓▓"; break; case 4: borderArt = "♡-----♡\n| |\n| |\n♡-----♡"; break; case 5: borderArt = "◆-----◆\n| |\n| |\n◆-----◆"; break; } } else { switch (borderStyle) { case 0: borderArt = "+-----+\n| |\n| |\n+-----+"; borderColor = 0xAAAAAA; break; case 1: borderArt = "☆-----☆\n| |\n| |\n☆-----☆"; borderColor = 0xFFD700; break; case 2: borderArt = "🔥-----🔥\n| |\n| |\n🔥-----🔥"; borderColor = 0xFF5500; break; case 3: borderArt = "▓▓▓▓▓▓▓\n| |\n| |\n▓▓▓▓▓▓▓"; borderColor = 0x00FFFF; break; case 4: borderArt = "♡-----♡\n| |\n| |\n♡-----♡"; borderColor = 0xFF66CC; break; case 5: borderArt = "◆-----◆\n| |\n| |\n◆-----◆"; borderColor = 0x66FF99; break; } } var borderTxt = new Text2(borderArt, { size: 100, fill: borderColor, font: "monospace" }); borderTxt.anchor.set(0.5, 0.5); borderTxt.x = 0; borderTxt.y = 0; player.borderBox.addChild(borderTxt); }; // Puan arttıran fonksiyon function addScore(amount) { score += amount * currentScoreMultiplier; // Apply multiplier here player.updateBorder(score); } // İlk borderı göster player.updateBorder(score); // Score Text scoreText = new Text2("Score: 0", { size: 100, fill: 0xFFFFFF, font: "monospace" }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); // Health Stars above player var stars = ""; for (var h = 0; h < health; h++) { stars += "★"; } healthText = new Text2(stars, { size: 100, fill: 0xFFDD44, // gold/yellow for stars font: "monospace" }); healthText.anchor.set(0.5, 1); healthText.x = 0; healthText.y = -180; player.addChild(healthText); // Cosmetic tag player.tagText.setText(""); // On-screen left/right controls leftBtn = new AsciiButton(); leftBtn.setLabel("<"); leftBtn.x = 200; leftBtn.y = 2600; leftBtn.txt.fill = 0x00FF99; leftBtn.down = function () { if (gameState !== STATE_PLAY) { return; } player.x = Math.max(90, player.x - player.xMoveAmount); // Use dynamic move amount }; game.addChild(leftBtn); rightBtn = new AsciiButton(); rightBtn.setLabel(">"); rightBtn.x = 2048 - 200; rightBtn.y = 2600; rightBtn.txt.fill = 0x00FF99; rightBtn.down = function () { if (gameState !== STATE_PLAY) { return; } player.x = Math.min(2048 - 90, player.x + player.xMoveAmount); // Use dynamic move amount }; game.addChild(rightBtn); // Move handler: player follows finger/mouse horizontally game.move = function (x, y, obj) { if (gameState !== STATE_PLAY) { return; } // Clamp player within screen var px = Math.max(90, Math.min(2048 - 90, x)); player.x = px; }; // Down handler: also move instantly game.down = function (x, y, obj) { if (gameState !== STATE_PLAY) { return; } var px = Math.max(90, Math.min(2048 - 90, x)); player.x = px; }; // Up handler: not used, but required for drag logic game.up = function (x, y, obj) {}; // Start with a clear obstacle and powerup list for (var i = 0; i < obstacles.length; i++) { obstacles[i].destroy(); } obstacles = []; for (var i = 0; i < powerups.length; i++) { powerups[i].destroy(); } powerups = []; } // --- GAME CLEAR HELPERS --- function clearMenu() { if (menuTitle) { menuTitle.destroy(); menuTitle = null; } if (startBtn) { startBtn.destroy(); startBtn = null; } if (profileBtn) { profileBtn.destroy(); profileBtn = null; } if (bestText) { bestText.destroy(); bestText = null; } } if (game._inputCleanup) { game._inputCleanup(); } function clearProfile() { if (profilePanel) { profilePanel.destroy(); profilePanel = null; } } function clearGame() { if (player) { player.destroy(); player = null; } for (var i = 0; i < obstacles.length; i++) { obstacles[i].destroy(); } obstacles = []; if (scoreText) { scoreText.destroy(); scoreText = null; } if (healthText) { healthText.destroy(); healthText = null; } if (leftBtn) { leftBtn.destroy(); leftBtn = null; } if (rightBtn) { rightBtn.destroy(); rightBtn = null; } if (powerups) { for (var i = 0; i < powerups.length; i++) { powerups[i].destroy(); } powerups = []; } game.move = null; game.down = null; game.up = null; } // --- GAME LOOP --- game.update = function () { if (gameState !== STATE_PLAY) { // NEW: Scroll background even in menu/profile for a dynamic feel backgroundText1.y += backgroundSpeed; backgroundText2.y += backgroundSpeed; if (backgroundText1.y >= 2732) { backgroundText1.y = backgroundText2.y - 2732; } if (backgroundText2.y >= 2732) { backgroundText2.y = backgroundText1.y - 2732; } return; } // NEW: Scroll background during gameplay backgroundText1.y += backgroundSpeed; backgroundText2.y += backgroundSpeed; if (backgroundText1.y >= 2732) { backgroundText1.y = backgroundText2.y - 2732; } if (backgroundText2.y >= 2732) { backgroundText2.y = backgroundText1.y - 2732; } // Dynamic difficulty: speed and spawn rate increase every 100 points var baseSpeed = 12; var baseSpawn = 40; var speedup = Math.floor(score / 100); var currentSpeed = baseSpeed + speedup * 2; var currentSpawn = Math.max(12, baseSpawn - speedup * 5); // Cosmetic tag reward every 100 points var cosmeticIdx = Math.min(Math.floor(score / 100), cosmeticTags.length - 1); if (cosmeticIdx !== lastCosmetic) { player.tagText.setText(cosmeticTags[cosmeticIdx]); lastCosmetic = cosmeticIdx; } // Cosmetic border every 500 score if (player && player.updateBorder) { var borderStyle = Math.floor(score / 500) % 4; if (typeof player._lastBorderStyle === "undefined" || player._lastBorderStyle !== borderStyle) { player.updateBorder(score); player._lastBorderStyle = borderStyle; } } // Unlock new features at milestones (minimal: e.g. new obstacle shapes, color, etc.) var extraShapes = []; if (score >= 200) { extraShapes.push("/////"); } if (score >= 300) { extraShapes.push("\\\\\\\\\\"); } if (score >= 400) { extraShapes.push("#####", "====="); } if (score >= 500) { extraShapes.push("~~~~~"); } if (score >= 1000) { extraShapes.push("*****"); } // --- ASCII ENEMY/DECORATION LOGIC --- // Enemy words that can hurt the player var ENEMY_WORDS = ["LOL", "UwU", "=====", "!!!"]; // Harmless decorations (fun/chaotic) var DECOR_WORDS = ["<3", "⚔", "~*", "★彡", "✿", "☠", "owo", "zzz", "☆", "彡", "♡", "∞", "☀", "☁", "☂", "☃", "☄", "☾", "☽", "☼", "☻", "☺", "♪", "♫", "♬", "♩", "♭", "♯", "♮", "✧", "✪", "✩", "✰", "✶", "✹", "✺", "✻", "✼", "✽", "✾", "✿", "❀", "❁", "❂", "❃", "❄", "❅", "❆", "❇", "❈", "❉", "❊", "❋", "☘", "☾", "☽", "☄", "☀", "☁", "☂", "☃", "☼", "☽", "彡★", "彡☆", "彡✿", "彡♡"]; // All possible shapes for obstacles (enemies + decos) var ALL_ASCII_SHAPES = ["#####", "=====", "-----", "|||||", "oOoOo", "UwU", "0v0v0", "><(((º>", "LOL", ":-)", "ZZZZZ", "MOO", "BEEP", "!!!", "T_T", "12345", "abcde"].concat(extraShapes).concat(ENEMY_WORDS).concat(DECOR_WORDS); // Decide if this spawn is an enemy or a decoration if (LK.ticks % currentSpawn === 0) { var isEnemy = Math.random() < 0.5; // 50% chance for enemy, 50% for deco var ascii; if (isEnemy) { ascii = ENEMY_WORDS[Math.floor(Math.random() * ENEMY_WORDS.length)]; } else { ascii = DECOR_WORDS[Math.floor(Math.random() * DECOR_WORDS.length)]; } var obs = new AsciiObstacle(); // Set the ASCII text if (obs.children[0] && obs.children[0].setText) { obs.children[0].setText(ascii); } obs.x = 200 + Math.floor(Math.random() * (2048 - 400)); obs.y = -60; obs.speed = currentSpeed; // Mark if this is an enemy for collision logic obs.isEnemy = isEnemy; obstacles.push(obs); game.addChild(obs); } // --- POWER-UP DROP LOGIC --- // Drop shield exactly at every 100 points if (score > 0 && score % 100 === 0 && game._lastShieldScore !== score) { var shield = new ShieldPowerup(); shield.x = 200 + Math.floor(Math.random() * (2048 - 400)); shield.y = -60; shield.speed = Math.max(8, currentSpeed - 2); powerups.push(shield); game.addChild(shield); game._lastShieldScore = score; } // Drop Speed Boost Power-up every 150 points if (score > 0 && score % 150 === 0 && game._lastSpeedBoostScore !== score) { var speedBoost = new SpeedBoostPowerup(); speedBoost.x = 200 + Math.floor(Math.random() * (2048 - 400)); speedBoost.y = -60; speedBoost.speed = Math.max(8, currentSpeed - 2); powerups.push(speedBoost); game.addChild(speedBoost); game._lastSpeedBoostScore = score; } // Drop Score Multiplier Power-up every 250 points if (score > 0 && score % 250 === 0 && game._lastScoreMultiplierScore !== score) { var scoreMultiplier = new ScoreMultiplierPowerup(); scoreMultiplier.x = 200 + Math.floor(Math.random() * (2048 - 400)); scoreMultiplier.y = -60; scoreMultiplier.speed = Math.max(8, currentSpeed - 2); powerups.push(scoreMultiplier); game.addChild(scoreMultiplier); game._lastScoreMultiplierScore = score; } // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { var obs = obstacles[i]; obs.update(); // Only process collision if this is an enemy if (obs.isEnemy && intersects(player, obs)) { // Flash screen LK.effects.flashScreen(0xff2222, 800); // NEW: Player character flash on hit player.children[0].fill = 0xFFFFFF; // Reset to white initially tween(player.children[0]).to({ fill: 0xFF0000 }, 100).to({ fill: 0xFFFFFF }, 100).start(); health -= 1; combo = 0; if (healthText) { var stars = ""; for (var h = 0; h < health; h++) { stars += "★"; } healthText.setText(stars); } // Remove obstacle obs.destroy(); obstacles.splice(i, 1); // Game over if health depleted if (health <= 0) { // Update best score if (score > bestScore) { bestScore = score; storage.bestScore = bestScore; } // Update milestones for (var m = 0; m < milestoneThresholds.length; m++) { var th = milestoneThresholds[m]; if (score >= th && milestones.indexOf(th) === -1) { milestones.push(th); } } storage.milestones = milestones; // Show game over (handled by LK) LK.showGameOver(); return; } continue; } // Remove if off screen if (obs.y > 2732 + 100) { obs.destroy(); obstacles.splice(i, 1); } } // Update powerups for (var i = powerups.length - 1; i >= 0; i--) { var p = powerups[i]; p.update(); if (intersects(player, p)) { // Remove any existing power-up effect text player.effectsContainer.removeChildren(); if (p instanceof ShieldPowerup) { // Collect shield: +1 health (max 5) if (health < maxHealth) { health += 1; var stars = ""; for (var h = 0; h < health; h++) { stars += "★"; } healthText.setText(stars); } LK.effects.flashScreen(0x00ffff, 400); // NEW: Visual effect for shield var shieldEffect = new Text2("[SHIELD ON]", { size: 70, fill: 0x00FFFF, font: "monospace" }); shieldEffect.anchor.set(0.5, 0.5); shieldEffect.y = -220; player.effectsContainer.addChild(shieldEffect); tween(shieldEffect).wait(4000).to({ alpha: 0 }, 500).call(function () { shieldEffect.destroy(); }).start(); } else if (p instanceof SpeedBoostPowerup) { LK.effects.flashScreen(0xFFFF00, 400); // Yellow flash // Temporarily increase player's horizontal movement speed player.xMoveAmount = player.originalMoveSpeed * 2; // Double speed // NEW: Visual effect for speed boost var speedEffect = new Text2("[FAST]", { size: 70, fill: 0xFFFF00, font: "monospace" }); speedEffect.anchor.set(0.5, 0.5); speedEffect.y = -220; player.effectsContainer.addChild(speedEffect); setTimeout(function () { player.xMoveAmount = player.originalMoveSpeed; // Revert after 5 seconds if (speedEffect && !speedEffect._isDestroyed) { // Check if not already destroyed tween(speedEffect).to({ alpha: 0 }, 500).call(function () { speedEffect.destroy(); }).start(); } }, 5000); } else if (p instanceof ScoreMultiplierPowerup) { LK.effects.flashScreen(0xFF00FF, 400); // Magenta flash currentScoreMultiplier = 2; // Set multiplier to x2 // NEW: Visual effect for score multiplier var multiplierEffect = new Text2("[x2]", { size: 70, fill: 0xFF00FF, font: "monospace" }); multiplierEffect.anchor.set(0.5, 0.5); multiplierEffect.y = -220; player.effectsContainer.addChild(multiplierEffect); setTimeout(function () { currentScoreMultiplier = 1; // Revert after 7 seconds if (multiplierEffect && !multiplierEffect._isDestroyed) { // Check if not already destroyed tween(multiplierEffect).to({ alpha: 0 }, 500).call(function () { multiplierEffect.destroy(); }).start(); } }, 7000); } p.destroy(); powerups.splice(i, 1); continue; } if (p.y > 2732 + 100) { p.destroy(); powerups.splice(i, 1); } } // Score increases with time if (LK.ticks % 6 === 0) { score += 1 * currentScoreMultiplier; // Apply multiplier here scoreText.setText("Score: " + score); // NEW: Score text "pop" effect scoreText.alpha = 1; scoreText.scale.set(1.1, 1.1); tween(scoreText).to({ alpha: 0.8, scale: { x: 1, y: 1 } }, 150).start(); combo++; } }; // --- GAME OVER HANDLER (reset to menu) --- LK.on('gameover', function () { showMenu(); }); // --- INITIALIZE --- showMenu();
===================================================================
--- original.js
+++ change.js
@@ -83,9 +83,9 @@
// ASCII Player Character
var AsciiPlayer = Container.expand(function () {
var self = Container.call(this);
// ASCII art for the player (simple stick figure)
- var asciiArt = [" O ", " /|\\ ", " / \\ "].join("\n");
+ var asciiArt = [" O ", " /|\\ ", " / \\ "].join("\n");
var playerText = self.addChild(new Text2(asciiArt, {
size: 90,
fill: 0xFFFFFF,
font: "monospace"
@@ -99,8 +99,10 @@
}));
self.tagText.anchor.set(0.5, 1);
self.tagText.x = 0;
self.tagText.y = -140;
+ // NEW: Container for power-up effects
+ self.effectsContainer = self.addChild(new Container());
// For collision, define a bounding box
self.getBounds = function () {
return {
x: self.x - 90,
@@ -110,8 +112,36 @@
};
};
return self;
});
+// NEW: Power-up: Score Multiplier
+var ScoreMultiplierPowerup = Container.expand(function () {
+ var self = Container.call(this);
+ var multiplierText = self.addChild(new Text2("[x2 SCORE]", {
+ size: 80,
+ fill: 0xFF00FF,
+ // Magenta color
+ font: "monospace"
+ }));
+ multiplierText.anchor.set(0.5, 0.5);
+ self.speed = 10;
+ self.getBounds = function () {
+ return {
+ x: self.x - 120,
+ y: self.y - 40,
+ width: 240,
+ height: 80
+ };
+ };
+ self.update = function () {
+ if (typeof self.lastY === "undefined") {
+ self.lastY = self.y;
+ }
+ self.y += self.speed;
+ self.lastY = self.y;
+ };
+ return self;
+});
// Power-up: Shield
var ShieldPowerup = Container.expand(function () {
var self = Container.call(this);
var shieldText = self.addChild(new Text2("[SHIELD]", {
@@ -137,8 +167,36 @@
self.lastY = self.y;
};
return self;
});
+// NEW: Power-up: Speed Boost
+var SpeedBoostPowerup = Container.expand(function () {
+ var self = Container.call(this);
+ var speedBoostText = self.addChild(new Text2("[SPEED]", {
+ size: 80,
+ fill: 0xFFFF00,
+ // Yellow color
+ font: "monospace"
+ }));
+ speedBoostText.anchor.set(0.5, 0.5);
+ self.speed = 10;
+ self.getBounds = function () {
+ return {
+ x: self.x - 120,
+ y: self.y - 40,
+ width: 240,
+ height: 80
+ };
+ };
+ self.update = function () {
+ if (typeof self.lastY === "undefined") {
+ self.lastY = self.y;
+ }
+ self.y += self.speed;
+ self.lastY = self.y;
+ };
+ return self;
+});
/****
* Initialize Game
****/
@@ -148,148 +206,58 @@
/****
* Game Code
****/
-// Game states
-// Tween for possible future use (not used in MVP, but included for extensibility)
-// Storage for persistent profile/milestones
-function _typeof2(o) {
- "@babel/helpers - typeof";
- return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
- return typeof o;
- } : function (o) {
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
- }, _typeof2(o);
-}
-function _classCallCheck2(a, n) {
- if (!(a instanceof n)) {
- throw new TypeError("Cannot call a class as a function");
- }
-}
-function __defineProperties(e, r) {
- for (var t = 0; t < r.length; t++) {
- var o = r[t];
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey2(o.key), o);
- }
-}
-function _createClass2(e, r, t) {
- return r && __defineProperties(e.prototype, r), t && __defineProperties(e, t), Object.defineProperty(e, "prototype", {
- writable: !1
- }), e;
-}
-function _toPropertyKey2(t) {
- var i = _toPrimitive2(t, "string");
- return "symbol" == _typeof2(i) ? i : i + "";
-}
-function _toPrimitive2(t, r) {
- if ("object" != _typeof2(t) || !t) {
- return t;
- }
- var e = t[Symbol.toPrimitive];
- if (void 0 !== e) {
- var i = e.call(t, r || "default");
- if ("object" != _typeof2(i)) {
- return i;
+// NEW: Dynamic background layers
+var backgroundText1, backgroundText2;
+var backgroundSpeed = 1; // Adjust for desired scroll speed
+function createBackgroundLayer(yPos) {
+ var bgArt = "";
+ for (var i = 0; i < 20; i++) {
+ for (var j = 0; j < 50; j++) {
+ bgArt += String.fromCharCode(33 + Math.floor(Math.random() * 94));
}
- throw new TypeError("@@toPrimitive must return a primitive value.");
+ bgArt += "\n";
}
- return ("string" === r ? String : Number)(t);
+ var bgText = new Text2(bgArt, {
+ size: 50,
+ fill: 0x282828,
+ font: "monospace"
+ });
+ bgText.anchor.set(0.5, 0);
+ bgText.x = 2048 / 2;
+ bgText.y = yPos;
+ game.addChild(bgText);
+ return bgText;
}
-var SpeedBoostPowerup = /*#__PURE__*/function () {
- function SpeedBoostPowerup() {
- _classCallCheck2(this, SpeedBoostPowerup);
- this.x = Math.floor(Math.random() * (canvas.width - 20));
- this.y = -20;
- this.width = 20;
- this.height = 20;
- this.speed = 2; // Power-up düşme hızı
- this.duration = 5000; // 5 saniye hız artışı süresi
- this.active = false;
- }
- return _createClass2(SpeedBoostPowerup, [{
- key: "update",
- value: function update() {
- this.y += this.speed;
- // Çarpışma kontrolü (player ile)
- if (this.y + this.height > player.y && this.x < player.x + player.width && this.x + this.width > player.x) {
- this.active = true;
- applySpeedBoost();
- this.remove = true; // Koleksiyondan silmek için işaretle
- }
- }
- }, {
- key: "draw",
- value: function draw(ctx) {
- ctx.fillStyle = 'yellow';
- ctx.fillRect(this.x, this.y, this.width, this.height);
- }
- }]);
-}();
-function applySpeedBoost() {
- player.speed *= 2; // Hızı 2 katına çıkar
- setTimeout(function () {
- player.speed /= 2; // Süre bitince normale dön
- }, 5000);
-}
-function _typeof(o) {
- "@babel/helpers - typeof";
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
- return typeof o;
- } : function (o) {
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
- }, _typeof(o);
-}
-function _classCallCheck(a, n) {
- if (!(a instanceof n)) {
- throw new TypeError("Cannot call a class as a function");
- }
-}
-function _defineProperties(e, r) {
- for (var t = 0; t < r.length; t++) {
- var o = r[t];
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
- }
-}
-function _createClass(e, r, t) {
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
- writable: !1
- }), e;
-}
-function _toPropertyKey(t) {
- var i = _toPrimitive(t, "string");
- return "symbol" == _typeof(i) ? i : i + "";
-}
-function _toPrimitive(t, r) {
- if ("object" != _typeof(t) || !t) {
- return t;
- }
- var e = t[Symbol.toPrimitive];
- if (void 0 !== e) {
- var i = e.call(t, r || "default");
- if ("object" != _typeof(i)) {
- return i;
- }
- throw new TypeError("@@toPrimitive must return a primitive value.");
- }
- return ("string" === r ? String : Number)(t);
-}
+// Initialize two background layers for seamless scrolling
+backgroundText1 = createBackgroundLayer(0);
+backgroundText2 = createBackgroundLayer(-2732); // Position above the first one
+// Game states
var STATE_MENU = 0;
var STATE_PLAY = 1;
var STATE_PROFILE = 2;
var gameState = STATE_MENU;
// Main elements
var player;
var obstacles = [];
-var powerups = []; // Make powerups globally defined so it is accessible everywhere
+var powerups = [];
var score = 0;
+var currentScoreMultiplier = 1; // Track the current score multiplier
var bestScore = storage.bestScore || 0;
var milestones = storage.milestones || [];
var milestoneThresholds = [10, 25, 50, 100, 200, 500, 1000];
// GUI elements
var scoreText, bestText, menuTitle, startBtn, profileBtn, profilePanel, profileTitle, profileMilestones, backBtn;
-var healthText; // Make healthText globally defined so it is accessible everywhere
-var leftBtn; // Make leftBtn globally defined so it is accessible everywhere
-var rightBtn; // Make rightBtn globally defined so it is accessible everywhere
+var healthText;
+var leftBtn;
+var rightBtn;
+// Game variables
+var health = 3;
+var maxHealth = 5;
+var combo = 0;
+var lastCosmetic = -1;
+var cosmeticTags = ["", "ASCII MAN", "ASCII PRO", "RUNNER", "ELITE", "ASCII KING", "GODMODE", "AMAZİNG", "777", "SHİT", "ADMİN"];
// Utility: collision detection (AABB)
function intersects(a, b) {
var ab = a.getBounds();
var bb = b.getBounds();
@@ -414,21 +382,25 @@
clearMenu();
clearProfile();
clearGame();
score = 0;
+ currentScoreMultiplier = 1; // Reset multiplier at start
obstacles = [];
powerups = [];
health = 3;
maxHealth = 5;
combo = 0;
lastCosmetic = -1;
- cosmeticTags = ["", "ASCII MAN", "ASCII PRO", "RUNNER", "ELITE", "ASCII KING", "GODMODE", "AMAZİNG", "777", "SHİT", "ADMİN"];
game._lastShieldScore = -1; // Reset shield drop tracker
+ game._lastSpeedBoostScore = -1; // Reset speed boost drop tracker
+ game._lastScoreMultiplierScore = -1; // Reset score multiplier drop tracker
// Player
player = new AsciiPlayer();
player.x = 2048 / 2;
player.y = 2200;
game.addChild(player);
+ player.originalMoveSpeed = 180; // Store original player movement speed
+ player.xMoveAmount = player.originalMoveSpeed; // Current horizontal move amount
// Cosmetic border container
player.borderBox = new Container();
player.addChild(player.borderBox);
// Function to update border style
@@ -447,50 +419,50 @@
if (score >= 100) {
borderColor = Math.random() * 0xFFFFFF; // Rastgele renk (istediğin gibi değiştir)
switch (borderStyle) {
case 0:
- borderArt = "+-----+\n| |\n| |\n+-----+";
+ borderArt = "+-----+\n| |\n| |\n+-----+";
break;
case 1:
- borderArt = "☆-----☆\n| |\n| |\n☆-----☆";
+ borderArt = "☆-----☆\n| |\n| |\n☆-----☆";
break;
case 2:
- borderArt = "🔥-----🔥\n| |\n| |\n🔥-----🔥";
+ borderArt = "🔥-----🔥\n| |\n| |\n🔥-----🔥";
break;
case 3:
- borderArt = "▓▓▓▓▓▓▓\n| |\n| |\n▓▓▓▓▓▓▓";
+ borderArt = "▓▓▓▓▓▓▓\n| |\n| |\n▓▓▓▓▓▓▓";
break;
case 4:
- borderArt = "♡-----♡\n| |\n| |\n♡-----♡";
+ borderArt = "♡-----♡\n| |\n| |\n♡-----♡";
break;
case 5:
- borderArt = "◆-----◆\n| |\n| |\n◆-----◆";
+ borderArt = "◆-----◆\n| |\n| |\n◆-----◆";
break;
}
} else {
switch (borderStyle) {
case 0:
- borderArt = "+-----+\n| |\n| |\n+-----+";
+ borderArt = "+-----+\n| |\n| |\n+-----+";
borderColor = 0xAAAAAA;
break;
case 1:
- borderArt = "☆-----☆\n| |\n| |\n☆-----☆";
+ borderArt = "☆-----☆\n| |\n| |\n☆-----☆";
borderColor = 0xFFD700;
break;
case 2:
- borderArt = "🔥-----🔥\n| |\n| |\n🔥-----🔥";
+ borderArt = "🔥-----🔥\n| |\n| |\n🔥-----🔥";
borderColor = 0xFF5500;
break;
case 3:
- borderArt = "▓▓▓▓▓▓▓\n| |\n| |\n▓▓▓▓▓▓▓";
+ borderArt = "▓▓▓▓▓▓▓\n| |\n| |\n▓▓▓▓▓▓▓";
borderColor = 0x00FFFF;
break;
case 4:
- borderArt = "♡-----♡\n| |\n| |\n♡-----♡";
+ borderArt = "♡-----♡\n| |\n| |\n♡-----♡";
borderColor = 0xFF66CC;
break;
case 5:
- borderArt = "◆-----◆\n| |\n| |\n◆-----◆";
+ borderArt = "◆-----◆\n| |\n| |\n◆-----◆";
borderColor = 0x66FF99;
break;
}
}
@@ -505,9 +477,9 @@
player.borderBox.addChild(borderTxt);
};
// Puan arttıran fonksiyon
function addScore(amount) {
- score += amount;
+ score += amount * currentScoreMultiplier; // Apply multiplier here
player.updateBorder(score);
}
// İlk borderı göster
player.updateBorder(score);
@@ -545,9 +517,9 @@
leftBtn.down = function () {
if (gameState !== STATE_PLAY) {
return;
}
- player.x = Math.max(90, player.x - 180);
+ player.x = Math.max(90, player.x - player.xMoveAmount); // Use dynamic move amount
};
game.addChild(leftBtn);
rightBtn = new AsciiButton();
rightBtn.setLabel(">");
@@ -557,9 +529,9 @@
rightBtn.down = function () {
if (gameState !== STATE_PLAY) {
return;
}
- player.x = Math.min(2048 - 90, player.x + 180);
+ player.x = Math.min(2048 - 90, player.x + player.xMoveAmount); // Use dynamic move amount
};
game.addChild(rightBtn);
// Move handler: player follows finger/mouse horizontally
game.move = function (x, y, obj) {
@@ -579,9 +551,9 @@
player.x = px;
};
// Up handler: not used, but required for drag logic
game.up = function (x, y, obj) {};
- // Start with a clear obstacle list
+ // Start with a clear obstacle and powerup list
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].destroy();
}
obstacles = [];
@@ -655,10 +627,28 @@
}
// --- GAME LOOP ---
game.update = function () {
if (gameState !== STATE_PLAY) {
+ // NEW: Scroll background even in menu/profile for a dynamic feel
+ backgroundText1.y += backgroundSpeed;
+ backgroundText2.y += backgroundSpeed;
+ if (backgroundText1.y >= 2732) {
+ backgroundText1.y = backgroundText2.y - 2732;
+ }
+ if (backgroundText2.y >= 2732) {
+ backgroundText2.y = backgroundText1.y - 2732;
+ }
return;
}
+ // NEW: Scroll background during gameplay
+ backgroundText1.y += backgroundSpeed;
+ backgroundText2.y += backgroundSpeed;
+ if (backgroundText1.y >= 2732) {
+ backgroundText1.y = backgroundText2.y - 2732;
+ }
+ if (backgroundText2.y >= 2732) {
+ backgroundText2.y = backgroundText1.y - 2732;
+ }
// Dynamic difficulty: speed and spawn rate increase every 100 points
var baseSpeed = 12;
var baseSpawn = 40;
var speedup = Math.floor(score / 100);
@@ -723,28 +713,54 @@
obs.isEnemy = isEnemy;
obstacles.push(obs);
game.addChild(obs);
}
- // --- SHIELD DROP LOGIC ---
- // Drop shield exactly at every 100 points (not random, not more than once per 100)
+ // --- POWER-UP DROP LOGIC ---
+ // Drop shield exactly at every 100 points
if (score > 0 && score % 100 === 0 && game._lastShieldScore !== score) {
- // Only drop once per 100 points
var shield = new ShieldPowerup();
shield.x = 200 + Math.floor(Math.random() * (2048 - 400));
shield.y = -60;
shield.speed = Math.max(8, currentSpeed - 2);
powerups.push(shield);
game.addChild(shield);
game._lastShieldScore = score;
}
+ // Drop Speed Boost Power-up every 150 points
+ if (score > 0 && score % 150 === 0 && game._lastSpeedBoostScore !== score) {
+ var speedBoost = new SpeedBoostPowerup();
+ speedBoost.x = 200 + Math.floor(Math.random() * (2048 - 400));
+ speedBoost.y = -60;
+ speedBoost.speed = Math.max(8, currentSpeed - 2);
+ powerups.push(speedBoost);
+ game.addChild(speedBoost);
+ game._lastSpeedBoostScore = score;
+ }
+ // Drop Score Multiplier Power-up every 250 points
+ if (score > 0 && score % 250 === 0 && game._lastScoreMultiplierScore !== score) {
+ var scoreMultiplier = new ScoreMultiplierPowerup();
+ scoreMultiplier.x = 200 + Math.floor(Math.random() * (2048 - 400));
+ scoreMultiplier.y = -60;
+ scoreMultiplier.speed = Math.max(8, currentSpeed - 2);
+ powerups.push(scoreMultiplier);
+ game.addChild(scoreMultiplier);
+ game._lastScoreMultiplierScore = score;
+ }
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obs = obstacles[i];
obs.update();
// Only process collision if this is an enemy
if (obs.isEnemy && intersects(player, obs)) {
// Flash screen
LK.effects.flashScreen(0xff2222, 800);
+ // NEW: Player character flash on hit
+ player.children[0].fill = 0xFFFFFF; // Reset to white initially
+ tween(player.children[0]).to({
+ fill: 0xFF0000
+ }, 100).to({
+ fill: 0xFFFFFF
+ }, 100).start();
health -= 1;
combo = 0;
if (healthText) {
var stars = "";
@@ -787,19 +803,83 @@
for (var i = powerups.length - 1; i >= 0; i--) {
var p = powerups[i];
p.update();
if (intersects(player, p)) {
- // Collect shield: +1 health (max 5)
- if (health < maxHealth) {
- health += 1;
- var stars = "";
- for (var h = 0; h < health; h++) {
- stars += "★";
+ // Remove any existing power-up effect text
+ player.effectsContainer.removeChildren();
+ if (p instanceof ShieldPowerup) {
+ // Collect shield: +1 health (max 5)
+ if (health < maxHealth) {
+ health += 1;
+ var stars = "";
+ for (var h = 0; h < health; h++) {
+ stars += "★";
+ }
+ healthText.setText(stars);
}
- healthText.setText(stars);
+ LK.effects.flashScreen(0x00ffff, 400);
+ // NEW: Visual effect for shield
+ var shieldEffect = new Text2("[SHIELD ON]", {
+ size: 70,
+ fill: 0x00FFFF,
+ font: "monospace"
+ });
+ shieldEffect.anchor.set(0.5, 0.5);
+ shieldEffect.y = -220;
+ player.effectsContainer.addChild(shieldEffect);
+ tween(shieldEffect).wait(4000).to({
+ alpha: 0
+ }, 500).call(function () {
+ shieldEffect.destroy();
+ }).start();
+ } else if (p instanceof SpeedBoostPowerup) {
+ LK.effects.flashScreen(0xFFFF00, 400); // Yellow flash
+ // Temporarily increase player's horizontal movement speed
+ player.xMoveAmount = player.originalMoveSpeed * 2; // Double speed
+ // NEW: Visual effect for speed boost
+ var speedEffect = new Text2("[FAST]", {
+ size: 70,
+ fill: 0xFFFF00,
+ font: "monospace"
+ });
+ speedEffect.anchor.set(0.5, 0.5);
+ speedEffect.y = -220;
+ player.effectsContainer.addChild(speedEffect);
+ setTimeout(function () {
+ player.xMoveAmount = player.originalMoveSpeed; // Revert after 5 seconds
+ if (speedEffect && !speedEffect._isDestroyed) {
+ // Check if not already destroyed
+ tween(speedEffect).to({
+ alpha: 0
+ }, 500).call(function () {
+ speedEffect.destroy();
+ }).start();
+ }
+ }, 5000);
+ } else if (p instanceof ScoreMultiplierPowerup) {
+ LK.effects.flashScreen(0xFF00FF, 400); // Magenta flash
+ currentScoreMultiplier = 2; // Set multiplier to x2
+ // NEW: Visual effect for score multiplier
+ var multiplierEffect = new Text2("[x2]", {
+ size: 70,
+ fill: 0xFF00FF,
+ font: "monospace"
+ });
+ multiplierEffect.anchor.set(0.5, 0.5);
+ multiplierEffect.y = -220;
+ player.effectsContainer.addChild(multiplierEffect);
+ setTimeout(function () {
+ currentScoreMultiplier = 1; // Revert after 7 seconds
+ if (multiplierEffect && !multiplierEffect._isDestroyed) {
+ // Check if not already destroyed
+ tween(multiplierEffect).to({
+ alpha: 0
+ }, 500).call(function () {
+ multiplierEffect.destroy();
+ }).start();
+ }
+ }, 7000);
}
- // Flash blue
- LK.effects.flashScreen(0x00ffff, 400);
p.destroy();
powerups.splice(i, 1);
continue;
}
@@ -809,10 +889,20 @@
}
}
// Score increases with time
if (LK.ticks % 6 === 0) {
- score++;
+ score += 1 * currentScoreMultiplier; // Apply multiplier here
scoreText.setText("Score: " + score);
+ // NEW: Score text "pop" effect
+ scoreText.alpha = 1;
+ scoreText.scale.set(1.1, 1.1);
+ tween(scoreText).to({
+ alpha: 0.8,
+ scale: {
+ x: 1,
+ y: 1
+ }
+ }, 150).start();
combo++;
}
};
// --- GAME OVER HANDLER (reset to menu) ---