Code edit (3 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: 'player._speedBoostTimeout = setTimeout(function () {' Line Number: 1030
Code edit (1 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: 907
Code edit (1 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: 911
Code edit (3 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: 'player._speedBoostTimeout = setTimeout(function () {' Line Number: 967
User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 922
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'wait')' in or related to this line: 'tween(shieldEffect).wait(4000).to({' Line Number: 779
Code edit (1 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: 855
Code edit (1 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({' Line Number: 718
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'to')' in or related to this line: 'tween(player.children[0]).to({' Line Number: 717
User prompt
Please fix the bug: 'TypeError: Invalid value used as weak map key' in or related to this line: 'tween(player.children[0].style).to({' Line Number: 717
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'to')' in or related to this line: 'tween(player.children[0]).to({' Line Number: 715
Code edit (1 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: 855
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: 855
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
/****
* 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
****/
// 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) {
return;
}
// 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].setStyle({
fill: 0xFFFFFF
}); // Reset to white initially
tween(player.children[0].style).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);
}
}
};
// --- GAME OVER HANDLER (reset to menu) ---
LK.on('gameover', function () {
showMenu();
});
// --- INITIALIZE ---
showMenu(); ===================================================================
--- original.js
+++ change.js
@@ -710,10 +710,12 @@
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({
+ player.children[0].setStyle({
+ fill: 0xFFFFFF
+ }); // Reset to white initially
+ tween(player.children[0].style).to({
fill: 0xFF0000
}, 100).to({
fill: 0xFFFFFF
}, 100).start();