User prompt
elimina la canción de fondo
User prompt
agrega a niveles un ID
User prompt
agrega a addnote a que nivel pertenecen asi forzar su aparición allí. addNote(nivel, time, x, y)
User prompt
crea una variable de objeto llamada niveles donde salen: Nombre, canción, puntuación max.
User prompt
agrega audio offset y noteoffset
User prompt
agrega un boton play al principio
Code edit (2 edits merged)
Please save this source code
User prompt
Agrega musica de fondo
Code edit (1 edits merged)
Please save this source code
User prompt
Asegúrate que las notas solo se puedan presionar si son 1 y que las que no son tengan un 0.8 de transparencia
User prompt
Haz que la nota tenga valor 1 para ser interactuable
User prompt
Haz que la nota 1 sea interactuable
User prompt
Crea un sistema para hacer que los viejas notas siempre aparezcan encima de las nuevas
User prompt
Crea un sistema para que siempre las primeras notas vayan por encima de las que aparecen mas tarde
User prompt
haz que solo se pueda tocar la nota 1
Code edit (1 edits merged)
Please save this source code
User prompt
si no se especifica la posición o si es === 0 que la posición sea random
User prompt
agrega en add note la ubicacion del eje x e y
Code edit (2 edits merged)
Please save this source code
User prompt
Agrega a las Notes un gran numero en el centro en el orden de aparición, cuando el 1 se rompe, el segundo pasa a ser 1
Code edit (1 edits merged)
Please save this source code
User prompt
agrega una forma más comoda visualmente de agregar notas. EN vez de los ticks (500) que sea con el timer (0:01.00)
User prompt
agrea 5 notas random
User prompt
Crea una función reusable para agregar notas manualmente según el tiempo. EJ: note(time)
User prompt
agrega 5 notas random
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Note = Container.expand(function () { var self = Container.call(this); var hitZone = self.attachAsset('hit', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.6, scaleY: 1.6 }); hitZone.alpha = 0.4; var hitAccuracy = self.attachAsset('hit', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.5, scaleY: 2.5 }); hitAccuracy.alpha = 0.25; var hitAccuracyTargetScale = 1.6; var hitAccuracyStartScale = 3.4; hitAccuracy.scaleX = hitAccuracyStartScale; hitAccuracy.scaleY = hitAccuracyStartScale; tween(hitAccuracy, { scaleX: hitAccuracyTargetScale, scaleY: hitAccuracyTargetScale }, { duration: 1000 / speed }); var noteAsset = self.attachAsset('note', { anchorX: 0.5, anchorY: 0.5 }); self.numberText = new Text2('1', { size: 150, fill: 0x000000 }); self.numberText.anchor.set(0.5, 0.5); self.addChild(self.numberText); self.setNumber = function (num) { self.numberText.setText(num.toString()); }; var margin = 100; self.x = margin + Math.random() * (2048 - 2 * margin); self.y = margin + Math.random() * (2732 - 2 * margin); var MARVELOUS_WINDOW = 30; var PERFECT_WINDOW = 70; var GOOD_WINDOW = 120; var BAD_WINDOW = 180; var FAIL_WINDOW = 250; self.spawnTime = Date.now(); self.hitZoneTime = self.spawnTime + 1000 / speed; function showFeedback(result, msValue) { var colorMap = { marvelous: 0x00fffc, perfect: 0x00ff00, good: 0xffff00, bad: 0xffa500, fail: 0xff0000 }; var color = colorMap[result] || 0xffffff; var msText = ""; if (typeof msValue === "number") { var msAbs = Math.abs(Math.round(msValue)); msText = " / " + (msValue > 0 ? "-" : "") + msAbs + "ms"; } var feedback = new Text2(result.toUpperCase() + msText, { size: 120, fill: "#" + ("000000" + color.toString(16)).slice(-6) }); feedback.anchor.set(0.5, 0); feedback.x = 2048 / 2; feedback.y = 120; game.addChild(feedback); tween(feedback, { alpha: 0, y: feedback.y - 60 }, { duration: 500 }); LK.setTimeout(function () { feedback.destroy(); }, 500); } self.down = function (x, y, obj) { var now = Date.now(); var msDiff = now - self.hitZoneTime; var absMs = Math.abs(msDiff); var result = "fail"; if (absMs <= MARVELOUS_WINDOW) { result = "marvelous"; marvelousCount++; } else if (absMs <= PERFECT_WINDOW) { result = "perfect"; perfectCount++; } else if (absMs <= GOOD_WINDOW) { result = "good"; goodCount++; } else if (absMs <= BAD_WINDOW) { result = "bad"; badCount++; } else if (absMs <= FAIL_WINDOW) { result = "fail"; failCount++; } if (now < self.spawnTime + 0.2 * (self.hitZoneTime - self.spawnTime)) { result = "fail"; failCount++; } updateAccuracyDisplay(); LK.getSound('hitSound').play(); showFeedback(result, msDiff); removeNoteFromActive(self); self.destroy(); }; self.update = function () { var now = Date.now(); if (now - self.hitZoneTime > FAIL_WINDOW) { failCount++; updateAccuracyDisplay(); showFeedback("fail", undefined); removeNoteFromActive(self); self.destroy(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var ms; var time = 0; var gameStartTime; var gameStart; var timerText; var speed = 1.3; var note; var life = 100; var combo = 0; var score = 0; var marvelousCount = 0; var perfectCount = 0; var goodCount = 0; var badCount = 0; var failCount = 0; var noteCounter = 0; var activeNotes = []; var accuracyDisplayConfig = [{ label: 'Marvelous', color: 0x00FFFC, yOffset: -300, type: 'marvelous' }, { label: 'Perfect', color: 0x00FF00, yOffset: -240, type: 'perfect' }, { label: 'Good', color: 0xFFFF00, yOffset: -180, type: 'good' }, { label: 'Bad', color: 0xFFA500, yOffset: -120, type: 'bad' }, { label: 'Fail', color: 0xFF0000, yOffset: -60, type: 'fail' }]; var accuracyTexts = {}; function createAccuracyText(label, color, yOffset) { var txt = new Text2(label + ': 0', { size: 40, fill: color }); txt.anchor.set(1, 0); txt.x = -20; txt.y = yOffset; LK.gui.bottomRight.addChild(txt); return txt; } // Reusable function to create notes at specific times var scheduledNotes = []; function addNote(timeString, x, y) { // Convert time string format "M:SS.CC" or "MM:SS.CC" to milliseconds var parts = timeString.split(':'); var minutes = parseInt(parts[0]); var secondsParts = parts[1].split('.'); var seconds = parseInt(secondsParts[0]); var centiseconds = parseInt(secondsParts[1]); var totalMs = minutes * 60 * 1000 + seconds * 1000 + centiseconds * 10; scheduledNotes.push({ time: totalMs, created: false, x: x, y: y }); } function createNoteAtPosition(x, y) { var newNote = new Note(); // Use random position if x is undefined, null, or 0 if (x === undefined || x === null || x === 0) { newNote.x = 100 + Math.random() * (2048 - 200); } else { newNote.x = x; } // Use random position if y is undefined, null, or 0 if (y === undefined || y === null || y === 0) { newNote.y = 100 + Math.random() * (2732 - 200); } else { newNote.y = y; } noteCounter++; newNote.orderNumber = noteCounter; newNote.setNumber(activeNotes.length + 1); activeNotes.push(newNote); // Remove from game if already present (defensive, in case of re-adding) if (newNote.parent) { newNote.parent.removeChild(newNote); } // Always add as topmost child so it appears above previous notes game.addChild(newNote); // Move all active notes to top in order, so the first note is always on top for (var i = 0; i < activeNotes.length; i++) { if (activeNotes[i].parent === game) { game.removeChild(activeNotes[i]); game.addChild(activeNotes[i]); } } return newNote; } function updateNoteNumbers() { for (var i = 0; i < activeNotes.length; i++) { activeNotes[i].setNumber(i + 1); } } function removeNoteFromActive(note) { var index = activeNotes.indexOf(note); if (index > -1) { activeNotes.splice(index, 1); updateNoteNumbers(); } } accuracyDisplayConfig.forEach(function (cfg) { accuracyTexts[cfg.type] = createAccuracyText(cfg.label, cfg.color, cfg.yOffset); }); function updateAccuracyDisplay() { accuracyTexts.marvelous.setText('Marvelous: ' + marvelousCount); accuracyTexts.perfect.setText('Perfect: ' + perfectCount); accuracyTexts.good.setText('Good: ' + goodCount); accuracyTexts.bad.setText('Bad: ' + badCount); accuracyTexts.fail.setText('Fail: ' + failCount); } /* * Initializations */ gameStartTime = Date.now(); timerText = new Text2('0:00.00', { size: 60, fill: 0xFFFFFF }); timerText.anchor.set(0.5, 0); timerText.x = 0; timerText.y = 50; LK.gui.top.addChild(timerText); // Example usage: addNote("0:01.00") will create a note at 1 second // addNote("0:02.00") will create a note at 2 seconds // addNote("0:03.50") will create a note at 3.5 seconds // Add 5 random notes addNote("0:00.50", 1000, 400); addNote("0:00.60", 1000, 500); addNote("0:00.70", 1000, 600); addNote("0:00.80", 1000, 700); addNote("0:00.90", 1000, 800); game.update = function () { var currentTime = Date.now(); var elapsedMs = currentTime - gameStartTime; var totalSeconds = Math.floor(elapsedMs / 1000); var minutes = Math.floor(totalSeconds / 60); var seconds = totalSeconds % 60; var centiseconds = Math.floor(elapsedMs % 1000 / 10); var timeString = minutes + ':' + (seconds < 10 ? '0' : '') + seconds + '.' + (centiseconds < 10 ? '0' : '') + centiseconds; timerText.setText(timeString); // Check scheduled notes for (var i = 0; i < scheduledNotes.length; i++) { var scheduled = scheduledNotes[i]; if (!scheduled.created && elapsedMs >= scheduled.time) { createNoteAtPosition(scheduled.x, scheduled.y); scheduled.created = true; } } };
===================================================================
--- original.js
+++ change.js
@@ -87,13 +87,8 @@
feedback.destroy();
}, 500);
}
self.down = function (x, y, obj) {
- // Only allow the first note in activeNotes to be touched
- if (activeNotes.length === 0 || activeNotes[0] !== self) {
- // Ignore touch if not the first note
- return;
- }
var now = Date.now();
var msDiff = now - self.hitZoneTime;
var absMs = Math.abs(msDiff);
var result = "fail";
@@ -235,9 +230,21 @@
noteCounter++;
newNote.orderNumber = noteCounter;
newNote.setNumber(activeNotes.length + 1);
activeNotes.push(newNote);
+ // Remove from game if already present (defensive, in case of re-adding)
+ if (newNote.parent) {
+ newNote.parent.removeChild(newNote);
+ }
+ // Always add as topmost child so it appears above previous notes
game.addChild(newNote);
+ // Move all active notes to top in order, so the first note is always on top
+ for (var i = 0; i < activeNotes.length; i++) {
+ if (activeNotes[i].parent === game) {
+ game.removeChild(activeNotes[i]);
+ game.addChild(activeNotes[i]);
+ }
+ }
return newNote;
}
function updateNoteNumbers() {
for (var i = 0; i < activeNotes.length; i++) {