User prompt
Score and high score delete ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
var combo = 0; var feverMode = false; var score = 0; var highScore = storage.get("highscore") || 0; var comboText; var scoreText;comboText = game.createText("", 64); comboText.x = 360; comboText.y = 300; comboText.align = "center"; comboText.visible = false; scoreText = game.createText("", 24); scoreText.x = 360; scoreText.y = 50; scoreText.align = "center";combo += 1; if (combo >= 10 && !feverMode) { feverMode = true; game.shake(1); game.background.color = "#FFD700"; // Gold game.wait(5000, () => { feverMode = false; game.background.color = "#000000"; combo = 0; }); } score += feverMode ? 10 : 5; comboText.text = "Perfect!"; comboText.visible = true; game.wait(500, () => comboText.visible = false);combo = 0; score -= 5; comboText.text = "Miss!"; comboText.visible = true; game.wait(500, () => comboText.visible = false);if (score > highScore) { highScore = score; storage.set("highscore", highScore); } scoreText.text = "Score: " + score + " | High Score: " + highScore; ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
Make all the text in how to play white
User prompt
Make the background of the text in how to play black
User prompt
Add this sentence to how to play "We must move the red note that comes every 25 notes to the left. If we move it, we gain 20 points. If we cannot, our 20 points will be deducted"
User prompt
or give 20 points if we miss -20 points ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Let's say a red mode comes every 25 notes and if we move it to the left we gain 10 points ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Let's earn 15 points when you smile at the screen ↪💡 Consider importing and using the following plugins: @upit/facekit.v1
User prompt
These should be rectangular, not in the shape of notes.
User prompt
hold down and these notes will disappear ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Also long notes will appear on the screen. If the player holds that note, give 5 points. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Let separate long notes appear on the screen and let's hold them down ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
and for those two seconds the text "light up the darkness with music" will appear ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The screen should be pitch black for the first 2 seconds we enter the game. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The screen should not shake and the background color should change every time we press the notes. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the text "Light up the darkness with music" much more prominent ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When the game opens, it should immediately go dark and the text should be more visible. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Let it be 2 seconds earlier ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
DECIDE 2.5 SECONDS EARLIER ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When this text appears the screen goes black ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When the game first starts, the text "lighten the darkness with music" should appear on the screen ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When we smile at the camera we get a bonus note and if we touch it we get 20 points ↪💡 Consider importing and using the following plugins: @upit/facekit.v1
User prompt
shake it a little bit more ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When you destroy the notes, the screen should shake a little ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When the notes are pressed and disappear, an explosion effect appears ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var LongNote = Container.expand(function (lane) {
var self = Container.call(this);
var noteGraphics = self.attachAsset('note', {
anchorX: 0.5,
anchorY: 0.5
});
// Make long notes visually distinct (taller and different color)
noteGraphics.scaleY = 2.5;
noteGraphics.tint = 0x9932cc; // Purple color for long notes
self.lane = lane;
self.speed = Note.prototype.speed || 8;
self.hasBeenHit = false;
self.isBeingHeld = false;
self.holdStartY = null;
self.holdTimer = 0;
self.holdDuration = 60; // 1 second at 60fps
self.update = function () {
self.y += self.speed;
// If being held, count down and make note disappear when hold is complete
if (self.isBeingHeld && !self.hasBeenHit) {
self.holdTimer++;
if (self.holdTimer >= self.holdDuration) {
// Successfully held for required duration - make note disappear
self.hasBeenHit = true;
gameScore += 5;
gameCombo += 1;
// Create explosion effect
createExplosionEffect(self.x, self.y);
// Visual effect - fade out and scale up
tween(self, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 200,
onFinish: function onFinish() {
removeLongNote(self);
}
});
LK.getSound('success').play();
updateUI();
}
}
};
self.down = function (x, y, obj) {
if (!self.hasBeenHit && !self.isBeingHeld) {
// Check if touch is in the hold zone
var distance = Math.abs(self.y - perfectZoneY);
if (distance < perfectTolerance * 2) {
// Larger tolerance for long notes
self.isBeingHeld = true;
self.holdStartY = self.y;
self.holdTimer = 0; // Reset hold timer
// Visual feedback for holding
noteGraphics.tint = 0x00ff00; // Green when being held
// Change background color effect
var colors = [0xff6b6b, 0x4ecdc4, 0x45b7d1, 0x96ceb4, 0xfeca57, 0xff9ff3, 0x54a0ff];
var randomColor = colors[Math.floor(Math.random() * colors.length)];
game.setBackgroundColor(randomColor);
}
}
};
self.up = function (x, y, obj) {
// If released before hold duration is complete, stop holding
if (self.isBeingHeld && !self.hasBeenHit) {
self.isBeingHeld = false;
self.holdTimer = 0;
// Reset visual feedback
noteGraphics.tint = 0x9932cc; // Back to purple
}
};
return self;
});
// Game starts in menu state
var MenuButton = Container.expand(function (text, onClickCallback) {
var self = Container.call(this);
// Create button background
var buttonBg = self.attachAsset('notePad', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3.0,
scaleY: 2.4
});
buttonBg.tint = 0xffffff;
// Create button text
var buttonText = new Text2(text, {
size: 120,
fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.onClickCallback = onClickCallback;
self.down = function (x, y, obj) {
buttonBg.tint = 0xcccccc;
if (self.onClickCallback) {
self.onClickCallback();
}
};
self.up = function (x, y, obj) {
buttonBg.tint = 0xffffff;
};
return self;
});
var Note = Container.expand(function (lane) {
var self = Container.call(this);
var noteGraphics = self.attachAsset('note', {
anchorX: 0.5,
anchorY: 0.5
});
self.lane = lane; // 0 = left, 1 = center, 2 = right
self.speed = Note.prototype.speed || 8;
self.hasBeenHit = false;
self.update = function () {
self.y += self.speed;
};
self.down = function (x, y, obj) {
if (!self.hasBeenHit) {
self.hasBeenHit = true;
gameScore += 5;
gameCombo += 1;
// Create explosion effect
createExplosionEffect(self.x, self.y);
// Change background color effect
var colors = [0xff6b6b, 0x4ecdc4, 0x45b7d1, 0x96ceb4, 0xfeca57, 0xff9ff3, 0x54a0ff];
var randomColor = colors[Math.floor(Math.random() * colors.length)];
game.setBackgroundColor(randomColor);
// Visual effect
tween(self, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 200,
onFinish: function onFinish() {
removeNote(self);
}
});
LK.getSound('success').play();
updateUI();
}
};
return self;
});
var NotePad = Container.expand(function (lane) {
var self = Container.call(this);
var padGraphics = self.attachAsset('notePad', {
anchorX: 0.5,
anchorY: 0.5
});
var perfectZone = self.attachAsset('perfectZone', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.3
});
self.lane = lane;
self.isPressed = false;
self.down = function (x, y, obj) {
self.isPressed = true;
checkNoteHit(self.lane);
checkLongNoteHit(self.lane);
};
self.up = function (x, y, obj) {
self.isPressed = false;
checkLongNoteRelease(self.lane);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
// Create background
var background = LK.getAsset('Background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
game.addChild(background);
var notes = [];
var longNotes = [];
var gameScore = 0;
var gameCombo = 0;
var spawnTimer = 0;
var spawnInterval = 45; // 0.75 seconds at 60fps
var perfectZoneY = 2400;
var perfectTolerance = 100;
// Game state
var gameState = 'menu'; // 'menu', 'difficulty', or 'playing'
var selectedDifficulty = 'normal';
var mainMenu = new Container();
var difficultyMenu = new Container();
var howToPlayMenu = new Container();
var gameContainer = new Container();
// Main Menu Elements
var titleText = new Text2('Rhythm Tap Challenge', {
size: 80,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 800;
mainMenu.addChild(titleText);
var startButton = new MenuButton('START', function () {
showDifficultyMenu();
});
startButton.x = 1024;
startButton.y = 1200;
mainMenu.addChild(startButton);
var howToPlayButton = new MenuButton('HOW TO PLAY', function () {
showHowToPlayMenu();
});
// Enlarge the green area behind the How To Play button
howToPlayButton.children[0].scaleX = 5.0;
howToPlayButton.children[0].scaleY = 4.0;
howToPlayButton.x = 1024;
howToPlayButton.y = 1500;
mainMenu.addChild(howToPlayButton);
// Difficulty Menu Elements
var difficultyTitle = new Text2('Select Difficulty', {
size: 70,
fill: 0xFFFFFF
});
difficultyTitle.anchor.set(0.5, 0.5);
difficultyTitle.x = 1024;
difficultyTitle.y = 800;
difficultyMenu.addChild(difficultyTitle);
var easyButton = new MenuButton('EASY', function () {
selectedDifficulty = 'easy';
startGame();
});
easyButton.x = 1024;
easyButton.y = 1000;
difficultyMenu.addChild(easyButton);
var normalButton = new MenuButton('NORMAL', function () {
selectedDifficulty = 'normal';
startGame();
});
normalButton.x = 1024;
normalButton.y = 1150;
difficultyMenu.addChild(normalButton);
var hardButton = new MenuButton('HARD', function () {
selectedDifficulty = 'hard';
startGame();
});
hardButton.x = 1024;
hardButton.y = 1300;
difficultyMenu.addChild(hardButton);
var backButton = new MenuButton('BACK', function () {
showMainMenu();
});
backButton.x = 1024;
backButton.y = 1500;
difficultyMenu.addChild(backButton);
// How To Play Menu Elements
var howToPlayTitle = new Text2('How To Play', {
size: 70,
fill: 0xFFFFFF
});
howToPlayTitle.anchor.set(0.5, 0.5);
howToPlayTitle.x = 1024;
howToPlayTitle.y = 600;
howToPlayMenu.addChild(howToPlayTitle);
var instructionsText1 = new Text2('Notes fall from 3 different points', {
size: 50,
fill: 0xFFFFFF
});
instructionsText1.anchor.set(0.5, 0.5);
instructionsText1.x = 1024;
instructionsText1.y = 900;
howToPlayMenu.addChild(instructionsText1);
var instructionsText2 = new Text2('from top to bottom.', {
size: 50,
fill: 0xFFFFFF
});
instructionsText2.anchor.set(0.5, 0.5);
instructionsText2.x = 1024;
instructionsText2.y = 970;
howToPlayMenu.addChild(instructionsText2);
var instructionsText3 = new Text2('Touch the notes before they disappear', {
size: 50,
fill: 0xFFFFFF
});
instructionsText3.anchor.set(0.5, 0.5);
instructionsText3.x = 1024;
instructionsText3.y = 1040;
howToPlayMenu.addChild(instructionsText3);
var instructionsText4 = new Text2('and earn 5 points.', {
size: 50,
fill: 0xFFFFFF
});
instructionsText4.anchor.set(0.5, 0.5);
instructionsText4.x = 1024;
instructionsText4.y = 1110;
howToPlayMenu.addChild(instructionsText4);
var instructionsText5 = new Text2('If you cannot touch them in time,', {
size: 50,
fill: 0xFFFFFF
});
instructionsText5.anchor.set(0.5, 0.5);
instructionsText5.x = 1024;
instructionsText5.y = 1180;
howToPlayMenu.addChild(instructionsText5);
var instructionsText6 = new Text2('your 5 points will decrease and', {
size: 50,
fill: 0xFFFFFF
});
instructionsText6.anchor.set(0.5, 0.5);
instructionsText6.x = 1024;
instructionsText6.y = 1250;
howToPlayMenu.addChild(instructionsText6);
var instructionsText7 = new Text2('the game will end at -50 points', {
size: 50,
fill: 0xFFFFFF
});
instructionsText7.anchor.set(0.5, 0.5);
instructionsText7.x = 1024;
instructionsText7.y = 1320;
howToPlayMenu.addChild(instructionsText7);
var backFromHowToPlayButton = new MenuButton('BACK', function () {
showMainMenu();
});
backFromHowToPlayButton.x = 1024;
backFromHowToPlayButton.y = 1500;
howToPlayMenu.addChild(backFromHowToPlayButton);
game.addChild(mainMenu);
game.addChild(difficultyMenu);
game.addChild(howToPlayMenu);
difficultyMenu.visible = false;
howToPlayMenu.visible = false;
// UI Elements
var scoreText = new Text2('0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
scoreText.x = 0;
scoreText.y = 50;
LK.gui.top.addChild(scoreText);
var comboText = new Text2('Combo: 0', {
size: 50,
fill: 0xFFFF00
});
comboText.anchor.set(1, 0);
comboText.x = -50;
comboText.y = 130;
LK.gui.topRight.addChild(comboText);
var highScoreText = new Text2('High Score: ' + (storage.highScore || 0), {
size: 40,
fill: 0xFFFFFF
});
highScoreText.anchor.set(1, 0);
highScoreText.x = -50;
highScoreText.y = 200;
LK.gui.topRight.addChild(highScoreText);
// Hide UI initially
scoreText.visible = false;
comboText.visible = false;
highScoreText.visible = false;
// Create restart button for game screen
var restartButton = new MenuButton('↺', function () {
// Reset game state
gameScore = 0;
gameCombo = 0;
spawnTimer = 0;
// Clear all notes
for (var i = notes.length - 1; i >= 0; i--) {
removeNote(notes[i]);
}
// Clear all long notes
for (var i = longNotes.length - 1; i >= 0; i--) {
removeLongNote(longNotes[i]);
}
updateUI();
});
restartButton.x = 924;
restartButton.y = 50;
restartButton.scaleX = 0.42;
restartButton.scaleY = 0.42;
gameContainer.addChild(restartButton);
// Create return to main menu button for game screen
var returnMenuButton = new MenuButton('🏠', function () {
// Stop game music and start menu music
LK.stopMusic();
LK.playMusic('menumusic', {
loop: true
});
gameState = 'menu';
gameContainer.visible = false;
scoreText.visible = false;
comboText.visible = false;
highScoreText.visible = false;
// Clear all notes
for (var i = notes.length - 1; i >= 0; i--) {
removeNote(notes[i]);
}
// Clear all long notes
for (var i = longNotes.length - 1; i >= 0; i--) {
removeLongNote(longNotes[i]);
}
// Reset game variables
gameScore = 0;
gameCombo = 0;
spawnTimer = 0;
updateUI();
// Show main menu
showMainMenu();
});
returnMenuButton.x = 1124;
returnMenuButton.y = 50;
returnMenuButton.scaleX = 0.42;
returnMenuButton.scaleY = 0.42;
gameContainer.addChild(returnMenuButton);
// Create note pads
var padPositions = [512, 1024, 1536]; // Left, center, right positions
game.addChild(gameContainer);
gameContainer.visible = false;
// Create intro text
var introText = new Text2('lighten the darkness with music', {
size: 80,
fill: 0xFFFFFF
});
introText.anchor.set(0.5, 0.5);
introText.x = 1024;
introText.y = 1366;
introText.alpha = 1;
game.addChild(introText);
// Create black overlay for screen blackout effect
var blackOverlay = LK.getAsset('notePad', {
anchorX: 0,
anchorY: 0,
scaleX: 10,
scaleY: 35,
x: 0,
y: 0
});
blackOverlay.tint = 0x000000;
blackOverlay.alpha = 0.8;
game.addChild(blackOverlay);
// Show intro text with fade in effect and black screen - starting 4.5 seconds earlier
LK.setTimeout(function () {
// Hold for 2 seconds then fade out
LK.setTimeout(function () {
tween(introText, {
alpha: 0
}, {
duration: 1500,
onFinish: function onFinish() {
game.removeChild(introText);
}
});
// Fade black overlay out
tween(blackOverlay, {
alpha: 0
}, {
duration: 1500,
onFinish: function onFinish() {
game.removeChild(blackOverlay);
}
});
}, 2000);
}, 0); // Start 4.5 seconds earlier (reduced from 500ms to 0ms)
// Start menu music
LK.playMusic('menumusic', {
loop: true
});
function showDifficultyMenu() {
gameState = 'difficulty';
mainMenu.visible = false;
difficultyMenu.visible = true;
}
function showHowToPlayMenu() {
gameState = 'howtoplay';
mainMenu.visible = false;
howToPlayMenu.visible = true;
}
function showMainMenu() {
gameState = 'menu';
mainMenu.visible = true;
difficultyMenu.visible = false;
howToPlayMenu.visible = false;
}
function startGame() {
gameState = 'playing';
mainMenu.visible = false;
difficultyMenu.visible = false;
gameContainer.visible = true;
scoreText.visible = true;
comboText.visible = true;
highScoreText.visible = true;
// Reset game state
gameScore = 0;
gameCombo = 0;
spawnTimer = 0;
// Set note speed based on difficulty
var noteSpeed = 8; // normal speed
if (selectedDifficulty === 'easy') {
noteSpeed = 12; // 1.5 times faster than normal (8 * 1.5)
} else if (selectedDifficulty === 'normal') {
noteSpeed = 28; // 3.5 times faster than normal (8 * 3.5)
} else if (selectedDifficulty === 'hard') {
noteSpeed = 32; // 4 times faster than normal (8 * 4)
}
// Update all note pads with new speed
Note.prototype.speed = noteSpeed;
// Clear any existing notes
for (var i = notes.length - 1; i >= 0; i--) {
removeNote(notes[i]);
}
// Clear any existing long notes
for (var i = longNotes.length - 1; i >= 0; i--) {
removeLongNote(longNotes[i]);
}
// Stop menu music and start game music
LK.stopMusic();
LK.playMusic('bgmusic', {
loop: true
});
updateUI();
// Update high score display for selected difficulty
var highScoreKey = 'highScore_' + selectedDifficulty;
highScoreText.setText('Best (' + selectedDifficulty.toUpperCase() + '): ' + (storage[highScoreKey] || 0));
}
function spawnNote() {
var randomLane = Math.floor(Math.random() * 3);
// 20% chance to spawn a long note instead of regular note
if (Math.random() < 0.2) {
var longNote = new LongNote(randomLane);
longNote.x = padPositions[randomLane];
longNote.y = -50;
longNotes.push(longNote);
gameContainer.addChild(longNote);
} else {
var note = new Note(randomLane);
note.x = padPositions[randomLane];
note.y = -50;
notes.push(note);
gameContainer.addChild(note);
}
}
function checkNoteHit(lane) {
var hitNote = null;
var bestDistance = Infinity;
// Find the closest note in the perfect zone for this lane
for (var i = 0; i < notes.length; i++) {
var note = notes[i];
if (note.lane === lane && !note.hasBeenHit) {
var distance = Math.abs(note.y - perfectZoneY);
if (distance < perfectTolerance && distance < bestDistance) {
hitNote = note;
bestDistance = distance;
}
}
}
if (hitNote) {
// Perfect hit
hitNote.hasBeenHit = true;
gameScore += 5;
gameCombo += 1;
// Create explosion effect
createExplosionEffect(hitNote.x, hitNote.y);
// Change background color effect
var colors = [0xff6b6b, 0x4ecdc4, 0x45b7d1, 0x96ceb4, 0xfeca57, 0xff9ff3, 0x54a0ff];
var randomColor = colors[Math.floor(Math.random() * colors.length)];
game.setBackgroundColor(randomColor);
// Visual effect
tween(hitNote, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 200,
onFinish: function onFinish() {
removeNote(hitNote);
}
});
LK.getSound('success').play();
updateUI();
} else {
// Wrong timing
gameScore -= 5;
gameCombo = 0;
LK.effects.flashScreen(0xff0000, 200);
updateUI();
}
}
function createExplosionEffect(x, y) {
// Create multiple explosion particles
for (var i = 0; i < 8; i++) {
var particle = LK.getAsset('note', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
particle.x = x;
particle.y = y;
particle.tint = 0xFFFF00; // Yellow explosion color
gameContainer.addChild(particle);
// Random direction for each particle
var angle = i / 8 * Math.PI * 2;
var speed = 100 + Math.random() * 50;
var targetX = x + Math.cos(angle) * speed;
var targetY = y + Math.sin(angle) * speed;
// Animate particle outward and fade
tween(particle, {
x: targetX,
y: targetY,
alpha: 0,
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
gameContainer.removeChild(particle);
}
});
}
}
function showComboEffect(x, y) {
var comboEffect = new Text2('COMBO!', {
size: 80,
fill: 0xFFFF00
});
comboEffect.anchor.set(0.5, 0.5);
comboEffect.x = x;
comboEffect.y = y;
gameContainer.addChild(comboEffect);
tween(comboEffect, {
y: y - 100,
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
gameContainer.removeChild(comboEffect);
}
});
}
function checkLongNoteHit(lane) {
for (var i = 0; i < longNotes.length; i++) {
var longNote = longNotes[i];
if (longNote.lane === lane && !longNote.hasBeenHit && !longNote.isBeingHeld) {
var distance = Math.abs(longNote.y - perfectZoneY);
if (distance < perfectTolerance * 2) {
longNote.isBeingHeld = true;
longNote.holdStartY = longNote.y;
// Visual feedback for holding
longNote.children[0].tint = 0x00ff00; // Green when being held
// Change background color effect
var colors = [0xff6b6b, 0x4ecdc4, 0x45b7d1, 0x96ceb4, 0xfeca57, 0xff9ff3, 0x54a0ff];
var randomColor = colors[Math.floor(Math.random() * colors.length)];
game.setBackgroundColor(randomColor);
break;
}
}
}
}
function checkLongNoteRelease(lane) {
for (var i = longNotes.length - 1; i >= 0; i--) {
var longNote = longNotes[i];
if (longNote.lane === lane && longNote.isBeingHeld && !longNote.hasBeenHit) {
// Released before completion - stop holding
longNote.isBeingHeld = false;
longNote.holdTimer = 0;
// Reset visual feedback
longNote.children[0].tint = 0x9932cc; // Back to purple
break;
}
}
}
function removeLongNote(longNote) {
var index = longNotes.indexOf(longNote);
if (index > -1) {
longNotes.splice(index, 1);
gameContainer.removeChild(longNote);
}
}
function removeNote(note) {
var index = notes.indexOf(note);
if (index > -1) {
notes.splice(index, 1);
gameContainer.removeChild(note);
}
}
function updateUI() {
scoreText.setText(gameScore);
comboText.setText('Combo: ' + gameCombo);
LK.setScore(gameScore);
// Update high score if current score is higher
var highScoreKey = 'highScore_' + selectedDifficulty;
var currentHighScore = storage[highScoreKey] || 0;
if (gameScore > currentHighScore) {
storage[highScoreKey] = gameScore;
}
highScoreText.setText('Best (' + selectedDifficulty.toUpperCase() + '): ' + (storage[highScoreKey] || 0));
// Check for game over at -50 points
if (gameScore <= -50) {
LK.showGameOver();
}
}
// Add pause menu functionality
var pauseMenu = new Container();
var pauseTitle = new Text2('Game Paused', {
size: 70,
fill: 0xFFFFFF
});
pauseTitle.anchor.set(0.5, 0.5);
pauseTitle.x = 1024;
pauseTitle.y = 1000;
pauseMenu.addChild(pauseTitle);
var resumeButton = new MenuButton('RESUME', function () {
pauseMenu.visible = false;
});
resumeButton.x = 1024;
resumeButton.y = 1200;
pauseMenu.addChild(resumeButton);
var mainMenuButton = new MenuButton('MAIN MENU', function () {
// Stop game music and start menu music
LK.stopMusic();
LK.playMusic('menumusic', {
loop: true
});
gameState = 'menu';
pauseMenu.visible = false;
gameContainer.visible = false;
scoreText.visible = false;
comboText.visible = false;
highScoreText.visible = false;
// Clear all notes
for (var i = notes.length - 1; i >= 0; i--) {
removeNote(notes[i]);
}
// Clear all long notes
for (var i = longNotes.length - 1; i >= 0; i--) {
removeLongNote(longNotes[i]);
}
// Reset game variables
gameScore = 0;
gameCombo = 0;
spawnTimer = 0;
updateUI();
// Show main menu
showMainMenu();
});
mainMenuButton.x = 1024;
mainMenuButton.y = 1350;
pauseMenu.addChild(mainMenuButton);
game.addChild(pauseMenu);
pauseMenu.visible = false;
game.update = function () {
if (gameState !== 'playing') {
return;
}
// Spawn notes
spawnTimer++;
if (spawnTimer >= spawnInterval) {
spawnNote();
spawnTimer = 0;
}
// Update and check notes
for (var i = notes.length - 1; i >= 0; i--) {
var note = notes[i];
// Check if note reached bottom (missed)
if (note.y > 2800 && !note.hasBeenHit) {
gameScore -= 5;
gameCombo = 0;
LK.getSound('fail').play();
updateUI();
removeNote(note);
}
}
// Update and check long notes
for (var i = longNotes.length - 1; i >= 0; i--) {
var longNote = longNotes[i];
// Check if long note reached bottom
if (longNote.y > 2800) {
if (!longNote.hasBeenHit) {
// Missed long note, lose points
gameScore -= 5;
gameCombo = 0;
LK.getSound('fail').play();
updateUI();
}
removeLongNote(longNote);
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -20,10 +20,37 @@
self.speed = Note.prototype.speed || 8;
self.hasBeenHit = false;
self.isBeingHeld = false;
self.holdStartY = null;
+ self.holdTimer = 0;
+ self.holdDuration = 60; // 1 second at 60fps
self.update = function () {
self.y += self.speed;
+ // If being held, count down and make note disappear when hold is complete
+ if (self.isBeingHeld && !self.hasBeenHit) {
+ self.holdTimer++;
+ if (self.holdTimer >= self.holdDuration) {
+ // Successfully held for required duration - make note disappear
+ self.hasBeenHit = true;
+ gameScore += 5;
+ gameCombo += 1;
+ // Create explosion effect
+ createExplosionEffect(self.x, self.y);
+ // Visual effect - fade out and scale up
+ tween(self, {
+ alpha: 0,
+ scaleX: 2,
+ scaleY: 2
+ }, {
+ duration: 200,
+ onFinish: function onFinish() {
+ removeLongNote(self);
+ }
+ });
+ LK.getSound('success').play();
+ updateUI();
+ }
+ }
};
self.down = function (x, y, obj) {
if (!self.hasBeenHit && !self.isBeingHeld) {
// Check if touch is in the hold zone
@@ -31,8 +58,9 @@
if (distance < perfectTolerance * 2) {
// Larger tolerance for long notes
self.isBeingHeld = true;
self.holdStartY = self.y;
+ self.holdTimer = 0; // Reset hold timer
// Visual feedback for holding
noteGraphics.tint = 0x00ff00; // Green when being held
// Change background color effect
var colors = [0xff6b6b, 0x4ecdc4, 0x45b7d1, 0x96ceb4, 0xfeca57, 0xff9ff3, 0x54a0ff];
@@ -40,8 +68,17 @@
game.setBackgroundColor(randomColor);
}
}
};
+ self.up = function (x, y, obj) {
+ // If released before hold duration is complete, stop holding
+ if (self.isBeingHeld && !self.hasBeenHit) {
+ self.isBeingHeld = false;
+ self.holdTimer = 0;
+ // Reset visual feedback
+ noteGraphics.tint = 0x9932cc; // Back to purple
+ }
+ };
return self;
});
// Game starts in menu state
var MenuButton = Container.expand(function (text, onClickCallback) {
@@ -640,28 +677,14 @@
}
function checkLongNoteRelease(lane) {
for (var i = longNotes.length - 1; i >= 0; i--) {
var longNote = longNotes[i];
- if (longNote.lane === lane && longNote.isBeingHeld) {
- // Successfully held the long note, give 5 points
- gameScore += 5;
- gameCombo += 1;
- longNote.hasBeenHit = true;
- // Create explosion effect
- createExplosionEffect(longNote.x, longNote.y);
- // Visual effect
- tween(longNote, {
- alpha: 0,
- scaleX: 2,
- scaleY: 2
- }, {
- duration: 200,
- onFinish: function onFinish() {
- removeLongNote(longNote);
- }
- });
- LK.getSound('success').play();
- updateUI();
+ if (longNote.lane === lane && longNote.isBeingHeld && !longNote.hasBeenHit) {
+ // Released before completion - stop holding
+ longNote.isBeingHeld = false;
+ longNote.holdTimer = 0;
+ // Reset visual feedback
+ longNote.children[0].tint = 0x9932cc; // Back to purple
break;
}
}
}