User prompt
Make actual music
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'comboText.style.fill = comboColors[colorIndex];' Line Number: 750
User prompt
Make the bottom circles (hitnotes) higher
User prompt
Make it so if the accuracy is less than 40% game over and the background purple
User prompt
Or notes are circles with 12345678§∆×÷π√✓><
User prompt
Try making the notes to <>∆✓
User prompt
Make so i can choose
User prompt
The notes too
User prompt
Make bigger
User prompt
Make 4 squares in the bottom for me to click
User prompt
Exactly:
Click anywhere when the glowing notes reach the bottom area!
User prompt
Make it exactly:
Click anywhere when the glowing notes reach the bottom area!
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var HitEffect = Container.expand(function (x, y) {
var self = Container.call(this);
self.x = x;
self.y = y;
self.lifetime = 30;
self.age = 0;
self.effect = self.attachAsset('hitEffect', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0,
scaleY: 0
});
// Animate the effect
tween(self.effect, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 600,
onFinish: function onFinish() {
self.destroy();
for (var i = hitEffects.length - 1; i >= 0; i--) {
if (hitEffects[i] === self) {
hitEffects.splice(i, 1);
break;
}
}
}
});
return self;
});
var Note = Container.expand(function (position, type, duration) {
var self = Container.call(this);
self.position = position || 0;
self.type = type || 'normal';
self.duration = duration || 0;
self.speed = 5;
self.hit = false;
self.missed = false;
self.holdPressed = false;
self.holdDuration = 0;
self.lastY = -100;
self.lastIntersecting = false;
// Note data for different positions
var noteColors = ['note1', 'note2', 'note3', 'note4', 'note5'];
var noteSymbols = ['♪', '♫', '♩', '♬', '♭'];
if (self.type === 'hold') {
self.noteGraphics = self.attachAsset('holdNote', {
anchorX: 0.5,
anchorY: 0.5
});
} else {
self.noteGraphics = self.attachAsset(noteColors[self.position], {
anchorX: 0.5,
anchorY: 0.5
});
}
// Position based on lane (5 lanes across screen)
self.x = 50 + self.position * 400 + Math.random() * 40;
self.y = -100;
self.lastY = self.y;
self.update = function () {
self.y += self.speed;
// Add pulsing glow effect
var pulse = Math.sin(LK.ticks * 0.3) * 0.2 + 0.8;
self.noteGraphics.alpha = pulse;
// Check if note reached hit zone
var hitZoneY = 2732 - 150;
var currentIntersecting = Math.abs(self.y - hitZoneY) < 80;
// Miss detection - when note passes hit zone
if (self.lastY <= hitZoneY + 100 && self.y > hitZoneY + 100 && !self.hit && !self.missed) {
self.missed = true;
combo = 0;
totalNotes++;
updateDisplays();
}
// Update tracking variables
self.lastY = self.y;
self.lastIntersecting = currentIntersecting;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0a0a1a
});
/****
* Game Code
****/
// Game variables
var notes = [];
var hitEffects = [];
var combo = 0;
var score = 0;
var hits = 0;
var totalNotes = 0;
var gameStarted = false;
var noteSpawnTimer = 0;
var currentSong = 'random';
var gameStartTime = 0;
var songData = {
random: {
name: "Random Notes",
bpm: 100
},
falseMeaning: {
name: "False Meaning",
bpm: 95,
notes: [{
time: 1000,
positions: [0],
type: "normal"
}, {
time: 1250,
positions: [1],
type: "normal"
}, {
time: 1500,
positions: [2],
type: "hold",
duration: 500
}, {
time: 1500,
positions: [3],
type: "normal"
}, {
time: 2000,
positions: [4],
type: "normal"
}, {
time: 2250,
positions: [3],
type: "hold",
duration: 750
}, {
time: 2500,
positions: [0],
type: "normal"
}, {
time: 2750,
positions: [1],
type: "normal"
}, {
time: 3000,
positions: [2],
type: "hold",
duration: 1000
}, {
time: 3250,
positions: [1],
type: "normal"
}, {
time: 3500,
positions: [3],
type: "hold",
duration: 500
}, {
time: 3750,
positions: [4],
type: "normal"
}, {
time: 4000,
positions: [0],
type: "hold",
duration: 1500
}, {
time: 4000,
positions: [2],
type: "normal"
}, {
time: 4200,
positions: [4],
type: "hold",
duration: 1000
}, {
time: 4300,
positions: [1, 3],
type: "normal"
}]
}
};
// Create hit zone
var hitZone = game.addChild(LK.getAsset('hitZone', {
anchorX: 0.5,
anchorY: 0.5
}));
hitZone.x = 2048 / 2;
hitZone.y = 2732 - 150;
hitZone.alpha = 0.2;
// UI Elements
var scoreText = new Text2('Score: 0', {
size: 80,
fill: 0x9D65FF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var comboText = new Text2('Combo: 0', {
size: 60,
fill: 0xFF65D7
});
comboText.anchor.set(1, 0);
LK.gui.topRight.addChild(comboText);
var accuracyText = new Text2('Accuracy: 100%', {
size: 50,
fill: 0x65B3FF
});
accuracyText.anchor.set(0, 0);
LK.gui.topLeft.addChild(accuracyText);
accuracyText.x = 120;
function spawnNote() {
var position = Math.floor(Math.random() * 5);
var noteType = Math.random() < 0.2 ? 'hold' : 'normal';
var duration = noteType === 'hold' ? 300 + Math.random() * 700 : 0;
var note = new Note(position, noteType, duration);
notes.push(note);
game.addChild(note);
totalNotes++;
}
function updateDisplays() {
LK.setScore(score);
scoreText.setText('Score: ' + score);
comboText.setText('Combo: ' + combo);
var accuracy = totalNotes > 0 ? Math.round(hits / totalNotes * 100) : 100;
accuracyText.setText('Accuracy: ' + accuracy + '%');
// Dynamic combo glow effect
if (combo > 5) {
var glowIntensity = Math.min(combo, 20);
comboText.alpha = 0.8 + Math.sin(LK.ticks * 0.2) * 0.2;
} else {
comboText.alpha = 1;
}
}
function createHitEffect(x, y) {
var effect = new HitEffect(x, y);
hitEffects.push(effect);
game.addChild(effect);
}
function getLaneFromX(x) {
if (x < 250) return 0;
if (x < 650) return 1;
if (x < 1050) return 2;
if (x < 1450) return 3;
return 4;
}
game.down = function (x, y, obj) {
var lane = getLaneFromX(x);
var hitZoneY = 2732 - 150;
var hitFound = false;
// Find the closest note in this lane
var closestNote = null;
var closestDistance = Infinity;
for (var i = 0; i < notes.length; i++) {
var note = notes[i];
if (note.position === lane && !note.hit && !note.missed) {
var distance = Math.abs(note.y - hitZoneY);
if (distance < closestDistance) {
closestDistance = distance;
closestNote = note;
}
}
}
if (closestNote && closestDistance < 80) {
closestNote.hit = true;
hitFound = true;
hits++;
combo++;
// Score calculation
var basePoints = 100;
var multiplier = Math.max(1, Math.floor(combo / 10) + 1);
if (closestDistance < 30) {
// Perfect hit
score += basePoints * 2 * multiplier;
LK.getSound('shoot').play();
createHitEffect(closestNote.x, closestNote.y);
} else {
// Good hit
score += basePoints * multiplier;
LK.getSound('shoot').play();
}
updateDisplays();
// Flash hit zone
tween(hitZone, {
alpha: 0.6
}, {
duration: 100,
onFinish: function onFinish() {
tween(hitZone, {
alpha: 0.2
}, {
duration: 200
});
}
});
// Create neon flash effect on screen
LK.effects.flashScreen(0xff65d7, 100);
}
if (!hitFound) {
combo = 0;
updateDisplays();
}
};
game.update = function () {
// Start background music
if (!gameStarted) {
LK.playMusic('bgmusic');
gameStarted = true;
gameStartTime = LK.ticks;
}
// Spawn notes
if (currentSong === 'random') {
noteSpawnTimer++;
if (noteSpawnTimer >= 60) {
// Spawn every second
spawnNote();
noteSpawnTimer = 0;
// Increase difficulty over time
if (totalNotes % 20 === 0 && noteSpawnTimer > 30) {
noteSpawnTimer = Math.max(30, noteSpawnTimer - 5);
}
}
}
// Clean up off-screen notes
for (var i = notes.length - 1; i >= 0; i--) {
var note = notes[i];
// Remove notes that are off screen or hit
if (note.y > 2800 || note.hit && note.type === 'normal') {
note.destroy();
notes.splice(i, 1);
}
}
// End game condition
if (score >= 50000) {
LK.showYouWin();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -5,93 +5,90 @@
/****
* Classes
****/
-var Note = Container.expand(function (type, lane) {
+var HitEffect = Container.expand(function (x, y) {
var self = Container.call(this);
- self.type = type || 'regular'; // 'regular' or 'hold'
- self.lane = lane || 0;
- self.speed = 8;
+ self.x = x;
+ self.y = y;
+ self.lifetime = 30;
+ self.age = 0;
+ self.effect = self.attachAsset('hitEffect', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0,
+ scaleY: 0
+ });
+ // Animate the effect
+ tween(self.effect, {
+ scaleX: 1.5,
+ scaleY: 1.5,
+ alpha: 0
+ }, {
+ duration: 600,
+ onFinish: function onFinish() {
+ self.destroy();
+ for (var i = hitEffects.length - 1; i >= 0; i--) {
+ if (hitEffects[i] === self) {
+ hitEffects.splice(i, 1);
+ break;
+ }
+ }
+ }
+ });
+ return self;
+});
+var Note = Container.expand(function (position, type, duration) {
+ var self = Container.call(this);
+ self.position = position || 0;
+ self.type = type || 'normal';
+ self.duration = duration || 0;
+ self.speed = 5;
self.hit = false;
self.missed = false;
self.holdPressed = false;
self.holdDuration = 0;
- self.maxHoldDuration = 0;
- // Create note graphics based on type
+ self.lastY = -100;
+ self.lastIntersecting = false;
+ // Note data for different positions
+ var noteColors = ['note1', 'note2', 'note3', 'note4', 'note5'];
+ var noteSymbols = ['♪', '♫', '♩', '♬', '♭'];
if (self.type === 'hold') {
- self.noteGraphics = self.attachAsset('noteHold', {
+ self.noteGraphics = self.attachAsset('holdNote', {
anchorX: 0.5,
anchorY: 0.5
});
- self.maxHoldDuration = 60; // 1 second at 60fps
} else {
- self.noteGraphics = self.attachAsset('noteRegular', {
+ self.noteGraphics = self.attachAsset(noteColors[self.position], {
anchorX: 0.5,
anchorY: 0.5
});
}
- // Position based on lane
- self.x = 256 + self.lane * 384; // 4 lanes across screen
- self.y = -50;
- // Add glow effect
- self.noteGraphics.alpha = 0.9;
+ // Position based on lane (5 lanes across screen)
+ self.x = 50 + self.position * 400 + Math.random() * 40;
+ self.y = -100;
+ self.lastY = self.y;
self.update = function () {
self.y += self.speed;
// Add pulsing glow effect
- var pulse = Math.sin(LK.ticks * 0.2) * 0.1 + 0.9;
+ var pulse = Math.sin(LK.ticks * 0.3) * 0.2 + 0.8;
self.noteGraphics.alpha = pulse;
- // Check if note is in hit zone
+ // Check if note reached hit zone
var hitZoneY = 2732 - 150;
- var distanceFromHitZone = Math.abs(self.y - hitZoneY);
- // Miss detection
- if (self.y > hitZoneY + 100 && !self.hit && !self.missed) {
+ var currentIntersecting = Math.abs(self.y - hitZoneY) < 80;
+ // Miss detection - when note passes hit zone
+ if (self.lastY <= hitZoneY + 100 && self.y > hitZoneY + 100 && !self.hit && !self.missed) {
self.missed = true;
combo = 0;
- accuracy.total++;
- accuracy.missed++;
- LK.getSound('miss').play();
+ totalNotes++;
+ updateDisplays();
}
- // Handle hold notes
- if (self.type === 'hold' && self.hit && self.holdPressed) {
- self.holdDuration++;
- // Change color while holding
- self.noteGraphics.tint = 0x00ff00;
- }
+ // Update tracking variables
+ self.lastY = self.y;
+ self.lastIntersecting = currentIntersecting;
};
return self;
});
-var ParticleEffect = Container.expand(function (x, y) {
- var self = Container.call(this);
- self.x = x;
- self.y = y;
- self.lifetime = 30;
- self.age = 0;
- self.particle = self.attachAsset('perfectEffect', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.5,
- scaleY: 0.5
- });
- self.velocityX = (Math.random() - 0.5) * 10;
- self.velocityY = (Math.random() - 0.5) * 10 - 5;
- self.update = function () {
- self.age++;
- self.x += self.velocityX;
- self.y += self.velocityY;
- var alpha = 1 - self.age / self.lifetime;
- self.particle.alpha = alpha;
- if (self.age >= self.lifetime) {
- self.destroy();
- for (var i = particles.length - 1; i >= 0; i--) {
- if (particles[i] === self) {
- particles.splice(i, 1);
- break;
- }
- }
- }
- };
- return self;
-});
/****
* Initialize Game
****/
@@ -103,95 +100,160 @@
* Game Code
****/
// Game variables
var notes = [];
-var particles = [];
+var hitEffects = [];
var combo = 0;
var score = 0;
-var accuracy = {
- perfect: 0,
- good: 0,
- missed: 0,
- total: 0
-};
+var hits = 0;
+var totalNotes = 0;
var gameStarted = false;
var noteSpawnTimer = 0;
-var activeTouches = {};
+var currentSong = 'random';
+var gameStartTime = 0;
+var songData = {
+ random: {
+ name: "Random Notes",
+ bpm: 100
+ },
+ falseMeaning: {
+ name: "False Meaning",
+ bpm: 95,
+ notes: [{
+ time: 1000,
+ positions: [0],
+ type: "normal"
+ }, {
+ time: 1250,
+ positions: [1],
+ type: "normal"
+ }, {
+ time: 1500,
+ positions: [2],
+ type: "hold",
+ duration: 500
+ }, {
+ time: 1500,
+ positions: [3],
+ type: "normal"
+ }, {
+ time: 2000,
+ positions: [4],
+ type: "normal"
+ }, {
+ time: 2250,
+ positions: [3],
+ type: "hold",
+ duration: 750
+ }, {
+ time: 2500,
+ positions: [0],
+ type: "normal"
+ }, {
+ time: 2750,
+ positions: [1],
+ type: "normal"
+ }, {
+ time: 3000,
+ positions: [2],
+ type: "hold",
+ duration: 1000
+ }, {
+ time: 3250,
+ positions: [1],
+ type: "normal"
+ }, {
+ time: 3500,
+ positions: [3],
+ type: "hold",
+ duration: 500
+ }, {
+ time: 3750,
+ positions: [4],
+ type: "normal"
+ }, {
+ time: 4000,
+ positions: [0],
+ type: "hold",
+ duration: 1500
+ }, {
+ time: 4000,
+ positions: [2],
+ type: "normal"
+ }, {
+ time: 4200,
+ positions: [4],
+ type: "hold",
+ duration: 1000
+ }, {
+ time: 4300,
+ positions: [1, 3],
+ type: "normal"
+ }]
+ }
+};
// Create hit zone
var hitZone = game.addChild(LK.getAsset('hitZone', {
anchorX: 0.5,
anchorY: 0.5
}));
hitZone.x = 2048 / 2;
hitZone.y = 2732 - 150;
-hitZone.alpha = 0.3;
-// Create lane markers
-for (var i = 0; i < 4; i++) {
- var laneMarker = game.addChild(LK.getAsset('trail', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleY: 40
- }));
- laneMarker.x = 256 + i * 384;
- laneMarker.y = 2732 / 2;
- laneMarker.alpha = 0.2;
-}
+hitZone.alpha = 0.2;
// UI Elements
var scoreText = new Text2('Score: 0', {
- size: 60,
- fill: 0x00FFFF
+ size: 80,
+ fill: 0x9D65FF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var comboText = new Text2('Combo: 0', {
- size: 50,
- fill: 0xFFFF00
+ size: 60,
+ fill: 0xFF65D7
});
comboText.anchor.set(1, 0);
LK.gui.topRight.addChild(comboText);
var accuracyText = new Text2('Accuracy: 100%', {
- size: 40,
- fill: 0xFFFFFF
+ size: 50,
+ fill: 0x65B3FF
});
accuracyText.anchor.set(0, 0);
LK.gui.topLeft.addChild(accuracyText);
-accuracyText.x = 120; // Offset from menu button
+accuracyText.x = 120;
function spawnNote() {
- var lane = Math.floor(Math.random() * 4);
- var noteType = Math.random() < 0.2 ? 'hold' : 'regular';
- var note = new Note(noteType, lane);
+ var position = Math.floor(Math.random() * 5);
+ var noteType = Math.random() < 0.2 ? 'hold' : 'normal';
+ var duration = noteType === 'hold' ? 300 + Math.random() * 700 : 0;
+ var note = new Note(position, noteType, duration);
notes.push(note);
game.addChild(note);
+ totalNotes++;
}
-function updateScore(hitType) {
- var basePoints = 100;
- var multiplier = Math.max(1, Math.floor(combo / 10) + 1);
- if (hitType === 'perfect') {
- score += basePoints * 2 * multiplier;
- accuracy.perfect++;
- } else if (hitType === 'good') {
- score += basePoints * multiplier;
- accuracy.good++;
- }
- accuracy.total++;
+function updateDisplays() {
LK.setScore(score);
scoreText.setText('Score: ' + score);
comboText.setText('Combo: ' + combo);
- var accuracyPercent = Math.round((accuracy.perfect + accuracy.good) / accuracy.total * 100);
- accuracyText.setText('Accuracy: ' + accuracyPercent + '%');
-}
-function createParticleEffect(x, y) {
- for (var i = 0; i < 5; i++) {
- var particle = new ParticleEffect(x, y);
- particles.push(particle);
- game.addChild(particle);
+ var accuracy = totalNotes > 0 ? Math.round(hits / totalNotes * 100) : 100;
+ accuracyText.setText('Accuracy: ' + accuracy + '%');
+ // Dynamic combo glow effect
+ if (combo > 5) {
+ var glowIntensity = Math.min(combo, 20);
+ comboText.alpha = 0.8 + Math.sin(LK.ticks * 0.2) * 0.2;
+ } else {
+ comboText.alpha = 1;
}
}
+function createHitEffect(x, y) {
+ var effect = new HitEffect(x, y);
+ hitEffects.push(effect);
+ game.addChild(effect);
+}
function getLaneFromX(x) {
- if (x < 448) return 0;
- if (x < 832) return 1;
- if (x < 1216) return 2;
- return 3;
+ if (x < 250) return 0;
+ if (x < 650) return 1;
+ if (x < 1050) return 2;
+ if (x < 1450) return 3;
+ return 4;
}
game.down = function (x, y, obj) {
var lane = getLaneFromX(x);
var hitZoneY = 2732 - 150;
@@ -200,9 +262,9 @@
var closestNote = null;
var closestDistance = Infinity;
for (var i = 0; i < notes.length; i++) {
var note = notes[i];
- if (note.lane === lane && !note.hit && !note.missed) {
+ if (note.position === lane && !note.hit && !note.missed) {
var distance = Math.abs(note.y - hitZoneY);
if (distance < closestDistance) {
closestDistance = distance;
closestNote = note;
@@ -211,97 +273,75 @@
}
if (closestNote && closestDistance < 80) {
closestNote.hit = true;
hitFound = true;
- if (closestNote.type === 'hold') {
- closestNote.holdPressed = true;
- activeTouches[lane] = true;
- }
- // Determine hit accuracy
- var hitType = 'good';
+ hits++;
+ combo++;
+ // Score calculation
+ var basePoints = 100;
+ var multiplier = Math.max(1, Math.floor(combo / 10) + 1);
if (closestDistance < 30) {
- hitType = 'perfect';
- combo++;
- LK.getSound('hitPerfect').play();
- createParticleEffect(closestNote.x, closestNote.y);
+ // Perfect hit
+ score += basePoints * 2 * multiplier;
+ LK.getSound('shoot').play();
+ createHitEffect(closestNote.x, closestNote.y);
} else {
- combo++;
- LK.getSound('hitGood').play();
+ // Good hit
+ score += basePoints * multiplier;
+ LK.getSound('shoot').play();
}
- updateScore(hitType);
+ updateDisplays();
// Flash hit zone
tween(hitZone, {
- alpha: 0.8
+ alpha: 0.6
}, {
duration: 100,
onFinish: function onFinish() {
tween(hitZone, {
- alpha: 0.3
+ alpha: 0.2
}, {
duration: 200
});
}
});
+ // Create neon flash effect on screen
+ LK.effects.flashScreen(0xff65d7, 100);
}
if (!hitFound) {
combo = 0;
- comboText.setText('Combo: 0');
+ updateDisplays();
}
};
-game.up = function (x, y, obj) {
- var lane = getLaneFromX(x);
- activeTouches[lane] = false;
- // Release hold notes in this lane
- for (var i = 0; i < notes.length; i++) {
- var note = notes[i];
- if (note.lane === lane && note.type === 'hold' && note.holdPressed) {
- note.holdPressed = false;
- // Score based on hold duration
- if (note.holdDuration >= note.maxHoldDuration * 0.8) {
- combo++;
- updateScore('perfect');
- } else if (note.holdDuration >= note.maxHoldDuration * 0.5) {
- updateScore('good');
- } else {
- combo = 0;
- }
- }
- }
-};
game.update = function () {
// Start background music
if (!gameStarted) {
LK.playMusic('bgmusic');
gameStarted = true;
+ gameStartTime = LK.ticks;
}
// Spawn notes
- noteSpawnTimer++;
- if (noteSpawnTimer >= 45) {
- // Spawn every 0.75 seconds
- spawnNote();
- noteSpawnTimer = 0;
+ if (currentSong === 'random') {
+ noteSpawnTimer++;
+ if (noteSpawnTimer >= 60) {
+ // Spawn every second
+ spawnNote();
+ noteSpawnTimer = 0;
+ // Increase difficulty over time
+ if (totalNotes % 20 === 0 && noteSpawnTimer > 30) {
+ noteSpawnTimer = Math.max(30, noteSpawnTimer - 5);
+ }
+ }
}
// Clean up off-screen notes
for (var i = notes.length - 1; i >= 0; i--) {
var note = notes[i];
- // Remove notes that are off screen or completed
- if (note.y > 2800 || note.hit && note.type === 'regular' || note.hit && note.type === 'hold' && !note.holdPressed && note.holdDuration > 0) {
+ // Remove notes that are off screen or hit
+ if (note.y > 2800 || note.hit && note.type === 'normal') {
note.destroy();
notes.splice(i, 1);
}
}
- // Update hold note states
- for (var lane = 0; lane < 4; lane++) {
- if (!activeTouches[lane]) {
- for (var j = 0; j < notes.length; j++) {
- var note = notes[j];
- if (note.lane === lane && note.type === 'hold' && note.holdPressed) {
- note.holdPressed = false;
- }
- }
- }
- }
- // End game condition (for demo purposes, end after reaching high score)
+ // End game condition
if (score >= 50000) {
LK.showYouWin();
}
};
\ No newline at end of file