Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Note = Container.expand(function (noteType, swipeDir, targetHitTimeFull, centerXVal, noteColumnIndex, isIncomingBuffNote, incomingBuffType, holdDurationMs) {
var self = Container.call(this);
self.noteColumnIndex = noteColumnIndex;
self.noteType = noteType || 'tap';
self.swipeDir = swipeDir || null;
self.targetHitTime = targetHitTimeFull;
self.visualSpawnTime = self.targetHitTime - noteTravelTime;
self.hit = false;
self.judged = false;
self.scaleStart = 1.0;
self.scaleEnd = 1.0;
self.centerX = centerXVal;
self.centerY = 1800;
self.startY = -150;
self.noteAsset = null;
self.brightnessOverlay = null;
self.isWiderSwipePart = false;
self.isBuffNote = isIncomingBuffNote || false;
self.buffType = incomingBuffType || null;
self.isHoldNote = self.noteType === 'hold';
self.holdDuration = self.isHoldNote ? holdDurationMs || 1000 : 0;
self.holdPressTime = 0;
self.isBeingHeld = false;
self.holdFullyCompleted = false;
self.holdBroken = false;
self.initialHoldHeight = 0;
self.feedbackShownForBroken = false;
self.holdButton = null;
self.yOffset = 0;
if (self.isBuffNote) {
var buffAssetKey = '';
if (self.buffType === 'potion') {
buffAssetKey = 'hpPotionAsset';
} else if (self.buffType === 'shield') {
buffAssetKey = 'shieldAsset';
} else if (self.buffType === 'precision') {
buffAssetKey = 'precisionAsset';
}
if (buffAssetKey) {
self.noteAsset = self.attachAsset(buffAssetKey, {
anchorX: 0.5,
anchorY: 0.5,
width: 400,
height: 400
});
}
if (self.isBuffNote) {
self.noteType = 'tap';
self.isHoldNote = false;
}
} else if (self.isHoldNote) {
var pixelsPerMs = (self.centerY - self.startY) / noteTravelTime;
var calculatedTotalHeight = Math.max(50, self.holdDuration * pixelsPerMs);
self.initialHoldHeight = calculatedTotalHeight;
var holdAssetKey = 'hold';
var calculatedYOffset;
if (noteColumnIndex === 1) {
holdAssetKey = 'hold1';
calculatedYOffset = 135;
} else if (noteColumnIndex === 2) {
holdAssetKey = 'hold2';
calculatedYOffset = 225;
} else {
holdAssetKey = 'hold';
calculatedYOffset = 185;
}
self.yOffset = calculatedYOffset;
self.noteAsset = self.attachAsset(holdAssetKey, {
anchorX: 0.5,
anchorY: 1,
y: self.yOffset,
height: self.initialHoldHeight
});
var holdButtonAssetKey;
if (noteColumnIndex === 0) {
holdButtonAssetKey = 'holdButtonAsset_col0';
} else if (noteColumnIndex === 1) {
holdButtonAssetKey = 'holdButtonAsset_col1';
} else {
holdButtonAssetKey = 'holdButtonAsset_col2';
}
self.holdButton = self.attachAsset(holdButtonAssetKey, {
anchorX: 0.5,
anchorY: 1,
y: self.yOffset,
interactive: true,
cursor: "pointer"
});
self.brightnessOverlay = self.attachAsset('brightnessOverlayAsset', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: self.yOffset,
width: 200,
height: 200,
alpha: 0,
visible: true
});
} else {
if (self.noteType === 'tap') {
var tapAssetKey = 'tap0';
if (noteColumnIndex !== undefined) {
if (noteColumnIndex === 0) {
tapAssetKey = 'tap0';
} else if (noteColumnIndex === 1) {
tapAssetKey = 'tap1';
} else if (noteColumnIndex === 2) {
tapAssetKey = 'tap2';
}
}
self.noteAsset = self.attachAsset(tapAssetKey, {
anchorX: 0.5,
anchorY: 0.5
});
self.noteAsset.scaleX = 1.3;
self.noteAsset.scaleY = 1.3;
} else if (self.noteType === 'swipe') {
var swipeAssetKey = 'swipe_col0';
if (noteColumnIndex !== undefined) {
if (noteColumnIndex === 0) {
swipeAssetKey = 'swipe_col0';
} else if (noteColumnIndex === 1) {
swipeAssetKey = 'swipe_col1';
} else if (noteColumnIndex === 2) {
swipeAssetKey = 'swipe_col2';
}
}
self.noteAsset = self.attachAsset(swipeAssetKey, {
anchorX: 0.5,
anchorY: 0.5
});
if (self.swipeDir && self.noteAsset) {
var rotationAngle = 0;
if (self.swipeDir === 'left') {
rotationAngle = Math.PI;
} else if (self.swipeDir === 'right') {
rotationAngle = 0;
} else if (self.swipeDir === 'up') {
rotationAngle = -Math.PI / 2;
} else if (self.swipeDir === 'down') {
rotationAngle = Math.PI / 2;
}
self.noteAsset.rotation = rotationAngle;
}
} else if (self.noteType === 'trap') {
self.noteAsset = self.attachAsset('trapNote', {
anchorX: 0.5,
anchorY: 0.5
});
}
}
self.alpha = 0;
if (typeof DEBUG_SHOW_HITBOXES !== 'undefined' && DEBUG_SHOW_HITBOXES) {
self.debugHitboxVisual = self.attachAsset('debugHitboxAsset', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.35,
visible: false
});
}
self.showHitFeedback = function (result, feedbackTextOverride) {
var feedbackCircle = LK.getAsset('hitFeedback', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: self.yOffset,
scaleX: 0.7,
scaleY: 0.7,
alpha: 0.7
});
if (self.isHoldNote) {
feedbackCircle.x = 0;
} else if (self.noteAsset && self.noteAsset.anchorY === 0) {
feedbackCircle.y = self.noteAsset.height / 2;
} else if (self.noteAsset && self.noteAsset.anchorY === 0.5) {
feedbackCircle.x = 0;
feedbackCircle.y = 0;
}
var feedbackTextContent = feedbackTextOverride || "";
var feedbackTextColor = 0xFFFFFF;
if (!feedbackTextOverride) {
if (self.isBuffNote && result !== 'miss') {
feedbackCircle.tint = 0x40E0D0;
feedbackTextContent = self.buffType.charAt(0).toUpperCase() + self.buffType.slice(1) + "!";
feedbackTextColor = 0x40E0D0;
} else if (result === 'perfect') {
feedbackCircle.tint = 0xffff00;
feedbackTextContent = "Perfect!";
feedbackTextColor = 0xffff00;
} else if (result === 'good') {
feedbackCircle.tint = 0x00ff00;
feedbackTextContent = "Good!";
feedbackTextColor = 0x00ff00;
} else if (result === 'hold_ok') {
feedbackCircle.tint = 0x00FF7F;
feedbackTextContent = "Held!";
feedbackTextColor = 0x00FF7F;
} else {
feedbackCircle.tint = 0xff0000;
feedbackTextContent = result === 'hold_broken' ? "Broken!" : "Miss";
feedbackTextColor = 0xff0000;
}
}
self.addChild(feedbackCircle);
tween(feedbackCircle, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 350,
easing: tween.easeOut,
onFinish: function onFinish() {
if (feedbackCircle.parent) {
feedbackCircle.destroy();
}
}
});
if (feedbackTextContent) {
var scorePopup = new Text2(feedbackTextContent, {
size: 60,
fill: feedbackTextColor,
stroke: 0x000000,
strokeThickness: 3
});
scorePopup.anchor.set(0.5, 0.5);
var initialYPopup;
var noteVisualHeightForFeedback = self.noteAsset ? self.noteAsset.height : SWIPE_NOTE_WIDTH;
if (self.isHoldNote && self.noteAsset) {
initialYPopup = self.y - self.noteAsset.width * 0.25 - 30;
} else if (self.noteAsset && self.noteAsset.anchorY === 0.5) {
initialYPopup = self.y - noteVisualHeightForFeedback / 2 - 30;
} else {
initialYPopup = self.y - 30;
}
scorePopup.x = self.x;
scorePopup.y = initialYPopup;
if (self.parent) {
self.parent.addChild(scorePopup);
tween(scorePopup, {
y: initialYPopup - 80,
alpha: 0
}, {
duration: 700,
easing: tween.easeOut,
onFinish: function onFinish() {
if (scorePopup.parent) {
scorePopup.destroy();
}
}
});
}
}
if (self.parent && (result === 'good' || result === 'perfect' || result === 'hold_ok')) {
var particleSpawnX = self.x;
var particleSpawnY;
if (self.isHoldNote && self.noteAsset) {
particleSpawnY = self.y - self.noteAsset.width * 0.25;
} else if (self.noteAsset && self.noteAsset.anchorY === 0.5) {
particleSpawnY = self.y;
} else if (self.noteAsset) {
particleSpawnY = self.y + self.noteAsset.height / 2;
} else {
particleSpawnY = self.y;
}
spawnParticleEffect(particleSpawnX, particleSpawnY, result, self.parent);
}
};
self.update = function () {
var now = Date.now();
if (self.judged) {
if (self.alpha > 0) {
self.alpha = 0;
}
if (self.brightnessOverlay) {
self.brightnessOverlay.alpha = 0;
}
if (typeof DEBUG_SHOW_HITBOXES !== 'undefined' && DEBUG_SHOW_HITBOXES && self.debugHitboxVisual) {
self.debugHitboxVisual.visible = false;
}
return;
}
if (self.alpha === 0 && now >= self.visualSpawnTime) {
self.alpha = 1;
}
if (self.alpha === 0) {
return;
}
if (self.isHoldNote && self.isBeingHeld) {
if (self.holdBroken) {
self.isBeingHeld = false;
self.judged = true;
if (self.brightnessOverlay) {
self.brightnessOverlay.alpha = 0;
}
if (!self.feedbackShownForBroken) {
self.showHitFeedback('hold_broken');
self.feedbackShownForBroken = true;
}
return;
}
if (self.noteAsset) {
if (now >= self.targetHitTime) {
var timeHeldPastHitLine = now - self.targetHitTime;
var pixelsPerMs = (self.centerY - self.startY) / noteTravelTime;
var pixelsConsumed = Math.min(timeHeldPastHitLine * pixelsPerMs, self.initialHoldHeight);
self.noteAsset.height = Math.max(0, self.initialHoldHeight - pixelsConsumed);
} else {
self.noteAsset.height = self.initialHoldHeight;
}
}
if (self.brightnessOverlay && !self.holdBroken) {}
if (now >= self.targetHitTime + self.holdDuration && !self.holdFullyCompleted) {
self.holdFullyCompleted = true;
}
var progressHold = (now - self.visualSpawnTime) / noteTravelTime;
var newYHold = self.startY + (self.centerY - self.startY) * progressHold;
if (newYHold >= self.centerY || self.y === self.centerY) {
self.y = self.centerY;
} else {
self.y = newYHold;
}
self.x = self.centerX;
if (typeof DEBUG_SHOW_HITBOXES !== 'undefined' && DEBUG_SHOW_HITBOXES && self.debugHitboxVisual && self.alpha > 0) {
var hitboxHeight = 250;
self.debugHitboxVisual.visible = true;
self.debugHitboxVisual.width = 250;
self.debugHitboxVisual.height = hitboxHeight;
self.debugHitboxVisual.x = 0;
self.debugHitboxVisual.y = self.yOffset - hitboxHeight / 2;
}
return;
} else if (self.isHoldNote && self.brightnessOverlay) {
self.brightnessOverlay.alpha = 0;
}
var progress = (now - self.visualSpawnTime) / noteTravelTime;
self.y = self.startY + (self.centerY - self.startY) * progress;
self.x = self.centerX;
if (!self.judged) {
var currentTime = Date.now();
if (self.isHoldNote && self.holdPressTime === 0) {
if (currentTime > self.targetHitTime + hitWindowGood + ADDITIONAL_HOLD_MISS_DELAY) {
self.judged = true;
self.showHitFeedback('miss');
if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
}
} else if (self.noteType !== 'trap' && !self.isHoldNote) {
if (currentTime > self.targetHitTime + hitWindowGood) {
self.judged = true;
if (self.isBuffNote) {
self.showHitFeedback('miss');
if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
} else {
game.onNoteMiss(self);
}
}
}
}
if (typeof DEBUG_SHOW_HITBOXES !== 'undefined' && DEBUG_SHOW_HITBOXES && self.debugHitboxVisual) {
if (self.alpha > 0 && !self.judged) {
var hitboxWidth, hitboxHeight;
var spatialBuffMultiplier = typeof isPrecisionBuffActive !== 'undefined' && isPrecisionBuffActive ? 1.5 : 1.0;
if (self.noteAsset) {
hitboxWidth = self.noteAsset.width * self.scale.x;
hitboxHeight = self.noteAsset.height * self.scale.y;
self.debugHitboxVisual.y = 0;
} else {
hitboxWidth = 0;
hitboxHeight = 0;
}
self.debugHitboxVisual.width = hitboxWidth * spatialBuffMultiplier;
self.debugHitboxVisual.height = hitboxHeight * spatialBuffMultiplier;
self.debugHitboxVisual.x = 0;
self.debugHitboxVisual.visible = true;
} else {
self.debugHitboxVisual.visible = false;
}
}
};
self.isInHitWindow = function () {
var now = Date.now();
var dt = Math.abs(now - self.targetHitTime);
return dt <= hitWindowGood;
};
self.getHitAccuracy = function () {
var now = Date.now();
var dt = Math.abs(now - self.targetHitTime);
if (dt <= hitWindowPerfect) {
return 'perfect';
}
if (dt <= hitWindowGood) {
return 'good';
}
return 'miss';
};
self.judgeHoldRelease = function () {
if (self.brightnessOverlay) {
self.brightnessOverlay.alpha = 0;
}
if (!self.isHoldNote || self.judged && self.holdFullyCompleted && !self.holdBroken) {
if (self.isBeingHeld) {
self.isBeingHeld = false;
}
return;
}
var now = Date.now();
self.isBeingHeld = false;
self.judged = true;
if (self.holdBroken) {
if (!self.feedbackShownForBroken) {
self.showHitFeedback('hold_broken');
self.feedbackShownForBroken = true;
}
if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
if (self.alpha > 0) {
self.alpha = 0;
}
if (self.noteColumnIndex !== undefined) {
var overlay = columnFlashOverlays[self.noteColumnIndex];
if (overlay) {
tween(overlay, {
alpha: 0
}, {
duration: 150,
easing: tween.easeOutQuad
});
}
}
return;
}
var requiredHoldTimeOnScreen = self.targetHitTime + self.holdDuration;
if (now >= requiredHoldTimeOnScreen - hitWindowGood) {
self.holdFullyCompleted = true;
self.showHitFeedback('hold_ok');
if (!isTutorialMode) {
addScore('perfect');
addCombo();
if (!gameOverFlag) {
bossCurrentHP = Math.max(0, bossCurrentHP - 2);
updateBossHpDisplay();
}
}
} else {
self.showHitFeedback('miss', 'Too Early!');
if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
}
if (self.alpha > 0) {
self.alpha = 0;
}
if (self.noteColumnIndex !== undefined) {
var overlay = columnFlashOverlays[self.noteColumnIndex];
if (overlay) {
tween(overlay, {
alpha: 0
}, {
duration: 150,
easing: tween.easeOutQuad
});
}
}
};
return self;
});
var SpriteAnimation = Container.expand(function (options) {
var self = Container.call(this);
options = options || {};
self.frames = options.frames || [];
self.frameDuration = options.frameDuration || 60;
self.loop = options.loop !== undefined ? options.loop : true;
self.currentFrame = 0;
self.frameTimer = 0;
self.playing = true;
self.alpha = options.alpha !== undefined ? options.alpha : 1;
if (options.x !== undefined) {
self.x = options.x;
}
if (options.y !== undefined) {
self.y = options.y;
}
if (options.anchorX !== undefined || options.anchorY !== undefined) {
var anchorX = options.anchorX !== undefined ? options.anchorX : 0;
var anchorY = options.anchorY !== undefined ? options.anchorY : 0;
self.frames.forEach(function (frame) {
if (frame && frame.anchor) {
frame.anchor.set(anchorX, anchorY);
}
});
}
if (self.frames.length > 0) {
self.removeChildren();
var firstFrame = self.frames[self.currentFrame];
if (firstFrame && firstFrame.anchor) {
firstFrame.anchor.set(options.anchorX || 0, options.anchorY || 0);
}
if (firstFrame) {
firstFrame.alpha = self.alpha;
}
self.addChild(firstFrame);
}
self.update = function () {
if (!self.playing || self.frames.length === 0) {
return;
}
self.frameTimer++;
if (self.frameTimer >= self.frameDuration / (1000 / 60)) {
self.frameTimer = 0;
if (self.children.length > 0) {
self.removeChild(self.children[0]);
}
self.currentFrame++;
if (self.currentFrame >= self.frames.length) {
if (self.loop) {
self.currentFrame = 0;
var nextFrame = self.frames[self.currentFrame];
if (nextFrame) {
nextFrame.alpha = self.alpha;
}
self.addChild(nextFrame);
} else {
self.playing = false;
if (typeof self.onComplete === 'function') {
self.onComplete();
}
return;
}
} else {
var nextFrame = self.frames[self.currentFrame];
if (nextFrame) {
nextFrame.alpha = self.alpha;
}
self.addChild(nextFrame);
}
}
};
self.stop = function () {
self.playing = false;
};
self.play = function () {
self.playing = true;
};
self.gotoFrame = function (frameIndex) {
if (frameIndex >= 0 && frameIndex < self.frames.length) {
self.removeChildren();
self.currentFrame = frameIndex;
self.addChild(self.frames[self.currentFrame]);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x181828
});
/****
* Game Code
****/
// np. fioletowy box
// np. pomarańczowy/żółty box
// Złoty segment ogona (wysokość bazowa)
// Pomarańczowa główka
// np. węższa środkowa
// Placeholder strzałki
function _typeof6(o) {
"@babel/helpers - typeof";
return _typeof6 = "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;
}, _typeof6(o);
}
function _defineProperty(e, r, t) {
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[r] = t, e;
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == _typeof6(i) ? i : i + "";
}
function _toPrimitive(t, r) {
if ("object" != _typeof6(t) || !t) {
return t;
}
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof6(i)) {
return i;
}
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
var currentScreenState = '';
var columnFlashOverlays = [null, null, null];
var mainMenuScreenElements = [];
var DEBUG_SHOW_HITBOXES = false;
var isTutorialMode = false;
var HOLD_HITBOX_WIDTH = 250;
var HOLD_HITBOX_HEIGHT = 250;
var currentlyHeldNotes = {};
var tutorialSongData = {
id: "TutorialTrack",
title: "How to Play",
artist: "Game System",
musicAsset: "tutorial",
bossAssetKey: null,
config: {
playerMaxHP: 10,
bossMaxHP: 1
},
rawRhythmMap: [{
time: 12000,
type: "tap",
columnIndex: 0
}, {
time: 12524,
type: "tap",
columnIndex: 1
}, {
time: 12978,
type: "tap",
columnIndex: 2
}, {
time: 16966,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 20420,
type: "swipe",
columnIndex: 2,
swipeDir: "left"
}, {
time: 24711,
type: "tap",
columnIndex: 0
}, {
time: 25125,
type: "tap",
columnIndex: 1
}, {
time: 25510,
type: "tap",
columnIndex: 2
}, {
time: 25934,
type: "tap",
columnIndex: 1
}, {
time: 39597,
type: "tap",
columnIndex: 0
}, {
time: 40031,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 40484,
type: "tap",
columnIndex: 1
}, {
time: 41747,
type: "tap",
columnIndex: 0
}, {
time: 42204,
type: "tap",
columnIndex: 1
}, {
time: 42626,
type: "tap",
columnIndex: 0
}, {
time: 51606,
type: "hold",
columnIndex: 1,
duration: 2500
}, {
time: 66984,
type: "tap",
columnIndex: 0
}, {
time: 67396,
type: "tap",
columnIndex: 0
}, {
time: 67863,
type: "tap",
columnIndex: 1
}, {
time: 68315,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 68764,
type: "tap",
columnIndex: 0
}, {
time: 69171,
type: "tap",
columnIndex: 0
}, {
time: 69629,
type: "tap",
columnIndex: 2
}, {
time: 69818,
type: "tap",
columnIndex: 2
}, {
time: 70008,
type: "tap",
columnIndex: 2
}, {
time: 70449,
type: "tap",
columnIndex: 0
}, {
time: 71766,
type: "hold",
columnIndex: 1,
duration: 1094
}, {
time: 73943,
type: "tap",
columnIndex: 0
}, {
time: 75129,
type: "tap",
columnIndex: 0
}, {
time: 75572,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 76046,
type: "tap",
columnIndex: 0
}, {
time: 76470,
type: "tap",
columnIndex: 0
}, {
time: 76653,
type: "tap",
columnIndex: 0
}, {
time: 76833,
type: "tap",
columnIndex: 0
}, {
time: 76999,
type: "tap",
columnIndex: 0
}, {
time: 77326,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 80766,
type: "tap",
columnIndex: 0
}, {
time: 81199,
type: "tap",
columnIndex: 0
}, {
time: 81586,
type: "tap",
columnIndex: 0
}, {
time: 81816,
type: "tap",
columnIndex: 0
}, {
time: 82002,
type: "tap",
columnIndex: 0
}, {
time: 84273,
type: "tap",
columnIndex: 0
}, {
time: 84674,
type: "tap",
columnIndex: 0
}, {
time: 85091,
type: "tap",
columnIndex: 1
}, {
time: 85919,
type: "tap",
columnIndex: 2
}, {
time: 86772,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 87770,
type: "tap",
columnIndex: 0
}],
isTutorial: true
};
var hasShownInitialMenuAnimation = false;
var statsScreenElements = [];
var currentBossDisplayElements = [];
var currentStatsBossIndex = 0;
var miniGameBackgroundInstance = null;
var miniGameViewport = {
x: 380,
y: 1020,
width: 1150,
height: 780
};
var miniGameScreenElements = [];
var miniGamePlayer = null;
var miniGameObstacles = [];
var miniGameScore = 0;
var miniGameScoreText = null;
var isMiniGameOver = false;
var currentMiniGameMusicTrack = null;
var startScreenElements = [];
var pressStartBlinkInterval = null;
var PLAYER_HP_BAR_X = 1020;
var PLAYER_HP_BAR_Y = 2680;
var MINI_GAME_LANE_Y_POSITIONS = [];
var MINI_GAME_NUMBER_OF_LANES = 3;
var MINI_GAME_LANE_HEIGHT = 0;
var MINI_GAME_OBJECT_SPEED = 8;
var currentMiniGameObjectSpeed = 0;
var miniGameTimeActive = 0;
var SPATIAL_HITBOX_MULTIPLIER = 1.3;
var MINI_GAME_SPEED_INCREASE_INTERVAL = 5000;
var MINI_GAME_OBSTACLE_SPAWN_INTERVAL = 2000;
var MINI_GAME_SPEED_INCREMENT = 0.5;
var MINI_GAME_MOB_SPAWN_INTERVAL = 3500;
var lastMiniGameObstacleSpawnTime = 0;
var MINI_GAME_OBSTACLE_WIDTH = 100;
var MINI_GAME_OBSTACLE_HEIGHT = 100;
var mainMenuItemTextObjects = [];
var currentMainMenuMusicTrack = null;
var mainMenuItems = ["Music Battle", "How To Play", "Endless Loop", "Mini game", "Stats", "Credits"];
var selectedMainMenuItemIndex = 0;
var gameScreenWidth = 2048;
var hitZoneY = 1800;
var playerShieldAnimation = null;
// === PONIŻSZE DEKLARACJE PRZENOSIMY NA GÓRĘ ===
var STATIC_HIT_FRAME_WIDTH = 2000; // Dodana nowa stała dla szerokości statycznej ramki
var STATIC_HIT_FRAME_HEIGHT = 300; // Dodana nowa stała dla wysokości statycznej ramki
var staticHitFrame = null; // Deklaracja statycznej ramki obszaru uderzenia
var staticPerfectLine = null; // Deklaracja statycznej linii perfect
var PERFECT_LINE_ASSET_KEY = 'perfectLineAsset'; // Nazwa assetu dla cienkiej linii
var PERFECT_LINE_HEIGHT = 2; // Wysokość cienkiej linii perfect
// === KONIEC PRZENIESIONYCH DEKLARACJI ===
var gameScreenHeight = Math.round(gameScreenWidth * (2732 / 2048));
var playfieldWidth = 1808;
var NUM_COLUMNS = 3;
var columnCenterXs = [350, 1024, 1700]; // Podaj swoje wartości!
var columnFlashWidths = [620, 400, 620];
var SWIPE_NOTE_WIDTH = 180;
// HP System Variables
var playerMaxHP = 10;
var BOSS_HP_BAR_X = 2030 / 2;
var BOSS_HP_BAR_Y = 70;
var playerCurrentHP = 10;
var bossMaxHP = 30;
var bossCurrentHP = 30;
var gameOverFlag = false;
// HP Bar UI Elements Configuration (actual elements created in setupHpBars)
var hpBarWidth = 600;
var hpBarHeight = 100;
// UI Container
var gameUIContainer; // Declare gameUIContainer
// HP Bar Containers (will be initialized in setupHpBars)
var playerHpBarContainer;
var playerHpBarFill;
var endlessSongs = ['Orctave', 'Goblop', 'Noizboy'];
var currentEndlessSongIndex = 0;
var currentEndlessDifficulty = 0.1;
var ENDLESS_DIFFICULTY_INCREASE_RATE = 0.004;
var MAX_ENDLESS_DIFFICULTY = 1.0;
var endlessTimelineTime = 0;
var bossHpBarContainer;
var bossHpBarFill;
var isLockedBossMessageActive = false;
var activePowerUpItems = [];
var SHIELD_DURATION = 8000;
var isShieldActive = false;
var shieldEndTime = 0;
var POTION_HEAL_AMOUNT = 5;
var SWIPE_TO_TAP_BUFF_DURATION = 5000;
var isSwipeToTapBuffActive = false;
var swipeToTapBuffEndTime = 0;
var shieldTimerDisplayContainer;
var playerHUD = null;
var bossHUD = null;
var precisionBuffTimerDisplayContainer;
var smallPrecisionIconDisplay;
var precisionBuffTimerTextDisplay;
var smallShieldIconDisplay;
var shieldTimerTextDisplay;
var swipeToTapTimerDisplayContainer;
var smallSwipeToTapIconDisplay;
var swipeToTapTimerTextDisplay;
var currentBossSprite;
var powerUpDisplayContainer;
var hpPotionIcon, shieldIcon, swipeToTapIcon;
var hpPotionCountText, shieldCountText, swipeToTapCountText;
var currentActiveRhythmMap = null;
var noteTravelTime = 3300;
var BUFF_CHANCE = 0.04;
var gameplayBackground = null;
var PRECISION_BUFF_DURATION = 7000;
var isPrecisionBuffActive = false;
var precisionBuffEndTime = 0;
var originalHitWindowPerfect = 0;
var precisionBuffHitWindowMultiplier = 1.8;
var hitWindowPerfect = 220;
var hitWindowGood = 310;
var ADDITIONAL_HOLD_MISS_DELAY = 350;
var HOLD_NOTE_GOOD_WINDOW_EXTENSION = 120;
var MIN_SWIPE_DISTANCE = 60;
var notes = [];
var nextNoteIdx = 0;
var gameStartTime = 0;
var score = 0;
var bossWasDefeatedThisSong = false;
var songSummaryContainer = null;
var bossUnlockProgress = {};
var GAME_SCORES_KEY = 'walkmanFighters_scores';
var BOSS_UNLOCK_KEY = 'walkmanFighters_bossUnlock';
var currentFightingBossId = null;
var lastPlayedSongKeyForRestart = null;
var combo = 0;
var maxCombo = 0;
var swipeStart = null;
var inputLocked = false;
var hpBarsInitialized = false;
function _typeof5(o) {
"@babel/helpers - typeof";
return _typeof5 = "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;
}, _typeof5(o);
}
function _typeof4(o) {
"@babel/helpers - typeof";
return _typeof4 = "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;
}, _typeof4(o);
}
function _typeof3(o) {
"@babel/helpers - typeof";
return _typeof3 = "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;
}, _typeof3(o);
}
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 _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 showTemporaryMessage(message, duration, styleOptions) {
var textStyle = {
size: 70,
fill: 0xFFD700,
stroke: 0x000000,
strokeThickness: 4,
align: 'center',
wordWrap: true,
wordWrapWidth: gameScreenWidth * 0.8
};
if (styleOptions) {
for (var key in styleOptions) {
if (styleOptions.hasOwnProperty(key)) {
textStyle[key] = styleOptions[key];
}
}
}
var messageText = new Text2(message, textStyle);
messageText.anchor.set(0.5, 0.5);
messageText.x = gameScreenWidth / 2;
messageText.y = gameScreenHeight / 2;
messageText.alpha = 0;
game.addChild(messageText);
tween(messageText, {
alpha: 1
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(messageText, {
alpha: 0
}, {
duration: 300,
delay: duration || 2000,
easing: tween.easeIn,
onFinish: function onFinish() {
if (messageText.parent) {
messageText.destroy();
}
}
});
}
});
}
var activeMusicTrack = null;
var activeMusicKey = null;
function setMusic(trackKey) {
// Jeśli próbujemy włączyć tę samą piosenkę, która już gra, nic nie rób.
if (trackKey === activeMusicKey) {
return;
}
// --- NOWA LOGIKA ZATRZYMYWANIA ---
// Jeśli jakakolwiek muzyka grała wcześniej (mamy zapisaną jej nazwę)...
if (activeMusicKey) {
// ...pobierz z silnika ŚWIEŻY uchwyt do tej starej piosenki...
var oldTrack = LK.getSound(activeMusicKey);
// ...i dopiero na tym świeżym uchwycie wykonaj komendę stop().
if (oldTrack && typeof oldTrack.stop === 'function') {
oldTrack.stop();
}
}
// Zawsze resetuj stan po próbie zatrzymania
activeMusicTrack = null;
activeMusicKey = null;
// Jeśli nowa nazwa to null, to znaczy, że chcieliśmy tylko wszystko zatrzymać.
if (!trackKey) {
return;
}
// Włącz nową piosenkę
var newTrack = LK.getSound(trackKey);
if (newTrack) {
newTrack.play({
loop: true
});
// Zapisz stan nowej piosenki
activeMusicTrack = newTrack;
activeMusicKey = trackKey;
}
}
function restartMiniGame() {
isMiniGameOver = false;
miniGameScore = 0;
miniGameTimeActive = 0;
currentMiniGameObjectSpeed = MINI_GAME_OBJECT_SPEED;
lastMiniGameObstacleSpawnTime = Date.now();
if (miniGamePlayer && miniGamePlayer.asset) {
miniGamePlayer.lane = 1;
miniGamePlayer.y = MINI_GAME_LANE_Y_POSITIONS[1];
if (miniGamePlayer.asset) {
miniGamePlayer.asset.y = miniGamePlayer.y;
miniGamePlayer.asset.tint = 0xFFFFFF;
}
}
for (var i = miniGameObstacles.length - 1; i >= 0; i--) {
if (miniGameObstacles[i].asset && miniGameObstacles[i].asset.parent) {
miniGameObstacles[i].asset.destroy();
}
}
miniGameObstacles = [];
var gameOverText = miniGameScreenElements.find(function (el) {
return el.isGameOverText;
});
if (gameOverText && gameOverText.parent) {
gameOverText.destroy();
var idx = miniGameScreenElements.indexOf(gameOverText);
if (idx > -1) {
miniGameScreenElements.splice(idx, 1);
}
}
updateMiniGameScoreDisplay();
}
function setupGameplayElements() {
if (staticPerfectLine && staticPerfectLine.parent) {
staticPerfectLine.destroy();
}
staticPerfectLine = LK.getAsset(PERFECT_LINE_ASSET_KEY, {
anchorX: 0.5,
anchorY: 0.5,
x: gameScreenWidth / 2,
y: hitZoneY,
width: playfieldWidth,
height: PERFECT_LINE_HEIGHT,
alpha: 0.9,
visible: false
});
game.addChild(staticPerfectLine);
if (staticHitFrame && staticHitFrame.parent) {
staticHitFrame.destroy();
}
staticHitFrame = LK.getAsset('FRAME1', {
anchorX: 0.5,
anchorY: 0.5,
x: gameScreenWidth / 2,
y: hitZoneY,
width: STATIC_HIT_FRAME_WIDTH,
height: STATIC_HIT_FRAME_HEIGHT,
alpha: 0.7,
visible: false
});
game.addChild(staticHitFrame);
// Tworzenie nakładek błysku
for (var i = 0; i < NUM_COLUMNS; i++) {
if (columnFlashOverlays[i] && columnFlashOverlays[i].parent) {
columnFlashOverlays[i].destroy();
}
var overlayAssetKey = 'flashOverlay_col' + i;
columnFlashOverlays[i] = LK.getAsset(overlayAssetKey, {
// Pobieramy asset
anchorX: 0.5,
anchorY: 0.5,
x: columnCenterXs[i],
y: gameScreenHeight / 2
// Nie ustawiamy tu alpha, zrobimy to poniżej
});
if (columnFlashOverlays[i]) {
// Sprawdzenie, czy asset został poprawnie załadowany
game.addChild(columnFlashOverlays[i]);
columnFlashOverlays[i].alpha = 0; // <<<< KLUCZOWA ZMIANA: Ustawiamy alpha na 0 ZARAZ PO DODANIU
}
}
}
var allParticleAssetKeys = [];
for (var i = 1; i <= 12; i++) {
allParticleAssetKeys.push('particle' + i);
}
function createAndAnimateParticle(assetKey, startX, startY, parentContainer) {
var comboScaleMultiplier = 1 + Math.floor(combo / 20) * 0.1; // Bazowy mnożnik 1, zwiększa się o 0.1 co 20 combo
var particle = LK.getAsset(assetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: startX,
y: startY,
alpha: 1,
scaleX: (3 + Math.random() * 1.2) * comboScaleMultiplier,
scaleY: (3 + Math.random() * 1.2) * comboScaleMultiplier,
rotation: Math.random() * Math.PI * 2 // Losowa rotacja początkowa
});
parentContainer.addChild(particle);
var travelAngle = Math.random() * Math.PI * 2;
var travelDistance = 50 + Math.random() * 100; // 50 do 150px
var targetX = startX + Math.cos(travelAngle) * travelDistance;
var targetY = startY + Math.sin(travelAngle) * travelDistance;
var duration = 500 + Math.random() * 500; // 500ms do 1000ms
tween(particle, {
x: targetX,
y: targetY,
alpha: 0,
scaleX: 1 + Math.random() * 2,
// Większa skala końcowa X (np. od 0.3 do 0.6)
scaleY: 1 + Math.random() * 2,
// Większa skala końcowa Y (np. od 0.3 do 0.6)
// Skala końcowa Y
rotation: particle.rotation + (Math.random() * Math.PI - Math.PI / 2) // Dodatkowa losowa rotacja
}, {
duration: duration,
easing: tween.easeOutQuad,
onFinish: function onFinish() {
if (particle.parent) {
particle.destroy();
}
}
});
}
function spawnParticleEffect(spawnX, spawnY, accuracy, parentContainer) {
var numParticlesBase = 0;
var numTypesToPick = 0;
if (accuracy === 'good') {
numParticlesBase = 4;
numTypesToPick = 2 + Math.floor(Math.random() * 2); // 2 lub 3 typy
} else if (accuracy === 'perfect') {
numParticlesBase = 9;
numTypesToPick = 3 + Math.floor(Math.random() * 2); // 3 lub 4 typy
} else {
return; // Nie twórz cząsteczek dla 'miss' lub innych
}
// Wzmocnienie z combo (prosty przykład, można dostosować)
var comboBonusParticles = Math.floor(combo / 3); // 1 dodatkowa cząsteczka co 10 combo
var totalParticlesToSpawn = numParticlesBase + comboBonusParticles;
if (totalParticlesToSpawn === 0) {
return;
}
// Losowy wybór typów cząsteczek
var availableTypes = [].concat(allParticleAssetKeys); // Kopia tablicy
var pickedTypes = [];
for (var i = 0; i < numTypesToPick; i++) {
if (availableTypes.length === 0) {
break;
}
var randomIndex = Math.floor(Math.random() * availableTypes.length);
pickedTypes.push(availableTypes.splice(randomIndex, 1)[0]);
}
if (pickedTypes.length === 0) {
// Na wszelki wypadek, jeśli coś pójdzie nie tak
pickedTypes.push(allParticleAssetKeys[Math.floor(Math.random() * allParticleAssetKeys.length)]);
}
for (var i = 0; i < totalParticlesToSpawn; i++) {
var particleAssetKey = pickedTypes[i % pickedTypes.length]; // Cyklicznie przez wybrane typy
createAndAnimateParticle(particleAssetKey, spawnX, spawnY, parentContainer);
}
}
function flashColumn(columnIndex) {
if (columnIndex >= 0 && columnIndex < NUM_COLUMNS && columnFlashOverlays[columnIndex]) {
var overlay = columnFlashOverlays[columnIndex];
// Upewnij się, że nakładka jest na wierzchu innych elementów w tej samej warstwie,
// ale pod UI (jeśli UI jest wyżej). Można to zrobić raz w setupGameplayElements
// lub tutaj, jeśli jest taka potrzeba: game.setChildIndex(overlay, game.children.length - 1);
overlay.alpha = 0.6; // Początkowa alpha dla błysku (np. 60%)
tween(overlay, {
alpha: 0
}, {
duration: 250,
// Czas trwania zanikania błysku (w ms)
easing: tween.easeOutQuad // Typ animacji
});
}
}
function showStartScreen() {
if (typeof startScreenElements !== 'undefined' && startScreenElements.forEach) {
startScreenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
}
startScreenElements = [];
if (typeof simpleFlickerTimeout !== 'undefined' && simpleFlickerTimeout) {
LK.clearTimeout(simpleFlickerTimeout);
simpleFlickerTimeout = null;
}
if (typeof simpleFlickerPhaseEndTimeout !== 'undefined' && simpleFlickerPhaseEndTimeout) {
LK.clearTimeout(simpleFlickerPhaseEndTimeout);
simpleFlickerPhaseEndTimeout = null;
}
if (typeof pressStartBlinkInterval !== 'undefined' && pressStartBlinkInterval) {
LK.clearInterval(pressStartBlinkInterval);
pressStartBlinkInterval = null;
}
var pressStartMainGlitchTimer = null;
var glowFlickerBurstTimer = null;
var subtleJitterTimer = null;
currentScreenState = 'startScreenWithGlitch';
if (typeof gameUIContainer !== 'undefined' && gameUIContainer) {
gameUIContainer.visible = false;
}
if (typeof staticHitFrame !== 'undefined' && staticHitFrame) {
staticHitFrame.visible = false;
}
if (typeof staticPerfectLine !== 'undefined' && staticPerfectLine) {
staticPerfectLine.visible = false;
}
var walkmanScreenCenterX = gameScreenWidth / 2 - 300;
var walkmanScreenCenterY = gameScreenHeight / 2 + 100;
var walkmanScreenWidth = 1200;
var walkmanScreenHeight = 1200;
var pressStartRotation = Math.PI / 16;
var pressStartAssetKey = 'pressStartTextAsset';
var glowAssetKey = 'walkmanScreenGlowAsset';
var backgroundAssetKey = 'walkmanStartScreenBg';
var pressStartVisuals = {
main: null,
copies: []
};
var pressStartContainer = new Container();
pressStartContainer.x = walkmanScreenCenterX;
pressStartContainer.y = walkmanScreenCenterY;
startScreenElements.push(pressStartContainer);
game.addChild(pressStartContainer);
pressStartVisuals.main = LK.getAsset(pressStartAssetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
rotation: pressStartRotation,
interactive: true,
cursor: "pointer"
});
pressStartContainer.addChild(pressStartVisuals.main);
for (var i = 0; i < 2; i++) {
var copy = LK.getAsset(pressStartAssetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
rotation: pressStartRotation,
alpha: 0
});
pressStartContainer.addChild(copy);
pressStartVisuals.copies.push(copy);
}
var glowingScreen = LK.getAsset(glowAssetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: walkmanScreenCenterX,
y: walkmanScreenCenterY,
width: walkmanScreenWidth,
height: walkmanScreenHeight,
alpha: 0.5
});
startScreenElements.push(glowingScreen);
game.addChild(glowingScreen);
var background = LK.getAsset(backgroundAssetKey, {
x: gameScreenWidth / 2,
y: gameScreenHeight / 2,
anchorX: 0.5,
anchorY: 0.5,
width: gameScreenWidth,
height: gameScreenHeight
});
startScreenElements.push(background);
game.addChild(background);
game.setChildIndex(pressStartContainer, game.children.length - 3);
game.setChildIndex(glowingScreen, game.children.length - 2);
game.setChildIndex(background, game.children.length - 1);
function triggerGlowFlickerBurst() {
if (currentScreenState !== 'startScreenWithGlitch' || !glowingScreen || !glowingScreen.parent) {
if (glowFlickerBurstTimer) {
LK.clearTimeout(glowFlickerBurstTimer);
}
glowFlickerBurstTimer = null;
return;
}
var burstCount = Math.floor(Math.random() * 3) + 2;
var currentBurst = 0;
var baseAlpha = 0.5 + Math.random() * 0.2;
function singleGlowFlicker() {
if (currentBurst >= burstCount || !glowingScreen || !glowingScreen.parent || currentScreenState !== 'startScreenWithGlitch') {
if (glowingScreen && glowingScreen.parent) {
glowingScreen.alpha = baseAlpha * 0.8;
}
glowFlickerBurstTimer = LK.setTimeout(triggerGlowFlickerBurst, 2500 + Math.random() * 3000);
return;
}
var flickerToAlpha = Math.random() < 0.5 ? baseAlpha * 0.3 + Math.random() * 0.2 : baseAlpha * 1.2 + Math.random() * 0.3;
glowingScreen.alpha = Math.max(0.1, Math.min(0.9, flickerToAlpha));
currentBurst++;
glowFlickerBurstTimer = LK.setTimeout(singleGlowFlicker, 50 + Math.random() * 100);
}
singleGlowFlicker();
}
function continuousSubtleJitter() {
if (currentScreenState !== 'startScreenWithGlitch' || !pressStartVisuals.main || !pressStartVisuals.main.parent) {
if (subtleJitterTimer) {
LK.clearTimeout(subtleJitterTimer);
}
subtleJitterTimer = null;
return;
}
var mainAsset = pressStartVisuals.main;
var jitterAmount = 1.5;
mainAsset.x = (Math.random() - 0.5) * jitterAmount;
mainAsset.y = (Math.random() - 0.5) * jitterAmount;
subtleJitterTimer = LK.setTimeout(continuousSubtleJitter, 70 + Math.random() * 60);
}
function performMainGlitch() {
if (currentScreenState !== 'startScreenWithGlitch' || !pressStartVisuals.main || !pressStartVisuals.main.parent) {
if (pressStartMainGlitchTimer) {
LK.clearTimeout(pressStartMainGlitchTimer);
}
pressStartMainGlitchTimer = null;
return;
}
var glitchType = Math.random();
var mainAsset = pressStartVisuals.main;
var copies = pressStartVisuals.copies;
var originalTint = mainAsset.tint || 0xFFFFFF;
var originalAlpha = mainAsset.alpha;
var textAssetNominalWidth = 280;
var textAssetNominalHeight = 70;
if (glitchType < 0.08) {
var animateDuringSlide = function animateDuringSlide() {
if (!mainAsset.parent || !mainAsset.visible || currentScreenState !== 'startScreenWithGlitch') {
if (slideEffectInterval) {
LK.clearInterval(slideEffectInterval);
}
if (mainAsset.parent) {
mainAsset.tint = originalTint;
mainAsset.alpha = originalAlpha;
}
return;
}
mainAsset.alpha = 0.15 + Math.random() * 0.5;
mainAsset.tint = glitchColors[effectStep % glitchColors.length];
effectStep++;
};
var currentJitterX = mainAsset.x;
var currentJitterY = mainAsset.y;
var slideOutFactorX = 3.0 + Math.random() * 2.0;
var slideOutFactorY = Math.random() < 0.3 ? 2.0 + Math.random() * 1.5 : 0;
var slideDistanceX = textAssetNominalWidth * slideOutFactorX;
var slideDistanceY = textAssetNominalHeight * slideOutFactorY;
var targetX = (Math.random() > 0.5 ? 1 : -1) * slideDistanceX;
var targetY = (Math.random() > 0.5 ? 1 : -1) * slideDistanceY;
var slideDuration = 30 + Math.random() * 20;
var slideEffectInterval = null;
var effectStep = 0;
var glitchColors = [0xff3333, 0x33ff33, 0x3333ff, 0xffff33, 0xcccccc, 0x555555];
if (mainAsset.parent) {
slideEffectInterval = LK.setInterval(animateDuringSlide, 20);
}
tween(mainAsset, {
x: targetX,
y: targetY
}, {
duration: slideDuration,
easing: tween.easeOutQuad,
onFinish: function onFinish() {
if (slideEffectInterval) {
LK.clearInterval(slideEffectInterval);
}
if (mainAsset.parent) {
mainAsset.tint = originalTint;
mainAsset.alpha = 0;
}
LK.setTimeout(function () {
if (mainAsset.parent) {
mainAsset.alpha = originalAlpha;
tween(mainAsset, {
x: currentJitterX,
y: currentJitterY
}, {
duration: 100 + Math.random() * 70,
easing: tween.easeInCubic
});
}
}, 150 + Math.random() * 200);
}
});
} else if (glitchType < 0.25) {
if (!mainAsset.parent) {
return;
}
var prevAlpha = mainAsset.alpha;
mainAsset.alpha = 0;
LK.setTimeout(function () {
if (mainAsset.parent && currentScreenState === 'startScreenWithGlitch') {
mainAsset.alpha = prevAlpha;
}
}, 500);
} else if (glitchType < 0.45) {
if (!mainAsset.parent) {
return;
}
var glitchColorsSet = [0xff0000, 0x00ff00, 0x0000ff, 0x8A2BE2, 0xFFD700, 0x333333];
var oldTint = mainAsset.tint || 0xFFFFFF;
mainAsset.tint = glitchColorsSet[Math.floor(Math.random() * glitchColorsSet.length)];
LK.setTimeout(function () {
if (mainAsset.parent && currentScreenState === 'startScreenWithGlitch') {
mainAsset.tint = oldTint;
}
}, 100 + Math.random() * 150);
} else if (glitchType < 0.70) {
var _doSingleTextFlicker = function doSingleTextFlicker(count) {
if (!mainAsset.parent || count <= 0 || currentScreenState !== 'startScreenWithGlitch') {
if (mainAsset.parent) {
mainAsset.alpha = baseAlpha;
}
return;
}
mainAsset.alpha = Math.random() < 0.6 ? 0.1 : Math.random() * 0.4 + 0.5;
LK.setTimeout(function () {
_doSingleTextFlicker(count - 1);
}, flickerInterval);
};
var baseAlpha = mainAsset.alpha;
if (!mainAsset.parent) {
return;
}
var flickerCount = Math.floor(Math.random() * 4) + 3;
var flickerInterval = 25 + Math.random() * 30;
_doSingleTextFlicker(flickerCount);
} else {
if (mainAsset.parent) {
mainAsset.alpha = 0;
} else {
return;
}
var colors = [0xff0000, 0x00ff00, 0x0000ff];
var offsetAmount = 12 + Math.random() * 6;
copies.forEach(function (copy, index) {
if (!copy.parent) {
return;
}
copy.tint = colors[index % colors.length];
copy.alpha = 0.55 + Math.random() * 0.25;
copy.x = mainAsset.x + (Math.random() - 0.5) * offsetAmount * (index + 1.8);
copy.y = mainAsset.y + (Math.random() - 0.5) * offsetAmount * (index + 1.8);
});
LK.setTimeout(function () {
if (mainAsset.parent && currentScreenState === 'startScreenWithGlitch') {
mainAsset.alpha = 1;
}
copies.forEach(function (copy) {
if (copy.parent) {
copy.alpha = 0;
}
});
}, 70 + Math.random() * 80);
}
pressStartMainGlitchTimer = LK.setTimeout(performMainGlitch, 800 + Math.random() * 1500);
}
pressStartVisuals.main.down = function () {
if (currentScreenState !== 'startScreenWithGlitch') {
return;
}
setMusic('introMusic'); // <-- DODAJEMY TĘ LINIĘ
if (pressStartMainGlitchTimer) {
LK.clearTimeout(pressStartMainGlitchTimer);
pressStartMainGlitchTimer = null;
}
if (glowFlickerBurstTimer) {
LK.clearTimeout(glowFlickerBurstTimer);
glowFlickerBurstTimer = null;
}
if (subtleJitterTimer) {
LK.clearTimeout(subtleJitterTimer);
subtleJitterTimer = null;
}
startScreenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
startScreenElements = [];
showIntro();
};
glowFlickerBurstTimer = LK.setTimeout(triggerGlowFlickerBurst, 800 + Math.random() * 700);
subtleJitterTimer = LK.setTimeout(continuousSubtleJitter, 100);
pressStartMainGlitchTimer = LK.setTimeout(performMainGlitch, 1500 + Math.random() * 1000);
}
function updateMainMenuHighlight(newIndex) {
var defaultTint = 0xFFFFFF; // Biały tint (brak efektu, oryginalny kolor tekstu)
var highlightTint = 0xFFD700; // Żółty tint dla podświetlenia
var defaultScale = 1.0;
var highlightScale = 1.15; // Skala dla podświetlonej opcji
// Resetuj styl dla wszystkich opcji
for (var i = 0; i < mainMenuItemTextObjects.length; i++) {
if (mainMenuItemTextObjects[i] && mainMenuItemTextObjects[i].parent) {
// Zakładamy, że bazowy .fill tekstu jest biały (ustawiony przy tworzeniu)
mainMenuItemTextObjects[i].tint = defaultTint;
mainMenuItemTextObjects[i].scale.set(defaultScale);
}
}
// Ustaw styl dla nowo wybranej opcji
if (newIndex >= 0 && newIndex < mainMenuItemTextObjects.length) {
if (mainMenuItemTextObjects[newIndex] && mainMenuItemTextObjects[newIndex].parent) {
var targetItem = mainMenuItemTextObjects[newIndex];
targetItem.tint = highlightTint;
targetItem.scale.set(highlightScale);
}
}
selectedMainMenuItemIndex = newIndex; // Aktualizuj globalny indeks
}
function showMainMenu(fadeInDuration) {
while (mainMenuScreenElements.length > 0) {
var el = mainMenuScreenElements.pop();
if (el && el.parent) {
el.destroy();
}
}
if (gameplayBackground && gameplayBackground.parent) {
gameplayBackground.destroy();
gameplayBackground = null;
}
mainMenuScreenElements = [];
mainMenuItemTextObjects = [];
var mainMenuContainer = new Container();
game.addChild(mainMenuContainer);
mainMenuScreenElements.push(mainMenuContainer);
currentScreenState = 'mainmenu_walkman';
initializeBossData();
if (gameUIContainer) {
gameUIContainer.visible = false;
}
if (staticHitFrame) {
staticHitFrame.visible = false;
}
if (staticPerfectLine) {
staticPerfectLine.visible = false;
}
if (shieldTimerDisplayContainer) {
shieldTimerDisplayContainer.visible = false;
}
if (swipeToTapTimerDisplayContainer) {
swipeToTapTimerDisplayContainer.visible = false;
}
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
songSummaryContainer = null;
}
var glassX = 380;
var glassY = 1020;
var glassWidth = 1150;
var glassHeight = 820;
var glassInitialAlpha = 0.3;
var glassFinalAlpha = 0.7;
var menuItemFontSize = 120;
var menuItemSpacing = 225;
var TARGET_CENTER_X_FOR_MENU_ITEMS = glassX + glassWidth / 2;
var TARGET_CENTER_Y_FOR_SELECTED_ITEM = glassY + glassHeight / 2;
var menuTextContainer = new Container();
mainMenuContainer.addChild(menuTextContainer);
var creditsGraphic = LK.getAsset('creditsTextAsset', {
x: TARGET_CENTER_X_FOR_MENU_ITEMS,
y: TARGET_CENTER_Y_FOR_SELECTED_ITEM,
anchorX: 0.5,
anchorY: 0.5,
visible: false
});
mainMenuContainer.addChild(creditsGraphic);
selectedMainMenuItemIndex = 0;
for (var i_menu = 0; i_menu < mainMenuItems.length; i_menu++) {
var itemText_menu = new Text2(mainMenuItems[i_menu], {
size: menuItemFontSize,
fill: 0xFFFFFF,
align: 'center'
});
itemText_menu.anchor.set(0.5, 0.5);
itemText_menu.interactive = false;
menuTextContainer.addChild(itemText_menu);
mainMenuItemTextObjects.push(itemText_menu);
}
var layoutAndHighlightFunctionRef = function layoutAndHighlightFunctionRef() {
var defaultTint = 0xFFFFFF;
var highlightTint = 0xFFD700;
var defaultScale = 1.0;
var highlightScale = 1.15;
for (var idx = 0; idx < mainMenuItemTextObjects.length; idx++) {
var item_layout = mainMenuItemTextObjects[idx];
if (item_layout && item_layout.parent) {
item_layout.x = TARGET_CENTER_X_FOR_MENU_ITEMS;
item_layout.y = TARGET_CENTER_Y_FOR_SELECTED_ITEM + (idx - selectedMainMenuItemIndex) * menuItemSpacing;
if (idx === selectedMainMenuItemIndex) {
item_layout.tint = highlightTint;
item_layout.scale.set(highlightScale);
} else {
item_layout.tint = defaultTint;
item_layout.scale.set(defaultScale);
}
}
}
};
var glass = LK.getAsset('glass', {
x: glassX,
y: glassY,
width: glassWidth,
height: glassHeight,
alpha: 0,
interactive: false
});
mainMenuContainer.addChild(glass);
var glass2 = LK.getAsset('glass2', {
x: glassX,
y: glassY,
width: glassWidth,
height: glassHeight,
alpha: 0,
interactive: false
});
mainMenuContainer.addChild(glass2);
var walkmanFrame = LK.getAsset('mainmenu', {
x: 0,
y: 0,
width: gameScreenWidth,
height: gameScreenHeight
});
mainMenuContainer.addChild(walkmanFrame);
var upButton = LK.getAsset('upbutton', {});
upButton.x = 210;
upButton.y = gameScreenHeight / 2 - 180;
upButton.anchor.set(0.5, 0.5);
upButton.interactive = true;
upButton.cursor = "pointer";
upButton.down = function () {
if (currentScreenState === 'mainmenu_walkman') {
if (selectedMainMenuItemIndex > 0) {
selectedMainMenuItemIndex--;
} else {
selectedMainMenuItemIndex = mainMenuItems.length - 1;
}
layoutAndHighlightFunctionRef();
} else if (currentScreenState === 'miniGameActive' && !isMiniGameOver) {
if (miniGamePlayer && miniGamePlayer.lane > 0) {
miniGamePlayer.lane--;
miniGamePlayer.y = MINI_GAME_LANE_Y_POSITIONS[miniGamePlayer.lane];
if (miniGamePlayer.asset) {
miniGamePlayer.asset.y = miniGamePlayer.y;
}
}
}
};
mainMenuContainer.addChild(upButton);
var downButton = LK.getAsset('downbutton', {});
downButton.x = 210;
downButton.y = gameScreenHeight / 2 + 220;
downButton.anchor.set(0.5, 0.5);
downButton.interactive = true;
downButton.cursor = "pointer";
downButton.down = function () {
if (currentScreenState === 'mainmenu_walkman') {
if (selectedMainMenuItemIndex < mainMenuItems.length - 1) {
selectedMainMenuItemIndex++;
} else {
selectedMainMenuItemIndex = 0;
}
layoutAndHighlightFunctionRef();
} else if (currentScreenState === 'miniGameActive' && !isMiniGameOver) {
if (miniGamePlayer && miniGamePlayer.lane < MINI_GAME_NUMBER_OF_LANES - 1) {
miniGamePlayer.lane++;
miniGamePlayer.y = MINI_GAME_LANE_Y_POSITIONS[miniGamePlayer.lane];
if (miniGamePlayer.asset) {
miniGamePlayer.asset.y = miniGamePlayer.y;
}
}
}
};
mainMenuContainer.addChild(downButton);
var playButton = LK.getAsset('play', {});
playButton.x = gameScreenWidth - 350;
playButton.y = gameScreenHeight / 2 - 240;
playButton.anchor.set(0.5, 0.5);
playButton.interactive = true;
playButton.cursor = "pointer";
playButton.down = function () {
if (currentScreenState === 'mainmenu_walkman') {
setMusic('introMusic');
}
};
mainMenuContainer.addChild(playButton);
var stopButton = LK.getAsset('stop', {});
stopButton.x = gameScreenWidth - 350;
stopButton.y = gameScreenHeight / 2;
stopButton.anchor.set(0.5, 0.5);
stopButton.interactive = true;
stopButton.cursor = "pointer";
stopButton.down = function () {
setMusic(null);
};
mainMenuContainer.addChild(stopButton);
var fightButton = LK.getAsset('fight', {});
fightButton.x = gameScreenWidth - 350;
fightButton.y = gameScreenHeight / 2 + 240;
fightButton.anchor.set(0.5, 0.5);
fightButton.interactive = true;
fightButton.cursor = "pointer";
fightButton.down = function () {
var selectedAction = mainMenuItems[selectedMainMenuItemIndex];
if (currentScreenState === 'mainmenu_walkman') {
if (selectedAction === "Credits") {
currentScreenState = 'mainmenu_credits';
menuTextContainer.visible = false;
creditsGraphic.visible = true;
} else {
if (selectedAction === "Mini game" || selectedAction === "Stats") {
menuTextContainer.visible = false;
} else {
mainMenuScreenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
mainMenuScreenElements = [];
mainMenuItemTextObjects = [];
if (menuTextContainer && menuTextContainer.parent) {
menuTextContainer.destroy();
}
menuTextContainer = null;
}
if (selectedAction === "Mini game") {
setMusic(null);
showMiniGameScreen();
} else if (selectedAction === "Stats") {
showStatsScreen();
} else if (selectedAction === "Music Battle") {
showBossSelectionScreen();
} else if (selectedAction === "Endless Loop") {
mainMenuScreenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
mainMenuScreenElements = [];
mainMenuItemTextObjects = [];
if (menuTextContainer && menuTextContainer.parent) {
menuTextContainer.destroy();
}
menuTextContainer = null;
setMusic(null);
startEndlessMode();
} else if (selectedAction === "How To Play") {
setMusic(null);
runTutorialGameplay();
}
}
} else if (currentScreenState === 'miniGameActive' && isMiniGameOver) {
restartMiniGame();
}
};
mainMenuContainer.addChild(fightButton);
var rewindButtonMainMenu = LK.getAsset('rewindbutton', {});
rewindButtonMainMenu.x = 350;
rewindButtonMainMenu.y = gameScreenHeight / 2 + 650;
rewindButtonMainMenu.anchor.set(0.5, 0.5);
rewindButtonMainMenu.interactive = true;
rewindButtonMainMenu.cursor = "pointer";
rewindButtonMainMenu.down = function () {
if (currentScreenState === 'mainmenu_credits') {
currentScreenState = 'mainmenu_walkman';
menuTextContainer.visible = true;
creditsGraphic.visible = false;
}
};
mainMenuContainer.addChild(rewindButtonMainMenu);
var actualDefeatedCount = getNumberOfDefeatedBosses();
var allStandardBossesDefeated = allBossData.length > 0 && actualDefeatedCount === allBossData.length;
var specialBossButtonAssetKey = allStandardBossesDefeated ? 'specialboss_unlocked' : 'specialboss_locked';
var specialBossButtonMainMenu = LK.getAsset(specialBossButtonAssetKey, {});
specialBossButtonMainMenu.width = 250;
var originalAssetWidthForRatioSB = 300;
var originalAssetHeightUnlockedSB = 250;
var originalAssetHeightLockedSB = 250;
specialBossButtonMainMenu.height = (specialBossButtonAssetKey === 'specialboss_unlocked' ? originalAssetHeightUnlockedSB : originalAssetHeightLockedSB) * (specialBossButtonMainMenu.width / originalAssetWidthForRatioSB);
specialBossButtonMainMenu.x = 950;
specialBossButtonMainMenu.y = 2030;
specialBossButtonMainMenu.anchor.set(0.5, 0.5);
specialBossButtonMainMenu.interactive = true;
if (allStandardBossesDefeated) {
specialBossButtonMainMenu.cursor = "pointer";
specialBossButtonMainMenu.down = function () {};
} else {
specialBossButtonMainMenu.cursor = "default";
specialBossButtonMainMenu.down = function () {
if (isLockedBossMessageActive) {
return;
}
isLockedBossMessageActive = true;
tween(menuTextContainer, {
alpha: 0
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
menuTextContainer.visible = false;
}
});
var lockedGraphic = LK.getAsset('silasLockedMessage', {
anchorX: 0.5,
anchorY: 0.5,
x: TARGET_CENTER_X_FOR_MENU_ITEMS,
y: TARGET_CENTER_Y_FOR_SELECTED_ITEM - 30,
alpha: 0
});
mainMenuContainer.addChildAt(lockedGraphic, mainMenuContainer.getChildIndex(glass2));
tween(lockedGraphic, {
alpha: 1
}, {
duration: 800,
easing: tween.easeIn
});
LK.setTimeout(function () {
tween(lockedGraphic, {
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
if (lockedGraphic.parent) {
lockedGraphic.destroy();
}
menuTextContainer.visible = true;
tween(menuTextContainer, {
alpha: 1
}, {
duration: 400,
easing: tween.easeIn,
onFinish: function onFinish() {
isLockedBossMessageActive = false;
}
});
}
});
}, 4000);
};
}
mainMenuContainer.addChild(specialBossButtonMainMenu);
layoutAndHighlightFunctionRef();
if (!hasShownInitialMenuAnimation) {
hasShownInitialMenuAnimation = true;
mainMenuContainer.alpha = 0;
menuTextContainer.alpha = 0;
glass.alpha = glassInitialAlpha;
glass2.alpha = 0;
tween(mainMenuContainer, {
alpha: 1
}, {
duration: 1000,
easing: tween.easeLinear
});
tween(glass, {
alpha: 0
}, {
duration: 2000,
delay: 500,
easing: tween.easeLinear
});
tween(glass2, {
alpha: glassFinalAlpha
}, {
duration: 2000,
delay: 500,
easing: tween.easeLinear
});
LK.setTimeout(function () {
if (menuTextContainer && menuTextContainer.parent) {
tween(menuTextContainer, {
alpha: 1
}, {
duration: 800,
easing: tween.easeLinear
});
}
}, 2000);
} else {
mainMenuContainer.alpha = 1;
menuTextContainer.alpha = 1;
glass.alpha = 0;
glass2.alpha = glassFinalAlpha;
}
}
function exitMiniGameAndReturnToMainMenu() {
if (miniGamePlayer && miniGamePlayer.asset && miniGamePlayer.asset.hasOwnProperty('tint')) {
miniGamePlayer.asset.tint = 0xFFFFFF;
}
isMiniGameOver = true;
if (miniGameBackgroundInstance && miniGameBackgroundInstance.parent) {
miniGameBackgroundInstance.visible = false;
}
while (miniGameScreenElements.length > 0) {
var el_exit_mg = miniGameScreenElements.pop();
if (el_exit_mg && el_exit_mg.parent) {
if (el_exit_mg === miniGameBackgroundInstance && miniGameBackgroundInstance && miniGameBackgroundInstance.visible === false) {} else {
el_exit_mg.destroy();
}
}
}
if (miniGameBackgroundInstance && miniGameBackgroundInstance.parent && miniGameBackgroundInstance.visible === false) {} else if (miniGameBackgroundInstance && !miniGameBackgroundInstance.parent) {
miniGameBackgroundInstance = null;
}
miniGamePlayer = null;
miniGameObstacles = [];
if (miniGameScoreText && miniGameScoreText.parent) {
miniGameScoreText.destroy();
}
miniGameScoreText = null;
currentScreenState = 'mainmenu_walkman';
showMainMenu();
}
function spawnMiniGameObstacle() {
// Zmieniona nazwa i usunięte mobki
var now = Date.now();
if (now > lastMiniGameObstacleSpawnTime + MINI_GAME_OBSTACLE_SPAWN_INTERVAL * (0.5 + Math.random())) {
var randomLane = Math.floor(Math.random() * MINI_GAME_NUMBER_OF_LANES);
var obstacleFrames = [LK.getAsset('obstacle_anim_1', {}), LK.getAsset('obstacle_anim_2', {}), LK.getAsset('obstacle_anim_3', {}), LK.getAsset('obstacle_anim_4', {}), LK.getAsset('obstacle_anim_5', {})];
var obstacleAnimation = new SpriteAnimation({
frames: obstacleFrames,
frameDuration: 350,
loop: true,
anchorX: 0.5,
anchorY: 0.5,
x: miniGameViewport.x + miniGameViewport.width + MINI_GAME_OBSTACLE_WIDTH / 2 - 50,
y: MINI_GAME_LANE_Y_POSITIONS[randomLane]
});
var newObstacle = {
x: obstacleAnimation.x,
y: obstacleAnimation.y,
width: MINI_GAME_OBSTACLE_WIDTH,
height: MINI_GAME_OBSTACLE_HEIGHT,
type: 'obstacle',
asset: obstacleAnimation,
scored: false
};
game.addChild(obstacleAnimation);
miniGameScreenElements.push(obstacleAnimation);
miniGameObstacles.push(newObstacle);
lastMiniGameObstacleSpawnTime = now;
// console.log("Spawned obstacle in lane " + randomLane);
}
}
function moveMiniGameObstacles() {
if (!miniGamePlayer || isMiniGameOver) {
return;
}
for (var i = miniGameObstacles.length - 1; i >= 0; i--) {
var obs = miniGameObstacles[i];
obs.x -= currentMiniGameObjectSpeed;
if (obs.asset) {
obs.asset.x = obs.x;
}
if (!obs.scored && obs.x < miniGamePlayer.x - miniGamePlayer.width / 2) {
miniGameScore += 5;
obs.scored = true;
updateMiniGameScoreDisplay();
}
if (obs.x < miniGameViewport.x - obs.width / 2 + 50) {
if (obs.asset && obs.asset.parent) {
obs.asset.destroy();
}
var obsAssetIndex = miniGameScreenElements.indexOf(obs.asset);
if (obsAssetIndex > -1) {
miniGameScreenElements.splice(obsAssetIndex, 1);
}
miniGameObstacles.splice(i, 1);
}
}
}
function updateMiniGameScoreDisplay() {
if (miniGameScoreText) {
miniGameScoreText.setText("Score: " + miniGameScore);
}
}
var allBossData = [];
var currentBossViewStartIndex = 0;
var cardsContainer = null;
var visibleBossCards = [null, null, null, null];
var selectedCardSlotIndex = 0;
var peekingBossCards = [null, null];
var placeholderMusicKey = 'test1';
var placeholderSongMapKey = 'defaultTestTrack';
var visibleBossCards = [null, null];
function initializeBossData() {
allBossData = [{
id: 'boss1',
displayName: 'Boss 1',
cardAssetKey: 'boss1',
musicAssetKey: 'Orctave',
songMapKey: 'OrctaveBossTrack',
defeatsRequired: 0
}, {
id: 'boss2',
displayName: 'Boss 2',
cardAssetKey: 'boss2',
musicAssetKey: 'Goblop',
songMapKey: 'GoblopBossTrack',
defeatsRequired: 0
}, {
id: 'boss3',
displayName: 'Boss 3',
cardAssetKey: 'boss3',
musicAssetKey: 'Noizboy',
songMapKey: 'NoizboyTrack',
defeatsRequired: 0
}, {
id: 'boss4',
displayName: 'Boss 4',
cardAssetKey: 'boss4',
musicAssetKey: placeholderMusicKey,
songMapKey: placeholderSongMapKey,
defeatsRequired: 1
}, {
id: 'boss5',
displayName: 'Boss 5',
cardAssetKey: 'boss5',
musicAssetKey: placeholderMusicKey,
songMapKey: placeholderSongMapKey,
defeatsRequired: 2
}, {
id: 'boss6',
displayName: 'Boss 6',
cardAssetKey: 'boss6',
musicAssetKey: placeholderMusicKey,
songMapKey: placeholderSongMapKey,
defeatsRequired: 3
}, {
id: 'boss7',
displayName: 'Boss 7',
cardAssetKey: 'boss7',
musicAssetKey: placeholderMusicKey,
songMapKey: placeholderSongMapKey,
defeatsRequired: 4
}, {
id: 'boss8',
displayName: 'Boss 8',
cardAssetKey: 'boss8',
musicAssetKey: placeholderMusicKey,
songMapKey: placeholderSongMapKey,
defeatsRequired: 5
}];
var loadedUnlockProgress = storage[BOSS_UNLOCK_KEY];
if (loadedUnlockProgress) {
bossUnlockProgress = loadedUnlockProgress;
for (var i = 0; i < allBossData.length; i++) {
var bossId = allBossData[i].id;
if (!bossUnlockProgress.hasOwnProperty(bossId)) {
bossUnlockProgress[bossId] = false;
}
}
} else {
bossUnlockProgress = {};
for (var j = 0; j < allBossData.length; j++) {
bossUnlockProgress[allBossData[j].id] = false;
}
}
}
function updateSelectedCardVisual() {
for (var i = 0; i < visibleBossCards.length; i++) {
var cardContainer = visibleBossCards[i];
if (cardContainer && cardContainer.visualAsset) {
if (i === selectedCardSlotIndex) {
cardContainer.visualAsset.tint = 0xFFFF00;
cardContainer.scale.set(1.05);
} else {
cardContainer.visualAsset.tint = 0xFFFFFF;
cardContainer.scale.set(1.0);
}
}
}
}
function displayBossCards(newStartIndex, isInitialDisplay, numberOfDefeated) {
currentBossViewStartIndex = newStartIndex;
var singleCardDisplayWidth = 400;
var singleCardDisplayHeight = 380;
var spacingBetweenCardsX = 80;
var cardSlotX_0 = singleCardDisplayWidth / 2;
var cardSlotX_1 = singleCardDisplayWidth * 1.5 + spacingBetweenCardsX;
var mainCardsCenterY_relative = singleCardDisplayHeight / 2;
var peekingCardVisibleSliceHeight = 80;
var verticalOffsetMainToPeeking = 140;
var mainCardSlotsPositions = [{
x: cardSlotX_0,
y: mainCardsCenterY_relative
}, {
x: cardSlotX_1,
y: mainCardsCenterY_relative
}];
var peekingCardsTopY_relative = mainCardsCenterY_relative + singleCardDisplayHeight / 2 + verticalOffsetMainToPeeking;
var peekingCardSlotsPositions = [{
x: cardSlotX_0,
y: peekingCardsTopY_relative
}, {
x: cardSlotX_1,
y: peekingCardsTopY_relative
}];
if (!cardsContainer) {
return;
}
while (cardsContainer.children[0]) {
cardsContainer.removeChild(cardsContainer.children[0]).destroy();
}
visibleBossCards = [null, null];
peekingBossCards = [null, null];
for (var i = 0; i < 2; i++) {
var dataIndex = currentBossViewStartIndex + i;
if (dataIndex < allBossData.length) {
var bossData = allBossData[dataIndex];
var cardContainer = new Container();
cardContainer.x = mainCardSlotsPositions[i].x;
cardContainer.y = mainCardSlotsPositions[i].y;
cardContainer.bossData = bossData;
cardContainer.slotIndex = i;
var cardAsset = LK.getAsset(bossData.cardAssetKey, {});
cardAsset.anchor.set(0.5, 0.5);
cardAsset.width = singleCardDisplayWidth;
cardAsset.height = singleCardDisplayHeight;
cardContainer.visualAsset = cardAsset;
cardContainer.addChild(cardAsset);
var isUnlocked = bossData.defeatsRequired === 0 || numberOfDefeated >= bossData.defeatsRequired;
bossData.isUnlocked = isUnlocked;
cardContainer.interactive = true;
cardContainer.cursor = "pointer";
cardContainer.down = function () {
selectedCardSlotIndex = this.slotIndex;
updateSelectedCardVisual();
};
cardsContainer.addChild(cardContainer);
visibleBossCards[i] = cardContainer;
}
}
for (var j = 0; j < 2; j++) {
var peekingDataIndex = currentBossViewStartIndex + 2 + j;
if (peekingDataIndex < allBossData.length) {
var peekingBossData = allBossData[peekingDataIndex];
var peekingCardContainer = new Container();
peekingCardContainer.x = peekingCardSlotsPositions[j].x;
peekingCardContainer.y = peekingCardSlotsPositions[j].y;
var peekingCardAsset = LK.getAsset(peekingBossData.cardAssetKey, {});
peekingCardAsset.anchor.set(0.5, 0);
peekingCardAsset.width = singleCardDisplayWidth;
peekingCardAsset.height = singleCardDisplayHeight;
peekingCardContainer.addChild(peekingCardAsset);
peekingCardContainer.interactive = false;
cardsContainer.addChild(peekingCardContainer);
peekingBossCards[j] = peekingCardContainer;
}
}
if (isInitialDisplay) {
selectedCardSlotIndex = 0;
} else {
var maxSlotOnNewPage = Math.min(1, allBossData.length - 1 - currentBossViewStartIndex);
if (selectedCardSlotIndex > maxSlotOnNewPage) {
selectedCardSlotIndex = maxSlotOnNewPage;
}
}
updateSelectedCardVisual();
}
function getNumberOfDefeatedBosses() {
var count = 0;
for (var i = 0; i < allBossData.length; i++) {
// Zakładamy, że allBossData zawiera tylko standardowych bossów (1-8)
var bossId = allBossData[i].id;
if (bossUnlockProgress.hasOwnProperty(bossId) && bossUnlockProgress[bossId] === true) {
count++;
}
}
return count;
}
function showBossSelectionScreen() {
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
songSummaryContainer = null;
}
currentScreenState = 'bossGallery_paged';
if (gameUIContainer) {
gameUIContainer.visible = false;
}
if (staticHitFrame) {
staticHitFrame.visible = false;
}
if (staticPerfectLine) {
staticPerfectLine.visible = false;
}
if (shieldTimerDisplayContainer) {
shieldTimerDisplayContainer.visible = false;
}
if (swipeToTapTimerDisplayContainer) {
swipeToTapTimerDisplayContainer.visible = false;
}
initializeBossData();
var numberOfDefeated = getNumberOfDefeatedBosses();
var screenElements = [];
var tempSingleCardDisplayWidth = 400;
var tempSingleCardDisplayHeight = 380;
var tempSpacingBetweenCardsX = 80;
var tempGroupHorizontalOffset = -60;
var tempGroupVerticalOffset = -90;
var screenAreaContentWidth = tempSingleCardDisplayWidth * 2 + tempSpacingBetweenCardsX;
var screenAreaX = (gameScreenWidth - screenAreaContentWidth) / 2 + tempGroupHorizontalOffset;
var screenAreaY = gameScreenHeight / 2 + tempGroupVerticalOffset - tempSingleCardDisplayHeight / 2;
if (cardsContainer && cardsContainer.parent) {
cardsContainer.destroy();
}
cardsContainer = new Container();
cardsContainer.x = screenAreaX;
cardsContainer.y = screenAreaY;
game.addChild(cardsContainer);
screenElements.push(cardsContainer);
displayBossCards(0, true, numberOfDefeated);
var glassAsset = LK.getAsset('glass2', {
x: 324,
y: 886,
width: 1180,
height: 1300,
alpha: 0.4,
interactive: false
});
game.addChild(glassAsset);
screenElements.push(glassAsset);
var galleryBg = LK.getAsset('galleryBackground', {
width: gameScreenWidth,
height: gameScreenHeight,
x: 0,
y: 0
});
game.addChild(galleryBg);
screenElements.push(galleryBg);
var upButton = LK.getAsset('upbutton', {});
upButton.x = 210;
upButton.y = gameScreenHeight / 2 - 180;
upButton.anchor.set(0.5, 0.5);
upButton.interactive = true;
upButton.cursor = "pointer";
upButton.down = function () {
var newStartIndex = currentBossViewStartIndex - 2;
if (newStartIndex < 0) {
newStartIndex = 0;
}
if (newStartIndex !== currentBossViewStartIndex) {
displayBossCards(newStartIndex, false, numberOfDefeated);
}
};
game.addChild(upButton);
screenElements.push(upButton);
var downButton = LK.getAsset('downbutton', {});
downButton.x = 210;
downButton.y = gameScreenHeight / 2 + 220;
downButton.anchor.set(0.5, 0.5);
downButton.interactive = true;
downButton.cursor = "pointer";
downButton.down = function () {
var newStartIndex = currentBossViewStartIndex + 2;
if (newStartIndex < allBossData.length) {
displayBossCards(newStartIndex, false, numberOfDefeated);
}
};
game.addChild(downButton);
screenElements.push(downButton);
var playButton = LK.getAsset('play', {});
playButton.x = gameScreenWidth - 350;
playButton.y = gameScreenHeight / 2 - 240;
playButton.anchor.set(0.5, 0.5);
playButton.interactive = true;
playButton.cursor = "pointer";
playButton.down = function () {
var selectedBossDataIndex = currentBossViewStartIndex + selectedCardSlotIndex;
if (selectedBossDataIndex < allBossData.length) {
var bossData = allBossData[selectedBossDataIndex];
if (bossData.musicAssetKey) {
setMusic(bossData.musicAssetKey);
}
}
};
game.addChild(playButton);
screenElements.push(playButton);
var stopButton = LK.getAsset('stop', {});
stopButton.x = gameScreenWidth - 350;
stopButton.y = gameScreenHeight / 2;
stopButton.anchor.set(0.5, 0.5);
stopButton.interactive = true;
stopButton.cursor = "pointer";
stopButton.down = function () {
setMusic(null);
};
game.addChild(stopButton);
screenElements.push(stopButton);
var fightButton = LK.getAsset('fight', {});
fightButton.x = gameScreenWidth - 350;
fightButton.y = gameScreenHeight / 2 + 240;
fightButton.anchor.set(0.5, 0.5);
fightButton.interactive = true;
fightButton.cursor = "pointer";
fightButton.down = function () {
setMusic(null);
var selectedDataIndex = currentBossViewStartIndex + selectedCardSlotIndex;
if (selectedDataIndex < allBossData.length) {
var selectedBoss = allBossData[selectedDataIndex];
if (selectedBoss && selectedBoss.isUnlocked) {
var bossIdNumber = parseInt(selectedBoss.id.replace('boss', ''), 10);
if (bossIdNumber >= 4) {
showTemporaryMessage("Soon on update", 1500, {
size: 80,
fill: 0xFFD700
});
} else {
screenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
screenElements = [];
if (cardsContainer && cardsContainer.parent) {
cardsContainer.destroy();
cardsContainer = null;
}
loadSong(selectedBoss.songMapKey);
}
}
}
};
game.addChild(fightButton);
screenElements.push(fightButton);
var actualDefeatedCount = getNumberOfDefeatedBosses();
var allStandardBossesDefeated = allBossData.length > 0 && actualDefeatedCount === allBossData.length;
var specialBossButtonAssetKey = allStandardBossesDefeated ? 'specialboss_unlocked' : 'specialboss_locked';
var specialBossButton = LK.getAsset(specialBossButtonAssetKey, {});
specialBossButton.width = 250;
var originalAssetWidthForRatioSB = 300;
var originalAssetHeightUnlockedSB = 250;
var originalAssetHeightLockedSB = 250;
specialBossButton.height = (specialBossButtonAssetKey === 'specialboss_unlocked' ? originalAssetHeightUnlockedSB : originalAssetHeightLockedSB) * (specialBossButton.width / originalAssetWidthForRatioSB);
specialBossButton.x = 950;
specialBossButton.y = 2030;
specialBossButton.anchor.set(0.5, 0.5);
specialBossButton.interactive = true;
if (allStandardBossesDefeated) {
specialBossButton.cursor = "pointer";
specialBossButton.down = function () {};
} else {
specialBossButton.cursor = "default";
specialBossButton.down = function () {
if (isLockedBossMessageActive) {
return;
}
isLockedBossMessageActive = true;
tween(cardsContainer, {
alpha: 0
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
cardsContainer.visible = false;
}
});
var centerX = 380 + 1150 / 2;
var centerY = 1020 + 890 / 2;
var lockedGraphic = LK.getAsset('silasLockedMessage', {
anchorX: 0.5,
anchorY: 0.5,
x: centerX,
y: centerY - 90,
alpha: 0
});
game.addChildAt(lockedGraphic, game.getChildIndex(glassAsset));
tween(lockedGraphic, {
alpha: 1
}, {
duration: 800,
easing: tween.easeIn
});
LK.setTimeout(function () {
tween(lockedGraphic, {
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
if (lockedGraphic.parent) {
lockedGraphic.destroy();
}
cardsContainer.visible = true;
tween(cardsContainer, {
alpha: 1
}, {
duration: 400,
easing: tween.easeIn,
onFinish: function onFinish() {
isLockedBossMessageActive = false;
}
});
}
});
}, 4000);
};
}
game.addChild(specialBossButton);
screenElements.push(specialBossButton);
var rewindButton = LK.getAsset('rewindbutton', {});
rewindButton.x = 350;
rewindButton.y = gameScreenHeight / 2 + 650;
rewindButton.anchorX = 0.5;
rewindButton.anchorY = 0.5;
rewindButton.interactive = true;
rewindButton.cursor = "pointer";
rewindButton.down = function () {
setMusic('introMusic');
screenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
screenElements = [];
if (cardsContainer && cardsContainer.parent) {
cardsContainer.destroy();
cardsContainer = null;
}
currentBossViewStartIndex = 0;
selectedCardSlotIndex = 0;
showMainMenu();
};
game.addChild(rewindButton);
screenElements.push(rewindButton);
}
function displayStatsForBoss(bossIndex) {
console.log("--- displayStatsForBoss called for index: " + bossIndex + " ---");
while (currentBossDisplayElements.length > 0) {
var el = currentBossDisplayElements.pop();
if (el && el.parent) {
el.destroy();
}
}
if (bossIndex < 0 || bossIndex >= allBossData.length) {
console.error("Invalid bossIndex for stats: " + bossIndex);
return;
}
var bossData = allBossData[bossIndex];
if (!bossData) {
console.error("No bossData found for index: " + bossIndex);
return;
}
console.log("Displaying stats for boss: " + bossData.displayName);
var viewport = miniGameViewport;
var padding = 40;
var bossStatDetailsContainer = new Container();
bossStatDetailsContainer.x = viewport.x;
bossStatDetailsContainer.y = viewport.y + 60 + 80;
game.addChild(bossStatDetailsContainer);
currentBossDisplayElements.push(bossStatDetailsContainer);
var bossImageWidth = viewport.width * 0.35;
var bossImageHeight = (viewport.height - (viewport.y + 60 + 80 - bossStatDetailsContainer.y)) * 0.7;
if (bossImageHeight > bossImageWidth * 1.5) {
bossImageHeight = bossImageWidth * 1.5;
}
var bossImageX = padding + bossImageWidth / 2;
var bossImageY = padding + bossImageHeight / 2;
var bossAssetKeyToDisplay = bossData.cardAssetKey;
if (!bossAssetKeyToDisplay) {
console.warn("Boss " + bossData.displayName + " has an empty cardAssetKey. Using placeholder.");
bossAssetKeyToDisplay = 'statsBossPlaceholder';
}
var bossImage = LK.getAsset(bossAssetKeyToDisplay, {
anchorX: 0.5,
anchorY: 0.5,
x: bossImageX,
y: bossImageY,
width: bossImageWidth,
height: bossImageHeight
});
bossStatDetailsContainer.addChild(bossImage);
console.log("Boss image: " + bossAssetKeyToDisplay + " at x=" + bossImageX + ", y=" + bossImageY);
// B. Teksty statystyk
var statsTextX = bossImageX + bossImageWidth / 2 + 40; // Zwiększony odstęp od obrazka
var currentTextY = padding + 30; // Startowa pozycja Y dla pierwszego tekstu statystyk (Best Score)
// Możesz dostosować tę wartość, aby ładnie pasowała pod/obok obrazka
var valueFontSize = 65; // Zwiększyłem trochę rozmiar dla wartości statystyk
var lineSpacing = 115; // Zwiększyłem trochę odstęp między liniami
var statsMaxWidth = viewport.width - statsTextX - padding * 1.5;
var songStats = getSongStats(bossData.songMapKey);
var bestScore = songStats.bestScore;
var bestCombo = songStats.bestCombo;
var defeatedStatus = bossUnlockProgress[bossData.id] ? "YES" : "NO";
var defeatedColor = bossUnlockProgress[bossData.id] ? 0x32CD32 : 0xFF4500;
console.log("Stats values - Score: " + bestScore + ", Combo: " + bestCombo + ", Defeated: " + defeatedStatus);
// Usunięto wyświetlanie "nameText" (nazwy bossa)
// Best Score - teraz jako pierwszy tekst
var scoreText = new Text2("Best Score: " + bestScore, {
size: valueFontSize,
fill: 0xFFFFFF,
align: 'left',
wordWrap: true,
wordWrapWidth: statsMaxWidth
});
scoreText.anchor.set(0, 0);
scoreText.x = statsTextX;
scoreText.y = currentTextY;
bossStatDetailsContainer.addChild(scoreText);
currentTextY += valueFontSize + 65; // Odstęp pod Best Score (dostosuj)
// Best Combo
var comboText = new Text2("Best Combo: " + bestCombo, {
size: valueFontSize,
fill: 0xFFFFFF,
align: 'left',
wordWrap: true,
wordWrapWidth: statsMaxWidth
});
comboText.anchor.set(0, 0);
comboText.x = statsTextX;
comboText.y = currentTextY;
bossStatDetailsContainer.addChild(comboText);
currentTextY += valueFontSize + 65; // Odstęp pod Best Combo (dostosuj)
// Boss Defeated
var defeatedText = new Text2("Defeated: ", {
size: valueFontSize,
fill: 0xFFFFFF,
align: 'left'
});
defeatedText.anchor.set(0, 0);
defeatedText.x = statsTextX;
defeatedText.y = currentTextY;
bossStatDetailsContainer.addChild(defeatedText);
var defeatedValue = new Text2(defeatedStatus, {
size: valueFontSize,
fill: defeatedColor,
align: 'left'
});
defeatedValue.anchor.set(0, 0);
defeatedValue.x = statsTextX + defeatedText.width + 10;
defeatedValue.y = currentTextY;
bossStatDetailsContainer.addChild(defeatedValue);
console.log("Stat texts (without boss name) added to container.");
}
function createPlayerHUD() {
if (playerHUD && playerHUD.parent) {
playerHUD.destroy();
}
playerHUD = new Container();
playerHUD.alpha = 0;
playerHUD.visible = false;
gameUIContainer.addChild(playerHUD);
var bg = playerHUD.addChild(LK.getAsset('playerHudBgAsset', {
anchorX: 0.5,
anchorY: 1,
x: gameScreenWidth / 2,
y: 2950,
width: 900,
height: 500,
alpha: 1
}));
playerHpBarFill = playerHUD.addChild(LK.getAsset('playerHpFill', {
width: hpBarWidth,
height: hpBarHeight,
anchorX: 0,
anchorY: 0.5,
x: PLAYER_HP_BAR_X - hpBarWidth / 2,
y: PLAYER_HP_BAR_Y
}));
var shieldFrames = [];
for (var i = 1; i <= 11; i++) {
shieldFrames.push(LK.getAsset('shield' + i, {}));
}
playerShieldAnimation = new SpriteAnimation({
frames: shieldFrames,
frameDuration: 100,
loop: true,
anchorX: 0.5,
anchorY: 0.5,
x: gameScreenWidth / 2,
y: 2700
});
playerShieldAnimation.rotation = Math.PI / 2;
playerShieldAnimation.visible = false;
playerHUD.addChild(playerShieldAnimation);
}
function createBossHUD() {
if (bossHUD && bossHUD.parent) {
bossHUD.destroy();
}
bossHUD = new Container();
bossHUD.alpha = 0;
bossHUD.visible = false;
gameUIContainer.addChild(bossHUD);
var bg = bossHUD.addChild(LK.getAsset('bossHudBgAsset', {
anchorX: 0.5,
anchorY: 0,
x: gameScreenWidth / 2,
y: -200,
width: 900,
height: 500,
alpha: 0.8
}));
bossHpBarFill = bossHUD.addChild(LK.getAsset('bossHpFill', {
width: 600,
height: 100,
anchorX: 0,
anchorY: 0.5,
x: BOSS_HP_BAR_X - hpBarWidth / 2,
y: BOSS_HP_BAR_Y
}));
}
function showMiniGameScreen() {
currentScreenState = 'miniGameActive';
isMiniGameOver = false;
miniGameScore = 0;
miniGameObstacles = [];
while (miniGameScreenElements.length > 0) {
var el_mg_clear = miniGameScreenElements.pop();
if (el_mg_clear && el_mg_clear.parent) {
el_mg_clear.destroy();
}
}
if (miniGamePlayer && miniGamePlayer.asset && miniGamePlayer.asset.parent) {
miniGamePlayer.asset.destroy();
}
miniGamePlayer = null;
if (miniGameScoreText && miniGameScoreText.parent) {
miniGameScoreText.destroy();
}
miniGameScoreText = null;
setMusic('rollsouls');
if (!miniGameBackgroundInstance || !miniGameBackgroundInstance.parent) {
miniGameBackgroundInstance = LK.getAsset('miniGameRollSoulsBg', {});
if (miniGameBackgroundInstance) {
var faktorSkali = 0.8;
var nowaSzerokoscTla = miniGameViewport.width * faktorSkali;
var nowaWysokoscTla = miniGameViewport.height * faktorSkali;
miniGameBackgroundInstance.width = nowaSzerokoscTla;
miniGameBackgroundInstance.height = nowaWysokoscTla;
miniGameBackgroundInstance.x = miniGameViewport.x + (miniGameViewport.width - nowaSzerokoscTla) / 2;
miniGameBackgroundInstance.y = miniGameViewport.y + (miniGameViewport.height - nowaWysokoscTla) / 2;
game.addChild(miniGameBackgroundInstance);
}
}
if (miniGameBackgroundInstance) {
miniGameBackgroundInstance.visible = true;
miniGameBackgroundInstance.alpha = 0.7;
if (!miniGameScreenElements.includes(miniGameBackgroundInstance)) {
miniGameScreenElements.push(miniGameBackgroundInstance);
}
}
MINI_GAME_LANE_HEIGHT = miniGameViewport.height / MINI_GAME_NUMBER_OF_LANES;
MINI_GAME_LANE_Y_POSITIONS = [];
for (var lane_idx = 0; lane_idx < MINI_GAME_NUMBER_OF_LANES; lane_idx++) {
MINI_GAME_LANE_Y_POSITIONS.push(miniGameViewport.y + lane_idx * MINI_GAME_LANE_HEIGHT + MINI_GAME_LANE_HEIGHT / 2);
}
var playerFrames = [LK.getAsset('player_anim_1', {}), LK.getAsset('player_anim_2', {}), LK.getAsset('player_anim_3', {})];
var playerAnimation = new SpriteAnimation({
frames: playerFrames,
frameDuration: 350,
loop: true,
anchorX: 0.5,
anchorY: 0.5
});
miniGamePlayer = {
lane: 1,
y: MINI_GAME_LANE_Y_POSITIONS[1],
x: miniGameViewport.x + 100,
width: 50,
height: 50,
asset: playerAnimation
};
playerAnimation.x = miniGamePlayer.x;
playerAnimation.y = miniGamePlayer.y;
game.addChild(playerAnimation);
miniGameScreenElements.push(playerAnimation);
var scoreTextInstance = new Text2("Score: 0", {
size: 40,
fill: 0xFFFFFF,
align: 'left'
});
scoreTextInstance.anchor.set(0, 0);
scoreTextInstance.x = miniGameViewport.x + 20;
scoreTextInstance.y = miniGameViewport.y + 20;
game.addChild(scoreTextInstance);
miniGameScreenElements.push(scoreTextInstance);
miniGameScoreText = scoreTextInstance;
lastMiniGameObstacleSpawnTime = Date.now();
currentMiniGameObjectSpeed = MINI_GAME_OBJECT_SPEED;
miniGameTimeActive = 0;
var glassAssetFromMainMenu = null;
for (var i_glass = 0; i_glass < mainMenuScreenElements.length; i_glass++) {
var el_glass_check = mainMenuScreenElements[i_glass];
if (el_glass_check && el_glass_check.x === miniGameViewport.x && el_glass_check.y === miniGameViewport.y && el_glass_check.width === miniGameViewport.width && el_glass_check.height === miniGameViewport.height && el_glass_check.alpha && Math.abs(el_glass_check.alpha - 0.3) < 0.01) {
glassAssetFromMainMenu = el_glass_check;
break;
}
}
if (glassAssetFromMainMenu && glassAssetFromMainMenu.parent) {
var parentContainer = glassAssetFromMainMenu.parent;
parentContainer.removeChild(glassAssetFromMainMenu);
parentContainer.addChild(glassAssetFromMainMenu);
}
var rewindButtonMiniGame = LK.getAsset('rewindbutton', {
x: 350,
y: gameScreenHeight / 2 + 650,
anchorX: 0.5,
anchorY: 0.5,
interactive: true,
cursor: "pointer"
});
rewindButtonMiniGame.down = function () {
exitMiniGameAndReturnToMainMenu();
};
game.addChild(rewindButtonMiniGame);
miniGameScreenElements.push(rewindButtonMiniGame);
}
function showStatsScreen() {
console.log("Showing Stats Screen - Full Setup");
while (statsScreenElements.length > 0) {
var el = statsScreenElements.pop();
if (el && el.parent) {
el.destroy();
}
}
while (currentBossDisplayElements.length > 0) {
var cbdEl = currentBossDisplayElements.pop();
if (cbdEl && cbdEl.parent) {
cbdEl.destroy();
}
}
initializeBossData(); // <<<< DODAJ TĘ LINIĘ NA POCZĄTKU FUNKCJI
currentScreenState = 'statsScreen';
currentStatsBossIndex = 0;
var walkmanFrameStats = LK.getAsset('mainmenu', {
x: 0,
y: 0,
width: gameScreenWidth,
height: gameScreenHeight
});
game.addChild(walkmanFrameStats);
statsScreenElements.push(walkmanFrameStats);
var glassStats = LK.getAsset('glass2', {
x: miniGameViewport.x,
y: miniGameViewport.y,
width: miniGameViewport.width,
height: miniGameViewport.height,
alpha: 0.15,
interactive: false
});
game.addChild(glassStats);
statsScreenElements.push(glassStats);
var statsTitle = new Text2("PLAYER STATS", {
size: 60,
fill: 0xFFFFFF,
align: 'center',
stroke: 0x000000,
strokeThickness: 4
});
statsTitle.anchor.set(0.5, 0.5);
statsTitle.x = miniGameViewport.x + miniGameViewport.width / 2;
statsTitle.y = miniGameViewport.y + 100;
game.addChild(statsTitle);
statsScreenElements.push(statsTitle);
displayStatsForBoss(currentStatsBossIndex);
// Przyciski nawigacyjne dla ekranu Stats
var upButtonStats = LK.getAsset('upbutton', {});
upButtonStats.x = 210;
upButtonStats.y = gameScreenHeight / 2 - 180;
upButtonStats.anchor.set(0.5, 0.5);
upButtonStats.interactive = true;
upButtonStats.cursor = "pointer";
upButtonStats.down = function () {
if (currentStatsBossIndex > 0) {
currentStatsBossIndex--;
displayStatsForBoss(currentStatsBossIndex);
}
};
game.addChild(upButtonStats);
statsScreenElements.push(upButtonStats);
var downButtonStats = LK.getAsset('downbutton', {});
downButtonStats.x = 210;
downButtonStats.y = gameScreenHeight / 2 + 220;
downButtonStats.anchor.set(0.5, 0.5);
downButtonStats.interactive = true;
downButtonStats.cursor = "pointer";
downButtonStats.down = function () {
if (currentStatsBossIndex < allBossData.length - 1) {
currentStatsBossIndex++;
displayStatsForBoss(currentStatsBossIndex);
}
};
game.addChild(downButtonStats);
statsScreenElements.push(downButtonStats);
var rewindButtonStats = LK.getAsset('rewindbutton', {
x: 350,
y: gameScreenHeight / 2 + 650,
anchorX: 0.5,
anchorY: 0.5,
interactive: true,
cursor: "pointer"
});
rewindButtonStats.down = function () {
console.log("Rewind button pressed: Exiting Stats screen.");
while (statsScreenElements.length > 0) {
var elToDestroyStats = statsScreenElements.pop();
if (elToDestroyStats && elToDestroyStats.parent) {
elToDestroyStats.destroy();
}
}
while (currentBossDisplayElements.length > 0) {
var cbdElExit = currentBossDisplayElements.pop(); // Zmieniona nazwa zmiennej
if (cbdElExit && cbdElExit.parent) {
cbdElExit.destroy();
}
}
showMainMenu();
};
game.addChild(rewindButtonStats);
statsScreenElements.push(rewindButtonStats);
var playButtonStats = LK.getAsset('play', {});
playButtonStats.x = gameScreenWidth - 350;
playButtonStats.y = gameScreenHeight / 2 - 240;
playButtonStats.anchor.set(0.5, 0.5);
playButtonStats.interactive = false;
playButtonStats.alpha = 0.5;
game.addChild(playButtonStats);
statsScreenElements.push(playButtonStats);
var stopButtonStats = LK.getAsset('stop', {});
stopButtonStats.x = gameScreenWidth - 350;
stopButtonStats.y = gameScreenHeight / 2;
stopButtonStats.anchor.set(0.5, 0.5);
stopButtonStats.interactive = false;
stopButtonStats.alpha = 0.5;
game.addChild(stopButtonStats);
statsScreenElements.push(stopButtonStats);
var fightButtonStats = LK.getAsset('fight', {});
fightButtonStats.x = gameScreenWidth - 350;
fightButtonStats.y = gameScreenHeight / 2 + 240;
fightButtonStats.anchor.set(0.5, 0.5);
fightButtonStats.interactive = false;
fightButtonStats.alpha = 0.5;
game.addChild(fightButtonStats);
statsScreenElements.push(fightButtonStats);
}
function showEndlessIntro() {
var introElements = [];
var localIntroTimers = [];
var introArrowObject = null;
var isWaitingForUserClick = false;
var comicPanelsContainer = null;
var skipButton = null;
function clearLocalIntroTimers(clearArrowPulse) {
localIntroTimers.forEach(function (timerId) {
if (timerId) {
LK.clearTimeout(timerId);
}
});
localIntroTimers = [];
if (clearArrowPulse && introArrowObject && introArrowObject.pulseTimerId) {
LK.clearTimeout(introArrowObject.pulseTimerId);
introArrowObject.pulseTimerId = null;
}
}
currentScreenState = 'intro_endless';
game.setBackgroundColor(0x000000);
comicPanelsContainer = new Container();
game.addChild(comicPanelsContainer);
introElements.push(comicPanelsContainer);
skipButton = new Text2("SKIP", {
size: 60,
fill: 0xBBBBBB,
align: 'right'
});
skipButton.anchor.set(1, 0);
skipButton.x = gameScreenWidth - 40;
skipButton.y = 40;
skipButton.interactive = true;
skipButton.cursor = "pointer";
game.addChild(skipButton);
introElements.push(skipButton);
skipButton.down = function () {
if (currentScreenState === 'intro_endless') {
endEndlessIntroAndStartGame();
}
};
var panelWidth = gameScreenWidth * 0.85;
var panelHeight = gameScreenHeight / 3 - 60;
var panelX = gameScreenWidth / 2;
var panelPositions = [{
x: panelX,
y: panelHeight / 2 + 40,
width: panelWidth,
height: panelHeight
}, {
x: panelX,
y: panelHeight * 1.5 + 60,
width: panelWidth,
height: panelHeight
}, {
x: panelX,
y: panelHeight * 2.5 + 80,
width: panelWidth,
height: panelHeight
}];
var endlessIntroAssetKeys = ['endless_intro_1', 'endless_intro_2', 'endless_intro_3', 'endless_intro_4', 'endless_intro_5', 'endless_intro_6'];
var introArrowAssetKey = 'intro_arrow_down';
var activePanelObjects = [];
function endEndlessIntroAndStartGame() {
if (currentScreenState !== 'intro_endless' && currentScreenState !== 'transitioning_to_endless') {
return;
}
currentScreenState = 'transitioning_to_endless';
clearLocalIntroTimers(true);
isWaitingForUserClick = false;
var elementsToFade = introElements.slice();
var fadedCount = 0;
var totalToFade = elementsToFade.length;
var onAllFadedOut = function onAllFadedOut() {
elementsToFade.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
introElements = [];
activePanelObjects = [];
comicPanelsContainer = null;
skipButton = null;
introArrowObject = null;
initializeEndlessGameplay();
};
if (totalToFade === 0) {
onAllFadedOut();
return;
}
elementsToFade.forEach(function (el) {
tween(el, {
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
fadedCount++;
if (fadedCount === totalToFade) {
onAllFadedOut();
}
}
});
});
}
function displayPanelWithFadeIn(assetKey, positionConfig, durationMs, callback) {
if (currentScreenState !== 'intro_endless' || !comicPanelsContainer) {
return;
}
var panel = LK.getAsset(assetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: positionConfig.x,
y: positionConfig.y,
width: positionConfig.width,
height: positionConfig.height,
alpha: 0
});
comicPanelsContainer.addChild(panel);
activePanelObjects.push(panel);
tween(panel, {
alpha: 1
}, {
duration: durationMs,
easing: tween.linear,
onFinish: function onFinish() {
if (callback && currentScreenState === 'intro_endless') {
callback();
}
}
});
}
function hideAndDestroyPanels(panelsToProcess, durationMs, callback) {
var panelsToFade = panelsToProcess.slice();
activePanelObjects = [];
if (currentScreenState !== 'intro_endless' && panelsToFade.length > 0) {
panelsToFade.forEach(function (p) {
if (p && p.parent) {
p.destroy();
}
});
if (callback) {
callback();
}
return;
}
if (panelsToFade.length === 0) {
if (callback) {
callback();
}
return;
}
var fadedCount = 0;
panelsToFade.forEach(function (p) {
if (p && p.parent) {
tween(p, {
alpha: 0
}, {
duration: durationMs,
easing: tween.linear,
onFinish: function onFinish() {
if (p.parent) {
p.destroy();
}
fadedCount++;
if (fadedCount === panelsToFade.length && callback && currentScreenState === 'intro_endless') {
callback();
}
}
});
} else {
fadedCount++;
if (fadedCount === panelsToFade.length && callback && currentScreenState === 'intro_endless') {
callback();
}
}
});
}
function showArrowAndAwaitClick(actionOnClick) {
if (currentScreenState !== 'intro_endless') {
return;
}
isWaitingForUserClick = true;
introArrowObject = LK.getAsset(introArrowAssetKey, {
anchorX: 0.5,
anchorY: 1,
x: gameScreenWidth / 2,
y: gameScreenHeight - 30,
alpha: 0,
interactive: true,
cursor: "pointer"
});
game.addChild(introArrowObject);
introElements.push(introArrowObject);
tween(introArrowObject, {
alpha: 1
}, {
duration: 500
});
introArrowObject.down = function () {
if (isWaitingForUserClick && currentScreenState === 'intro_endless') {
isWaitingForUserClick = false;
var self = this;
tween(this, {
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
if (self.parent) {
self.destroy();
}
}
});
clearLocalIntroTimers(false);
actionOnClick();
}
};
}
function proceedToEndlessPhase2() {
if (currentScreenState !== 'intro_endless') {
return;
}
hideAndDestroyPanels(activePanelObjects.slice(), 800, function () {
if (currentScreenState !== 'intro_endless') {
return;
}
displayPanelWithFadeIn(endlessIntroAssetKeys[3], panelPositions[0], 800, function () {
localIntroTimers.push(LK.setTimeout(function () {
displayPanelWithFadeIn(endlessIntroAssetKeys[4], panelPositions[1], 800, function () {
localIntroTimers.push(LK.setTimeout(function () {
displayPanelWithFadeIn(endlessIntroAssetKeys[5], panelPositions[2], 800, function () {
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState === 'intro_endless') {
endEndlessIntroAndStartGame();
}
}, 3000));
});
}, 3000));
});
}, 3000));
});
});
}
// Start Phase 1
displayPanelWithFadeIn(endlessIntroAssetKeys[0], panelPositions[0], 800, function () {
localIntroTimers.push(LK.setTimeout(function () {
displayPanelWithFadeIn(endlessIntroAssetKeys[1], panelPositions[1], 800, function () {
localIntroTimers.push(LK.setTimeout(function () {
displayPanelWithFadeIn(endlessIntroAssetKeys[2], panelPositions[2], 800, function () {
showArrowAndAwaitClick(proceedToEndlessPhase2);
});
}, 3000));
});
}, 3000));
});
}
// Musimy też dodać tę pustą funkcję, aby uniknąć błędu.
// W niej zbudujemy logikę ładowania tła, muzyki i generatora.
function initializeEndlessGameplay() {
console.log("Intro skończone, uruchamiam rozgrywkę Endless...");
currentScreenState = 'endlessLoopActive';
gameStartTime = Date.now();
endlessTimelineTime = 0;
currentEndlessDifficulty = 0.1;
if (gameplayBackground && gameplayBackground.parent) {
gameplayBackground.destroy();
}
gameplayBackground = LK.getAsset('endless_background_asset', {
x: 0,
y: 0,
width: gameScreenWidth,
height: gameScreenHeight,
alpha: 0.8
});
game.addChildAt(gameplayBackground, 0);
resetGameState();
currentActiveRhythmMap = [];
createPlayerHUD();
playerCurrentHP = playerMaxHP;
updatePlayerHpDisplay();
if (gameUIContainer) {
gameUIContainer.visible = true;
}
if (playerHUD) {
playerHUD.visible = true;
tween(playerHUD, {
alpha: 1
}, {
duration: 500
});
}
if (bossHUD) {
bossHUD.visible = false;
}
if (scoreTxt) {
scoreTxt.visible = true;
}
if (comboTxt) {
comboTxt.visible = true;
}
setupGameplayElements();
if (staticHitFrame) {
staticHitFrame.visible = true;
}
if (staticPerfectLine) {
staticPerfectLine.visible = true;
}
currentEndlessSongIndex = 0;
LK.setTimeout(function () {
playNextEndlessSong();
}, 7000);
}
function playNextEndlessSong() {
var songKey = endlessSongs[currentEndlessSongIndex];
var musicAsset = LK.getSound(songKey);
var bpm = 120;
console.log("Endless Loop: Odtwarzam " + songKey + " | Trudność: " + currentEndlessDifficulty.toFixed(2));
var songDuration = musicAsset.duration || 60;
var newNotes = generateProceduralRhythmMap(songDuration, currentEndlessDifficulty, bpm);
currentActiveRhythmMap = currentActiveRhythmMap.concat(newNotes);
setMusic(songKey);
currentEndlessSongIndex = (currentEndlessSongIndex + 1) % endlessSongs.length;
}
function generateProceduralRhythmMap(durationSeconds, currentDifficulty, bpm) {
var newMap = [];
var beatDuration = 60000 / bpm;
var currentTimeInSegment = 0;
var endTime = durationSeconds * 1000;
var lastNoteTime = -1000;
var MIN_TIME_BETWEEN_NOTES = 200;
while (currentTimeInSegment < endTime) {
var timeStepMultiplier = 2;
if (currentDifficulty > 0.7) {
timeStepMultiplier = 1 / 2;
} else if (currentDifficulty > 0.3) {
timeStepMultiplier = 1;
}
currentTimeInSegment += beatDuration * timeStepMultiplier;
if (currentTimeInSegment - lastNoteTime < MIN_TIME_BETWEEN_NOTES) {
continue;
}
var noteChance = 0.30 + currentDifficulty * 0.5;
if (Math.random() > noteChance) {
continue;
}
var columnIndex = Math.floor(Math.random() * NUM_COLUMNS);
var noteType = 'tap';
var buffType = null;
var roll = Math.random();
var trapChance = currentDifficulty > 0.7 ? 0.10 : 0;
var holdChance = currentDifficulty > 0.5 ? 0.15 : 0;
var swipeChance = currentDifficulty > 0.3 ? 0.25 : 0;
var buffChance = 0.1; // 10% szans na buffa zamiast zwykłego tapa
if (roll < trapChance) {
noteType = 'trap';
} else if (roll < trapChance + holdChance) {
noteType = 'hold';
} else if (roll < trapChance + holdChance + swipeChance) {
noteType = 'swipe';
} else if (roll < trapChance + holdChance + swipeChance + buffChance) {
var buffTypesAvailable = ['potion', 'shield', 'precision'];
buffType = buffTypesAvailable[Math.floor(Math.random() * buffTypesAvailable.length)];
}
var note = {
time: Math.round(endlessTimelineTime + currentTimeInSegment),
type: buffType ? 'tap' : noteType,
columnIndex: columnIndex,
isBuffNote: buffType !== null,
buffType: buffType
};
if (noteType === 'swipe') {
var swipeDirs = ['up', 'down', 'left', 'right'];
note.swipeDir = swipeDirs[Math.floor(Math.random() * swipeDirs.length)];
} else if (noteType === 'hold') {
var holdDuration = beatDuration * (1 + Math.random() * currentDifficulty);
note.duration = Math.round(holdDuration);
}
newMap.push(note);
lastNoteTime = currentTimeInSegment;
}
endlessTimelineTime += endTime;
return newMap;
}
function showIntro() {
if (typeof introElements !== 'undefined' && introElements.forEach) {
introElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
}
introElements = [];
var localIntroTimers = [];
var introArrowObject = null;
var isWaitingForUserClick = false;
var comicPanelsContainer = null;
var skipButton = null;
function clearLocalIntroTimers(clearArrowPulse) {
localIntroTimers.forEach(function (timerId) {
if (timerId) {
LK.clearTimeout(timerId);
}
});
localIntroTimers = [];
if (clearArrowPulse && introArrowObject && introArrowObject.pulseTimerId) {
LK.clearTimeout(introArrowObject.pulseTimerId);
introArrowObject.pulseTimerId = null;
}
}
if (typeof gameUIContainer !== 'undefined' && gameUIContainer) {
gameUIContainer.visible = false;
}
if (typeof staticHitFrame !== 'undefined' && staticHitFrame) {
staticHitFrame.visible = false;
}
if (typeof staticPerfectLine !== 'undefined' && staticPerfectLine) {
staticPerfectLine.visible = false;
}
currentScreenState = 'intro';
game.setBackgroundColor(0x000000);
comicPanelsContainer = new Container();
game.addChild(comicPanelsContainer);
introElements.push(comicPanelsContainer);
skipButton = new Text2("SKIP", {
size: 60,
fill: 0xBBBBBB,
align: 'right'
});
skipButton.anchor.set(1, 0);
skipButton.x = gameScreenWidth - 40;
skipButton.y = 40;
skipButton.interactive = true;
skipButton.cursor = "pointer";
game.addChild(skipButton);
introElements.push(skipButton);
skipButton.down = function () {
if (currentScreenState === 'intro') {
endIntroSequence();
}
};
var panelWidth = gameScreenWidth * 0.85;
var panelHeight = gameScreenHeight / 3 - 60;
var panelX = gameScreenWidth / 2;
var panelPositions = [{
x: panelX,
y: panelHeight / 2 + 40,
width: panelWidth,
height: panelHeight
}, {
x: panelX,
y: panelHeight * 1.5 + 60,
width: panelWidth,
height: panelHeight
}, {
x: panelX,
y: panelHeight * 2.5 + 80,
width: panelWidth,
height: panelHeight
}];
var introAssetKeys = ['intro_scene_1', 'intro_scene_2', 'intro_scene_3', 'intro_scene_4', 'intro_scene_5', 'intro_scene_6', 'intro_scene_7', 'intro_scene_8', 'intro_scene_9'];
var introArrowAssetKey = 'intro_arrow_down';
var activePanelObjects = [];
function endIntroSequence() {
if (currentScreenState !== 'intro' && currentScreenState !== 'transitioning_to_menu') {
return;
}
currentScreenState = 'transitioning_to_menu';
clearLocalIntroTimers(true);
isWaitingForUserClick = false;
var elementsToFade = [];
if (comicPanelsContainer && comicPanelsContainer.parent) {
elementsToFade.push(comicPanelsContainer);
}
if (skipButton && skipButton.parent) {
elementsToFade.push(skipButton);
}
if (introArrowObject && introArrowObject.parent) {
elementsToFade.push(introArrowObject);
}
var fadedCount = 0;
var totalToFade = elementsToFade.length;
var onAllFadedOut = function onAllFadedOut() {
introElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
introElements = [];
activePanelObjects = [];
comicPanelsContainer = null;
skipButton = null;
introArrowObject = null;
showMainMenu(1000);
};
if (totalToFade === 0) {
onAllFadedOut();
return;
}
elementsToFade.forEach(function (el) {
tween(el, {
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
fadedCount++;
if (fadedCount === totalToFade) {
onAllFadedOut();
}
}
});
});
}
function displayPanelWithFadeIn(assetKey, positionConfig, durationMs, callback) {
if (currentScreenState !== 'intro' || !comicPanelsContainer) {
return;
}
var panel = LK.getAsset(assetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: positionConfig.x,
y: positionConfig.y,
width: positionConfig.width,
height: positionConfig.height,
alpha: 0
});
comicPanelsContainer.addChild(panel);
activePanelObjects.push(panel);
tween(panel, {
alpha: 1
}, {
duration: durationMs,
easing: tween.linear,
onFinish: function onFinish() {
if (callback && currentScreenState === 'intro') {
callback();
}
}
});
}
function hideAndDestroyPanels(panelsToProcess, durationMs, callback) {
var panelsToFade = panelsToProcess.slice();
activePanelObjects = [];
if (currentScreenState !== 'intro' && panelsToFade.length > 0) {
panelsToFade.forEach(function (p) {
if (p && p.parent) {
p.destroy();
}
});
if (callback) {
callback();
}
return;
}
if (panelsToFade.length === 0) {
if (callback) {
callback();
}
return;
}
var fadedCount = 0;
panelsToFade.forEach(function (p) {
if (p && p.parent) {
tween(p, {
alpha: 0
}, {
duration: durationMs,
easing: tween.linear,
onFinish: function onFinish() {
if (p.parent) {
p.destroy();
}
fadedCount++;
if (fadedCount === panelsToFade.length && callback && currentScreenState === 'intro') {
callback();
}
}
});
} else {
fadedCount++;
if (fadedCount === panelsToFade.length && callback && currentScreenState === 'intro') {
callback();
}
}
});
}
function showArrowAndAwaitClick(actionOnClick) {
if (currentScreenState !== 'intro') {
return;
}
if (introArrowObject && introArrowObject.parent) {
if (introArrowObject.pulseTimerId) {
LK.clearTimeout(introArrowObject.pulseTimerId);
}
introArrowObject.destroy();
var idxOldArr = introElements.indexOf(introArrowObject);
if (idxOldArr > -1) {
introElements.splice(idxOldArr, 1);
}
introArrowObject = null;
}
isWaitingForUserClick = true;
introArrowObject = LK.getAsset(introArrowAssetKey, {
anchorX: 0.5,
anchorY: 1,
x: gameScreenWidth / 2,
y: gameScreenHeight - 30,
alpha: 0,
interactive: true,
cursor: "pointer"
});
game.addChild(introArrowObject);
introElements.push(introArrowObject);
if (comicPanelsContainer && comicPanelsContainer.parent) {
game.setChildIndex(introArrowObject, game.getChildIndex(comicPanelsContainer) + 1);
}
if (skipButton && skipButton.parent) {
game.setChildIndex(skipButton, game.children.length - 1);
}
tween(introArrowObject, {
alpha: 1
}, {
duration: 500
});
var arrowPulseDir = 1;
function pulseArrow() {
if (!isWaitingForUserClick || !introArrowObject || !introArrowObject.parent || currentScreenState !== 'intro') {
if (introArrowObject && introArrowObject.pulseTimerId) {
LK.clearTimeout(introArrowObject.pulseTimerId);
}
if (introArrowObject) {
introArrowObject.pulseTimerId = null;
}
return;
}
var targetScale = arrowPulseDir > 0 ? 1.15 : 1.0;
arrowPulseDir *= -1;
tween(introArrowObject.scale, {
x: targetScale,
y: targetScale
}, {
duration: 700,
easing: tween.easeInOutQuad,
onFinish: function onFinish() {
if (isWaitingForUserClick && introArrowObject && introArrowObject.parent) {
introArrowObject.pulseTimerId = LK.setTimeout(pulseArrow, 100);
}
}
});
}
introArrowObject.pulseTimerId = LK.setTimeout(pulseArrow, 500);
var thisArrowInstance = introArrowObject;
thisArrowInstance.down = function () {
if (isWaitingForUserClick && currentScreenState === 'intro' && thisArrowInstance && thisArrowInstance.parent) {
isWaitingForUserClick = false;
if (thisArrowInstance.pulseTimerId) {
LK.clearTimeout(thisArrowInstance.pulseTimerId);
thisArrowInstance.pulseTimerId = null;
}
tween(thisArrowInstance, {
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
if (thisArrowInstance.parent) {
thisArrowInstance.destroy();
}
var idx = introElements.indexOf(thisArrowInstance);
if (idx > -1) {
introElements.splice(idx, 1);
}
if (introArrowObject === thisArrowInstance) {
introArrowObject = null;
}
}
});
clearLocalIntroTimers(false);
actionOnClick();
}
};
}
function proceedToPhase2() {
if (currentScreenState !== 'intro') {
return;
}
hideAndDestroyPanels(activePanelObjects.slice(), 800, function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[3], panelPositions[0], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[4], panelPositions[1], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[5], panelPositions[2], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState === 'intro') {
showArrowAndAwaitClick(proceedToPhase3);
}
}, 3000));
});
}, 3000));
});
}, 3000));
});
});
}
function proceedToPhase3() {
if (currentScreenState !== 'intro') {
return;
}
hideAndDestroyPanels(activePanelObjects.slice(), 800, function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[6], panelPositions[0], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[7], panelPositions[1], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[8], panelPositions[2], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState === 'intro') {
endIntroSequence();
}
}, 3000));
});
}, 3000));
});
}, 3000));
});
});
}
displayPanelWithFadeIn(introAssetKeys[0], panelPositions[0], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[1], panelPositions[1], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[2], panelPositions[2], 800, function () {
if (currentScreenState === 'intro') {
showArrowAndAwaitClick(proceedToPhase2);
}
});
}, 3000));
});
}, 3000));
});
}
function checkMiniGameCollisions() {
if (!miniGamePlayer || !miniGamePlayer.asset || isMiniGameOver) {
return;
}
for (var i = miniGameObstacles.length - 1; i >= 0; i--) {
var obs = miniGameObstacles[i];
if (miniGameRectsIntersect(miniGamePlayer, obs)) {
console.log("Game Over - Hit obstacle!");
isMiniGameOver = true;
if (miniGamePlayer.asset) {
miniGamePlayer.asset.tint = 0xFF0000;
}
return;
}
}
}
function miniGameRectsIntersect(r1Player, r2Object) {
var r1Details = {
x: r1Player.x,
y: r1Player.y,
width: r1Player.width,
height: r1Player.height
};
var r2Details = {
x: r2Object.x,
y: r2Object.y,
width: r2Object.width,
height: r2Object.height
};
var r1left = r1Details.x - r1Details.width / 2;
var r1right = r1Details.x + r1Details.width / 2;
var r1top = r1Details.y - r1Details.height / 2;
var r1bottom = r1Details.y + r1Details.height / 2;
var r2left = r2Details.x - r2Details.width / 2;
var r2right = r2Details.x + r2Details.width / 2;
var r2top = r2Details.y - r2Details.height / 2;
var r2bottom = r2Details.y + r2Details.height / 2;
return !(r2left >= r1right || r2right <= r1left || r2top >= r1bottom || r2bottom <= r1top);
}
function runTutorialGameplay() {
if (currentMainMenuMusicTrack && typeof currentMainMenuMusicTrack.stop === 'function') {
currentMainMenuMusicTrack.stop();
}
while (mainMenuScreenElements.length > 0) {
var elemToDestroy = mainMenuScreenElements.pop();
if (elemToDestroy && elemToDestroy.parent) {
elemToDestroy.destroy();
}
}
mainMenuItemTextObjects = [];
if (typeof menuTextContainer !== 'undefined' && menuTextContainer && menuTextContainer.parent) {
menuTextContainer.destroy(); // Zniszcz kontener, jeśli istnieje
}
menuTextContainer = null; // Zresetuj referencję
isTutorialMode = true;
currentScreenState = 'gameplay';
allSongData["TutorialTrack"] = tutorialSongData;
currentFightingBossId = null;
loadSong("TutorialTrack");
}
function exitTutorialGameplay() {
isTutorialMode = false;
if (activeMusicTrack) {
activeMusicTrack.stop();
activeMusicTrack = null;
}
resetGameState();
if (gameplayBackground && gameplayBackground.parent) {
gameplayBackground.destroy();
gameplayBackground = null;
}
if (scoreTxt) {
scoreTxt.visible = true;
}
if (comboTxt) {
comboTxt.visible = true;
}
if (gameUIContainer) {
gameUIContainer.visible = false;
}
if (staticHitFrame) {
staticHitFrame.visible = false;
}
if (staticPerfectLine) {
staticPerfectLine.visible = false;
}
showMainMenu();
}
// Game State & Rhythm Logic Variables
var allSongData = {
"NoizboyTrack": {
musicAsset: 'Noizboy',
bossAssetKey: 'Boss3',
config: {
playerMaxHP: 20,
bossMaxHP: 220
},
rawRhythmMap: [{
time: 12000,
type: "tap",
columnIndex: 0
}, {
time: 12613,
type: "tap",
columnIndex: 1
}, {
time: 13148,
type: "tap",
columnIndex: 0
}, {
time: 13759,
type: "tap",
columnIndex: 1
}, {
time: 14293,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 14860,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 15437,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 15960,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 16561,
type: "tap",
columnIndex: 2
}, {
time: 17133,
type: "tap",
columnIndex: 1
}, {
time: 17647,
type: "tap",
columnIndex: 0
}, {
time: 18180,
type: "tap",
columnIndex: 0
}, {
time: 18859,
type: "tap",
columnIndex: 1
}, {
time: 19422,
type: "tap",
columnIndex: 0
}, {
time: 20010,
type: "tap",
columnIndex: 1
}, {
time: 20272,
type: "tap",
columnIndex: 2
}, {
time: 20609,
type: "tap",
columnIndex: 2
}, {
time: 20840,
type: "tap",
columnIndex: 2
}, {
time: 21186,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 21829,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 22364,
type: "swipe",
columnIndex: 1,
swipeDir: "left"
}, {
time: 22935,
type: "swipe",
columnIndex: 1,
swipeDir: "left"
}, {
time: 23517,
type: "tap",
columnIndex: 1
}, {
time: 23812,
type: "tap",
columnIndex: 1
}, {
time: 24063,
type: "tap",
columnIndex: 2
}, {
time: 24415,
type: "tap",
columnIndex: 2
}, {
time: 24678,
type: "tap",
columnIndex: 0
}, {
time: 24965,
type: "tap",
columnIndex: 0
}, {
time: 25234,
type: "tap",
columnIndex: 1
}, {
time: 25846,
type: "tap",
columnIndex: 2
}, {
time: 26440,
type: "tap",
columnIndex: 2
}, {
time: 27003,
type: "tap",
columnIndex: 1
}, {
time: 27535,
type: "tap",
columnIndex: 1
}, {
time: 28133,
type: "tap",
columnIndex: 0
}, {
time: 28680,
type: "tap",
columnIndex: 0
}, {
time: 29225,
type: "tap",
columnIndex: 0
}, {
time: 29846,
type: "tap",
columnIndex: 0
}, {
time: 30459,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 31100,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 31660,
type: "swipe",
columnIndex: 2,
swipeDir: "left"
}, {
time: 32775,
type: "swipe",
columnIndex: 2,
swipeDir: "down"
}, {
time: 33347,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 33930,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 35058,
type: "tap",
columnIndex: 2
}, {
time: 35640,
type: "tap",
columnIndex: 1
}, {
time: 36187,
type: "tap",
columnIndex: 2
}, {
time: 36722,
type: "tap",
columnIndex: 1
}, {
time: 37385,
type: "tap",
columnIndex: 0
}, {
time: 37928,
type: "tap",
columnIndex: 0
}, {
time: 38148,
type: "tap",
columnIndex: 0
}, {
time: 38502,
type: "tap",
columnIndex: 0
}, {
time: 39022,
type: "tap",
columnIndex: 1
}, {
time: 39657,
type: "tap",
columnIndex: 2
}, {
time: 40209,
type: "tap",
columnIndex: 2
}, {
time: 40800,
type: "tap",
columnIndex: 0
}, {
time: 41347,
type: "tap",
columnIndex: 0
}, {
time: 41963,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 42496,
type: "tap",
columnIndex: 0
}, {
time: 43113,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 43723,
type: "tap",
columnIndex: 0
}, {
time: 44318,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 44871,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 45456,
type: "tap",
columnIndex: 1
}, {
time: 45996,
type: "tap",
columnIndex: 1
}, {
time: 46548,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 47158,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 47720,
type: "tap",
columnIndex: 2
}, {
time: 48324,
type: "tap",
columnIndex: 2
}, {
time: 48833,
type: "swipe",
columnIndex: 2,
swipeDir: "down"
}, {
time: 49449,
type: "swipe",
columnIndex: 2,
swipeDir: "down"
}, {
time: 50039,
type: "tap",
columnIndex: 0
}, {
time: 50616,
type: "tap",
columnIndex: 0
}, {
time: 51149,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 51781,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 52401,
type: "tap",
columnIndex: 2
}, {
time: 52729,
type: "tap",
columnIndex: 2
}, {
time: 53030,
type: "tap",
columnIndex: 2
}, {
time: 53306,
type: "tap",
columnIndex: 2
}, {
time: 53560,
type: "tap",
columnIndex: 1
}, {
time: 54118,
type: "tap",
columnIndex: 2
}, {
time: 54687,
type: "tap",
columnIndex: 1
}, {
time: 55274,
type: "tap",
columnIndex: 2
}, {
time: 55842,
type: "tap",
columnIndex: 1
}, {
time: 56416,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 57066,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 57597,
type: "tap",
columnIndex: 2
}, {
time: 58182,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 58773,
type: "tap",
columnIndex: 2
}, {
time: 59339,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 59894,
type: "tap",
columnIndex: 1
}, {
time: 60459,
type: "tap",
columnIndex: 2
}, {
time: 61083,
type: "tap",
columnIndex: 1
}, {
time: 61659,
type: "tap",
columnIndex: 2
}, {
time: 62221,
type: "tap",
columnIndex: 0
}, {
time: 62754,
type: "tap",
columnIndex: 1
}, {
time: 68064,
type: "hold",
columnIndex: 1,
duration: 1227
}, {
time: 69302,
type: "hold",
columnIndex: 2,
duration: 1134
}, {
time: 70476,
type: "hold",
columnIndex: 0,
duration: 1249
}, {
time: 71721,
type: "hold",
columnIndex: 1,
duration: 1188
}, {
time: 72898,
type: "hold",
columnIndex: 2,
duration: 1232
}, {
time: 74104,
type: "hold",
columnIndex: 0,
duration: 1277
}, {
time: 75409,
type: "hold",
columnIndex: 1,
duration: 965
}, {
time: 76370,
type: "hold",
columnIndex: 2,
duration: 1539
}, {
time: 78101,
type: "hold",
columnIndex: 1,
duration: 1002
}, {
time: 79259,
type: "hold",
columnIndex: 0,
duration: 1222
}, {
time: 80575,
type: "hold",
columnIndex: 1,
duration: 1071
}, {
time: 81723,
type: "hold",
columnIndex: 2,
duration: 884
}, {
time: 82719,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 83490,
type: "hold",
columnIndex: 2,
duration: 1150
}, {
time: 84679,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 85134,
type: "hold",
columnIndex: 1,
duration: 1173
}, {
time: 86436,
type: "tap",
columnIndex: 0
}, {
time: 86983,
type: "tap",
columnIndex: 1
}, {
time: 87567,
type: "tap",
columnIndex: 0
}, {
time: 88162,
type: "tap",
columnIndex: 0
}, {
time: 88727,
type: "tap",
columnIndex: 1
}, {
time: 89296,
type: "tap",
columnIndex: 1
}, {
time: 89880,
type: "tap",
columnIndex: 2
}, {
time: 90438,
type: "tap",
columnIndex: 2
}, {
time: 90998,
type: "tap",
columnIndex: 1
}, {
time: 91591,
type: "tap",
columnIndex: 1
}, {
time: 92159,
type: "tap",
columnIndex: 1
}, {
time: 92717,
type: "tap",
columnIndex: 1
}, {
time: 93030,
type: "tap",
columnIndex: 2
}, {
time: 93403,
type: "tap",
columnIndex: 0
}, {
time: 93950,
type: "tap",
columnIndex: 1
}, {
time: 94528,
type: "tap",
columnIndex: 0
}, {
time: 95074,
type: "tap",
columnIndex: 1
}, {
time: 95304,
type: "tap",
columnIndex: 2
}, {
time: 95642,
type: "tap",
columnIndex: 0
}, {
time: 96220,
type: "tap",
columnIndex: 1
}, {
time: 96811,
type: "tap",
columnIndex: 2
}, {
time: 97429,
type: "tap",
columnIndex: 1
}, {
time: 97926,
type: "tap",
columnIndex: 2
}]
},
"GoblopBossTrack": {
musicAsset: "Goblop",
bossAssetKey: 'Boss2_Asset',
config: {
playerMaxHP: 15,
bossMaxHP: 200
},
rawRhythmMap: [{
time: 7000,
type: "tap",
columnIndex: 0
}, {
time: 7637,
type: "tap",
columnIndex: 1
}, {
time: 8205,
type: "tap",
columnIndex: 2
}, {
time: 8783,
type: "tap",
columnIndex: 2
}, {
time: 9355,
type: "tap",
columnIndex: 0
}, {
time: 9966,
type: "tap",
columnIndex: 1
}, {
time: 10584,
type: "tap",
columnIndex: 0
}, {
time: 11124,
type: "tap",
columnIndex: 0
}, {
time: 11668,
type: "tap",
columnIndex: 0
}, {
time: 12254,
type: "tap",
columnIndex: 1
}, {
time: 12833,
type: "tap",
columnIndex: 2
}, {
time: 13428,
type: "tap",
columnIndex: 1
}, {
time: 14026,
type: "hold",
columnIndex: 1,
duration: 1205
}, {
time: 15270,
type: "hold",
columnIndex: 2,
duration: 1028
}, {
time: 16918,
type: "tap",
columnIndex: 0
}, {
time: 17481,
type: "tap",
columnIndex: 1
}, {
time: 18120,
type: "tap",
columnIndex: 0
}, {
time: 18697,
type: "tap",
columnIndex: 1
}, {
time: 19238,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 19853,
type: "tap",
columnIndex: 1
}, {
time: 20442,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 21008,
type: "tap",
columnIndex: 2
}, {
time: 21561,
type: "swipe",
columnIndex: 2,
swipeDir: "left"
}, {
time: 22225,
type: "tap",
columnIndex: 2
}, {
time: 22794,
type: "swipe",
columnIndex: 2,
swipeDir: "up"
}, {
time: 23316,
type: "tap",
columnIndex: 2
}, {
time: 23933,
type: "swipe",
columnIndex: 1,
swipeDir: "left"
}, {
time: 24538,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 25132,
type: "tap",
columnIndex: 1
}, {
time: 25655,
type: "tap",
columnIndex: 2
}, {
time: 26261,
type: "tap",
columnIndex: 0
}, {
time: 26840,
type: "tap",
columnIndex: 1
}, {
time: 27382,
type: "tap",
columnIndex: 2
}, {
time: 28000,
type: "tap",
columnIndex: 1
}, {
time: 28617,
type: "tap",
columnIndex: 0
}, {
time: 29194,
type: "tap",
columnIndex: 1
}, {
time: 29777,
type: "tap",
columnIndex: 2
}, {
time: 30341,
type: "tap",
columnIndex: 0
}, {
time: 30816,
type: "tap",
columnIndex: 1
}, {
time: 31506,
type: "tap",
columnIndex: 2
}, {
time: 32106,
type: "tap",
columnIndex: 0
}, {
time: 32693,
type: "hold",
columnIndex: 0,
duration: 1057
}, {
time: 33803,
type: "hold",
columnIndex: 1,
duration: 1052
}, {
time: 35102,
type: "tap",
columnIndex: 0
}, {
time: 37350,
type: "hold",
columnIndex: 1,
duration: 1851
}, {
time: 39629,
type: "hold",
columnIndex: 2,
duration: 2237
}, {
time: 42031,
type: "hold",
columnIndex: 0,
duration: 2178
}, {
time: 44365,
type: "tap",
columnIndex: 0
}, {
time: 44996,
type: "tap",
columnIndex: 0
}, {
time: 45618,
type: "tap",
columnIndex: 0
}, {
time: 46143,
type: "tap",
columnIndex: 0
}, {
time: 46708,
type: "tap",
columnIndex: 0
}, {
time: 47258,
type: "tap",
columnIndex: 0
}, {
time: 47812,
type: "tap",
columnIndex: 0
}, {
time: 48333,
type: "tap",
columnIndex: 0
}, {
time: 48601,
type: "tap",
columnIndex: 0
}, {
time: 48988,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 49568,
type: "swipe",
columnIndex: 2,
swipeDir: "up"
}, {
time: 50154,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 50768,
type: "swipe",
columnIndex: 1,
swipeDir: "down"
}, {
time: 51337,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 51939,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 52497,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 53086,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 53638,
type: "tap",
columnIndex: 2
}, {
time: 54286,
type: "tap",
columnIndex: 1
}, {
time: 54830,
type: "tap",
columnIndex: 2
}, {
time: 55440,
type: "tap",
columnIndex: 1
}, {
time: 55971,
type: "tap",
columnIndex: 2
}, {
time: 56523,
type: "tap",
columnIndex: 0
}, {
time: 57124,
type: "tap",
columnIndex: 1
}, {
time: 57742,
type: "tap",
columnIndex: 2
}, {
time: 58339,
type: "tap",
columnIndex: 0
}, {
time: 59372,
type: "hold",
columnIndex: 0,
duration: 1269
}, {
time: 60694,
type: "hold",
columnIndex: 1,
duration: 2119
}, {
time: 62848,
type: "hold",
columnIndex: 2,
duration: 2364
}, {
time: 65253,
type: "hold",
columnIndex: 0,
duration: 2294
}, {
time: 67709,
type: "tap",
columnIndex: 0
}, {
time: 68257,
type: "tap",
columnIndex: 0
}, {
time: 68812,
type: "tap",
columnIndex: 0
}, {
time: 69407,
type: "tap",
columnIndex: 0
}, {
time: 69707,
type: "tap",
columnIndex: 0
}, {
time: 69989,
type: "tap",
columnIndex: 0
}, {
time: 70554,
type: "tap",
columnIndex: 1
}, {
time: 71147,
type: "tap",
columnIndex: 0
}, {
time: 71721,
type: "tap",
columnIndex: 1
}, {
time: 72304,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 72909,
type: "swipe",
columnIndex: 1,
swipeDir: "down"
}, {
time: 73509,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 74070,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 74655,
type: "tap",
columnIndex: 0
}, {
time: 75270,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 75835,
type: "tap",
columnIndex: 0
}, {
time: 76391,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 76968,
type: "tap",
columnIndex: 0
}, {
time: 77527,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 78153,
type: "tap",
columnIndex: 1
}, {
time: 78701,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 79300,
type: "tap",
columnIndex: 2
}, {
time: 79856,
type: "swipe",
columnIndex: 1,
swipeDir: "down"
}, {
time: 80433,
type: "tap",
columnIndex: 2
}, {
time: 81041,
type: "tap",
columnIndex: 1
}, {
time: 81632,
type: "tap",
columnIndex: 2
}, {
time: 82232,
type: "tap",
columnIndex: 1
}, {
time: 82769,
type: "tap",
columnIndex: 2
}, {
time: 83391,
type: "tap",
columnIndex: 2
}, {
time: 83960,
type: "tap",
columnIndex: 1
}, {
time: 84554,
type: "tap",
columnIndex: 2
}, {
time: 85139,
type: "tap",
columnIndex: 0
}, {
time: 85715,
type: "tap",
columnIndex: 1
}, {
time: 86261,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 86858,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 87427,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 88060,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 88630,
type: "tap",
columnIndex: 1
}, {
time: 89198,
type: "swipe",
columnIndex: 1,
swipeDir: "down"
}, {
time: 89777,
type: "tap",
columnIndex: 1
}, {
time: 90334,
type: "swipe",
columnIndex: 2,
swipeDir: "up"
}, {
time: 90976,
type: "tap",
columnIndex: 2
}, {
time: 91533,
type: "swipe",
columnIndex: 2,
swipeDir: "left"
}, {
time: 92125,
type: "tap",
columnIndex: 2
}, {
time: 92691,
type: "swipe",
columnIndex: 2,
swipeDir: "right"
}, {
time: 93264,
type: "tap",
columnIndex: 0
}, {
time: 93848,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 94458,
type: "tap",
columnIndex: 1
}, {
time: 95026,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 95599,
type: "tap",
columnIndex: 2
}, {
time: 96194,
type: "tap",
columnIndex: 1
}, {
time: 96765,
type: "tap",
columnIndex: 0
}, {
time: 97338,
type: "tap",
columnIndex: 1
}, {
time: 97640,
type: "tap",
columnIndex: 2
}, {
time: 97979,
type: "tap",
columnIndex: 0
}]
},
"OrctaveBossTrack": {
musicAsset: "Orctave",
// Upewnij się, że masz asset muzyczny o tym kluczu
bossAssetKey: 'Boss1_Asset',
// Asset dla pierwszego bossa
config: {
playerMaxHP: 10,
bossMaxHP: 200
},
rawRhythmMap: [{
time: 8596,
type: 'tap',
columnIndex: 0
}, {
time: 8795,
type: 'tap',
columnIndex: 1
}, {
time: 9117,
type: 'tap',
columnIndex: 2
}, {
time: 9832,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 10536,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 11245,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 11888,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 12628,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 13308,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 13986,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 14696,
type: 'tap',
columnIndex: 2
}, {
time: 15456,
type: 'tap',
columnIndex: 2
}, {
time: 16140,
type: 'tap',
columnIndex: 1
}, {
time: 16863,
type: 'tap',
columnIndex: 1
}, {
time: 17547,
type: 'tap',
columnIndex: 0
}, {
time: 18275,
type: 'tap',
columnIndex: 0
}, {
time: 18955,
type: 'tap',
columnIndex: 0
}, {
time: 19670,
type: 'tap',
columnIndex: 0
}, {
time: 20333,
type: 'tap',
columnIndex: 1
}, {
time: 20740,
type: 'tap',
columnIndex: 2
}, {
time: 21063,
type: 'tap',
columnIndex: 1
}, {
time: 21411,
type: 'tap',
columnIndex: 0
}, {
time: 21742,
type: 'tap',
columnIndex: 1
}, {
time: 22110,
type: 'tap',
columnIndex: 2
}, {
time: 22463,
type: 'tap',
columnIndex: 1
}, {
time: 22797,
type: 'tap',
columnIndex: 0
}, {
time: 23336,
type: 'tap',
columnIndex: 2
}, {
time: 26163,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 26737,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 27351,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 27764,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 28116,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 28827,
type: 'swipe',
columnIndex: 1,
swipeDir: 'right'
}, {
time: 29546,
type: 'swipe',
columnIndex: 0,
swipeDir: 'left'
}, {
time: 30102,
type: 'swipe',
columnIndex: 1,
swipeDir: 'right'
}, {
time: 30534,
type: 'swipe',
columnIndex: 1,
swipeDir: 'right'
}, {
time: 30931,
type: 'swipe',
columnIndex: 0,
swipeDir: 'left'
}, {
time: 31677,
type: 'tap',
columnIndex: 2
}, {
time: 32392,
type: 'tap',
columnIndex: 1
}, {
time: 32989,
type: 'tap',
columnIndex: 2
}, {
time: 33386,
type: 'tap',
columnIndex: 2
}, {
time: 33781,
type: 'tap',
columnIndex: 1
}, {
time: 34568,
type: 'tap',
columnIndex: 2
}, {
time: 35234,
type: 'tap',
columnIndex: 1
}, {
time: 35749,
type: 'tap',
columnIndex: 2
}, {
time: 36182,
type: 'tap',
columnIndex: 2
}, {
time: 36583,
type: 'tap',
columnIndex: 0
}, {
time: 37302,
type: 'tap',
columnIndex: 0
}, {
time: 37681,
type: 'tap',
columnIndex: 1
}, {
time: 38033,
type: 'tap',
columnIndex: 2
}, {
time: 38354,
type: 'tap',
columnIndex: 2
}, {
time: 38721,
type: 'tap',
columnIndex: 1
}, {
time: 39067,
type: 'tap',
columnIndex: 0
}, {
time: 39471,
type: 'tap',
columnIndex: 1
}, {
time: 39821,
type: 'tap',
columnIndex: 2
}, {
time: 40164,
type: 'tap',
columnIndex: 1
}, {
time: 40488,
type: 'tap',
columnIndex: 0
}, {
time: 40861,
type: 'tap',
columnIndex: 0
}, {
time: 41250,
type: 'tap',
columnIndex: 1
}, {
time: 41609,
type: 'tap',
columnIndex: 2
}, {
time: 41946,
type: 'tap',
columnIndex: 1
}, {
time: 42290,
type: 'tap',
columnIndex: 0
}, {
time: 42643,
type: 'tap',
columnIndex: 2
}, {
time: 43068,
type: 'tap',
columnIndex: 1
}, {
time: 43379,
type: 'tap',
columnIndex: 2
}, {
time: 43726,
type: 'tap',
columnIndex: 1
}, {
time: 44078,
type: 'tap',
columnIndex: 2
}, {
time: 44414,
type: 'tap',
columnIndex: 1
}, {
time: 44728,
type: 'tap',
columnIndex: 2
}, {
time: 45115,
type: 'tap',
columnIndex: 1
}, {
time: 45475,
type: 'tap',
columnIndex: 2
}, {
time: 45809,
type: 'tap',
columnIndex: 0
}, {
time: 46199,
type: 'tap',
columnIndex: 1
}, {
time: 46521,
type: 'tap',
columnIndex: 2
}, {
time: 46855,
type: 'tap',
columnIndex: 1
}, {
time: 47190,
type: 'tap',
columnIndex: 0
}, {
time: 47535,
type: 'tap',
columnIndex: 2
}, {
time: 47874,
type: 'tap',
columnIndex: 1
}, {
time: 48252,
type: 'tap',
columnIndex: 2
}, {
time: 51448,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 52112,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 52853,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 53536,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 54251,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 54964,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 55618,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 56339,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 57058,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 57799,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 58512,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 59170,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 59911,
type: 'swipe',
columnIndex: 2,
swipeDir: 'right'
}, {
time: 60668,
type: 'tap',
columnIndex: 2
}, {
time: 61334,
type: 'swipe',
columnIndex: 2,
swipeDir: 'right'
}, {
time: 62084,
type: 'tap',
columnIndex: 2
}, {
time: 62744,
type: 'swipe',
columnIndex: 2,
swipeDir: 'right'
}, {
time: 63445,
type: 'tap',
columnIndex: 2
}, {
time: 64134,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 64827,
type: 'tap',
columnIndex: 1
}, {
time: 65532,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 66199,
type: 'tap',
columnIndex: 1
}, {
time: 66921,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 67679,
type: 'tap',
columnIndex: 1
}, {
time: 68353,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 69005,
type: 'tap',
columnIndex: 0
}, {
time: 69772,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 70457,
type: 'tap',
columnIndex: 0
}, {
time: 71178,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 71892,
type: 'swipe',
columnIndex: 2,
swipeDir: 'right'
}, {
time: 72585,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 73287,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 74094,
type: 'tap',
columnIndex: 2
}, {
time: 75031,
type: 'tap',
columnIndex: 1
}, {
time: 75469,
type: 'tap',
columnIndex: 2
}, {
time: 75831,
type: 'tap',
columnIndex: 2
}, {
time: 76181,
type: 'tap',
columnIndex: 1
}, {
time: 76909,
type: 'tap',
columnIndex: 0
}, {
time: 77641,
type: 'tap',
columnIndex: 1
}, {
time: 78208,
type: 'tap',
columnIndex: 2
}, {
time: 78675,
type: 'tap',
columnIndex: 2
}, {
time: 79001,
type: 'tap',
columnIndex: 1
}, {
time: 79743,
type: 'tap',
columnIndex: 0
}, {
time: 80401,
type: 'tap',
columnIndex: 1
}, {
time: 80982,
type: 'tap',
columnIndex: 0
}, {
time: 81387,
type: 'tap',
columnIndex: 0
}, {
time: 81769,
type: 'tap',
columnIndex: 1
}, {
time: 82537,
type: 'tap',
columnIndex: 2
}, {
time: 83216,
type: 'tap',
columnIndex: 1
}, {
time: 83789,
type: 'tap',
columnIndex: 0
}, {
time: 84229,
type: 'tap',
columnIndex: 0
}, {
time: 84566,
type: 'tap',
columnIndex: 0
}, {
time: 84923,
type: 'tap',
columnIndex: 0
}, {
time: 85105,
type: 'tap',
columnIndex: 0
}, {
time: 85305,
type: 'tap',
columnIndex: 1
}]
}
};
// Initialize and add gameUIContainer to the game scene
gameUIContainer = new Container();
game.addChild(gameUIContainer);
// Function to process raw rhythm map data (remains unchanged, ensure it's here)
function processRawRhythmMap(rawMapData, songKeyForLogging) {
console.log("Processing raw map for: " + songKeyForLogging + " with " + rawMapData.length + " initial notes.");
var processedMap = [];
var tempMap = [];
for (var k = 0; k < rawMapData.length; k++) {
var originalNote = rawMapData[k];
var copiedNote = {};
for (var key in originalNote) {
if (originalNote.hasOwnProperty(key)) {
copiedNote[key] = originalNote[key];
}
}
tempMap.push(copiedNote);
}
for (var i = 0; i < tempMap.length; i++) {
var note = tempMap[i];
if (note.type === 'swipe' && note.swipeDir) {
var dir = note.swipeDir.toLowerCase();
if (dir.includes('right')) {
note.swipeDir = 'right';
} else if (dir.includes('left')) {
note.swipeDir = 'left';
} else if (dir.includes('up')) {
note.swipeDir = 'up';
} else if (dir.includes('down')) {
note.swipeDir = 'down';
}
}
}
var timeGroupedNotes = {};
tempMap.forEach(function (note) {
if (!timeGroupedNotes[note.time]) {
timeGroupedNotes[note.time] = [];
}
timeGroupedNotes[note.time].push(note);
});
var finalMapNotes = [];
var sortedTimes = Object.keys(timeGroupedNotes).map(Number).sort(function (a, b) {
return a - b;
});
for (var tIdx = 0; tIdx < sortedTimes.length; tIdx++) {
var time = sortedTimes[tIdx];
var notesAtThisTime = timeGroupedNotes[time];
var notesToKeepAtThisTime = [];
var processedForWiderSwipeConversion = [];
var colsWithVerticalSwipes = [null, null, null, null];
notesAtThisTime.forEach(function (note) {
if (note.type === 'swipe' && (note.swipeDir === 'up' || note.swipeDir === 'down')) {
if (note.columnIndex >= 0 && note.columnIndex < NUM_COLUMNS) {
var alreadyConverted = false;
for (var convIdx = 0; convIdx < processedForWiderSwipeConversion.length; convIdx++) {
if (processedForWiderSwipeConversion[convIdx].originalTime === note.time && processedForWiderSwipeConversion[convIdx].originalColumn === note.columnIndex) {
alreadyConverted = true;
break;
}
}
if (!alreadyConverted) {
colsWithVerticalSwipes[note.columnIndex] = note.swipeDir;
}
}
}
});
for (var c = 0; c < NUM_COLUMNS - 1; c++) {
if (colsWithVerticalSwipes[c] && colsWithVerticalSwipes[c + 1] && colsWithVerticalSwipes[c] === colsWithVerticalSwipes[c + 1]) {
var randomHorizontalDir = Math.random() < 0.5 ? 'left' : 'right';
var pairCenterX = (columnCenterXs[c] + columnCenterXs[c + 1]) / 2;
notesToKeepAtThisTime.push({
time: time,
type: 'swipe',
swipeDir: randomHorizontalDir,
partOfWiderSwipe: 'leftHalf',
widerSwipePairCenterX: pairCenterX,
originalColumnHint: c
});
notesToKeepAtThisTime.push({
time: time,
type: 'swipe',
swipeDir: randomHorizontalDir,
partOfWiderSwipe: 'rightHalf',
widerSwipePairCenterX: pairCenterX,
originalColumnHint: c + 1
});
processedForWiderSwipeConversion.push({
originalTime: time,
originalColumn: c
});
processedForWiderSwipeConversion.push({
originalTime: time,
originalColumn: c + 1
});
colsWithVerticalSwipes[c] = null;
colsWithVerticalSwipes[c + 1] = null;
c++;
}
}
notesAtThisTime.forEach(function (note) {
var wasConverted = false;
for (var convIdx = 0; convIdx < processedForWiderSwipeConversion.length; convIdx++) {
if (processedForWiderSwipeConversion[convIdx].originalTime === note.time && processedForWiderSwipeConversion[convIdx].originalColumn === note.columnIndex && (note.swipeDir === 'up' || note.swipeDir === 'down')) {
wasConverted = true;
break;
}
}
if (!wasConverted) {
notesToKeepAtThisTime.push(note);
}
});
var horizontalWiderSwipePairs = {};
var notesForFinalProcessing = [];
var uniqueNotesAtThisTime = [];
var seenNotesKeysAtThisTime = {};
notesToKeepAtThisTime.forEach(function (note) {
var key = "" + note.type + "_" + (note.columnIndex !== undefined ? note.columnIndex : note.partOfWiderSwipe ? note.widerSwipePairCenterX + note.partOfWiderSwipe : '') + "_" + (note.swipeDir || '');
if (!seenNotesKeysAtThisTime[key]) {
uniqueNotesAtThisTime.push(note);
seenNotesKeysAtThisTime[key] = true;
}
});
uniqueNotesAtThisTime.sort(function (a, b) {
var valA = a.originalColumnHint !== undefined ? a.originalColumnHint : a.columnIndex !== undefined ? a.columnIndex : a.widerSwipePairCenterX || 0;
var valB = b.originalColumnHint !== undefined ? b.originalColumnHint : b.columnIndex !== undefined ? b.columnIndex : b.widerSwipePairCenterX || 0;
return valA - valB;
});
for (var nIdx = 0; nIdx < uniqueNotesAtThisTime.length; nIdx++) {
var note = uniqueNotesAtThisTime[nIdx];
if (note.partOfWiderSwipe) {
notesForFinalProcessing.push(note);
continue;
}
var potentialPartner = null;
if (nIdx + 1 < uniqueNotesAtThisTime.length) {
potentialPartner = uniqueNotesAtThisTime[nIdx + 1];
}
if (note.type === 'swipe' && (note.swipeDir === 'left' || note.swipeDir === 'right') && potentialPartner && potentialPartner.type === 'swipe' && potentialPartner.time === note.time && potentialPartner.swipeDir === note.swipeDir && potentialPartner.columnIndex === note.columnIndex + 1) {
var pairCenterX = (columnCenterXs[note.columnIndex] + columnCenterXs[potentialPartner.columnIndex]) / 2;
notesForFinalProcessing.push({
time: note.time,
type: 'swipe',
swipeDir: note.swipeDir,
partOfWiderSwipe: 'leftHalf',
widerSwipePairCenterX: pairCenterX,
originalColumnHint: note.columnIndex
});
notesForFinalProcessing.push({
time: potentialPartner.time,
type: 'swipe',
swipeDir: potentialPartner.swipeDir,
partOfWiderSwipe: 'rightHalf',
widerSwipePairCenterX: pairCenterX,
originalColumnHint: potentialPartner.columnIndex
});
nIdx++;
} else {
notesForFinalProcessing.push(note);
}
}
finalMapNotes.push.apply(finalMapNotes, notesForFinalProcessing);
}
var uniqueNotesOverall = [];
var seenNotesOverall = {};
finalMapNotes.sort(function (a, b) {
return a.time - b.time;
});
finalMapNotes.forEach(function (note) {
var cX;
var keyPartForColumn;
if (note.partOfWiderSwipe) {
cX = note.widerSwipePairCenterX + (note.partOfWiderSwipe === 'leftHalf' ? -(SWIPE_NOTE_WIDTH / 2) : SWIPE_NOTE_WIDTH / 2);
keyPartForColumn = "pC" + note.widerSwipePairCenterX + "h" + (note.partOfWiderSwipe === 'leftHalf' ? 'L' : 'R');
} else if (note.columnIndex !== undefined) {
cX = columnCenterXs[note.columnIndex];
keyPartForColumn = "c" + note.columnIndex;
} else {
cX = gameScreenWidth / 2;
keyPartForColumn = "cX" + cX;
}
var key = "" + note.time + "_" + note.type + "_" + keyPartForColumn + "_" + (note.swipeDir || '');
if (!seenNotesOverall[key]) {
uniqueNotesOverall.push(note);
seenNotesOverall[key] = true;
} else {
// console.log("Filtered final duplicate note: " + key);
}
});
console.log("Processed map for: " + songKeyForLogging + " FINALLY contains " + uniqueNotesOverall.length + " notes.");
return uniqueNotesOverall;
}
var hpBarsInitialized = false;
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF,
alpha: 1
});
scoreTxt.anchor.set(1, 0); // Anchor center-top
scoreTxt.x = gameScreenWidth / 1;
scoreTxt.y = 20; // Position from the top of its container (gameUIContainer)
gameUIContainer.addChild(scoreTxt);
console.log("Restored scoreTxt: X=" + scoreTxt.x + " Y=" + scoreTxt.y + " Visible:" + scoreTxt.visible + " Parent: gameUIContainer");
var comboTxt = new Text2('Combo: 0', {
size: 50,
// Możesz dostosować rozmiar tekstu combo
fill: 0xFFFF00,
// Żółty kolor
alpha: 0.5
});
comboTxt.anchor.set(0, 0.5);
comboTxt.x = 100;
comboTxt.y = 1000;
comboTxt.rotation = -0.26;
gameUIContainer.addChild(comboTxt);
console.log("ComboTxt positioned: X=" + comboTxt.x + " Y=" + comboTxt.y + " Visible:" + comboTxt.visible + " Parent: gameUIContainer");
var hitZoneY = 1800;
var hitZoneVisualWidth = playfieldWidth;
function rectsIntersect(r1, r2) {
return !(r2.x > r1.x + r1.width || r2.x + r2.width < r1.x || r2.y > r1.y + r1.height || r2.y + r2.height < r1.y);
}
function resetGameState() {
notes.forEach(function (n) {
if (n && n.parent) {
n.destroy();
}
});
notes = [];
nextNoteIdx = 0;
score = 0;
combo = 0;
maxCombo = 0;
swipeStart = null;
inputLocked = false;
scoreTxt.setText('Score: 0');
comboTxt.setText('Combo: 0');
gameOverFlag = false;
playerCurrentHP = playerMaxHP;
bossCurrentHP = bossMaxHP;
hpBarsInitialized = false;
if (isShieldActive) {
isShieldActive = false;
}
if (shieldTimerDisplayContainer) {
shieldTimerDisplayContainer.visible = false;
}
if (isPrecisionBuffActive) {
isPrecisionBuffActive = false;
if (originalHitWindowPerfect > 0) {
hitWindowPerfect = originalHitWindowPerfect;
}
if (originalHitWindowGood > 0) {
hitWindowGood = originalHitWindowGood;
}
// Reset rozmiaru ramki, jeśli była powiększona
}
if (precisionBuffTimerDisplayContainer) {
precisionBuffTimerDisplayContainer.visible = false;
}
if (hpBarsInitialized && playerHpBarFill && bossHpBarFill) {
updatePlayerHpDisplay();
updateBossHpDisplay();
}
}
function loadSong(songKey) {
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
songSummaryContainer = null;
}
if (gameUIContainer) {
gameUIContainer.visible = true;
}
setupGameplayElements();
lastPlayedSongKeyForRestart = songKey;
bossWasDefeatedThisSong = false;
var songData;
if (isTutorialMode && songKey === "TutorialTrack") {
songData = tutorialSongData;
} else {
songData = allSongData[songKey];
}
if (!songData) {
console.log("Error: Song data not found for key: " + songKey);
if (allSongData["defaultTestTrack"]) {
songData = allSongData["defaultTestTrack"];
console.log("Fallback to defaultTestTrack");
} else {
currentActiveRhythmMap = [];
console.log("No fallback song data found.");
return;
}
}
currentFightingBossId = null;
if (!isTutorialMode) {
for (var i = 0; i < allBossData.length; i++) {
if (allBossData[i].songMapKey === songKey) {
currentFightingBossId = allBossData[i].id;
break;
}
}
}
if (songData.config) {
playerMaxHP = songData.config.playerMaxHP || 10;
bossMaxHP = songData.config.bossMaxHP || 50;
} else {
playerMaxHP = 10;
bossMaxHP = 50;
}
resetGameState();
createPlayerHUD();
createBossHUD();
if (gameplayBackground && gameplayBackground.parent) {
gameplayBackground.destroy();
gameplayBackground = null;
}
gameplayBackground = LK.getAsset('gameplayBg', {
x: 0,
y: 0,
width: gameScreenWidth,
height: gameScreenHeight,
alpha: 0.8
});
game.addChildAt(gameplayBackground, 0);
if (staticHitFrame) {
staticHitFrame.visible = true;
}
if (staticPerfectLine) {
staticPerfectLine.visible = true;
}
if (gameUIContainer) {
gameUIContainer.visible = true;
}
if (isTutorialMode) {
if (scoreTxt) {
scoreTxt.visible = false;
}
if (comboTxt) {
comboTxt.visible = false;
}
} else {
if (scoreTxt) {
scoreTxt.visible = true;
}
if (comboTxt) {
comboTxt.visible = true;
}
}
hpBarsInitialized = false;
nextNoteIdx = 0;
if (currentBossSprite && currentBossSprite.parent) {
currentBossSprite.destroy();
currentBossSprite = null;
} else if (isTutorialMode) {
if (currentBossSprite && currentBossSprite.parent) {
currentBossSprite.destroy();
currentBossSprite = null;
}
}
if (songData.rawRhythmMap) {
currentActiveRhythmMap = processRawRhythmMap(songData.rawRhythmMap, songKey);
} else {
currentActiveRhythmMap = [];
}
gameStartTime = Date.now();
setMusic(songData.musicAsset);
currentScreenState = 'gameplay';
if (!isTutorialMode) {
playerHUD.visible = true;
bossHUD.visible = true;
tween(playerHUD, {
alpha: 1
}, {
duration: 500
});
tween(bossHUD, {
alpha: 1
}, {
duration: 500
});
} else {
playerHUD.visible = false;
bossHUD.visible = false;
}
}
function setupPowerUpDisplay() {
var smallIconSize = 110;
if (shieldTimerDisplayContainer && shieldTimerDisplayContainer.parent) {
shieldTimerDisplayContainer.destroy();
}
shieldTimerDisplayContainer = new Container();
shieldTimerDisplayContainer.x = gameScreenWidth - 120;
shieldTimerDisplayContainer.y = 180;
if (gameUIContainer) {
gameUIContainer.addChild(shieldTimerDisplayContainer);
}
smallShieldIconDisplay = LK.getAsset('shieldAsset', {
anchorX: 0.5,
anchorY: 0.5,
width: smallIconSize,
height: smallIconSize
});
shieldTimerDisplayContainer.addChild(smallShieldIconDisplay);
shieldTimerTextDisplay = new Text2("", {
size: 50,
fill: 0xFFFFFF,
anchorX: 0.5,
anchorY: 0
});
shieldTimerTextDisplay.y = smallIconSize / 2 + 5;
shieldTimerDisplayContainer.addChild(shieldTimerTextDisplay);
shieldTimerDisplayContainer.visible = false;
if (precisionBuffTimerDisplayContainer && precisionBuffTimerDisplayContainer.parent) {
precisionBuffTimerDisplayContainer.destroy();
}
precisionBuffTimerDisplayContainer = new Container();
precisionBuffTimerDisplayContainer.x = gameScreenWidth - 120;
// Umieść poniżej timera tarczy lub w innym odpowiednim miejscu
precisionBuffTimerDisplayContainer.y = shieldTimerDisplayContainer.y + smallIconSize + 40 + 10;
if (gameUIContainer) {
gameUIContainer.addChild(precisionBuffTimerDisplayContainer);
}
smallPrecisionIconDisplay = LK.getAsset('shieldAsset', {
anchorX: 0.5,
anchorY: 0.5,
width: smallIconSize,
height: smallIconSize
});
precisionBuffTimerDisplayContainer.addChild(smallPrecisionIconDisplay);
precisionBuffTimerTextDisplay = new Text2("", {
size: 35,
fill: 0xFFFFFF,
anchorX: 0.5,
anchorY: 0
});
precisionBuffTimerTextDisplay.y = smallIconSize / 2 + 5;
precisionBuffTimerDisplayContainer.addChild(precisionBuffTimerTextDisplay);
precisionBuffTimerDisplayContainer.visible = false;
console.log("Timer UIs for Shield & Precision Buff created.");
}
function updatePowerUpDisplayCounts() {
if (hpPotionCountText) {
hpPotionCountText.setText("x" + collectedPowerUps.potion);
shieldCountText.setText("x" + collectedPowerUps.shield);
swipeToTapCountText.setText("x" + collectedPowerUps.swipeToTap);
}
}
function updatePlayerHpDisplay() {
if (playerHpBarFill) {
var healthPercent = playerCurrentHP / playerMaxHP;
playerHpBarFill.width = hpBarWidth * Math.max(0, healthPercent);
}
}
function updateBossHpDisplay() {
if (bossHpBarFill) {
var healthPercent = bossCurrentHP / bossMaxHP;
bossHpBarFill.width = hpBarWidth * Math.max(0, healthPercent);
}
}
function spawnNotes() {
if (!currentActiveRhythmMap || currentActiveRhythmMap.length === 0) {
return;
}
var now = Date.now();
if (!currentActiveRhythmMap) {
return;
}
while (nextNoteIdx < currentActiveRhythmMap.length) {
var noteData = currentActiveRhythmMap[nextNoteIdx];
var noteTargetHitTime = gameStartTime + noteData.time;
if (noteTargetHitTime - noteTravelTime <= now) {
var targetCenterX;
if (noteData.partOfWiderSwipe && noteData.widerSwipePairCenterX !== undefined) {
if (noteData.partOfWiderSwipe === 'leftHalf') {
targetCenterX = noteData.widerSwipePairCenterX - SWIPE_NOTE_WIDTH / 2;
} else if (noteData.partOfWiderSwipe === 'rightHalf') {
targetCenterX = noteData.widerSwipePairCenterX + SWIPE_NOTE_WIDTH / 2;
} else {
targetCenterX = columnCenterXs[noteData.originalColumnHint !== undefined ? noteData.originalColumnHint : Math.floor(NUM_COLUMNS / 2)];
}
} else if (noteData.columnIndex !== undefined && noteData.columnIndex >= 0 && noteData.columnIndex < NUM_COLUMNS) {
targetCenterX = columnCenterXs[noteData.columnIndex];
} else {
targetCenterX = playfieldWidth / 2;
console.warn("spawnNotes - Note spawned without proper columnIndex or widerSwipe info:", noteData);
}
var isBuffNoteFromGenerator = noteData.isBuffNote || false;
var buffTypeFromGenerator = noteData.buffType || null;
var n = new Note(noteData.type, noteData.swipeDir, noteTargetHitTime, targetCenterX, noteData.columnIndex, isBuffNoteFromGenerator, buffTypeFromGenerator, noteData.duration);
n.mapData = noteData;
if (noteData.partOfWiderSwipe) {
n.isWiderSwipePart = true;
}
notes.push(n);
game.addChild(n);
nextNoteIdx++;
} else {
break;
}
}
}
function removeOldNotes() {
var now = Date.now();
for (var i = notes.length - 1; i >= 0; i--) {
var n = notes[i];
var timeToRemoveAfterJudged = 700; // ms po targetHitTime dla ocenionych notatek
var timeToRemoveIfNotJudged = noteTravelTime / 2 + hitWindowGood + 500; // Dłuższy czas, jeśli nieoceniona, liczony od targetHitTime
if (n.judged && now > n.targetHitTime + timeToRemoveAfterJudged) {
if (n.parent) {
n.destroy();
}
notes.splice(i, 1);
} else if (!n.judged && now > n.targetHitTime + timeToRemoveIfNotJudged) {
if (n.noteType !== 'trap') {}
if (n.parent) {
n.destroy();
}
notes.splice(i, 1);
}
}
}
function findNoteAt(x, y, typeToFind) {
var now = Date.now();
var bestNote = null;
var smallestTimeDiff = hitWindowGood + 1;
for (var i = 0; i < notes.length; i++) {
var n = notes[i];
if (n.judged || n.noteType !== typeToFind && !(typeToFind === 'tap' && n.isHoldNote && !n.isBeingHeld)) {
continue;
}
var compensatedTargetTime = n.targetHitTime;
var timeDiffWithCompensation = Math.abs(now - compensatedTargetTime);
if (timeDiffWithCompensation > hitWindowGood) {
continue;
}
var originalTimeDiff = Math.abs(now - n.targetHitTime);
var targetYCenter, hitRadiusX, hitRadiusY;
var spatialBuffMultiplier = isPrecisionBuffActive ? 1.5 : 1.0;
if (n.isHoldNote) {
targetYCenter = n.y + n.yOffset - HOLD_HITBOX_HEIGHT / 2;
hitRadiusX = HOLD_HITBOX_WIDTH / 2 * spatialBuffMultiplier;
hitRadiusY = HOLD_HITBOX_HEIGHT / 2 * spatialBuffMultiplier;
} else if (n.noteAsset) {
targetYCenter = n.y;
hitRadiusX = n.noteAsset.width * n.scale.x / 2 * spatialBuffMultiplier * SPATIAL_HITBOX_MULTIPLIER;
hitRadiusY = n.noteAsset.height * n.scale.y / 2 * spatialBuffMultiplier * SPATIAL_HITBOX_MULTIPLIER;
} else {
continue;
}
var dx = x - n.x;
var dy = y - targetYCenter;
if (Math.abs(dx) <= hitRadiusX && Math.abs(dy) <= hitRadiusY) {
if (originalTimeDiff < smallestTimeDiff) {
bestNote = n;
smallestTimeDiff = originalTimeDiff;
}
}
}
return bestNote;
}
function addScore(result) {
if (isTutorialMode) {
return;
}
if (result === 'perfect') {
score += 100;
} else if (result === 'good') {
score += 50;
}
scoreTxt.setText('Score: ' + score);
}
function addCombo() {
if (isTutorialMode) {
return;
}
combo += 1;
if (combo > maxCombo) {
maxCombo = combo;
}
comboTxt.setText('Combo: ' + combo);
if (combo > 1) {
var originalScale = comboTxt.scale.x;
tween(comboTxt.scale, {
x: originalScale * 1.3,
y: originalScale * 1.3
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(comboTxt.scale, {
x: originalScale,
y: originalScale
}, {
duration: 100,
easing: tween.easeIn
});
}
});
}
}
function resetCombo() {
combo = 0;
comboTxt.setText('Combo: 0');
}
function checkGameEnd() {
if (isTutorialMode || gameOverFlag) {
return;
}
var summaryData = {
score: score,
maxCombo: maxCombo,
bossWasActuallyDefeated: bossWasDefeatedThisSong,
statusMessage: ""
};
if (playerCurrentHP <= 0) {
gameOverFlag = true;
console.log("GAME OVER - Player HP depleted");
setMusic(null);
summaryData.statusMessage = "GAME OVER";
summaryData.bossWasActuallyDefeated = false;
displayEndOfSongScreen(summaryData);
return;
}
if (bossCurrentHP <= 0 && !bossWasDefeatedThisSong) {
bossWasDefeatedThisSong = true;
console.log("Boss HP depleted during song! Player continues playing.");
if (currentFightingBossId && bossUnlockProgress.hasOwnProperty(currentFightingBossId)) {
bossUnlockProgress[currentFightingBossId] = true;
console.log("Boss " + currentFightingBossId + " marked as defeated in progress.");
storage[BOSS_UNLOCK_KEY] = bossUnlockProgress;
console.log("Boss unlock progress saved to storage.");
}
}
if (currentScreenState !== 'endlessLoopActive') {
if (currentActiveRhythmMap && nextNoteIdx >= currentActiveRhythmMap.length && notes.length === 0) {
gameOverFlag = true;
console.log("SONG ENDED");
setMusic(null);
if (bossWasDefeatedThisSong) {
summaryData.statusMessage = "VICTORY!";
} else {
summaryData.statusMessage = "SONG COMPLETED";
}
summaryData.bossWasActuallyDefeated = bossWasDefeatedThisSong;
displayEndOfSongScreen(summaryData);
return;
}
}
}
function getSongStats(songMapKey) {
console.log("getSongStats called for songMapKey:", songMapKey);
if (!songMapKey) {
console.warn("getSongStats: No songMapKey provided, returning default stats.");
return {
bestScore: 0,
bestCombo: 0
};
}
var individualSongStorageKey = 'wf_stats_' + songMapKey;
console.log("getSongStats: Attempting to read from storage key:", individualSongStorageKey);
var songStats = storage[individualSongStorageKey];
// ZMIENIONA LINIA DEBUGOWANIA:
console.log("getSongStats: Raw data from storage for " + individualSongStorageKey + ":", songStats);
// Po prostu logujemy surowy obiekt songStats, bez JSON.parse(JSON.stringify(...))
if (songStats) {
var statsToReturn = {
bestScore: parseInt(songStats.bestScore, 10) || 0,
bestCombo: parseInt(songStats.bestCombo, 10) || 0
};
console.log("getSongStats: Parsed and returning stats:", statsToReturn);
return statsToReturn;
}
console.log("getSongStats: No stats found in storage for " + individualSongStorageKey + ", returning default stats.");
return {
bestScore: 0,
bestCombo: 0
};
}
function saveSongStats(songMapKey, currentScore, currentCombo) {
if (!songMapKey) {
return;
}
var individualSongStorageKey = 'wf_stats_' + songMapKey; // Unikalny klucz dla piosenki
// Odczytaj istniejące statystyki dla tej konkretnej piosenki lub utwórz nowy obiekt
var storedData = storage[individualSongStorageKey];
var songStats;
if (storedData) {
songStats = {
bestScore: storedData.bestScore,
bestCombo: storedData.bestCombo
};
} else {
songStats = {
bestScore: 0,
bestCombo: 0
};
}
var updated = false;
var numericCurrentScore = parseInt(currentScore, 10) || 0;
var numericCurrentCombo = parseInt(currentCombo, 10) || 0;
if (numericCurrentScore > (parseInt(songStats.bestScore, 10) || 0)) {
songStats.bestScore = numericCurrentScore;
updated = true;
console.log("New best score for " + songMapKey + " (" + individualSongStorageKey + "): " + numericCurrentScore);
}
if (numericCurrentCombo > (parseInt(songStats.bestCombo, 10) || 0)) {
songStats.bestCombo = numericCurrentCombo;
updated = true;
console.log("New best combo for " + songMapKey + " (" + individualSongStorageKey + "): " + numericCurrentCombo);
}
if (updated) {
storage[individualSongStorageKey] = songStats; // Zapisz obiekt statystyk dla tej piosenki
console.log("Song stats saved to storage for key: " + individualSongStorageKey);
}
}
function startEndlessMode() {
// Ta funkcja teraz tylko uruchamia dedykowane intro dla nowego trybu.
showEndlessIntro();
}
function displayEndOfSongScreen(summaryData) {
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
}
songSummaryContainer = new Container();
songSummaryContainer.x = 0;
songSummaryContainer.y = 0;
game.addChild(songSummaryContainer);
currentScreenState = 'songSummary';
if (lastPlayedSongKeyForRestart) {
saveSongStats(lastPlayedSongKeyForRestart, summaryData.score, summaryData.maxCombo);
}
var bestStats = getSongStats(lastPlayedSongKeyForRestart || summaryData.songMapKey);
var overlay = LK.getAsset('summaryOverlayAsset', {
width: gameScreenWidth,
height: gameScreenHeight,
alpha: 0.7,
interactive: true
});
songSummaryContainer.addChild(overlay);
var popupWidth = gameScreenWidth * 0.6;
var popupHeight = 1720;
var popupX = (gameScreenWidth - popupWidth) / 2;
var popupY = (gameScreenHeight - popupHeight) / 2;
var popupBackground = LK.getAsset('summaryPopupBackgroundAsset', {
x: popupX,
y: popupY,
width: popupWidth,
height: popupHeight
});
songSummaryContainer.addChild(popupBackground);
// --- Sekcja Layoutu ---
// DŹWIGNIE DO STEROWANIA ODSTĘPAMI (możesz je zmieniać)
var v_gap_title = 80;
var v_gap_stats = 55;
var v_gap_bests = 55;
var v_gap_buttons = 90;
// 1. Stwórz wszystkie elementy, ale jeszcze ich nie pozycjonuj
var titleText = new Text2(summaryData.statusMessage || "SONG ENDED", {
size: 70,
fill: 0xFFFFFF,
align: 'center'
});
var bossDefeatedContainer = new Container();
var bossDefeatedStatusText = new Text2("Boss Defeated: ", {
size: 60,
fill: 0xFFFFFF
});
var bossDefeatedValueText = new Text2(summaryData.bossWasActuallyDefeated ? "YES" : "NO", {
size: 60,
fill: summaryData.bossWasActuallyDefeated ? 0x00FF00 : 0xFF0000
});
bossDefeatedValueText.x = bossDefeatedStatusText.width + 10;
bossDefeatedContainer.addChild(bossDefeatedStatusText);
bossDefeatedContainer.addChild(bossDefeatedValueText);
var scoreTextSummary = new Text2("Score: " + summaryData.score, {
size: 50,
fill: 0xFFFFFF,
align: 'center'
});
var comboTextSummary = new Text2("Max Combo: " + summaryData.maxCombo, {
size: 50,
fill: 0xFFFFFF,
align: 'center'
});
var bestScoreText = new Text2("Best Score: " + bestStats.bestScore, {
size: 50,
fill: 0xFFFF00,
align: 'center'
});
var bestComboText = new Text2("Best Combo: " + bestStats.bestCombo, {
size: 50,
fill: 0xFFFF00,
align: 'center'
});
var allElements = [titleText, bossDefeatedContainer, scoreTextSummary, comboTextSummary, bestScoreText, bestComboText];
var gaps = [v_gap_title, v_gap_stats, v_gap_stats, v_gap_bests, v_gap_bests, v_gap_buttons];
// 2. Oblicz całkowitą wysokość bloku zawartości
var totalContentHeight = 0;
for (var i = 0; i < allElements.length; i++) {
totalContentHeight += allElements[i].height;
if (gaps[i]) {
totalContentHeight += gaps[i];
}
}
var buttonHeight = 70; // Wysokość przycisków
totalContentHeight += buttonHeight;
// 3. Oblicz pozycję startową Y, aby wyśrodkować cały blok
var currentY = popupY + (popupHeight - totalContentHeight) / 2;
// 4. Rozmieść wszystkie elementy jeden pod drugim
allElements.forEach(function (element, index) {
element.y = currentY + element.height / 2;
element.x = popupX + popupWidth / 2;
if (element.anchor) {
element.anchor.set(0.5, 0.5);
} else {
// dla kontenera
element.pivot.x = element.width / 2;
element.pivot.y = element.height / 2;
}
songSummaryContainer.addChild(element);
currentY += element.height + gaps[index];
});
// 5. Umieść przyciski na samym dole bloku
var buttonWidth = popupWidth * 0.4;
var buttonY = currentY + buttonHeight / 2;
var backButtonBg = LK.getAsset('summaryButtonBackgroundAsset', {
x: popupX + (popupWidth / 2 - buttonWidth - 15),
y: buttonY,
width: buttonWidth,
height: buttonHeight,
interactive: true,
cursor: "pointer"
});
songSummaryContainer.addChild(backButtonBg);
var backToMenuButton = new Text2("Back to Menu", {
size: 40,
fill: 0xFFD700,
stroke: 0x000000,
strokeThickness: 2
});
backToMenuButton.anchor.set(0.5, 0.5);
backToMenuButton.x = backButtonBg.x + buttonWidth / 2;
backToMenuButton.y = backButtonBg.y + buttonHeight / 2;
songSummaryContainer.addChild(backToMenuButton);
backButtonBg.down = function () {
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
songSummaryContainer = null;
}
if (gameplayBackground && gameplayBackground.parent) {
gameplayBackground.destroy();
gameplayBackground = null;
}
showBossSelectionScreen();
};
var restartButtonBg = LK.getAsset('summaryButtonBackgroundAsset', {
x: popupX + (popupWidth / 2 + 15),
y: buttonY,
width: buttonWidth,
height: buttonHeight,
interactive: true,
cursor: "pointer"
});
songSummaryContainer.addChild(restartButtonBg);
var restartButton = new Text2("Restart Battle", {
size: 40,
fill: 0xFFD700,
stroke: 0x000000,
strokeThickness: 2
});
restartButton.anchor.set(0.5, 0.5);
restartButton.x = restartButtonBg.x + buttonWidth / 2;
restartButton.y = restartButtonBg.y + buttonHeight / 2;
songSummaryContainer.addChild(restartButton);
restartButtonBg.down = function () {
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
songSummaryContainer = null;
}
if (lastPlayedSongKeyForRestart) {
loadSong(lastPlayedSongKeyForRestart);
} else {
showMainMenu();
}
};
if (gameUIContainer) {
gameUIContainer.visible = false;
}
if (staticHitFrame) {
staticHitFrame.visible = false;
}
if (staticPerfectLine) {
staticPerfectLine.visible = false;
}
}
game.onNoteMiss = function (note) {
if (!note) {
return;
}
note.showHitFeedback('miss');
if (!isTutorialMode) {
if (isShieldActive) {
console.log("Gracz ominął nutę, ale tarcza jest aktywna! Brak utraty HP i combo NIE zresetowane.");
} else {
resetCombo();
if (!gameOverFlag) {
playerCurrentHP = Math.max(0, playerCurrentHP - 1);
updatePlayerHpDisplay();
console.log("Player HP after miss: " + playerCurrentHP);
}
}
}
if (note.parent) {
LK.effects.flashObject(note, 0xff0000, 300);
}
};
game.down = function (x, y, obj) {
if (currentScreenState === 'gameplay' || currentScreenState === 'endlessLoopActive') {
if (inputLocked) {
return;
}
swipeStart = {
x: x,
y: y,
time: Date.now()
};
var now = Date.now();
for (var i_gp_pu = activePowerUpItems.length - 1; i_gp_pu >= 0; i_gp_pu--) {
var pItem_gp = activePowerUpItems[i_gp_pu];
if (pItem_gp && !pItem_gp.collected && pItem_gp.visualAsset && pItem_gp.parent) {
var pWidth_gp = pItem_gp.visualAsset.width * pItem_gp.scale.x;
var pHeight_gp = pItem_gp.visualAsset.height * pItem_gp.scale.y;
if (x >= pItem_gp.x - pWidth_gp / 2 && x <= pItem_gp.x + pWidth_gp / 2 && y >= pItem_gp.y - pHeight_gp / 2 && y <= pItem_gp.y + pHeight_gp / 2) {
if (Math.abs(pItem_gp.y - hitZoneY) < pHeight_gp * 1.5) {
pItem_gp.collect();
return;
}
}
}
}
var noteUnderCursorTrap = findNoteAt(x, y, 'trap');
if (noteUnderCursorTrap && !noteUnderCursorTrap.judged && noteUnderCursorTrap.isInHitWindow()) {
noteUnderCursorTrap.judged = true;
noteUnderCursorTrap.showHitFeedback('miss');
if (!isTutorialMode) {
if (isShieldActive) {
console.log("Gracz trafił w TRAP NOTE, ale tarcza jest aktywna! Brak utraty HP i combo NIE zresetowane.");
} else {
resetCombo();
LK.effects.flashScreen(0xff0000, 400);
if (!gameOverFlag) {
playerCurrentHP = Math.max(0, playerCurrentHP - 1);
updatePlayerHpDisplay();
}
}
}
if (noteUnderCursorTrap.alpha > 0) {
noteUnderCursorTrap.alpha = 0;
}
inputLocked = true;
LK.setTimeout(function () {
inputLocked = false;
}, 200);
return;
}
var noteUnderCursor = findNoteAt(x, y, 'tap');
if (noteUnderCursor && !noteUnderCursor.judged && !noteUnderCursor.isBeingHeld && noteUnderCursor.isInHitWindow()) {
var result = noteUnderCursor.getHitAccuracy();
noteUnderCursor.hit = true;
if (noteUnderCursor.isHoldNote) {
if (result !== 'miss') {
console.log("HOLD PRESSED: noteType=" + noteUnderCursor.noteType + ", y=" + noteUnderCursor.y.toFixed(2) + ", noteAsset.y=" + (noteUnderCursor.noteAsset ? noteUnderCursor.noteAsset.y.toFixed(2) : "N/A") + ", centerY=" + noteUnderCursor.centerY + ", now=" + now + ", targetHitTime=" + noteUnderCursor.targetHitTime + ", diffToTarget=" + (noteUnderCursor.targetHitTime - now) + ", result=" + result);
noteUnderCursor.isBeingHeld = true;
noteUnderCursor.holdPressTime = now;
noteUnderCursor.showHitFeedback(result);
if (noteUnderCursor.noteColumnIndex !== undefined) {
var overlay = columnFlashOverlays[noteUnderCursor.noteColumnIndex];
if (overlay) {
overlay.alpha = 0.5;
}
}
if (!isTutorialMode) {
addScore(result);
addCombo();
if (!gameOverFlag) {
if (result === 'perfect') {
bossCurrentHP = Math.max(0, bossCurrentHP - 2);
} else if (result === 'good') {
bossCurrentHP = Math.max(0, bossCurrentHP - 1);
}
updateBossHpDisplay();
}
}
if (noteUnderCursor.mapData && noteUnderCursor.mapData.columnIndex !== undefined) {
currentlyHeldNotes[noteUnderCursor.mapData.columnIndex] = noteUnderCursor;
} else if (noteUnderCursor.originalColumnHint !== undefined) {
currentlyHeldNotes[noteUnderCursor.originalColumnHint] = noteUnderCursor;
}
} else {
noteUnderCursor.judged = true;
noteUnderCursor.showHitFeedback('miss');
if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
if (noteUnderCursor.alpha > 0) {
noteUnderCursor.alpha = 0;
}
}
} else {
noteUnderCursor.judged = true;
noteUnderCursor.showHitFeedback(result);
if (noteUnderCursor.noteColumnIndex !== undefined) {
flashColumn(noteUnderCursor.noteColumnIndex);
}
if (noteUnderCursor.isBuffNote) {
if (result !== 'miss' && !isTutorialMode) {
var buffType = noteUnderCursor.buffType;
if (buffType === 'potion') {
playerCurrentHP = Math.min(playerMaxHP, playerCurrentHP + POTION_HEAL_AMOUNT);
updatePlayerHpDisplay();
} else if (buffType === 'shield') {
if (!isShieldActive) {
isShieldActive = true;
shieldEndTime = Date.now() + SHIELD_DURATION;
if (shieldTimerDisplayContainer) {
shieldTimerDisplayContainer.visible = true;
}
}
} else if (buffType === 'precision') {
if (!isPrecisionBuffActive) {
isPrecisionBuffActive = true;
precisionBuffEndTime = Date.now() + PRECISION_BUFF_DURATION;
originalHitWindowPerfect = hitWindowPerfect;
originalHitWindowGood = hitWindowGood;
hitWindowPerfect = Math.round(hitWindowPerfect * precisionBuffHitWindowMultiplier);
hitWindowGood = Math.round(hitWindowGood * precisionBuffHitWindowMultiplier);
if (precisionBuffTimerDisplayContainer) {
precisionBuffTimerDisplayContainer.visible = true;
}
if (staticHitFrame) {
tween(staticHitFrame, {
height: STATIC_HIT_FRAME_HEIGHT * 2
}, {
duration: 250,
easing: tween.easeOutQuad
});
}
}
}
} else if (result === 'miss' && !isTutorialMode && !isShieldActive) {
resetCombo();
}
} else {
if (result !== 'miss') {
addScore(result);
addCombo();
if (!isTutorialMode && !gameOverFlag) {
if (result === 'perfect') {
bossCurrentHP = Math.max(0, bossCurrentHP - 2);
} else if (result === 'good') {
bossCurrentHP = Math.max(0, bossCurrentHP - 1);
}
updateBossHpDisplay();
}
} else if (!isTutorialMode) {
if (!isShieldActive) {
resetCombo();
} else {
console.log("Tapnięcie nuty ocenione jako 'miss', ale tarcza jest aktywna! Combo NIE zresetowane.");
}
}
}
}
inputLocked = true;
LK.setTimeout(function () {
inputLocked = false;
}, 120);
return;
}
}
};
game.move = function (x, y, obj) {};
game.up = function (x, y, obj) {
if (currentScreenState === 'gameplay' || currentScreenState === 'endlessLoopActive') {
var holdReleasedThisUp = false;
for (var colIdx in currentlyHeldNotes) {
if (currentlyHeldNotes.hasOwnProperty(colIdx)) {
var heldNote = currentlyHeldNotes[colIdx];
if (heldNote && heldNote.isBeingHeld) {
console.log("Releasing hold note in column: " + (heldNote.noteColumnIndex !== undefined ? heldNote.noteColumnIndex : heldNote.mapData ? heldNote.mapData.columnIndex : 'unknown'));
heldNote.judgeHoldRelease();
delete currentlyHeldNotes[colIdx];
holdReleasedThisUp = true;
}
}
}
if (holdReleasedThisUp) {
swipeStart = null;
inputLocked = true;
LK.setTimeout(function () {
inputLocked = false;
}, 80);
return;
}
if (inputLocked || !swipeStart) {
swipeStart = null;
return;
}
var swipeEndX = x;
var swipeEndY = y;
var swipeEndTime = Date.now();
var dx = swipeEndX - swipeStart.x;
var dy = swipeEndY - swipeStart.y;
var dist = Math.sqrt(dx * dx + dy * dy);
var potentialSwipe = dist >= MIN_SWIPE_DISTANCE;
if (potentialSwipe) {
var detectedDir = null;
if (Math.abs(dx) > Math.abs(dy)) {
detectedDir = dx > 0 ? 'right' : 'left';
} else {
detectedDir = dy > 0 ? 'down' : 'up';
}
var swipeBoundingBox = {
x: Math.min(swipeStart.x, swipeEndX),
y: Math.min(swipeStart.y, swipeEndY),
width: Math.abs(dx),
height: Math.abs(dy)
};
var notesHitThisSwipe = [];
for (var i_swipe = 0; i_swipe < notes.length; i_swipe++) {
var n_swipe = notes[i_swipe];
if (n_swipe.judged || n_swipe.noteType !== 'swipe' || n_swipe.alpha === 0) {
continue;
}
var overallSwipeTimeMatchesNote = false;
if (n_swipe.targetHitTime >= swipeStart.time - hitWindowGood && n_swipe.targetHitTime <= swipeEndTime + hitWindowGood) {
overallSwipeTimeMatchesNote = true;
}
if (!overallSwipeTimeMatchesNote) {
if (swipeStart.time >= n_swipe.targetHitTime - hitWindowGood && swipeStart.time <= n_swipe.targetHitTime + hitWindowGood || swipeEndTime >= n_swipe.targetHitTime - hitWindowGood && swipeEndTime <= n_swipe.targetHitTime + hitWindowGood) {
overallSwipeTimeMatchesNote = true;
}
}
if (!overallSwipeTimeMatchesNote) {
continue;
}
var noteCurrentWidth_swipe = n_swipe.noteAsset ? n_swipe.noteAsset.width : SWIPE_NOTE_WIDTH;
var noteCurrentHeight_swipe = n_swipe.noteAsset ? n_swipe.noteAsset.height : SWIPE_NOTE_WIDTH;
var noteBoundingBox_swipe = {
x: n_swipe.x - noteCurrentWidth_swipe / 2,
y: n_swipe.y - noteCurrentHeight_swipe / 2,
width: noteCurrentWidth_swipe,
height: noteCurrentHeight_swipe
};
if (rectsIntersect(swipeBoundingBox, noteBoundingBox_swipe)) {
if (detectedDir === n_swipe.swipeDir) {
var verticalProximity = Math.abs(n_swipe.y - n_swipe.centerY);
var verticalTolerance = noteCurrentHeight_swipe / 1.5;
if (verticalProximity < verticalTolerance) {
notesHitThisSwipe.push(n_swipe);
}
}
}
}
if (notesHitThisSwipe.length > 0) {
notesHitThisSwipe.sort(function (a, b) {
var da = Math.abs(swipeEndTime - a.targetHitTime);
var db = Math.abs(swipeEndTime - b.targetHitTime);
return da - db;
});
var maxNotesToHitPerSwipe = 1;
var notesActuallyHitCount = 0;
for (var k_swipe = 0; k_swipe < notesHitThisSwipe.length && notesActuallyHitCount < maxNotesToHitPerSwipe; k_swipe++) {
var noteToJudge_swipe = notesHitThisSwipe[k_swipe];
if (noteToJudge_swipe.judged) {
continue;
}
var result_swipe = noteToJudge_swipe.getHitAccuracy();
noteToJudge_swipe.judged = true;
noteToJudge_swipe.showHitFeedback(result_swipe);
if (noteToJudge_swipe.noteColumnIndex !== undefined) {
flashColumn(noteToJudge_swipe.noteColumnIndex);
}
if (result_swipe !== 'miss') {
addScore(result_swipe);
addCombo();
if (!isTutorialMode && !gameOverFlag) {
if (result_swipe === 'perfect') {
bossCurrentHP = Math.max(0, bossCurrentHP - 2);
} else if (result_swipe === 'good') {
bossCurrentHP = Math.max(0, bossCurrentHP - 1);
}
updateBossHpDisplay();
}
} else if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
notesActuallyHitCount++;
}
}
}
inputLocked = true;
LK.setTimeout(function () {
inputLocked = false;
}, 80);
swipeStart = null;
}
};
game.update = function () {
if (typeof notes === 'undefined' || !Array.isArray(notes)) {
notes = [];
}
var now = Date.now();
if (currentScreenState === 'miniGameActive' && !isMiniGameOver) {
miniGameTimeActive += 16;
if (miniGameTimeActive >= MINI_GAME_SPEED_INCREASE_INTERVAL) {
currentMiniGameObjectSpeed += MINI_GAME_SPEED_INCREMENT;
miniGameTimeActive = 0;
}
if (miniGamePlayer && miniGamePlayer.asset && typeof miniGamePlayer.asset.update === 'function') {
miniGamePlayer.asset.update();
}
for (var i = 0; i < miniGameObstacles.length; i++) {
var obs = miniGameObstacles[i];
if (obs && obs.asset && typeof obs.asset.update === 'function') {
obs.asset.update();
}
}
spawnMiniGameObstacle();
moveMiniGameObstacles();
checkMiniGameCollisions();
updateMiniGameScoreDisplay();
} else if (currentScreenState === 'miniGameActive' && isMiniGameOver) {
if (miniGameScreenElements.find(function (el) {
return el.isGameOverText;
}) === undefined) {
var gameOverText = new Text2("GAME OVER", {
size: 100,
fill: 0xFF0000,
align: 'center'
});
gameOverText.anchor.set(0.5, 0.5);
gameOverText.x = miniGameViewport.x + miniGameViewport.width / 2;
gameOverText.y = miniGameViewport.y + miniGameViewport.height / 2;
gameOverText.isGameOverText = true;
game.addChild(gameOverText);
miniGameScreenElements.push(gameOverText);
}
} else if (currentScreenState === 'gameplay') {
if (!isTutorialMode) {
if (isShieldActive) {
if (playerShieldAnimation) {
playerShieldAnimation.visible = true;
playerShieldAnimation.update();
}
if (now > shieldEndTime) {
isShieldActive = false;
if (shieldTimerDisplayContainer) {
shieldTimerDisplayContainer.visible = false;
}
if (playerShieldAnimation) {
playerShieldAnimation.visible = false;
}
console.log("Tarcza WYGASŁA.");
} else {
if (shieldTimerDisplayContainer && shieldTimerDisplayContainer.visible) {
var remainingSecondsShield = (shieldEndTime - now) / 1000;
if (shieldTimerTextDisplay) {
shieldTimerTextDisplay.setText(remainingSecondsShield.toFixed(1) + "s");
}
}
}
} else {
if (shieldTimerDisplayContainer && shieldTimerDisplayContainer.visible) {
shieldTimerDisplayContainer.visible = false;
}
if (playerShieldAnimation && playerShieldAnimation.visible) {
playerShieldAnimation.visible = false;
}
}
if (isPrecisionBuffActive) {
if (now > precisionBuffEndTime) {
isPrecisionBuffActive = false;
hitWindowPerfect = originalHitWindowPerfect;
hitWindowGood = originalHitWindowGood;
if (precisionBuffTimerDisplayContainer) {
precisionBuffTimerDisplayContainer.visible = false;
}
if (staticHitFrame) {
tween(staticHitFrame, {
height: STATIC_HIT_FRAME_HEIGHT
}, {
duration: 250,
easing: tween.easeInQuad
});
}
} else {
if (precisionBuffTimerDisplayContainer && precisionBuffTimerDisplayContainer.visible) {
var remainingSecondsBuff = (precisionBuffEndTime - now) / 1000;
if (precisionBuffTimerTextDisplay) {
precisionBuffTimerTextDisplay.setText(remainingSecondsBuff.toFixed(1) + "s");
}
}
}
} else {
if (precisionBuffTimerDisplayContainer && precisionBuffTimerDisplayContainer.visible) {
precisionBuffTimerDisplayContainer.visible = false;
}
}
}
spawnNotes();
for (var i_update_notes = 0; i_update_notes < notes.length; i_update_notes++) {
if (notes[i_update_notes] && notes[i_update_notes].update) {
notes[i_update_notes].update();
}
}
removeOldNotes();
if (isTutorialMode) {
var songHasEnded = activeMusicTrack && !activeMusicTrack.playing && now - gameStartTime > (activeMusicTrack.duration || 0) * 1000;
var noNotesLeftOnScreen = notes.length === 0;
var allNotesProcessed = nextNoteIdx >= (currentActiveRhythmMap ? currentActiveRhythmMap.length : 0);
if (songHasEnded && noNotesLeftOnScreen && allNotesProcessed && activeMusicTrack && now - gameStartTime > (activeMusicTrack.duration || 0) * 1000 + 500) {
exitTutorialGameplay();
return;
}
} else {
checkGameEnd();
}
} else if (currentScreenState === 'endlessLoopActive') {
if (currentEndlessDifficulty < MAX_ENDLESS_DIFFICULTY) {
currentEndlessDifficulty += ENDLESS_DIFFICULTY_INCREASE_RATE * (16 / 1000);
}
if (activeMusicTrack && !activeMusicTrack.playing && notes.length === 0) {
console.log("Utwór w pętli zakończony, przełączam na następny...");
playNextEndlessSong();
}
spawnNotes();
for (var i_update_notes_endless = 0; i_update_notes_endless < notes.length; i_update_notes_endless++) {
if (notes[i_update_notes_endless] && notes[i_update_notes_endless].update) {
notes[i_update_notes_endless].update();
}
}
removeOldNotes();
checkGameEnd();
} else {
if (notes.length > 0) {
for (var i_notes_clear = notes.length - 1; i_notes_clear >= 0; i_notes_clear--) {
var n_clear = notes[i_notes_clear];
if (n_clear && n_clear.parent) {
n_clear.destroy();
}
}
notes = [];
}
if (staticHitFrame && staticHitFrame.visible) {
staticHitFrame.visible = false;
}
if (staticPerfectLine && staticPerfectLine.visible) {
staticPerfectLine.visible = false;
}
}
};
// Load the specific song for testing
showStartScreen(); /****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Note = Container.expand(function (noteType, swipeDir, targetHitTimeFull, centerXVal, noteColumnIndex, isIncomingBuffNote, incomingBuffType, holdDurationMs) {
var self = Container.call(this);
self.noteColumnIndex = noteColumnIndex;
self.noteType = noteType || 'tap';
self.swipeDir = swipeDir || null;
self.targetHitTime = targetHitTimeFull;
self.visualSpawnTime = self.targetHitTime - noteTravelTime;
self.hit = false;
self.judged = false;
self.scaleStart = 1.0;
self.scaleEnd = 1.0;
self.centerX = centerXVal;
self.centerY = 1800;
self.startY = -150;
self.noteAsset = null;
self.brightnessOverlay = null;
self.isWiderSwipePart = false;
self.isBuffNote = isIncomingBuffNote || false;
self.buffType = incomingBuffType || null;
self.isHoldNote = self.noteType === 'hold';
self.holdDuration = self.isHoldNote ? holdDurationMs || 1000 : 0;
self.holdPressTime = 0;
self.isBeingHeld = false;
self.holdFullyCompleted = false;
self.holdBroken = false;
self.initialHoldHeight = 0;
self.feedbackShownForBroken = false;
self.holdButton = null;
self.yOffset = 0;
if (self.isBuffNote) {
var buffAssetKey = '';
if (self.buffType === 'potion') {
buffAssetKey = 'hpPotionAsset';
} else if (self.buffType === 'shield') {
buffAssetKey = 'shieldAsset';
} else if (self.buffType === 'precision') {
buffAssetKey = 'precisionAsset';
}
if (buffAssetKey) {
self.noteAsset = self.attachAsset(buffAssetKey, {
anchorX: 0.5,
anchorY: 0.5,
width: 400,
height: 400
});
}
if (self.isBuffNote) {
self.noteType = 'tap';
self.isHoldNote = false;
}
} else if (self.isHoldNote) {
var pixelsPerMs = (self.centerY - self.startY) / noteTravelTime;
var calculatedTotalHeight = Math.max(50, self.holdDuration * pixelsPerMs);
self.initialHoldHeight = calculatedTotalHeight;
var holdAssetKey = 'hold';
var calculatedYOffset;
if (noteColumnIndex === 1) {
holdAssetKey = 'hold1';
calculatedYOffset = 135;
} else if (noteColumnIndex === 2) {
holdAssetKey = 'hold2';
calculatedYOffset = 225;
} else {
holdAssetKey = 'hold';
calculatedYOffset = 185;
}
self.yOffset = calculatedYOffset;
self.noteAsset = self.attachAsset(holdAssetKey, {
anchorX: 0.5,
anchorY: 1,
y: self.yOffset,
height: self.initialHoldHeight
});
var holdButtonAssetKey;
if (noteColumnIndex === 0) {
holdButtonAssetKey = 'holdButtonAsset_col0';
} else if (noteColumnIndex === 1) {
holdButtonAssetKey = 'holdButtonAsset_col1';
} else {
holdButtonAssetKey = 'holdButtonAsset_col2';
}
self.holdButton = self.attachAsset(holdButtonAssetKey, {
anchorX: 0.5,
anchorY: 1,
y: self.yOffset,
interactive: true,
cursor: "pointer"
});
self.brightnessOverlay = self.attachAsset('brightnessOverlayAsset', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: self.yOffset,
width: 200,
height: 200,
alpha: 0,
visible: true
});
} else {
if (self.noteType === 'tap') {
var tapAssetKey = 'tap0';
if (noteColumnIndex !== undefined) {
if (noteColumnIndex === 0) {
tapAssetKey = 'tap0';
} else if (noteColumnIndex === 1) {
tapAssetKey = 'tap1';
} else if (noteColumnIndex === 2) {
tapAssetKey = 'tap2';
}
}
self.noteAsset = self.attachAsset(tapAssetKey, {
anchorX: 0.5,
anchorY: 0.5
});
self.noteAsset.scaleX = 1.3;
self.noteAsset.scaleY = 1.3;
} else if (self.noteType === 'swipe') {
var swipeAssetKey = 'swipe_col0';
if (noteColumnIndex !== undefined) {
if (noteColumnIndex === 0) {
swipeAssetKey = 'swipe_col0';
} else if (noteColumnIndex === 1) {
swipeAssetKey = 'swipe_col1';
} else if (noteColumnIndex === 2) {
swipeAssetKey = 'swipe_col2';
}
}
self.noteAsset = self.attachAsset(swipeAssetKey, {
anchorX: 0.5,
anchorY: 0.5
});
if (self.swipeDir && self.noteAsset) {
var rotationAngle = 0;
if (self.swipeDir === 'left') {
rotationAngle = Math.PI;
} else if (self.swipeDir === 'right') {
rotationAngle = 0;
} else if (self.swipeDir === 'up') {
rotationAngle = -Math.PI / 2;
} else if (self.swipeDir === 'down') {
rotationAngle = Math.PI / 2;
}
self.noteAsset.rotation = rotationAngle;
}
} else if (self.noteType === 'trap') {
self.noteAsset = self.attachAsset('trapNote', {
anchorX: 0.5,
anchorY: 0.5
});
}
}
self.alpha = 0;
if (typeof DEBUG_SHOW_HITBOXES !== 'undefined' && DEBUG_SHOW_HITBOXES) {
self.debugHitboxVisual = self.attachAsset('debugHitboxAsset', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.35,
visible: false
});
}
self.showHitFeedback = function (result, feedbackTextOverride) {
var feedbackCircle = LK.getAsset('hitFeedback', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: self.yOffset,
scaleX: 0.7,
scaleY: 0.7,
alpha: 0.7
});
if (self.isHoldNote) {
feedbackCircle.x = 0;
} else if (self.noteAsset && self.noteAsset.anchorY === 0) {
feedbackCircle.y = self.noteAsset.height / 2;
} else if (self.noteAsset && self.noteAsset.anchorY === 0.5) {
feedbackCircle.x = 0;
feedbackCircle.y = 0;
}
var feedbackTextContent = feedbackTextOverride || "";
var feedbackTextColor = 0xFFFFFF;
if (!feedbackTextOverride) {
if (self.isBuffNote && result !== 'miss') {
feedbackCircle.tint = 0x40E0D0;
feedbackTextContent = self.buffType.charAt(0).toUpperCase() + self.buffType.slice(1) + "!";
feedbackTextColor = 0x40E0D0;
} else if (result === 'perfect') {
feedbackCircle.tint = 0xffff00;
feedbackTextContent = "Perfect!";
feedbackTextColor = 0xffff00;
} else if (result === 'good') {
feedbackCircle.tint = 0x00ff00;
feedbackTextContent = "Good!";
feedbackTextColor = 0x00ff00;
} else if (result === 'hold_ok') {
feedbackCircle.tint = 0x00FF7F;
feedbackTextContent = "Held!";
feedbackTextColor = 0x00FF7F;
} else {
feedbackCircle.tint = 0xff0000;
feedbackTextContent = result === 'hold_broken' ? "Broken!" : "Miss";
feedbackTextColor = 0xff0000;
}
}
self.addChild(feedbackCircle);
tween(feedbackCircle, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 350,
easing: tween.easeOut,
onFinish: function onFinish() {
if (feedbackCircle.parent) {
feedbackCircle.destroy();
}
}
});
if (feedbackTextContent) {
var scorePopup = new Text2(feedbackTextContent, {
size: 60,
fill: feedbackTextColor,
stroke: 0x000000,
strokeThickness: 3
});
scorePopup.anchor.set(0.5, 0.5);
var initialYPopup;
var noteVisualHeightForFeedback = self.noteAsset ? self.noteAsset.height : SWIPE_NOTE_WIDTH;
if (self.isHoldNote && self.noteAsset) {
initialYPopup = self.y - self.noteAsset.width * 0.25 - 30;
} else if (self.noteAsset && self.noteAsset.anchorY === 0.5) {
initialYPopup = self.y - noteVisualHeightForFeedback / 2 - 30;
} else {
initialYPopup = self.y - 30;
}
scorePopup.x = self.x;
scorePopup.y = initialYPopup;
if (self.parent) {
self.parent.addChild(scorePopup);
tween(scorePopup, {
y: initialYPopup - 80,
alpha: 0
}, {
duration: 700,
easing: tween.easeOut,
onFinish: function onFinish() {
if (scorePopup.parent) {
scorePopup.destroy();
}
}
});
}
}
if (self.parent && (result === 'good' || result === 'perfect' || result === 'hold_ok')) {
var particleSpawnX = self.x;
var particleSpawnY;
if (self.isHoldNote && self.noteAsset) {
particleSpawnY = self.y - self.noteAsset.width * 0.25;
} else if (self.noteAsset && self.noteAsset.anchorY === 0.5) {
particleSpawnY = self.y;
} else if (self.noteAsset) {
particleSpawnY = self.y + self.noteAsset.height / 2;
} else {
particleSpawnY = self.y;
}
spawnParticleEffect(particleSpawnX, particleSpawnY, result, self.parent);
}
};
self.update = function () {
var now = Date.now();
if (self.judged) {
if (self.alpha > 0) {
self.alpha = 0;
}
if (self.brightnessOverlay) {
self.brightnessOverlay.alpha = 0;
}
if (typeof DEBUG_SHOW_HITBOXES !== 'undefined' && DEBUG_SHOW_HITBOXES && self.debugHitboxVisual) {
self.debugHitboxVisual.visible = false;
}
return;
}
if (self.alpha === 0 && now >= self.visualSpawnTime) {
self.alpha = 1;
}
if (self.alpha === 0) {
return;
}
if (self.isHoldNote && self.isBeingHeld) {
if (self.holdBroken) {
self.isBeingHeld = false;
self.judged = true;
if (self.brightnessOverlay) {
self.brightnessOverlay.alpha = 0;
}
if (!self.feedbackShownForBroken) {
self.showHitFeedback('hold_broken');
self.feedbackShownForBroken = true;
}
return;
}
if (self.noteAsset) {
if (now >= self.targetHitTime) {
var timeHeldPastHitLine = now - self.targetHitTime;
var pixelsPerMs = (self.centerY - self.startY) / noteTravelTime;
var pixelsConsumed = Math.min(timeHeldPastHitLine * pixelsPerMs, self.initialHoldHeight);
self.noteAsset.height = Math.max(0, self.initialHoldHeight - pixelsConsumed);
} else {
self.noteAsset.height = self.initialHoldHeight;
}
}
if (self.brightnessOverlay && !self.holdBroken) {}
if (now >= self.targetHitTime + self.holdDuration && !self.holdFullyCompleted) {
self.holdFullyCompleted = true;
}
var progressHold = (now - self.visualSpawnTime) / noteTravelTime;
var newYHold = self.startY + (self.centerY - self.startY) * progressHold;
if (newYHold >= self.centerY || self.y === self.centerY) {
self.y = self.centerY;
} else {
self.y = newYHold;
}
self.x = self.centerX;
if (typeof DEBUG_SHOW_HITBOXES !== 'undefined' && DEBUG_SHOW_HITBOXES && self.debugHitboxVisual && self.alpha > 0) {
var hitboxHeight = 250;
self.debugHitboxVisual.visible = true;
self.debugHitboxVisual.width = 250;
self.debugHitboxVisual.height = hitboxHeight;
self.debugHitboxVisual.x = 0;
self.debugHitboxVisual.y = self.yOffset - hitboxHeight / 2;
}
return;
} else if (self.isHoldNote && self.brightnessOverlay) {
self.brightnessOverlay.alpha = 0;
}
var progress = (now - self.visualSpawnTime) / noteTravelTime;
self.y = self.startY + (self.centerY - self.startY) * progress;
self.x = self.centerX;
if (!self.judged) {
var currentTime = Date.now();
if (self.isHoldNote && self.holdPressTime === 0) {
if (currentTime > self.targetHitTime + hitWindowGood + ADDITIONAL_HOLD_MISS_DELAY) {
self.judged = true;
self.showHitFeedback('miss');
if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
}
} else if (self.noteType !== 'trap' && !self.isHoldNote) {
if (currentTime > self.targetHitTime + hitWindowGood) {
self.judged = true;
if (self.isBuffNote) {
self.showHitFeedback('miss');
if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
} else {
game.onNoteMiss(self);
}
}
}
}
if (typeof DEBUG_SHOW_HITBOXES !== 'undefined' && DEBUG_SHOW_HITBOXES && self.debugHitboxVisual) {
if (self.alpha > 0 && !self.judged) {
var hitboxWidth, hitboxHeight;
var spatialBuffMultiplier = typeof isPrecisionBuffActive !== 'undefined' && isPrecisionBuffActive ? 1.5 : 1.0;
if (self.noteAsset) {
hitboxWidth = self.noteAsset.width * self.scale.x;
hitboxHeight = self.noteAsset.height * self.scale.y;
self.debugHitboxVisual.y = 0;
} else {
hitboxWidth = 0;
hitboxHeight = 0;
}
self.debugHitboxVisual.width = hitboxWidth * spatialBuffMultiplier;
self.debugHitboxVisual.height = hitboxHeight * spatialBuffMultiplier;
self.debugHitboxVisual.x = 0;
self.debugHitboxVisual.visible = true;
} else {
self.debugHitboxVisual.visible = false;
}
}
};
self.isInHitWindow = function () {
var now = Date.now();
var dt = Math.abs(now - self.targetHitTime);
return dt <= hitWindowGood;
};
self.getHitAccuracy = function () {
var now = Date.now();
var dt = Math.abs(now - self.targetHitTime);
if (dt <= hitWindowPerfect) {
return 'perfect';
}
if (dt <= hitWindowGood) {
return 'good';
}
return 'miss';
};
self.judgeHoldRelease = function () {
if (self.brightnessOverlay) {
self.brightnessOverlay.alpha = 0;
}
if (!self.isHoldNote || self.judged && self.holdFullyCompleted && !self.holdBroken) {
if (self.isBeingHeld) {
self.isBeingHeld = false;
}
return;
}
var now = Date.now();
self.isBeingHeld = false;
self.judged = true;
if (self.holdBroken) {
if (!self.feedbackShownForBroken) {
self.showHitFeedback('hold_broken');
self.feedbackShownForBroken = true;
}
if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
if (self.alpha > 0) {
self.alpha = 0;
}
if (self.noteColumnIndex !== undefined) {
var overlay = columnFlashOverlays[self.noteColumnIndex];
if (overlay) {
tween(overlay, {
alpha: 0
}, {
duration: 150,
easing: tween.easeOutQuad
});
}
}
return;
}
var requiredHoldTimeOnScreen = self.targetHitTime + self.holdDuration;
if (now >= requiredHoldTimeOnScreen - hitWindowGood) {
self.holdFullyCompleted = true;
self.showHitFeedback('hold_ok');
if (!isTutorialMode) {
addScore('perfect');
addCombo();
if (!gameOverFlag) {
bossCurrentHP = Math.max(0, bossCurrentHP - 2);
updateBossHpDisplay();
}
}
} else {
self.showHitFeedback('miss', 'Too Early!');
if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
}
if (self.alpha > 0) {
self.alpha = 0;
}
if (self.noteColumnIndex !== undefined) {
var overlay = columnFlashOverlays[self.noteColumnIndex];
if (overlay) {
tween(overlay, {
alpha: 0
}, {
duration: 150,
easing: tween.easeOutQuad
});
}
}
};
return self;
});
var SpriteAnimation = Container.expand(function (options) {
var self = Container.call(this);
options = options || {};
self.frames = options.frames || [];
self.frameDuration = options.frameDuration || 60;
self.loop = options.loop !== undefined ? options.loop : true;
self.currentFrame = 0;
self.frameTimer = 0;
self.playing = true;
self.alpha = options.alpha !== undefined ? options.alpha : 1;
if (options.x !== undefined) {
self.x = options.x;
}
if (options.y !== undefined) {
self.y = options.y;
}
if (options.anchorX !== undefined || options.anchorY !== undefined) {
var anchorX = options.anchorX !== undefined ? options.anchorX : 0;
var anchorY = options.anchorY !== undefined ? options.anchorY : 0;
self.frames.forEach(function (frame) {
if (frame && frame.anchor) {
frame.anchor.set(anchorX, anchorY);
}
});
}
if (self.frames.length > 0) {
self.removeChildren();
var firstFrame = self.frames[self.currentFrame];
if (firstFrame && firstFrame.anchor) {
firstFrame.anchor.set(options.anchorX || 0, options.anchorY || 0);
}
if (firstFrame) {
firstFrame.alpha = self.alpha;
}
self.addChild(firstFrame);
}
self.update = function () {
if (!self.playing || self.frames.length === 0) {
return;
}
self.frameTimer++;
if (self.frameTimer >= self.frameDuration / (1000 / 60)) {
self.frameTimer = 0;
if (self.children.length > 0) {
self.removeChild(self.children[0]);
}
self.currentFrame++;
if (self.currentFrame >= self.frames.length) {
if (self.loop) {
self.currentFrame = 0;
var nextFrame = self.frames[self.currentFrame];
if (nextFrame) {
nextFrame.alpha = self.alpha;
}
self.addChild(nextFrame);
} else {
self.playing = false;
if (typeof self.onComplete === 'function') {
self.onComplete();
}
return;
}
} else {
var nextFrame = self.frames[self.currentFrame];
if (nextFrame) {
nextFrame.alpha = self.alpha;
}
self.addChild(nextFrame);
}
}
};
self.stop = function () {
self.playing = false;
};
self.play = function () {
self.playing = true;
};
self.gotoFrame = function (frameIndex) {
if (frameIndex >= 0 && frameIndex < self.frames.length) {
self.removeChildren();
self.currentFrame = frameIndex;
self.addChild(self.frames[self.currentFrame]);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x181828
});
/****
* Game Code
****/
// np. fioletowy box
// np. pomarańczowy/żółty box
// Złoty segment ogona (wysokość bazowa)
// Pomarańczowa główka
// np. węższa środkowa
// Placeholder strzałki
function _typeof6(o) {
"@babel/helpers - typeof";
return _typeof6 = "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;
}, _typeof6(o);
}
function _defineProperty(e, r, t) {
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[r] = t, e;
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == _typeof6(i) ? i : i + "";
}
function _toPrimitive(t, r) {
if ("object" != _typeof6(t) || !t) {
return t;
}
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof6(i)) {
return i;
}
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
var currentScreenState = '';
var columnFlashOverlays = [null, null, null];
var mainMenuScreenElements = [];
var DEBUG_SHOW_HITBOXES = false;
var isTutorialMode = false;
var HOLD_HITBOX_WIDTH = 250;
var HOLD_HITBOX_HEIGHT = 250;
var currentlyHeldNotes = {};
var tutorialSongData = {
id: "TutorialTrack",
title: "How to Play",
artist: "Game System",
musicAsset: "tutorial",
bossAssetKey: null,
config: {
playerMaxHP: 10,
bossMaxHP: 1
},
rawRhythmMap: [{
time: 12000,
type: "tap",
columnIndex: 0
}, {
time: 12524,
type: "tap",
columnIndex: 1
}, {
time: 12978,
type: "tap",
columnIndex: 2
}, {
time: 16966,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 20420,
type: "swipe",
columnIndex: 2,
swipeDir: "left"
}, {
time: 24711,
type: "tap",
columnIndex: 0
}, {
time: 25125,
type: "tap",
columnIndex: 1
}, {
time: 25510,
type: "tap",
columnIndex: 2
}, {
time: 25934,
type: "tap",
columnIndex: 1
}, {
time: 39597,
type: "tap",
columnIndex: 0
}, {
time: 40031,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 40484,
type: "tap",
columnIndex: 1
}, {
time: 41747,
type: "tap",
columnIndex: 0
}, {
time: 42204,
type: "tap",
columnIndex: 1
}, {
time: 42626,
type: "tap",
columnIndex: 0
}, {
time: 51606,
type: "hold",
columnIndex: 1,
duration: 2500
}, {
time: 66984,
type: "tap",
columnIndex: 0
}, {
time: 67396,
type: "tap",
columnIndex: 0
}, {
time: 67863,
type: "tap",
columnIndex: 1
}, {
time: 68315,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 68764,
type: "tap",
columnIndex: 0
}, {
time: 69171,
type: "tap",
columnIndex: 0
}, {
time: 69629,
type: "tap",
columnIndex: 2
}, {
time: 69818,
type: "tap",
columnIndex: 2
}, {
time: 70008,
type: "tap",
columnIndex: 2
}, {
time: 70449,
type: "tap",
columnIndex: 0
}, {
time: 71766,
type: "hold",
columnIndex: 1,
duration: 1094
}, {
time: 73943,
type: "tap",
columnIndex: 0
}, {
time: 75129,
type: "tap",
columnIndex: 0
}, {
time: 75572,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 76046,
type: "tap",
columnIndex: 0
}, {
time: 76470,
type: "tap",
columnIndex: 0
}, {
time: 76653,
type: "tap",
columnIndex: 0
}, {
time: 76833,
type: "tap",
columnIndex: 0
}, {
time: 76999,
type: "tap",
columnIndex: 0
}, {
time: 77326,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 80766,
type: "tap",
columnIndex: 0
}, {
time: 81199,
type: "tap",
columnIndex: 0
}, {
time: 81586,
type: "tap",
columnIndex: 0
}, {
time: 81816,
type: "tap",
columnIndex: 0
}, {
time: 82002,
type: "tap",
columnIndex: 0
}, {
time: 84273,
type: "tap",
columnIndex: 0
}, {
time: 84674,
type: "tap",
columnIndex: 0
}, {
time: 85091,
type: "tap",
columnIndex: 1
}, {
time: 85919,
type: "tap",
columnIndex: 2
}, {
time: 86772,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 87770,
type: "tap",
columnIndex: 0
}],
isTutorial: true
};
var hasShownInitialMenuAnimation = false;
var statsScreenElements = [];
var currentBossDisplayElements = [];
var currentStatsBossIndex = 0;
var miniGameBackgroundInstance = null;
var miniGameViewport = {
x: 380,
y: 1020,
width: 1150,
height: 780
};
var miniGameScreenElements = [];
var miniGamePlayer = null;
var miniGameObstacles = [];
var miniGameScore = 0;
var miniGameScoreText = null;
var isMiniGameOver = false;
var currentMiniGameMusicTrack = null;
var startScreenElements = [];
var pressStartBlinkInterval = null;
var PLAYER_HP_BAR_X = 1020;
var PLAYER_HP_BAR_Y = 2680;
var MINI_GAME_LANE_Y_POSITIONS = [];
var MINI_GAME_NUMBER_OF_LANES = 3;
var MINI_GAME_LANE_HEIGHT = 0;
var MINI_GAME_OBJECT_SPEED = 8;
var currentMiniGameObjectSpeed = 0;
var miniGameTimeActive = 0;
var SPATIAL_HITBOX_MULTIPLIER = 1.3;
var MINI_GAME_SPEED_INCREASE_INTERVAL = 5000;
var MINI_GAME_OBSTACLE_SPAWN_INTERVAL = 2000;
var MINI_GAME_SPEED_INCREMENT = 0.5;
var MINI_GAME_MOB_SPAWN_INTERVAL = 3500;
var lastMiniGameObstacleSpawnTime = 0;
var MINI_GAME_OBSTACLE_WIDTH = 100;
var MINI_GAME_OBSTACLE_HEIGHT = 100;
var mainMenuItemTextObjects = [];
var currentMainMenuMusicTrack = null;
var mainMenuItems = ["Music Battle", "How To Play", "Endless Loop", "Mini game", "Stats", "Credits"];
var selectedMainMenuItemIndex = 0;
var gameScreenWidth = 2048;
var hitZoneY = 1800;
var playerShieldAnimation = null;
// === PONIŻSZE DEKLARACJE PRZENOSIMY NA GÓRĘ ===
var STATIC_HIT_FRAME_WIDTH = 2000; // Dodana nowa stała dla szerokości statycznej ramki
var STATIC_HIT_FRAME_HEIGHT = 300; // Dodana nowa stała dla wysokości statycznej ramki
var staticHitFrame = null; // Deklaracja statycznej ramki obszaru uderzenia
var staticPerfectLine = null; // Deklaracja statycznej linii perfect
var PERFECT_LINE_ASSET_KEY = 'perfectLineAsset'; // Nazwa assetu dla cienkiej linii
var PERFECT_LINE_HEIGHT = 2; // Wysokość cienkiej linii perfect
// === KONIEC PRZENIESIONYCH DEKLARACJI ===
var gameScreenHeight = Math.round(gameScreenWidth * (2732 / 2048));
var playfieldWidth = 1808;
var NUM_COLUMNS = 3;
var columnCenterXs = [350, 1024, 1700]; // Podaj swoje wartości!
var columnFlashWidths = [620, 400, 620];
var SWIPE_NOTE_WIDTH = 180;
// HP System Variables
var playerMaxHP = 10;
var BOSS_HP_BAR_X = 2030 / 2;
var BOSS_HP_BAR_Y = 70;
var playerCurrentHP = 10;
var bossMaxHP = 30;
var bossCurrentHP = 30;
var gameOverFlag = false;
// HP Bar UI Elements Configuration (actual elements created in setupHpBars)
var hpBarWidth = 600;
var hpBarHeight = 100;
// UI Container
var gameUIContainer; // Declare gameUIContainer
// HP Bar Containers (will be initialized in setupHpBars)
var playerHpBarContainer;
var playerHpBarFill;
var endlessSongs = ['Orctave', 'Goblop', 'Noizboy'];
var currentEndlessSongIndex = 0;
var currentEndlessDifficulty = 0.1;
var ENDLESS_DIFFICULTY_INCREASE_RATE = 0.004;
var MAX_ENDLESS_DIFFICULTY = 1.0;
var endlessTimelineTime = 0;
var bossHpBarContainer;
var bossHpBarFill;
var isLockedBossMessageActive = false;
var activePowerUpItems = [];
var SHIELD_DURATION = 8000;
var isShieldActive = false;
var shieldEndTime = 0;
var POTION_HEAL_AMOUNT = 5;
var SWIPE_TO_TAP_BUFF_DURATION = 5000;
var isSwipeToTapBuffActive = false;
var swipeToTapBuffEndTime = 0;
var shieldTimerDisplayContainer;
var playerHUD = null;
var bossHUD = null;
var precisionBuffTimerDisplayContainer;
var smallPrecisionIconDisplay;
var precisionBuffTimerTextDisplay;
var smallShieldIconDisplay;
var shieldTimerTextDisplay;
var swipeToTapTimerDisplayContainer;
var smallSwipeToTapIconDisplay;
var swipeToTapTimerTextDisplay;
var currentBossSprite;
var powerUpDisplayContainer;
var hpPotionIcon, shieldIcon, swipeToTapIcon;
var hpPotionCountText, shieldCountText, swipeToTapCountText;
var currentActiveRhythmMap = null;
var noteTravelTime = 3300;
var BUFF_CHANCE = 0.04;
var gameplayBackground = null;
var PRECISION_BUFF_DURATION = 7000;
var isPrecisionBuffActive = false;
var precisionBuffEndTime = 0;
var originalHitWindowPerfect = 0;
var precisionBuffHitWindowMultiplier = 1.8;
var hitWindowPerfect = 220;
var hitWindowGood = 310;
var ADDITIONAL_HOLD_MISS_DELAY = 350;
var HOLD_NOTE_GOOD_WINDOW_EXTENSION = 120;
var MIN_SWIPE_DISTANCE = 60;
var notes = [];
var nextNoteIdx = 0;
var gameStartTime = 0;
var score = 0;
var bossWasDefeatedThisSong = false;
var songSummaryContainer = null;
var bossUnlockProgress = {};
var GAME_SCORES_KEY = 'walkmanFighters_scores';
var BOSS_UNLOCK_KEY = 'walkmanFighters_bossUnlock';
var currentFightingBossId = null;
var lastPlayedSongKeyForRestart = null;
var combo = 0;
var maxCombo = 0;
var swipeStart = null;
var inputLocked = false;
var hpBarsInitialized = false;
function _typeof5(o) {
"@babel/helpers - typeof";
return _typeof5 = "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;
}, _typeof5(o);
}
function _typeof4(o) {
"@babel/helpers - typeof";
return _typeof4 = "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;
}, _typeof4(o);
}
function _typeof3(o) {
"@babel/helpers - typeof";
return _typeof3 = "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;
}, _typeof3(o);
}
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 _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 showTemporaryMessage(message, duration, styleOptions) {
var textStyle = {
size: 70,
fill: 0xFFD700,
stroke: 0x000000,
strokeThickness: 4,
align: 'center',
wordWrap: true,
wordWrapWidth: gameScreenWidth * 0.8
};
if (styleOptions) {
for (var key in styleOptions) {
if (styleOptions.hasOwnProperty(key)) {
textStyle[key] = styleOptions[key];
}
}
}
var messageText = new Text2(message, textStyle);
messageText.anchor.set(0.5, 0.5);
messageText.x = gameScreenWidth / 2;
messageText.y = gameScreenHeight / 2;
messageText.alpha = 0;
game.addChild(messageText);
tween(messageText, {
alpha: 1
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(messageText, {
alpha: 0
}, {
duration: 300,
delay: duration || 2000,
easing: tween.easeIn,
onFinish: function onFinish() {
if (messageText.parent) {
messageText.destroy();
}
}
});
}
});
}
var activeMusicTrack = null;
var activeMusicKey = null;
function setMusic(trackKey) {
// Jeśli próbujemy włączyć tę samą piosenkę, która już gra, nic nie rób.
if (trackKey === activeMusicKey) {
return;
}
// --- NOWA LOGIKA ZATRZYMYWANIA ---
// Jeśli jakakolwiek muzyka grała wcześniej (mamy zapisaną jej nazwę)...
if (activeMusicKey) {
// ...pobierz z silnika ŚWIEŻY uchwyt do tej starej piosenki...
var oldTrack = LK.getSound(activeMusicKey);
// ...i dopiero na tym świeżym uchwycie wykonaj komendę stop().
if (oldTrack && typeof oldTrack.stop === 'function') {
oldTrack.stop();
}
}
// Zawsze resetuj stan po próbie zatrzymania
activeMusicTrack = null;
activeMusicKey = null;
// Jeśli nowa nazwa to null, to znaczy, że chcieliśmy tylko wszystko zatrzymać.
if (!trackKey) {
return;
}
// Włącz nową piosenkę
var newTrack = LK.getSound(trackKey);
if (newTrack) {
newTrack.play({
loop: true
});
// Zapisz stan nowej piosenki
activeMusicTrack = newTrack;
activeMusicKey = trackKey;
}
}
function restartMiniGame() {
isMiniGameOver = false;
miniGameScore = 0;
miniGameTimeActive = 0;
currentMiniGameObjectSpeed = MINI_GAME_OBJECT_SPEED;
lastMiniGameObstacleSpawnTime = Date.now();
if (miniGamePlayer && miniGamePlayer.asset) {
miniGamePlayer.lane = 1;
miniGamePlayer.y = MINI_GAME_LANE_Y_POSITIONS[1];
if (miniGamePlayer.asset) {
miniGamePlayer.asset.y = miniGamePlayer.y;
miniGamePlayer.asset.tint = 0xFFFFFF;
}
}
for (var i = miniGameObstacles.length - 1; i >= 0; i--) {
if (miniGameObstacles[i].asset && miniGameObstacles[i].asset.parent) {
miniGameObstacles[i].asset.destroy();
}
}
miniGameObstacles = [];
var gameOverText = miniGameScreenElements.find(function (el) {
return el.isGameOverText;
});
if (gameOverText && gameOverText.parent) {
gameOverText.destroy();
var idx = miniGameScreenElements.indexOf(gameOverText);
if (idx > -1) {
miniGameScreenElements.splice(idx, 1);
}
}
updateMiniGameScoreDisplay();
}
function setupGameplayElements() {
if (staticPerfectLine && staticPerfectLine.parent) {
staticPerfectLine.destroy();
}
staticPerfectLine = LK.getAsset(PERFECT_LINE_ASSET_KEY, {
anchorX: 0.5,
anchorY: 0.5,
x: gameScreenWidth / 2,
y: hitZoneY,
width: playfieldWidth,
height: PERFECT_LINE_HEIGHT,
alpha: 0.9,
visible: false
});
game.addChild(staticPerfectLine);
if (staticHitFrame && staticHitFrame.parent) {
staticHitFrame.destroy();
}
staticHitFrame = LK.getAsset('FRAME1', {
anchorX: 0.5,
anchorY: 0.5,
x: gameScreenWidth / 2,
y: hitZoneY,
width: STATIC_HIT_FRAME_WIDTH,
height: STATIC_HIT_FRAME_HEIGHT,
alpha: 0.7,
visible: false
});
game.addChild(staticHitFrame);
// Tworzenie nakładek błysku
for (var i = 0; i < NUM_COLUMNS; i++) {
if (columnFlashOverlays[i] && columnFlashOverlays[i].parent) {
columnFlashOverlays[i].destroy();
}
var overlayAssetKey = 'flashOverlay_col' + i;
columnFlashOverlays[i] = LK.getAsset(overlayAssetKey, {
// Pobieramy asset
anchorX: 0.5,
anchorY: 0.5,
x: columnCenterXs[i],
y: gameScreenHeight / 2
// Nie ustawiamy tu alpha, zrobimy to poniżej
});
if (columnFlashOverlays[i]) {
// Sprawdzenie, czy asset został poprawnie załadowany
game.addChild(columnFlashOverlays[i]);
columnFlashOverlays[i].alpha = 0; // <<<< KLUCZOWA ZMIANA: Ustawiamy alpha na 0 ZARAZ PO DODANIU
}
}
}
var allParticleAssetKeys = [];
for (var i = 1; i <= 12; i++) {
allParticleAssetKeys.push('particle' + i);
}
function createAndAnimateParticle(assetKey, startX, startY, parentContainer) {
var comboScaleMultiplier = 1 + Math.floor(combo / 20) * 0.1; // Bazowy mnożnik 1, zwiększa się o 0.1 co 20 combo
var particle = LK.getAsset(assetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: startX,
y: startY,
alpha: 1,
scaleX: (3 + Math.random() * 1.2) * comboScaleMultiplier,
scaleY: (3 + Math.random() * 1.2) * comboScaleMultiplier,
rotation: Math.random() * Math.PI * 2 // Losowa rotacja początkowa
});
parentContainer.addChild(particle);
var travelAngle = Math.random() * Math.PI * 2;
var travelDistance = 50 + Math.random() * 100; // 50 do 150px
var targetX = startX + Math.cos(travelAngle) * travelDistance;
var targetY = startY + Math.sin(travelAngle) * travelDistance;
var duration = 500 + Math.random() * 500; // 500ms do 1000ms
tween(particle, {
x: targetX,
y: targetY,
alpha: 0,
scaleX: 1 + Math.random() * 2,
// Większa skala końcowa X (np. od 0.3 do 0.6)
scaleY: 1 + Math.random() * 2,
// Większa skala końcowa Y (np. od 0.3 do 0.6)
// Skala końcowa Y
rotation: particle.rotation + (Math.random() * Math.PI - Math.PI / 2) // Dodatkowa losowa rotacja
}, {
duration: duration,
easing: tween.easeOutQuad,
onFinish: function onFinish() {
if (particle.parent) {
particle.destroy();
}
}
});
}
function spawnParticleEffect(spawnX, spawnY, accuracy, parentContainer) {
var numParticlesBase = 0;
var numTypesToPick = 0;
if (accuracy === 'good') {
numParticlesBase = 4;
numTypesToPick = 2 + Math.floor(Math.random() * 2); // 2 lub 3 typy
} else if (accuracy === 'perfect') {
numParticlesBase = 9;
numTypesToPick = 3 + Math.floor(Math.random() * 2); // 3 lub 4 typy
} else {
return; // Nie twórz cząsteczek dla 'miss' lub innych
}
// Wzmocnienie z combo (prosty przykład, można dostosować)
var comboBonusParticles = Math.floor(combo / 3); // 1 dodatkowa cząsteczka co 10 combo
var totalParticlesToSpawn = numParticlesBase + comboBonusParticles;
if (totalParticlesToSpawn === 0) {
return;
}
// Losowy wybór typów cząsteczek
var availableTypes = [].concat(allParticleAssetKeys); // Kopia tablicy
var pickedTypes = [];
for (var i = 0; i < numTypesToPick; i++) {
if (availableTypes.length === 0) {
break;
}
var randomIndex = Math.floor(Math.random() * availableTypes.length);
pickedTypes.push(availableTypes.splice(randomIndex, 1)[0]);
}
if (pickedTypes.length === 0) {
// Na wszelki wypadek, jeśli coś pójdzie nie tak
pickedTypes.push(allParticleAssetKeys[Math.floor(Math.random() * allParticleAssetKeys.length)]);
}
for (var i = 0; i < totalParticlesToSpawn; i++) {
var particleAssetKey = pickedTypes[i % pickedTypes.length]; // Cyklicznie przez wybrane typy
createAndAnimateParticle(particleAssetKey, spawnX, spawnY, parentContainer);
}
}
function flashColumn(columnIndex) {
if (columnIndex >= 0 && columnIndex < NUM_COLUMNS && columnFlashOverlays[columnIndex]) {
var overlay = columnFlashOverlays[columnIndex];
// Upewnij się, że nakładka jest na wierzchu innych elementów w tej samej warstwie,
// ale pod UI (jeśli UI jest wyżej). Można to zrobić raz w setupGameplayElements
// lub tutaj, jeśli jest taka potrzeba: game.setChildIndex(overlay, game.children.length - 1);
overlay.alpha = 0.6; // Początkowa alpha dla błysku (np. 60%)
tween(overlay, {
alpha: 0
}, {
duration: 250,
// Czas trwania zanikania błysku (w ms)
easing: tween.easeOutQuad // Typ animacji
});
}
}
function showStartScreen() {
if (typeof startScreenElements !== 'undefined' && startScreenElements.forEach) {
startScreenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
}
startScreenElements = [];
if (typeof simpleFlickerTimeout !== 'undefined' && simpleFlickerTimeout) {
LK.clearTimeout(simpleFlickerTimeout);
simpleFlickerTimeout = null;
}
if (typeof simpleFlickerPhaseEndTimeout !== 'undefined' && simpleFlickerPhaseEndTimeout) {
LK.clearTimeout(simpleFlickerPhaseEndTimeout);
simpleFlickerPhaseEndTimeout = null;
}
if (typeof pressStartBlinkInterval !== 'undefined' && pressStartBlinkInterval) {
LK.clearInterval(pressStartBlinkInterval);
pressStartBlinkInterval = null;
}
var pressStartMainGlitchTimer = null;
var glowFlickerBurstTimer = null;
var subtleJitterTimer = null;
currentScreenState = 'startScreenWithGlitch';
if (typeof gameUIContainer !== 'undefined' && gameUIContainer) {
gameUIContainer.visible = false;
}
if (typeof staticHitFrame !== 'undefined' && staticHitFrame) {
staticHitFrame.visible = false;
}
if (typeof staticPerfectLine !== 'undefined' && staticPerfectLine) {
staticPerfectLine.visible = false;
}
var walkmanScreenCenterX = gameScreenWidth / 2 - 300;
var walkmanScreenCenterY = gameScreenHeight / 2 + 100;
var walkmanScreenWidth = 1200;
var walkmanScreenHeight = 1200;
var pressStartRotation = Math.PI / 16;
var pressStartAssetKey = 'pressStartTextAsset';
var glowAssetKey = 'walkmanScreenGlowAsset';
var backgroundAssetKey = 'walkmanStartScreenBg';
var pressStartVisuals = {
main: null,
copies: []
};
var pressStartContainer = new Container();
pressStartContainer.x = walkmanScreenCenterX;
pressStartContainer.y = walkmanScreenCenterY;
startScreenElements.push(pressStartContainer);
game.addChild(pressStartContainer);
pressStartVisuals.main = LK.getAsset(pressStartAssetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
rotation: pressStartRotation,
interactive: true,
cursor: "pointer"
});
pressStartContainer.addChild(pressStartVisuals.main);
for (var i = 0; i < 2; i++) {
var copy = LK.getAsset(pressStartAssetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
rotation: pressStartRotation,
alpha: 0
});
pressStartContainer.addChild(copy);
pressStartVisuals.copies.push(copy);
}
var glowingScreen = LK.getAsset(glowAssetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: walkmanScreenCenterX,
y: walkmanScreenCenterY,
width: walkmanScreenWidth,
height: walkmanScreenHeight,
alpha: 0.5
});
startScreenElements.push(glowingScreen);
game.addChild(glowingScreen);
var background = LK.getAsset(backgroundAssetKey, {
x: gameScreenWidth / 2,
y: gameScreenHeight / 2,
anchorX: 0.5,
anchorY: 0.5,
width: gameScreenWidth,
height: gameScreenHeight
});
startScreenElements.push(background);
game.addChild(background);
game.setChildIndex(pressStartContainer, game.children.length - 3);
game.setChildIndex(glowingScreen, game.children.length - 2);
game.setChildIndex(background, game.children.length - 1);
function triggerGlowFlickerBurst() {
if (currentScreenState !== 'startScreenWithGlitch' || !glowingScreen || !glowingScreen.parent) {
if (glowFlickerBurstTimer) {
LK.clearTimeout(glowFlickerBurstTimer);
}
glowFlickerBurstTimer = null;
return;
}
var burstCount = Math.floor(Math.random() * 3) + 2;
var currentBurst = 0;
var baseAlpha = 0.5 + Math.random() * 0.2;
function singleGlowFlicker() {
if (currentBurst >= burstCount || !glowingScreen || !glowingScreen.parent || currentScreenState !== 'startScreenWithGlitch') {
if (glowingScreen && glowingScreen.parent) {
glowingScreen.alpha = baseAlpha * 0.8;
}
glowFlickerBurstTimer = LK.setTimeout(triggerGlowFlickerBurst, 2500 + Math.random() * 3000);
return;
}
var flickerToAlpha = Math.random() < 0.5 ? baseAlpha * 0.3 + Math.random() * 0.2 : baseAlpha * 1.2 + Math.random() * 0.3;
glowingScreen.alpha = Math.max(0.1, Math.min(0.9, flickerToAlpha));
currentBurst++;
glowFlickerBurstTimer = LK.setTimeout(singleGlowFlicker, 50 + Math.random() * 100);
}
singleGlowFlicker();
}
function continuousSubtleJitter() {
if (currentScreenState !== 'startScreenWithGlitch' || !pressStartVisuals.main || !pressStartVisuals.main.parent) {
if (subtleJitterTimer) {
LK.clearTimeout(subtleJitterTimer);
}
subtleJitterTimer = null;
return;
}
var mainAsset = pressStartVisuals.main;
var jitterAmount = 1.5;
mainAsset.x = (Math.random() - 0.5) * jitterAmount;
mainAsset.y = (Math.random() - 0.5) * jitterAmount;
subtleJitterTimer = LK.setTimeout(continuousSubtleJitter, 70 + Math.random() * 60);
}
function performMainGlitch() {
if (currentScreenState !== 'startScreenWithGlitch' || !pressStartVisuals.main || !pressStartVisuals.main.parent) {
if (pressStartMainGlitchTimer) {
LK.clearTimeout(pressStartMainGlitchTimer);
}
pressStartMainGlitchTimer = null;
return;
}
var glitchType = Math.random();
var mainAsset = pressStartVisuals.main;
var copies = pressStartVisuals.copies;
var originalTint = mainAsset.tint || 0xFFFFFF;
var originalAlpha = mainAsset.alpha;
var textAssetNominalWidth = 280;
var textAssetNominalHeight = 70;
if (glitchType < 0.08) {
var animateDuringSlide = function animateDuringSlide() {
if (!mainAsset.parent || !mainAsset.visible || currentScreenState !== 'startScreenWithGlitch') {
if (slideEffectInterval) {
LK.clearInterval(slideEffectInterval);
}
if (mainAsset.parent) {
mainAsset.tint = originalTint;
mainAsset.alpha = originalAlpha;
}
return;
}
mainAsset.alpha = 0.15 + Math.random() * 0.5;
mainAsset.tint = glitchColors[effectStep % glitchColors.length];
effectStep++;
};
var currentJitterX = mainAsset.x;
var currentJitterY = mainAsset.y;
var slideOutFactorX = 3.0 + Math.random() * 2.0;
var slideOutFactorY = Math.random() < 0.3 ? 2.0 + Math.random() * 1.5 : 0;
var slideDistanceX = textAssetNominalWidth * slideOutFactorX;
var slideDistanceY = textAssetNominalHeight * slideOutFactorY;
var targetX = (Math.random() > 0.5 ? 1 : -1) * slideDistanceX;
var targetY = (Math.random() > 0.5 ? 1 : -1) * slideDistanceY;
var slideDuration = 30 + Math.random() * 20;
var slideEffectInterval = null;
var effectStep = 0;
var glitchColors = [0xff3333, 0x33ff33, 0x3333ff, 0xffff33, 0xcccccc, 0x555555];
if (mainAsset.parent) {
slideEffectInterval = LK.setInterval(animateDuringSlide, 20);
}
tween(mainAsset, {
x: targetX,
y: targetY
}, {
duration: slideDuration,
easing: tween.easeOutQuad,
onFinish: function onFinish() {
if (slideEffectInterval) {
LK.clearInterval(slideEffectInterval);
}
if (mainAsset.parent) {
mainAsset.tint = originalTint;
mainAsset.alpha = 0;
}
LK.setTimeout(function () {
if (mainAsset.parent) {
mainAsset.alpha = originalAlpha;
tween(mainAsset, {
x: currentJitterX,
y: currentJitterY
}, {
duration: 100 + Math.random() * 70,
easing: tween.easeInCubic
});
}
}, 150 + Math.random() * 200);
}
});
} else if (glitchType < 0.25) {
if (!mainAsset.parent) {
return;
}
var prevAlpha = mainAsset.alpha;
mainAsset.alpha = 0;
LK.setTimeout(function () {
if (mainAsset.parent && currentScreenState === 'startScreenWithGlitch') {
mainAsset.alpha = prevAlpha;
}
}, 500);
} else if (glitchType < 0.45) {
if (!mainAsset.parent) {
return;
}
var glitchColorsSet = [0xff0000, 0x00ff00, 0x0000ff, 0x8A2BE2, 0xFFD700, 0x333333];
var oldTint = mainAsset.tint || 0xFFFFFF;
mainAsset.tint = glitchColorsSet[Math.floor(Math.random() * glitchColorsSet.length)];
LK.setTimeout(function () {
if (mainAsset.parent && currentScreenState === 'startScreenWithGlitch') {
mainAsset.tint = oldTint;
}
}, 100 + Math.random() * 150);
} else if (glitchType < 0.70) {
var _doSingleTextFlicker = function doSingleTextFlicker(count) {
if (!mainAsset.parent || count <= 0 || currentScreenState !== 'startScreenWithGlitch') {
if (mainAsset.parent) {
mainAsset.alpha = baseAlpha;
}
return;
}
mainAsset.alpha = Math.random() < 0.6 ? 0.1 : Math.random() * 0.4 + 0.5;
LK.setTimeout(function () {
_doSingleTextFlicker(count - 1);
}, flickerInterval);
};
var baseAlpha = mainAsset.alpha;
if (!mainAsset.parent) {
return;
}
var flickerCount = Math.floor(Math.random() * 4) + 3;
var flickerInterval = 25 + Math.random() * 30;
_doSingleTextFlicker(flickerCount);
} else {
if (mainAsset.parent) {
mainAsset.alpha = 0;
} else {
return;
}
var colors = [0xff0000, 0x00ff00, 0x0000ff];
var offsetAmount = 12 + Math.random() * 6;
copies.forEach(function (copy, index) {
if (!copy.parent) {
return;
}
copy.tint = colors[index % colors.length];
copy.alpha = 0.55 + Math.random() * 0.25;
copy.x = mainAsset.x + (Math.random() - 0.5) * offsetAmount * (index + 1.8);
copy.y = mainAsset.y + (Math.random() - 0.5) * offsetAmount * (index + 1.8);
});
LK.setTimeout(function () {
if (mainAsset.parent && currentScreenState === 'startScreenWithGlitch') {
mainAsset.alpha = 1;
}
copies.forEach(function (copy) {
if (copy.parent) {
copy.alpha = 0;
}
});
}, 70 + Math.random() * 80);
}
pressStartMainGlitchTimer = LK.setTimeout(performMainGlitch, 800 + Math.random() * 1500);
}
pressStartVisuals.main.down = function () {
if (currentScreenState !== 'startScreenWithGlitch') {
return;
}
setMusic('introMusic'); // <-- DODAJEMY TĘ LINIĘ
if (pressStartMainGlitchTimer) {
LK.clearTimeout(pressStartMainGlitchTimer);
pressStartMainGlitchTimer = null;
}
if (glowFlickerBurstTimer) {
LK.clearTimeout(glowFlickerBurstTimer);
glowFlickerBurstTimer = null;
}
if (subtleJitterTimer) {
LK.clearTimeout(subtleJitterTimer);
subtleJitterTimer = null;
}
startScreenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
startScreenElements = [];
showIntro();
};
glowFlickerBurstTimer = LK.setTimeout(triggerGlowFlickerBurst, 800 + Math.random() * 700);
subtleJitterTimer = LK.setTimeout(continuousSubtleJitter, 100);
pressStartMainGlitchTimer = LK.setTimeout(performMainGlitch, 1500 + Math.random() * 1000);
}
function updateMainMenuHighlight(newIndex) {
var defaultTint = 0xFFFFFF; // Biały tint (brak efektu, oryginalny kolor tekstu)
var highlightTint = 0xFFD700; // Żółty tint dla podświetlenia
var defaultScale = 1.0;
var highlightScale = 1.15; // Skala dla podświetlonej opcji
// Resetuj styl dla wszystkich opcji
for (var i = 0; i < mainMenuItemTextObjects.length; i++) {
if (mainMenuItemTextObjects[i] && mainMenuItemTextObjects[i].parent) {
// Zakładamy, że bazowy .fill tekstu jest biały (ustawiony przy tworzeniu)
mainMenuItemTextObjects[i].tint = defaultTint;
mainMenuItemTextObjects[i].scale.set(defaultScale);
}
}
// Ustaw styl dla nowo wybranej opcji
if (newIndex >= 0 && newIndex < mainMenuItemTextObjects.length) {
if (mainMenuItemTextObjects[newIndex] && mainMenuItemTextObjects[newIndex].parent) {
var targetItem = mainMenuItemTextObjects[newIndex];
targetItem.tint = highlightTint;
targetItem.scale.set(highlightScale);
}
}
selectedMainMenuItemIndex = newIndex; // Aktualizuj globalny indeks
}
function showMainMenu(fadeInDuration) {
while (mainMenuScreenElements.length > 0) {
var el = mainMenuScreenElements.pop();
if (el && el.parent) {
el.destroy();
}
}
if (gameplayBackground && gameplayBackground.parent) {
gameplayBackground.destroy();
gameplayBackground = null;
}
mainMenuScreenElements = [];
mainMenuItemTextObjects = [];
var mainMenuContainer = new Container();
game.addChild(mainMenuContainer);
mainMenuScreenElements.push(mainMenuContainer);
currentScreenState = 'mainmenu_walkman';
initializeBossData();
if (gameUIContainer) {
gameUIContainer.visible = false;
}
if (staticHitFrame) {
staticHitFrame.visible = false;
}
if (staticPerfectLine) {
staticPerfectLine.visible = false;
}
if (shieldTimerDisplayContainer) {
shieldTimerDisplayContainer.visible = false;
}
if (swipeToTapTimerDisplayContainer) {
swipeToTapTimerDisplayContainer.visible = false;
}
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
songSummaryContainer = null;
}
var glassX = 380;
var glassY = 1020;
var glassWidth = 1150;
var glassHeight = 820;
var glassInitialAlpha = 0.3;
var glassFinalAlpha = 0.7;
var menuItemFontSize = 120;
var menuItemSpacing = 225;
var TARGET_CENTER_X_FOR_MENU_ITEMS = glassX + glassWidth / 2;
var TARGET_CENTER_Y_FOR_SELECTED_ITEM = glassY + glassHeight / 2;
var menuTextContainer = new Container();
mainMenuContainer.addChild(menuTextContainer);
var creditsGraphic = LK.getAsset('creditsTextAsset', {
x: TARGET_CENTER_X_FOR_MENU_ITEMS,
y: TARGET_CENTER_Y_FOR_SELECTED_ITEM,
anchorX: 0.5,
anchorY: 0.5,
visible: false
});
mainMenuContainer.addChild(creditsGraphic);
selectedMainMenuItemIndex = 0;
for (var i_menu = 0; i_menu < mainMenuItems.length; i_menu++) {
var itemText_menu = new Text2(mainMenuItems[i_menu], {
size: menuItemFontSize,
fill: 0xFFFFFF,
align: 'center'
});
itemText_menu.anchor.set(0.5, 0.5);
itemText_menu.interactive = false;
menuTextContainer.addChild(itemText_menu);
mainMenuItemTextObjects.push(itemText_menu);
}
var layoutAndHighlightFunctionRef = function layoutAndHighlightFunctionRef() {
var defaultTint = 0xFFFFFF;
var highlightTint = 0xFFD700;
var defaultScale = 1.0;
var highlightScale = 1.15;
for (var idx = 0; idx < mainMenuItemTextObjects.length; idx++) {
var item_layout = mainMenuItemTextObjects[idx];
if (item_layout && item_layout.parent) {
item_layout.x = TARGET_CENTER_X_FOR_MENU_ITEMS;
item_layout.y = TARGET_CENTER_Y_FOR_SELECTED_ITEM + (idx - selectedMainMenuItemIndex) * menuItemSpacing;
if (idx === selectedMainMenuItemIndex) {
item_layout.tint = highlightTint;
item_layout.scale.set(highlightScale);
} else {
item_layout.tint = defaultTint;
item_layout.scale.set(defaultScale);
}
}
}
};
var glass = LK.getAsset('glass', {
x: glassX,
y: glassY,
width: glassWidth,
height: glassHeight,
alpha: 0,
interactive: false
});
mainMenuContainer.addChild(glass);
var glass2 = LK.getAsset('glass2', {
x: glassX,
y: glassY,
width: glassWidth,
height: glassHeight,
alpha: 0,
interactive: false
});
mainMenuContainer.addChild(glass2);
var walkmanFrame = LK.getAsset('mainmenu', {
x: 0,
y: 0,
width: gameScreenWidth,
height: gameScreenHeight
});
mainMenuContainer.addChild(walkmanFrame);
var upButton = LK.getAsset('upbutton', {});
upButton.x = 210;
upButton.y = gameScreenHeight / 2 - 180;
upButton.anchor.set(0.5, 0.5);
upButton.interactive = true;
upButton.cursor = "pointer";
upButton.down = function () {
if (currentScreenState === 'mainmenu_walkman') {
if (selectedMainMenuItemIndex > 0) {
selectedMainMenuItemIndex--;
} else {
selectedMainMenuItemIndex = mainMenuItems.length - 1;
}
layoutAndHighlightFunctionRef();
} else if (currentScreenState === 'miniGameActive' && !isMiniGameOver) {
if (miniGamePlayer && miniGamePlayer.lane > 0) {
miniGamePlayer.lane--;
miniGamePlayer.y = MINI_GAME_LANE_Y_POSITIONS[miniGamePlayer.lane];
if (miniGamePlayer.asset) {
miniGamePlayer.asset.y = miniGamePlayer.y;
}
}
}
};
mainMenuContainer.addChild(upButton);
var downButton = LK.getAsset('downbutton', {});
downButton.x = 210;
downButton.y = gameScreenHeight / 2 + 220;
downButton.anchor.set(0.5, 0.5);
downButton.interactive = true;
downButton.cursor = "pointer";
downButton.down = function () {
if (currentScreenState === 'mainmenu_walkman') {
if (selectedMainMenuItemIndex < mainMenuItems.length - 1) {
selectedMainMenuItemIndex++;
} else {
selectedMainMenuItemIndex = 0;
}
layoutAndHighlightFunctionRef();
} else if (currentScreenState === 'miniGameActive' && !isMiniGameOver) {
if (miniGamePlayer && miniGamePlayer.lane < MINI_GAME_NUMBER_OF_LANES - 1) {
miniGamePlayer.lane++;
miniGamePlayer.y = MINI_GAME_LANE_Y_POSITIONS[miniGamePlayer.lane];
if (miniGamePlayer.asset) {
miniGamePlayer.asset.y = miniGamePlayer.y;
}
}
}
};
mainMenuContainer.addChild(downButton);
var playButton = LK.getAsset('play', {});
playButton.x = gameScreenWidth - 350;
playButton.y = gameScreenHeight / 2 - 240;
playButton.anchor.set(0.5, 0.5);
playButton.interactive = true;
playButton.cursor = "pointer";
playButton.down = function () {
if (currentScreenState === 'mainmenu_walkman') {
setMusic('introMusic');
}
};
mainMenuContainer.addChild(playButton);
var stopButton = LK.getAsset('stop', {});
stopButton.x = gameScreenWidth - 350;
stopButton.y = gameScreenHeight / 2;
stopButton.anchor.set(0.5, 0.5);
stopButton.interactive = true;
stopButton.cursor = "pointer";
stopButton.down = function () {
setMusic(null);
};
mainMenuContainer.addChild(stopButton);
var fightButton = LK.getAsset('fight', {});
fightButton.x = gameScreenWidth - 350;
fightButton.y = gameScreenHeight / 2 + 240;
fightButton.anchor.set(0.5, 0.5);
fightButton.interactive = true;
fightButton.cursor = "pointer";
fightButton.down = function () {
var selectedAction = mainMenuItems[selectedMainMenuItemIndex];
if (currentScreenState === 'mainmenu_walkman') {
if (selectedAction === "Credits") {
currentScreenState = 'mainmenu_credits';
menuTextContainer.visible = false;
creditsGraphic.visible = true;
} else {
if (selectedAction === "Mini game" || selectedAction === "Stats") {
menuTextContainer.visible = false;
} else {
mainMenuScreenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
mainMenuScreenElements = [];
mainMenuItemTextObjects = [];
if (menuTextContainer && menuTextContainer.parent) {
menuTextContainer.destroy();
}
menuTextContainer = null;
}
if (selectedAction === "Mini game") {
setMusic(null);
showMiniGameScreen();
} else if (selectedAction === "Stats") {
showStatsScreen();
} else if (selectedAction === "Music Battle") {
showBossSelectionScreen();
} else if (selectedAction === "Endless Loop") {
mainMenuScreenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
mainMenuScreenElements = [];
mainMenuItemTextObjects = [];
if (menuTextContainer && menuTextContainer.parent) {
menuTextContainer.destroy();
}
menuTextContainer = null;
setMusic(null);
startEndlessMode();
} else if (selectedAction === "How To Play") {
setMusic(null);
runTutorialGameplay();
}
}
} else if (currentScreenState === 'miniGameActive' && isMiniGameOver) {
restartMiniGame();
}
};
mainMenuContainer.addChild(fightButton);
var rewindButtonMainMenu = LK.getAsset('rewindbutton', {});
rewindButtonMainMenu.x = 350;
rewindButtonMainMenu.y = gameScreenHeight / 2 + 650;
rewindButtonMainMenu.anchor.set(0.5, 0.5);
rewindButtonMainMenu.interactive = true;
rewindButtonMainMenu.cursor = "pointer";
rewindButtonMainMenu.down = function () {
if (currentScreenState === 'mainmenu_credits') {
currentScreenState = 'mainmenu_walkman';
menuTextContainer.visible = true;
creditsGraphic.visible = false;
}
};
mainMenuContainer.addChild(rewindButtonMainMenu);
var actualDefeatedCount = getNumberOfDefeatedBosses();
var allStandardBossesDefeated = allBossData.length > 0 && actualDefeatedCount === allBossData.length;
var specialBossButtonAssetKey = allStandardBossesDefeated ? 'specialboss_unlocked' : 'specialboss_locked';
var specialBossButtonMainMenu = LK.getAsset(specialBossButtonAssetKey, {});
specialBossButtonMainMenu.width = 250;
var originalAssetWidthForRatioSB = 300;
var originalAssetHeightUnlockedSB = 250;
var originalAssetHeightLockedSB = 250;
specialBossButtonMainMenu.height = (specialBossButtonAssetKey === 'specialboss_unlocked' ? originalAssetHeightUnlockedSB : originalAssetHeightLockedSB) * (specialBossButtonMainMenu.width / originalAssetWidthForRatioSB);
specialBossButtonMainMenu.x = 950;
specialBossButtonMainMenu.y = 2030;
specialBossButtonMainMenu.anchor.set(0.5, 0.5);
specialBossButtonMainMenu.interactive = true;
if (allStandardBossesDefeated) {
specialBossButtonMainMenu.cursor = "pointer";
specialBossButtonMainMenu.down = function () {};
} else {
specialBossButtonMainMenu.cursor = "default";
specialBossButtonMainMenu.down = function () {
if (isLockedBossMessageActive) {
return;
}
isLockedBossMessageActive = true;
tween(menuTextContainer, {
alpha: 0
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
menuTextContainer.visible = false;
}
});
var lockedGraphic = LK.getAsset('silasLockedMessage', {
anchorX: 0.5,
anchorY: 0.5,
x: TARGET_CENTER_X_FOR_MENU_ITEMS,
y: TARGET_CENTER_Y_FOR_SELECTED_ITEM - 30,
alpha: 0
});
mainMenuContainer.addChildAt(lockedGraphic, mainMenuContainer.getChildIndex(glass2));
tween(lockedGraphic, {
alpha: 1
}, {
duration: 800,
easing: tween.easeIn
});
LK.setTimeout(function () {
tween(lockedGraphic, {
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
if (lockedGraphic.parent) {
lockedGraphic.destroy();
}
menuTextContainer.visible = true;
tween(menuTextContainer, {
alpha: 1
}, {
duration: 400,
easing: tween.easeIn,
onFinish: function onFinish() {
isLockedBossMessageActive = false;
}
});
}
});
}, 4000);
};
}
mainMenuContainer.addChild(specialBossButtonMainMenu);
layoutAndHighlightFunctionRef();
if (!hasShownInitialMenuAnimation) {
hasShownInitialMenuAnimation = true;
mainMenuContainer.alpha = 0;
menuTextContainer.alpha = 0;
glass.alpha = glassInitialAlpha;
glass2.alpha = 0;
tween(mainMenuContainer, {
alpha: 1
}, {
duration: 1000,
easing: tween.easeLinear
});
tween(glass, {
alpha: 0
}, {
duration: 2000,
delay: 500,
easing: tween.easeLinear
});
tween(glass2, {
alpha: glassFinalAlpha
}, {
duration: 2000,
delay: 500,
easing: tween.easeLinear
});
LK.setTimeout(function () {
if (menuTextContainer && menuTextContainer.parent) {
tween(menuTextContainer, {
alpha: 1
}, {
duration: 800,
easing: tween.easeLinear
});
}
}, 2000);
} else {
mainMenuContainer.alpha = 1;
menuTextContainer.alpha = 1;
glass.alpha = 0;
glass2.alpha = glassFinalAlpha;
}
}
function exitMiniGameAndReturnToMainMenu() {
if (miniGamePlayer && miniGamePlayer.asset && miniGamePlayer.asset.hasOwnProperty('tint')) {
miniGamePlayer.asset.tint = 0xFFFFFF;
}
isMiniGameOver = true;
if (miniGameBackgroundInstance && miniGameBackgroundInstance.parent) {
miniGameBackgroundInstance.visible = false;
}
while (miniGameScreenElements.length > 0) {
var el_exit_mg = miniGameScreenElements.pop();
if (el_exit_mg && el_exit_mg.parent) {
if (el_exit_mg === miniGameBackgroundInstance && miniGameBackgroundInstance && miniGameBackgroundInstance.visible === false) {} else {
el_exit_mg.destroy();
}
}
}
if (miniGameBackgroundInstance && miniGameBackgroundInstance.parent && miniGameBackgroundInstance.visible === false) {} else if (miniGameBackgroundInstance && !miniGameBackgroundInstance.parent) {
miniGameBackgroundInstance = null;
}
miniGamePlayer = null;
miniGameObstacles = [];
if (miniGameScoreText && miniGameScoreText.parent) {
miniGameScoreText.destroy();
}
miniGameScoreText = null;
currentScreenState = 'mainmenu_walkman';
showMainMenu();
}
function spawnMiniGameObstacle() {
// Zmieniona nazwa i usunięte mobki
var now = Date.now();
if (now > lastMiniGameObstacleSpawnTime + MINI_GAME_OBSTACLE_SPAWN_INTERVAL * (0.5 + Math.random())) {
var randomLane = Math.floor(Math.random() * MINI_GAME_NUMBER_OF_LANES);
var obstacleFrames = [LK.getAsset('obstacle_anim_1', {}), LK.getAsset('obstacle_anim_2', {}), LK.getAsset('obstacle_anim_3', {}), LK.getAsset('obstacle_anim_4', {}), LK.getAsset('obstacle_anim_5', {})];
var obstacleAnimation = new SpriteAnimation({
frames: obstacleFrames,
frameDuration: 350,
loop: true,
anchorX: 0.5,
anchorY: 0.5,
x: miniGameViewport.x + miniGameViewport.width + MINI_GAME_OBSTACLE_WIDTH / 2 - 50,
y: MINI_GAME_LANE_Y_POSITIONS[randomLane]
});
var newObstacle = {
x: obstacleAnimation.x,
y: obstacleAnimation.y,
width: MINI_GAME_OBSTACLE_WIDTH,
height: MINI_GAME_OBSTACLE_HEIGHT,
type: 'obstacle',
asset: obstacleAnimation,
scored: false
};
game.addChild(obstacleAnimation);
miniGameScreenElements.push(obstacleAnimation);
miniGameObstacles.push(newObstacle);
lastMiniGameObstacleSpawnTime = now;
// console.log("Spawned obstacle in lane " + randomLane);
}
}
function moveMiniGameObstacles() {
if (!miniGamePlayer || isMiniGameOver) {
return;
}
for (var i = miniGameObstacles.length - 1; i >= 0; i--) {
var obs = miniGameObstacles[i];
obs.x -= currentMiniGameObjectSpeed;
if (obs.asset) {
obs.asset.x = obs.x;
}
if (!obs.scored && obs.x < miniGamePlayer.x - miniGamePlayer.width / 2) {
miniGameScore += 5;
obs.scored = true;
updateMiniGameScoreDisplay();
}
if (obs.x < miniGameViewport.x - obs.width / 2 + 50) {
if (obs.asset && obs.asset.parent) {
obs.asset.destroy();
}
var obsAssetIndex = miniGameScreenElements.indexOf(obs.asset);
if (obsAssetIndex > -1) {
miniGameScreenElements.splice(obsAssetIndex, 1);
}
miniGameObstacles.splice(i, 1);
}
}
}
function updateMiniGameScoreDisplay() {
if (miniGameScoreText) {
miniGameScoreText.setText("Score: " + miniGameScore);
}
}
var allBossData = [];
var currentBossViewStartIndex = 0;
var cardsContainer = null;
var visibleBossCards = [null, null, null, null];
var selectedCardSlotIndex = 0;
var peekingBossCards = [null, null];
var placeholderMusicKey = 'test1';
var placeholderSongMapKey = 'defaultTestTrack';
var visibleBossCards = [null, null];
function initializeBossData() {
allBossData = [{
id: 'boss1',
displayName: 'Boss 1',
cardAssetKey: 'boss1',
musicAssetKey: 'Orctave',
songMapKey: 'OrctaveBossTrack',
defeatsRequired: 0
}, {
id: 'boss2',
displayName: 'Boss 2',
cardAssetKey: 'boss2',
musicAssetKey: 'Goblop',
songMapKey: 'GoblopBossTrack',
defeatsRequired: 0
}, {
id: 'boss3',
displayName: 'Boss 3',
cardAssetKey: 'boss3',
musicAssetKey: 'Noizboy',
songMapKey: 'NoizboyTrack',
defeatsRequired: 0
}, {
id: 'boss4',
displayName: 'Boss 4',
cardAssetKey: 'boss4',
musicAssetKey: placeholderMusicKey,
songMapKey: placeholderSongMapKey,
defeatsRequired: 1
}, {
id: 'boss5',
displayName: 'Boss 5',
cardAssetKey: 'boss5',
musicAssetKey: placeholderMusicKey,
songMapKey: placeholderSongMapKey,
defeatsRequired: 2
}, {
id: 'boss6',
displayName: 'Boss 6',
cardAssetKey: 'boss6',
musicAssetKey: placeholderMusicKey,
songMapKey: placeholderSongMapKey,
defeatsRequired: 3
}, {
id: 'boss7',
displayName: 'Boss 7',
cardAssetKey: 'boss7',
musicAssetKey: placeholderMusicKey,
songMapKey: placeholderSongMapKey,
defeatsRequired: 4
}, {
id: 'boss8',
displayName: 'Boss 8',
cardAssetKey: 'boss8',
musicAssetKey: placeholderMusicKey,
songMapKey: placeholderSongMapKey,
defeatsRequired: 5
}];
var loadedUnlockProgress = storage[BOSS_UNLOCK_KEY];
if (loadedUnlockProgress) {
bossUnlockProgress = loadedUnlockProgress;
for (var i = 0; i < allBossData.length; i++) {
var bossId = allBossData[i].id;
if (!bossUnlockProgress.hasOwnProperty(bossId)) {
bossUnlockProgress[bossId] = false;
}
}
} else {
bossUnlockProgress = {};
for (var j = 0; j < allBossData.length; j++) {
bossUnlockProgress[allBossData[j].id] = false;
}
}
}
function updateSelectedCardVisual() {
for (var i = 0; i < visibleBossCards.length; i++) {
var cardContainer = visibleBossCards[i];
if (cardContainer && cardContainer.visualAsset) {
if (i === selectedCardSlotIndex) {
cardContainer.visualAsset.tint = 0xFFFF00;
cardContainer.scale.set(1.05);
} else {
cardContainer.visualAsset.tint = 0xFFFFFF;
cardContainer.scale.set(1.0);
}
}
}
}
function displayBossCards(newStartIndex, isInitialDisplay, numberOfDefeated) {
currentBossViewStartIndex = newStartIndex;
var singleCardDisplayWidth = 400;
var singleCardDisplayHeight = 380;
var spacingBetweenCardsX = 80;
var cardSlotX_0 = singleCardDisplayWidth / 2;
var cardSlotX_1 = singleCardDisplayWidth * 1.5 + spacingBetweenCardsX;
var mainCardsCenterY_relative = singleCardDisplayHeight / 2;
var peekingCardVisibleSliceHeight = 80;
var verticalOffsetMainToPeeking = 140;
var mainCardSlotsPositions = [{
x: cardSlotX_0,
y: mainCardsCenterY_relative
}, {
x: cardSlotX_1,
y: mainCardsCenterY_relative
}];
var peekingCardsTopY_relative = mainCardsCenterY_relative + singleCardDisplayHeight / 2 + verticalOffsetMainToPeeking;
var peekingCardSlotsPositions = [{
x: cardSlotX_0,
y: peekingCardsTopY_relative
}, {
x: cardSlotX_1,
y: peekingCardsTopY_relative
}];
if (!cardsContainer) {
return;
}
while (cardsContainer.children[0]) {
cardsContainer.removeChild(cardsContainer.children[0]).destroy();
}
visibleBossCards = [null, null];
peekingBossCards = [null, null];
for (var i = 0; i < 2; i++) {
var dataIndex = currentBossViewStartIndex + i;
if (dataIndex < allBossData.length) {
var bossData = allBossData[dataIndex];
var cardContainer = new Container();
cardContainer.x = mainCardSlotsPositions[i].x;
cardContainer.y = mainCardSlotsPositions[i].y;
cardContainer.bossData = bossData;
cardContainer.slotIndex = i;
var cardAsset = LK.getAsset(bossData.cardAssetKey, {});
cardAsset.anchor.set(0.5, 0.5);
cardAsset.width = singleCardDisplayWidth;
cardAsset.height = singleCardDisplayHeight;
cardContainer.visualAsset = cardAsset;
cardContainer.addChild(cardAsset);
var isUnlocked = bossData.defeatsRequired === 0 || numberOfDefeated >= bossData.defeatsRequired;
bossData.isUnlocked = isUnlocked;
cardContainer.interactive = true;
cardContainer.cursor = "pointer";
cardContainer.down = function () {
selectedCardSlotIndex = this.slotIndex;
updateSelectedCardVisual();
};
cardsContainer.addChild(cardContainer);
visibleBossCards[i] = cardContainer;
}
}
for (var j = 0; j < 2; j++) {
var peekingDataIndex = currentBossViewStartIndex + 2 + j;
if (peekingDataIndex < allBossData.length) {
var peekingBossData = allBossData[peekingDataIndex];
var peekingCardContainer = new Container();
peekingCardContainer.x = peekingCardSlotsPositions[j].x;
peekingCardContainer.y = peekingCardSlotsPositions[j].y;
var peekingCardAsset = LK.getAsset(peekingBossData.cardAssetKey, {});
peekingCardAsset.anchor.set(0.5, 0);
peekingCardAsset.width = singleCardDisplayWidth;
peekingCardAsset.height = singleCardDisplayHeight;
peekingCardContainer.addChild(peekingCardAsset);
peekingCardContainer.interactive = false;
cardsContainer.addChild(peekingCardContainer);
peekingBossCards[j] = peekingCardContainer;
}
}
if (isInitialDisplay) {
selectedCardSlotIndex = 0;
} else {
var maxSlotOnNewPage = Math.min(1, allBossData.length - 1 - currentBossViewStartIndex);
if (selectedCardSlotIndex > maxSlotOnNewPage) {
selectedCardSlotIndex = maxSlotOnNewPage;
}
}
updateSelectedCardVisual();
}
function getNumberOfDefeatedBosses() {
var count = 0;
for (var i = 0; i < allBossData.length; i++) {
// Zakładamy, że allBossData zawiera tylko standardowych bossów (1-8)
var bossId = allBossData[i].id;
if (bossUnlockProgress.hasOwnProperty(bossId) && bossUnlockProgress[bossId] === true) {
count++;
}
}
return count;
}
function showBossSelectionScreen() {
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
songSummaryContainer = null;
}
currentScreenState = 'bossGallery_paged';
if (gameUIContainer) {
gameUIContainer.visible = false;
}
if (staticHitFrame) {
staticHitFrame.visible = false;
}
if (staticPerfectLine) {
staticPerfectLine.visible = false;
}
if (shieldTimerDisplayContainer) {
shieldTimerDisplayContainer.visible = false;
}
if (swipeToTapTimerDisplayContainer) {
swipeToTapTimerDisplayContainer.visible = false;
}
initializeBossData();
var numberOfDefeated = getNumberOfDefeatedBosses();
var screenElements = [];
var tempSingleCardDisplayWidth = 400;
var tempSingleCardDisplayHeight = 380;
var tempSpacingBetweenCardsX = 80;
var tempGroupHorizontalOffset = -60;
var tempGroupVerticalOffset = -90;
var screenAreaContentWidth = tempSingleCardDisplayWidth * 2 + tempSpacingBetweenCardsX;
var screenAreaX = (gameScreenWidth - screenAreaContentWidth) / 2 + tempGroupHorizontalOffset;
var screenAreaY = gameScreenHeight / 2 + tempGroupVerticalOffset - tempSingleCardDisplayHeight / 2;
if (cardsContainer && cardsContainer.parent) {
cardsContainer.destroy();
}
cardsContainer = new Container();
cardsContainer.x = screenAreaX;
cardsContainer.y = screenAreaY;
game.addChild(cardsContainer);
screenElements.push(cardsContainer);
displayBossCards(0, true, numberOfDefeated);
var glassAsset = LK.getAsset('glass2', {
x: 324,
y: 886,
width: 1180,
height: 1300,
alpha: 0.4,
interactive: false
});
game.addChild(glassAsset);
screenElements.push(glassAsset);
var galleryBg = LK.getAsset('galleryBackground', {
width: gameScreenWidth,
height: gameScreenHeight,
x: 0,
y: 0
});
game.addChild(galleryBg);
screenElements.push(galleryBg);
var upButton = LK.getAsset('upbutton', {});
upButton.x = 210;
upButton.y = gameScreenHeight / 2 - 180;
upButton.anchor.set(0.5, 0.5);
upButton.interactive = true;
upButton.cursor = "pointer";
upButton.down = function () {
var newStartIndex = currentBossViewStartIndex - 2;
if (newStartIndex < 0) {
newStartIndex = 0;
}
if (newStartIndex !== currentBossViewStartIndex) {
displayBossCards(newStartIndex, false, numberOfDefeated);
}
};
game.addChild(upButton);
screenElements.push(upButton);
var downButton = LK.getAsset('downbutton', {});
downButton.x = 210;
downButton.y = gameScreenHeight / 2 + 220;
downButton.anchor.set(0.5, 0.5);
downButton.interactive = true;
downButton.cursor = "pointer";
downButton.down = function () {
var newStartIndex = currentBossViewStartIndex + 2;
if (newStartIndex < allBossData.length) {
displayBossCards(newStartIndex, false, numberOfDefeated);
}
};
game.addChild(downButton);
screenElements.push(downButton);
var playButton = LK.getAsset('play', {});
playButton.x = gameScreenWidth - 350;
playButton.y = gameScreenHeight / 2 - 240;
playButton.anchor.set(0.5, 0.5);
playButton.interactive = true;
playButton.cursor = "pointer";
playButton.down = function () {
var selectedBossDataIndex = currentBossViewStartIndex + selectedCardSlotIndex;
if (selectedBossDataIndex < allBossData.length) {
var bossData = allBossData[selectedBossDataIndex];
if (bossData.musicAssetKey) {
setMusic(bossData.musicAssetKey);
}
}
};
game.addChild(playButton);
screenElements.push(playButton);
var stopButton = LK.getAsset('stop', {});
stopButton.x = gameScreenWidth - 350;
stopButton.y = gameScreenHeight / 2;
stopButton.anchor.set(0.5, 0.5);
stopButton.interactive = true;
stopButton.cursor = "pointer";
stopButton.down = function () {
setMusic(null);
};
game.addChild(stopButton);
screenElements.push(stopButton);
var fightButton = LK.getAsset('fight', {});
fightButton.x = gameScreenWidth - 350;
fightButton.y = gameScreenHeight / 2 + 240;
fightButton.anchor.set(0.5, 0.5);
fightButton.interactive = true;
fightButton.cursor = "pointer";
fightButton.down = function () {
setMusic(null);
var selectedDataIndex = currentBossViewStartIndex + selectedCardSlotIndex;
if (selectedDataIndex < allBossData.length) {
var selectedBoss = allBossData[selectedDataIndex];
if (selectedBoss && selectedBoss.isUnlocked) {
var bossIdNumber = parseInt(selectedBoss.id.replace('boss', ''), 10);
if (bossIdNumber >= 4) {
showTemporaryMessage("Soon on update", 1500, {
size: 80,
fill: 0xFFD700
});
} else {
screenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
screenElements = [];
if (cardsContainer && cardsContainer.parent) {
cardsContainer.destroy();
cardsContainer = null;
}
loadSong(selectedBoss.songMapKey);
}
}
}
};
game.addChild(fightButton);
screenElements.push(fightButton);
var actualDefeatedCount = getNumberOfDefeatedBosses();
var allStandardBossesDefeated = allBossData.length > 0 && actualDefeatedCount === allBossData.length;
var specialBossButtonAssetKey = allStandardBossesDefeated ? 'specialboss_unlocked' : 'specialboss_locked';
var specialBossButton = LK.getAsset(specialBossButtonAssetKey, {});
specialBossButton.width = 250;
var originalAssetWidthForRatioSB = 300;
var originalAssetHeightUnlockedSB = 250;
var originalAssetHeightLockedSB = 250;
specialBossButton.height = (specialBossButtonAssetKey === 'specialboss_unlocked' ? originalAssetHeightUnlockedSB : originalAssetHeightLockedSB) * (specialBossButton.width / originalAssetWidthForRatioSB);
specialBossButton.x = 950;
specialBossButton.y = 2030;
specialBossButton.anchor.set(0.5, 0.5);
specialBossButton.interactive = true;
if (allStandardBossesDefeated) {
specialBossButton.cursor = "pointer";
specialBossButton.down = function () {};
} else {
specialBossButton.cursor = "default";
specialBossButton.down = function () {
if (isLockedBossMessageActive) {
return;
}
isLockedBossMessageActive = true;
tween(cardsContainer, {
alpha: 0
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
cardsContainer.visible = false;
}
});
var centerX = 380 + 1150 / 2;
var centerY = 1020 + 890 / 2;
var lockedGraphic = LK.getAsset('silasLockedMessage', {
anchorX: 0.5,
anchorY: 0.5,
x: centerX,
y: centerY - 90,
alpha: 0
});
game.addChildAt(lockedGraphic, game.getChildIndex(glassAsset));
tween(lockedGraphic, {
alpha: 1
}, {
duration: 800,
easing: tween.easeIn
});
LK.setTimeout(function () {
tween(lockedGraphic, {
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
if (lockedGraphic.parent) {
lockedGraphic.destroy();
}
cardsContainer.visible = true;
tween(cardsContainer, {
alpha: 1
}, {
duration: 400,
easing: tween.easeIn,
onFinish: function onFinish() {
isLockedBossMessageActive = false;
}
});
}
});
}, 4000);
};
}
game.addChild(specialBossButton);
screenElements.push(specialBossButton);
var rewindButton = LK.getAsset('rewindbutton', {});
rewindButton.x = 350;
rewindButton.y = gameScreenHeight / 2 + 650;
rewindButton.anchorX = 0.5;
rewindButton.anchorY = 0.5;
rewindButton.interactive = true;
rewindButton.cursor = "pointer";
rewindButton.down = function () {
setMusic('introMusic');
screenElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
screenElements = [];
if (cardsContainer && cardsContainer.parent) {
cardsContainer.destroy();
cardsContainer = null;
}
currentBossViewStartIndex = 0;
selectedCardSlotIndex = 0;
showMainMenu();
};
game.addChild(rewindButton);
screenElements.push(rewindButton);
}
function displayStatsForBoss(bossIndex) {
console.log("--- displayStatsForBoss called for index: " + bossIndex + " ---");
while (currentBossDisplayElements.length > 0) {
var el = currentBossDisplayElements.pop();
if (el && el.parent) {
el.destroy();
}
}
if (bossIndex < 0 || bossIndex >= allBossData.length) {
console.error("Invalid bossIndex for stats: " + bossIndex);
return;
}
var bossData = allBossData[bossIndex];
if (!bossData) {
console.error("No bossData found for index: " + bossIndex);
return;
}
console.log("Displaying stats for boss: " + bossData.displayName);
var viewport = miniGameViewport;
var padding = 40;
var bossStatDetailsContainer = new Container();
bossStatDetailsContainer.x = viewport.x;
bossStatDetailsContainer.y = viewport.y + 60 + 80;
game.addChild(bossStatDetailsContainer);
currentBossDisplayElements.push(bossStatDetailsContainer);
var bossImageWidth = viewport.width * 0.35;
var bossImageHeight = (viewport.height - (viewport.y + 60 + 80 - bossStatDetailsContainer.y)) * 0.7;
if (bossImageHeight > bossImageWidth * 1.5) {
bossImageHeight = bossImageWidth * 1.5;
}
var bossImageX = padding + bossImageWidth / 2;
var bossImageY = padding + bossImageHeight / 2;
var bossAssetKeyToDisplay = bossData.cardAssetKey;
if (!bossAssetKeyToDisplay) {
console.warn("Boss " + bossData.displayName + " has an empty cardAssetKey. Using placeholder.");
bossAssetKeyToDisplay = 'statsBossPlaceholder';
}
var bossImage = LK.getAsset(bossAssetKeyToDisplay, {
anchorX: 0.5,
anchorY: 0.5,
x: bossImageX,
y: bossImageY,
width: bossImageWidth,
height: bossImageHeight
});
bossStatDetailsContainer.addChild(bossImage);
console.log("Boss image: " + bossAssetKeyToDisplay + " at x=" + bossImageX + ", y=" + bossImageY);
// B. Teksty statystyk
var statsTextX = bossImageX + bossImageWidth / 2 + 40; // Zwiększony odstęp od obrazka
var currentTextY = padding + 30; // Startowa pozycja Y dla pierwszego tekstu statystyk (Best Score)
// Możesz dostosować tę wartość, aby ładnie pasowała pod/obok obrazka
var valueFontSize = 65; // Zwiększyłem trochę rozmiar dla wartości statystyk
var lineSpacing = 115; // Zwiększyłem trochę odstęp między liniami
var statsMaxWidth = viewport.width - statsTextX - padding * 1.5;
var songStats = getSongStats(bossData.songMapKey);
var bestScore = songStats.bestScore;
var bestCombo = songStats.bestCombo;
var defeatedStatus = bossUnlockProgress[bossData.id] ? "YES" : "NO";
var defeatedColor = bossUnlockProgress[bossData.id] ? 0x32CD32 : 0xFF4500;
console.log("Stats values - Score: " + bestScore + ", Combo: " + bestCombo + ", Defeated: " + defeatedStatus);
// Usunięto wyświetlanie "nameText" (nazwy bossa)
// Best Score - teraz jako pierwszy tekst
var scoreText = new Text2("Best Score: " + bestScore, {
size: valueFontSize,
fill: 0xFFFFFF,
align: 'left',
wordWrap: true,
wordWrapWidth: statsMaxWidth
});
scoreText.anchor.set(0, 0);
scoreText.x = statsTextX;
scoreText.y = currentTextY;
bossStatDetailsContainer.addChild(scoreText);
currentTextY += valueFontSize + 65; // Odstęp pod Best Score (dostosuj)
// Best Combo
var comboText = new Text2("Best Combo: " + bestCombo, {
size: valueFontSize,
fill: 0xFFFFFF,
align: 'left',
wordWrap: true,
wordWrapWidth: statsMaxWidth
});
comboText.anchor.set(0, 0);
comboText.x = statsTextX;
comboText.y = currentTextY;
bossStatDetailsContainer.addChild(comboText);
currentTextY += valueFontSize + 65; // Odstęp pod Best Combo (dostosuj)
// Boss Defeated
var defeatedText = new Text2("Defeated: ", {
size: valueFontSize,
fill: 0xFFFFFF,
align: 'left'
});
defeatedText.anchor.set(0, 0);
defeatedText.x = statsTextX;
defeatedText.y = currentTextY;
bossStatDetailsContainer.addChild(defeatedText);
var defeatedValue = new Text2(defeatedStatus, {
size: valueFontSize,
fill: defeatedColor,
align: 'left'
});
defeatedValue.anchor.set(0, 0);
defeatedValue.x = statsTextX + defeatedText.width + 10;
defeatedValue.y = currentTextY;
bossStatDetailsContainer.addChild(defeatedValue);
console.log("Stat texts (without boss name) added to container.");
}
function createPlayerHUD() {
if (playerHUD && playerHUD.parent) {
playerHUD.destroy();
}
playerHUD = new Container();
playerHUD.alpha = 0;
playerHUD.visible = false;
gameUIContainer.addChild(playerHUD);
var bg = playerHUD.addChild(LK.getAsset('playerHudBgAsset', {
anchorX: 0.5,
anchorY: 1,
x: gameScreenWidth / 2,
y: 2950,
width: 900,
height: 500,
alpha: 1
}));
playerHpBarFill = playerHUD.addChild(LK.getAsset('playerHpFill', {
width: hpBarWidth,
height: hpBarHeight,
anchorX: 0,
anchorY: 0.5,
x: PLAYER_HP_BAR_X - hpBarWidth / 2,
y: PLAYER_HP_BAR_Y
}));
var shieldFrames = [];
for (var i = 1; i <= 11; i++) {
shieldFrames.push(LK.getAsset('shield' + i, {}));
}
playerShieldAnimation = new SpriteAnimation({
frames: shieldFrames,
frameDuration: 100,
loop: true,
anchorX: 0.5,
anchorY: 0.5,
x: gameScreenWidth / 2,
y: 2700
});
playerShieldAnimation.rotation = Math.PI / 2;
playerShieldAnimation.visible = false;
playerHUD.addChild(playerShieldAnimation);
}
function createBossHUD() {
if (bossHUD && bossHUD.parent) {
bossHUD.destroy();
}
bossHUD = new Container();
bossHUD.alpha = 0;
bossHUD.visible = false;
gameUIContainer.addChild(bossHUD);
var bg = bossHUD.addChild(LK.getAsset('bossHudBgAsset', {
anchorX: 0.5,
anchorY: 0,
x: gameScreenWidth / 2,
y: -200,
width: 900,
height: 500,
alpha: 0.8
}));
bossHpBarFill = bossHUD.addChild(LK.getAsset('bossHpFill', {
width: 600,
height: 100,
anchorX: 0,
anchorY: 0.5,
x: BOSS_HP_BAR_X - hpBarWidth / 2,
y: BOSS_HP_BAR_Y
}));
}
function showMiniGameScreen() {
currentScreenState = 'miniGameActive';
isMiniGameOver = false;
miniGameScore = 0;
miniGameObstacles = [];
while (miniGameScreenElements.length > 0) {
var el_mg_clear = miniGameScreenElements.pop();
if (el_mg_clear && el_mg_clear.parent) {
el_mg_clear.destroy();
}
}
if (miniGamePlayer && miniGamePlayer.asset && miniGamePlayer.asset.parent) {
miniGamePlayer.asset.destroy();
}
miniGamePlayer = null;
if (miniGameScoreText && miniGameScoreText.parent) {
miniGameScoreText.destroy();
}
miniGameScoreText = null;
setMusic('rollsouls');
if (!miniGameBackgroundInstance || !miniGameBackgroundInstance.parent) {
miniGameBackgroundInstance = LK.getAsset('miniGameRollSoulsBg', {});
if (miniGameBackgroundInstance) {
var faktorSkali = 0.8;
var nowaSzerokoscTla = miniGameViewport.width * faktorSkali;
var nowaWysokoscTla = miniGameViewport.height * faktorSkali;
miniGameBackgroundInstance.width = nowaSzerokoscTla;
miniGameBackgroundInstance.height = nowaWysokoscTla;
miniGameBackgroundInstance.x = miniGameViewport.x + (miniGameViewport.width - nowaSzerokoscTla) / 2;
miniGameBackgroundInstance.y = miniGameViewport.y + (miniGameViewport.height - nowaWysokoscTla) / 2;
game.addChild(miniGameBackgroundInstance);
}
}
if (miniGameBackgroundInstance) {
miniGameBackgroundInstance.visible = true;
miniGameBackgroundInstance.alpha = 0.7;
if (!miniGameScreenElements.includes(miniGameBackgroundInstance)) {
miniGameScreenElements.push(miniGameBackgroundInstance);
}
}
MINI_GAME_LANE_HEIGHT = miniGameViewport.height / MINI_GAME_NUMBER_OF_LANES;
MINI_GAME_LANE_Y_POSITIONS = [];
for (var lane_idx = 0; lane_idx < MINI_GAME_NUMBER_OF_LANES; lane_idx++) {
MINI_GAME_LANE_Y_POSITIONS.push(miniGameViewport.y + lane_idx * MINI_GAME_LANE_HEIGHT + MINI_GAME_LANE_HEIGHT / 2);
}
var playerFrames = [LK.getAsset('player_anim_1', {}), LK.getAsset('player_anim_2', {}), LK.getAsset('player_anim_3', {})];
var playerAnimation = new SpriteAnimation({
frames: playerFrames,
frameDuration: 350,
loop: true,
anchorX: 0.5,
anchorY: 0.5
});
miniGamePlayer = {
lane: 1,
y: MINI_GAME_LANE_Y_POSITIONS[1],
x: miniGameViewport.x + 100,
width: 50,
height: 50,
asset: playerAnimation
};
playerAnimation.x = miniGamePlayer.x;
playerAnimation.y = miniGamePlayer.y;
game.addChild(playerAnimation);
miniGameScreenElements.push(playerAnimation);
var scoreTextInstance = new Text2("Score: 0", {
size: 40,
fill: 0xFFFFFF,
align: 'left'
});
scoreTextInstance.anchor.set(0, 0);
scoreTextInstance.x = miniGameViewport.x + 20;
scoreTextInstance.y = miniGameViewport.y + 20;
game.addChild(scoreTextInstance);
miniGameScreenElements.push(scoreTextInstance);
miniGameScoreText = scoreTextInstance;
lastMiniGameObstacleSpawnTime = Date.now();
currentMiniGameObjectSpeed = MINI_GAME_OBJECT_SPEED;
miniGameTimeActive = 0;
var glassAssetFromMainMenu = null;
for (var i_glass = 0; i_glass < mainMenuScreenElements.length; i_glass++) {
var el_glass_check = mainMenuScreenElements[i_glass];
if (el_glass_check && el_glass_check.x === miniGameViewport.x && el_glass_check.y === miniGameViewport.y && el_glass_check.width === miniGameViewport.width && el_glass_check.height === miniGameViewport.height && el_glass_check.alpha && Math.abs(el_glass_check.alpha - 0.3) < 0.01) {
glassAssetFromMainMenu = el_glass_check;
break;
}
}
if (glassAssetFromMainMenu && glassAssetFromMainMenu.parent) {
var parentContainer = glassAssetFromMainMenu.parent;
parentContainer.removeChild(glassAssetFromMainMenu);
parentContainer.addChild(glassAssetFromMainMenu);
}
var rewindButtonMiniGame = LK.getAsset('rewindbutton', {
x: 350,
y: gameScreenHeight / 2 + 650,
anchorX: 0.5,
anchorY: 0.5,
interactive: true,
cursor: "pointer"
});
rewindButtonMiniGame.down = function () {
exitMiniGameAndReturnToMainMenu();
};
game.addChild(rewindButtonMiniGame);
miniGameScreenElements.push(rewindButtonMiniGame);
}
function showStatsScreen() {
console.log("Showing Stats Screen - Full Setup");
while (statsScreenElements.length > 0) {
var el = statsScreenElements.pop();
if (el && el.parent) {
el.destroy();
}
}
while (currentBossDisplayElements.length > 0) {
var cbdEl = currentBossDisplayElements.pop();
if (cbdEl && cbdEl.parent) {
cbdEl.destroy();
}
}
initializeBossData(); // <<<< DODAJ TĘ LINIĘ NA POCZĄTKU FUNKCJI
currentScreenState = 'statsScreen';
currentStatsBossIndex = 0;
var walkmanFrameStats = LK.getAsset('mainmenu', {
x: 0,
y: 0,
width: gameScreenWidth,
height: gameScreenHeight
});
game.addChild(walkmanFrameStats);
statsScreenElements.push(walkmanFrameStats);
var glassStats = LK.getAsset('glass2', {
x: miniGameViewport.x,
y: miniGameViewport.y,
width: miniGameViewport.width,
height: miniGameViewport.height,
alpha: 0.15,
interactive: false
});
game.addChild(glassStats);
statsScreenElements.push(glassStats);
var statsTitle = new Text2("PLAYER STATS", {
size: 60,
fill: 0xFFFFFF,
align: 'center',
stroke: 0x000000,
strokeThickness: 4
});
statsTitle.anchor.set(0.5, 0.5);
statsTitle.x = miniGameViewport.x + miniGameViewport.width / 2;
statsTitle.y = miniGameViewport.y + 100;
game.addChild(statsTitle);
statsScreenElements.push(statsTitle);
displayStatsForBoss(currentStatsBossIndex);
// Przyciski nawigacyjne dla ekranu Stats
var upButtonStats = LK.getAsset('upbutton', {});
upButtonStats.x = 210;
upButtonStats.y = gameScreenHeight / 2 - 180;
upButtonStats.anchor.set(0.5, 0.5);
upButtonStats.interactive = true;
upButtonStats.cursor = "pointer";
upButtonStats.down = function () {
if (currentStatsBossIndex > 0) {
currentStatsBossIndex--;
displayStatsForBoss(currentStatsBossIndex);
}
};
game.addChild(upButtonStats);
statsScreenElements.push(upButtonStats);
var downButtonStats = LK.getAsset('downbutton', {});
downButtonStats.x = 210;
downButtonStats.y = gameScreenHeight / 2 + 220;
downButtonStats.anchor.set(0.5, 0.5);
downButtonStats.interactive = true;
downButtonStats.cursor = "pointer";
downButtonStats.down = function () {
if (currentStatsBossIndex < allBossData.length - 1) {
currentStatsBossIndex++;
displayStatsForBoss(currentStatsBossIndex);
}
};
game.addChild(downButtonStats);
statsScreenElements.push(downButtonStats);
var rewindButtonStats = LK.getAsset('rewindbutton', {
x: 350,
y: gameScreenHeight / 2 + 650,
anchorX: 0.5,
anchorY: 0.5,
interactive: true,
cursor: "pointer"
});
rewindButtonStats.down = function () {
console.log("Rewind button pressed: Exiting Stats screen.");
while (statsScreenElements.length > 0) {
var elToDestroyStats = statsScreenElements.pop();
if (elToDestroyStats && elToDestroyStats.parent) {
elToDestroyStats.destroy();
}
}
while (currentBossDisplayElements.length > 0) {
var cbdElExit = currentBossDisplayElements.pop(); // Zmieniona nazwa zmiennej
if (cbdElExit && cbdElExit.parent) {
cbdElExit.destroy();
}
}
showMainMenu();
};
game.addChild(rewindButtonStats);
statsScreenElements.push(rewindButtonStats);
var playButtonStats = LK.getAsset('play', {});
playButtonStats.x = gameScreenWidth - 350;
playButtonStats.y = gameScreenHeight / 2 - 240;
playButtonStats.anchor.set(0.5, 0.5);
playButtonStats.interactive = false;
playButtonStats.alpha = 0.5;
game.addChild(playButtonStats);
statsScreenElements.push(playButtonStats);
var stopButtonStats = LK.getAsset('stop', {});
stopButtonStats.x = gameScreenWidth - 350;
stopButtonStats.y = gameScreenHeight / 2;
stopButtonStats.anchor.set(0.5, 0.5);
stopButtonStats.interactive = false;
stopButtonStats.alpha = 0.5;
game.addChild(stopButtonStats);
statsScreenElements.push(stopButtonStats);
var fightButtonStats = LK.getAsset('fight', {});
fightButtonStats.x = gameScreenWidth - 350;
fightButtonStats.y = gameScreenHeight / 2 + 240;
fightButtonStats.anchor.set(0.5, 0.5);
fightButtonStats.interactive = false;
fightButtonStats.alpha = 0.5;
game.addChild(fightButtonStats);
statsScreenElements.push(fightButtonStats);
}
function showEndlessIntro() {
var introElements = [];
var localIntroTimers = [];
var introArrowObject = null;
var isWaitingForUserClick = false;
var comicPanelsContainer = null;
var skipButton = null;
function clearLocalIntroTimers(clearArrowPulse) {
localIntroTimers.forEach(function (timerId) {
if (timerId) {
LK.clearTimeout(timerId);
}
});
localIntroTimers = [];
if (clearArrowPulse && introArrowObject && introArrowObject.pulseTimerId) {
LK.clearTimeout(introArrowObject.pulseTimerId);
introArrowObject.pulseTimerId = null;
}
}
currentScreenState = 'intro_endless';
game.setBackgroundColor(0x000000);
comicPanelsContainer = new Container();
game.addChild(comicPanelsContainer);
introElements.push(comicPanelsContainer);
skipButton = new Text2("SKIP", {
size: 60,
fill: 0xBBBBBB,
align: 'right'
});
skipButton.anchor.set(1, 0);
skipButton.x = gameScreenWidth - 40;
skipButton.y = 40;
skipButton.interactive = true;
skipButton.cursor = "pointer";
game.addChild(skipButton);
introElements.push(skipButton);
skipButton.down = function () {
if (currentScreenState === 'intro_endless') {
endEndlessIntroAndStartGame();
}
};
var panelWidth = gameScreenWidth * 0.85;
var panelHeight = gameScreenHeight / 3 - 60;
var panelX = gameScreenWidth / 2;
var panelPositions = [{
x: panelX,
y: panelHeight / 2 + 40,
width: panelWidth,
height: panelHeight
}, {
x: panelX,
y: panelHeight * 1.5 + 60,
width: panelWidth,
height: panelHeight
}, {
x: panelX,
y: panelHeight * 2.5 + 80,
width: panelWidth,
height: panelHeight
}];
var endlessIntroAssetKeys = ['endless_intro_1', 'endless_intro_2', 'endless_intro_3', 'endless_intro_4', 'endless_intro_5', 'endless_intro_6'];
var introArrowAssetKey = 'intro_arrow_down';
var activePanelObjects = [];
function endEndlessIntroAndStartGame() {
if (currentScreenState !== 'intro_endless' && currentScreenState !== 'transitioning_to_endless') {
return;
}
currentScreenState = 'transitioning_to_endless';
clearLocalIntroTimers(true);
isWaitingForUserClick = false;
var elementsToFade = introElements.slice();
var fadedCount = 0;
var totalToFade = elementsToFade.length;
var onAllFadedOut = function onAllFadedOut() {
elementsToFade.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
introElements = [];
activePanelObjects = [];
comicPanelsContainer = null;
skipButton = null;
introArrowObject = null;
initializeEndlessGameplay();
};
if (totalToFade === 0) {
onAllFadedOut();
return;
}
elementsToFade.forEach(function (el) {
tween(el, {
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
fadedCount++;
if (fadedCount === totalToFade) {
onAllFadedOut();
}
}
});
});
}
function displayPanelWithFadeIn(assetKey, positionConfig, durationMs, callback) {
if (currentScreenState !== 'intro_endless' || !comicPanelsContainer) {
return;
}
var panel = LK.getAsset(assetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: positionConfig.x,
y: positionConfig.y,
width: positionConfig.width,
height: positionConfig.height,
alpha: 0
});
comicPanelsContainer.addChild(panel);
activePanelObjects.push(panel);
tween(panel, {
alpha: 1
}, {
duration: durationMs,
easing: tween.linear,
onFinish: function onFinish() {
if (callback && currentScreenState === 'intro_endless') {
callback();
}
}
});
}
function hideAndDestroyPanels(panelsToProcess, durationMs, callback) {
var panelsToFade = panelsToProcess.slice();
activePanelObjects = [];
if (currentScreenState !== 'intro_endless' && panelsToFade.length > 0) {
panelsToFade.forEach(function (p) {
if (p && p.parent) {
p.destroy();
}
});
if (callback) {
callback();
}
return;
}
if (panelsToFade.length === 0) {
if (callback) {
callback();
}
return;
}
var fadedCount = 0;
panelsToFade.forEach(function (p) {
if (p && p.parent) {
tween(p, {
alpha: 0
}, {
duration: durationMs,
easing: tween.linear,
onFinish: function onFinish() {
if (p.parent) {
p.destroy();
}
fadedCount++;
if (fadedCount === panelsToFade.length && callback && currentScreenState === 'intro_endless') {
callback();
}
}
});
} else {
fadedCount++;
if (fadedCount === panelsToFade.length && callback && currentScreenState === 'intro_endless') {
callback();
}
}
});
}
function showArrowAndAwaitClick(actionOnClick) {
if (currentScreenState !== 'intro_endless') {
return;
}
isWaitingForUserClick = true;
introArrowObject = LK.getAsset(introArrowAssetKey, {
anchorX: 0.5,
anchorY: 1,
x: gameScreenWidth / 2,
y: gameScreenHeight - 30,
alpha: 0,
interactive: true,
cursor: "pointer"
});
game.addChild(introArrowObject);
introElements.push(introArrowObject);
tween(introArrowObject, {
alpha: 1
}, {
duration: 500
});
introArrowObject.down = function () {
if (isWaitingForUserClick && currentScreenState === 'intro_endless') {
isWaitingForUserClick = false;
var self = this;
tween(this, {
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
if (self.parent) {
self.destroy();
}
}
});
clearLocalIntroTimers(false);
actionOnClick();
}
};
}
function proceedToEndlessPhase2() {
if (currentScreenState !== 'intro_endless') {
return;
}
hideAndDestroyPanels(activePanelObjects.slice(), 800, function () {
if (currentScreenState !== 'intro_endless') {
return;
}
displayPanelWithFadeIn(endlessIntroAssetKeys[3], panelPositions[0], 800, function () {
localIntroTimers.push(LK.setTimeout(function () {
displayPanelWithFadeIn(endlessIntroAssetKeys[4], panelPositions[1], 800, function () {
localIntroTimers.push(LK.setTimeout(function () {
displayPanelWithFadeIn(endlessIntroAssetKeys[5], panelPositions[2], 800, function () {
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState === 'intro_endless') {
endEndlessIntroAndStartGame();
}
}, 3000));
});
}, 3000));
});
}, 3000));
});
});
}
// Start Phase 1
displayPanelWithFadeIn(endlessIntroAssetKeys[0], panelPositions[0], 800, function () {
localIntroTimers.push(LK.setTimeout(function () {
displayPanelWithFadeIn(endlessIntroAssetKeys[1], panelPositions[1], 800, function () {
localIntroTimers.push(LK.setTimeout(function () {
displayPanelWithFadeIn(endlessIntroAssetKeys[2], panelPositions[2], 800, function () {
showArrowAndAwaitClick(proceedToEndlessPhase2);
});
}, 3000));
});
}, 3000));
});
}
// Musimy też dodać tę pustą funkcję, aby uniknąć błędu.
// W niej zbudujemy logikę ładowania tła, muzyki i generatora.
function initializeEndlessGameplay() {
console.log("Intro skończone, uruchamiam rozgrywkę Endless...");
currentScreenState = 'endlessLoopActive';
gameStartTime = Date.now();
endlessTimelineTime = 0;
currentEndlessDifficulty = 0.1;
if (gameplayBackground && gameplayBackground.parent) {
gameplayBackground.destroy();
}
gameplayBackground = LK.getAsset('endless_background_asset', {
x: 0,
y: 0,
width: gameScreenWidth,
height: gameScreenHeight,
alpha: 0.8
});
game.addChildAt(gameplayBackground, 0);
resetGameState();
currentActiveRhythmMap = [];
createPlayerHUD();
playerCurrentHP = playerMaxHP;
updatePlayerHpDisplay();
if (gameUIContainer) {
gameUIContainer.visible = true;
}
if (playerHUD) {
playerHUD.visible = true;
tween(playerHUD, {
alpha: 1
}, {
duration: 500
});
}
if (bossHUD) {
bossHUD.visible = false;
}
if (scoreTxt) {
scoreTxt.visible = true;
}
if (comboTxt) {
comboTxt.visible = true;
}
setupGameplayElements();
if (staticHitFrame) {
staticHitFrame.visible = true;
}
if (staticPerfectLine) {
staticPerfectLine.visible = true;
}
currentEndlessSongIndex = 0;
LK.setTimeout(function () {
playNextEndlessSong();
}, 7000);
}
function playNextEndlessSong() {
var songKey = endlessSongs[currentEndlessSongIndex];
var musicAsset = LK.getSound(songKey);
var bpm = 120;
console.log("Endless Loop: Odtwarzam " + songKey + " | Trudność: " + currentEndlessDifficulty.toFixed(2));
var songDuration = musicAsset.duration || 60;
var newNotes = generateProceduralRhythmMap(songDuration, currentEndlessDifficulty, bpm);
currentActiveRhythmMap = currentActiveRhythmMap.concat(newNotes);
setMusic(songKey);
currentEndlessSongIndex = (currentEndlessSongIndex + 1) % endlessSongs.length;
}
function generateProceduralRhythmMap(durationSeconds, currentDifficulty, bpm) {
var newMap = [];
var beatDuration = 60000 / bpm;
var currentTimeInSegment = 0;
var endTime = durationSeconds * 1000;
var lastNoteTime = -1000;
var MIN_TIME_BETWEEN_NOTES = 200;
while (currentTimeInSegment < endTime) {
var timeStepMultiplier = 2;
if (currentDifficulty > 0.7) {
timeStepMultiplier = 1 / 2;
} else if (currentDifficulty > 0.3) {
timeStepMultiplier = 1;
}
currentTimeInSegment += beatDuration * timeStepMultiplier;
if (currentTimeInSegment - lastNoteTime < MIN_TIME_BETWEEN_NOTES) {
continue;
}
var noteChance = 0.30 + currentDifficulty * 0.5;
if (Math.random() > noteChance) {
continue;
}
var columnIndex = Math.floor(Math.random() * NUM_COLUMNS);
var noteType = 'tap';
var buffType = null;
var roll = Math.random();
var trapChance = currentDifficulty > 0.7 ? 0.10 : 0;
var holdChance = currentDifficulty > 0.5 ? 0.15 : 0;
var swipeChance = currentDifficulty > 0.3 ? 0.25 : 0;
var buffChance = 0.1; // 10% szans na buffa zamiast zwykłego tapa
if (roll < trapChance) {
noteType = 'trap';
} else if (roll < trapChance + holdChance) {
noteType = 'hold';
} else if (roll < trapChance + holdChance + swipeChance) {
noteType = 'swipe';
} else if (roll < trapChance + holdChance + swipeChance + buffChance) {
var buffTypesAvailable = ['potion', 'shield', 'precision'];
buffType = buffTypesAvailable[Math.floor(Math.random() * buffTypesAvailable.length)];
}
var note = {
time: Math.round(endlessTimelineTime + currentTimeInSegment),
type: buffType ? 'tap' : noteType,
columnIndex: columnIndex,
isBuffNote: buffType !== null,
buffType: buffType
};
if (noteType === 'swipe') {
var swipeDirs = ['up', 'down', 'left', 'right'];
note.swipeDir = swipeDirs[Math.floor(Math.random() * swipeDirs.length)];
} else if (noteType === 'hold') {
var holdDuration = beatDuration * (1 + Math.random() * currentDifficulty);
note.duration = Math.round(holdDuration);
}
newMap.push(note);
lastNoteTime = currentTimeInSegment;
}
endlessTimelineTime += endTime;
return newMap;
}
function showIntro() {
if (typeof introElements !== 'undefined' && introElements.forEach) {
introElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
}
introElements = [];
var localIntroTimers = [];
var introArrowObject = null;
var isWaitingForUserClick = false;
var comicPanelsContainer = null;
var skipButton = null;
function clearLocalIntroTimers(clearArrowPulse) {
localIntroTimers.forEach(function (timerId) {
if (timerId) {
LK.clearTimeout(timerId);
}
});
localIntroTimers = [];
if (clearArrowPulse && introArrowObject && introArrowObject.pulseTimerId) {
LK.clearTimeout(introArrowObject.pulseTimerId);
introArrowObject.pulseTimerId = null;
}
}
if (typeof gameUIContainer !== 'undefined' && gameUIContainer) {
gameUIContainer.visible = false;
}
if (typeof staticHitFrame !== 'undefined' && staticHitFrame) {
staticHitFrame.visible = false;
}
if (typeof staticPerfectLine !== 'undefined' && staticPerfectLine) {
staticPerfectLine.visible = false;
}
currentScreenState = 'intro';
game.setBackgroundColor(0x000000);
comicPanelsContainer = new Container();
game.addChild(comicPanelsContainer);
introElements.push(comicPanelsContainer);
skipButton = new Text2("SKIP", {
size: 60,
fill: 0xBBBBBB,
align: 'right'
});
skipButton.anchor.set(1, 0);
skipButton.x = gameScreenWidth - 40;
skipButton.y = 40;
skipButton.interactive = true;
skipButton.cursor = "pointer";
game.addChild(skipButton);
introElements.push(skipButton);
skipButton.down = function () {
if (currentScreenState === 'intro') {
endIntroSequence();
}
};
var panelWidth = gameScreenWidth * 0.85;
var panelHeight = gameScreenHeight / 3 - 60;
var panelX = gameScreenWidth / 2;
var panelPositions = [{
x: panelX,
y: panelHeight / 2 + 40,
width: panelWidth,
height: panelHeight
}, {
x: panelX,
y: panelHeight * 1.5 + 60,
width: panelWidth,
height: panelHeight
}, {
x: panelX,
y: panelHeight * 2.5 + 80,
width: panelWidth,
height: panelHeight
}];
var introAssetKeys = ['intro_scene_1', 'intro_scene_2', 'intro_scene_3', 'intro_scene_4', 'intro_scene_5', 'intro_scene_6', 'intro_scene_7', 'intro_scene_8', 'intro_scene_9'];
var introArrowAssetKey = 'intro_arrow_down';
var activePanelObjects = [];
function endIntroSequence() {
if (currentScreenState !== 'intro' && currentScreenState !== 'transitioning_to_menu') {
return;
}
currentScreenState = 'transitioning_to_menu';
clearLocalIntroTimers(true);
isWaitingForUserClick = false;
var elementsToFade = [];
if (comicPanelsContainer && comicPanelsContainer.parent) {
elementsToFade.push(comicPanelsContainer);
}
if (skipButton && skipButton.parent) {
elementsToFade.push(skipButton);
}
if (introArrowObject && introArrowObject.parent) {
elementsToFade.push(introArrowObject);
}
var fadedCount = 0;
var totalToFade = elementsToFade.length;
var onAllFadedOut = function onAllFadedOut() {
introElements.forEach(function (el) {
if (el && el.parent) {
el.destroy();
}
});
introElements = [];
activePanelObjects = [];
comicPanelsContainer = null;
skipButton = null;
introArrowObject = null;
showMainMenu(1000);
};
if (totalToFade === 0) {
onAllFadedOut();
return;
}
elementsToFade.forEach(function (el) {
tween(el, {
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
fadedCount++;
if (fadedCount === totalToFade) {
onAllFadedOut();
}
}
});
});
}
function displayPanelWithFadeIn(assetKey, positionConfig, durationMs, callback) {
if (currentScreenState !== 'intro' || !comicPanelsContainer) {
return;
}
var panel = LK.getAsset(assetKey, {
anchorX: 0.5,
anchorY: 0.5,
x: positionConfig.x,
y: positionConfig.y,
width: positionConfig.width,
height: positionConfig.height,
alpha: 0
});
comicPanelsContainer.addChild(panel);
activePanelObjects.push(panel);
tween(panel, {
alpha: 1
}, {
duration: durationMs,
easing: tween.linear,
onFinish: function onFinish() {
if (callback && currentScreenState === 'intro') {
callback();
}
}
});
}
function hideAndDestroyPanels(panelsToProcess, durationMs, callback) {
var panelsToFade = panelsToProcess.slice();
activePanelObjects = [];
if (currentScreenState !== 'intro' && panelsToFade.length > 0) {
panelsToFade.forEach(function (p) {
if (p && p.parent) {
p.destroy();
}
});
if (callback) {
callback();
}
return;
}
if (panelsToFade.length === 0) {
if (callback) {
callback();
}
return;
}
var fadedCount = 0;
panelsToFade.forEach(function (p) {
if (p && p.parent) {
tween(p, {
alpha: 0
}, {
duration: durationMs,
easing: tween.linear,
onFinish: function onFinish() {
if (p.parent) {
p.destroy();
}
fadedCount++;
if (fadedCount === panelsToFade.length && callback && currentScreenState === 'intro') {
callback();
}
}
});
} else {
fadedCount++;
if (fadedCount === panelsToFade.length && callback && currentScreenState === 'intro') {
callback();
}
}
});
}
function showArrowAndAwaitClick(actionOnClick) {
if (currentScreenState !== 'intro') {
return;
}
if (introArrowObject && introArrowObject.parent) {
if (introArrowObject.pulseTimerId) {
LK.clearTimeout(introArrowObject.pulseTimerId);
}
introArrowObject.destroy();
var idxOldArr = introElements.indexOf(introArrowObject);
if (idxOldArr > -1) {
introElements.splice(idxOldArr, 1);
}
introArrowObject = null;
}
isWaitingForUserClick = true;
introArrowObject = LK.getAsset(introArrowAssetKey, {
anchorX: 0.5,
anchorY: 1,
x: gameScreenWidth / 2,
y: gameScreenHeight - 30,
alpha: 0,
interactive: true,
cursor: "pointer"
});
game.addChild(introArrowObject);
introElements.push(introArrowObject);
if (comicPanelsContainer && comicPanelsContainer.parent) {
game.setChildIndex(introArrowObject, game.getChildIndex(comicPanelsContainer) + 1);
}
if (skipButton && skipButton.parent) {
game.setChildIndex(skipButton, game.children.length - 1);
}
tween(introArrowObject, {
alpha: 1
}, {
duration: 500
});
var arrowPulseDir = 1;
function pulseArrow() {
if (!isWaitingForUserClick || !introArrowObject || !introArrowObject.parent || currentScreenState !== 'intro') {
if (introArrowObject && introArrowObject.pulseTimerId) {
LK.clearTimeout(introArrowObject.pulseTimerId);
}
if (introArrowObject) {
introArrowObject.pulseTimerId = null;
}
return;
}
var targetScale = arrowPulseDir > 0 ? 1.15 : 1.0;
arrowPulseDir *= -1;
tween(introArrowObject.scale, {
x: targetScale,
y: targetScale
}, {
duration: 700,
easing: tween.easeInOutQuad,
onFinish: function onFinish() {
if (isWaitingForUserClick && introArrowObject && introArrowObject.parent) {
introArrowObject.pulseTimerId = LK.setTimeout(pulseArrow, 100);
}
}
});
}
introArrowObject.pulseTimerId = LK.setTimeout(pulseArrow, 500);
var thisArrowInstance = introArrowObject;
thisArrowInstance.down = function () {
if (isWaitingForUserClick && currentScreenState === 'intro' && thisArrowInstance && thisArrowInstance.parent) {
isWaitingForUserClick = false;
if (thisArrowInstance.pulseTimerId) {
LK.clearTimeout(thisArrowInstance.pulseTimerId);
thisArrowInstance.pulseTimerId = null;
}
tween(thisArrowInstance, {
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
if (thisArrowInstance.parent) {
thisArrowInstance.destroy();
}
var idx = introElements.indexOf(thisArrowInstance);
if (idx > -1) {
introElements.splice(idx, 1);
}
if (introArrowObject === thisArrowInstance) {
introArrowObject = null;
}
}
});
clearLocalIntroTimers(false);
actionOnClick();
}
};
}
function proceedToPhase2() {
if (currentScreenState !== 'intro') {
return;
}
hideAndDestroyPanels(activePanelObjects.slice(), 800, function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[3], panelPositions[0], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[4], panelPositions[1], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[5], panelPositions[2], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState === 'intro') {
showArrowAndAwaitClick(proceedToPhase3);
}
}, 3000));
});
}, 3000));
});
}, 3000));
});
});
}
function proceedToPhase3() {
if (currentScreenState !== 'intro') {
return;
}
hideAndDestroyPanels(activePanelObjects.slice(), 800, function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[6], panelPositions[0], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[7], panelPositions[1], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[8], panelPositions[2], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState === 'intro') {
endIntroSequence();
}
}, 3000));
});
}, 3000));
});
}, 3000));
});
});
}
displayPanelWithFadeIn(introAssetKeys[0], panelPositions[0], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[1], panelPositions[1], 800, function () {
if (currentScreenState !== 'intro') {
return;
}
localIntroTimers.push(LK.setTimeout(function () {
if (currentScreenState !== 'intro') {
return;
}
displayPanelWithFadeIn(introAssetKeys[2], panelPositions[2], 800, function () {
if (currentScreenState === 'intro') {
showArrowAndAwaitClick(proceedToPhase2);
}
});
}, 3000));
});
}, 3000));
});
}
function checkMiniGameCollisions() {
if (!miniGamePlayer || !miniGamePlayer.asset || isMiniGameOver) {
return;
}
for (var i = miniGameObstacles.length - 1; i >= 0; i--) {
var obs = miniGameObstacles[i];
if (miniGameRectsIntersect(miniGamePlayer, obs)) {
console.log("Game Over - Hit obstacle!");
isMiniGameOver = true;
if (miniGamePlayer.asset) {
miniGamePlayer.asset.tint = 0xFF0000;
}
return;
}
}
}
function miniGameRectsIntersect(r1Player, r2Object) {
var r1Details = {
x: r1Player.x,
y: r1Player.y,
width: r1Player.width,
height: r1Player.height
};
var r2Details = {
x: r2Object.x,
y: r2Object.y,
width: r2Object.width,
height: r2Object.height
};
var r1left = r1Details.x - r1Details.width / 2;
var r1right = r1Details.x + r1Details.width / 2;
var r1top = r1Details.y - r1Details.height / 2;
var r1bottom = r1Details.y + r1Details.height / 2;
var r2left = r2Details.x - r2Details.width / 2;
var r2right = r2Details.x + r2Details.width / 2;
var r2top = r2Details.y - r2Details.height / 2;
var r2bottom = r2Details.y + r2Details.height / 2;
return !(r2left >= r1right || r2right <= r1left || r2top >= r1bottom || r2bottom <= r1top);
}
function runTutorialGameplay() {
if (currentMainMenuMusicTrack && typeof currentMainMenuMusicTrack.stop === 'function') {
currentMainMenuMusicTrack.stop();
}
while (mainMenuScreenElements.length > 0) {
var elemToDestroy = mainMenuScreenElements.pop();
if (elemToDestroy && elemToDestroy.parent) {
elemToDestroy.destroy();
}
}
mainMenuItemTextObjects = [];
if (typeof menuTextContainer !== 'undefined' && menuTextContainer && menuTextContainer.parent) {
menuTextContainer.destroy(); // Zniszcz kontener, jeśli istnieje
}
menuTextContainer = null; // Zresetuj referencję
isTutorialMode = true;
currentScreenState = 'gameplay';
allSongData["TutorialTrack"] = tutorialSongData;
currentFightingBossId = null;
loadSong("TutorialTrack");
}
function exitTutorialGameplay() {
isTutorialMode = false;
if (activeMusicTrack) {
activeMusicTrack.stop();
activeMusicTrack = null;
}
resetGameState();
if (gameplayBackground && gameplayBackground.parent) {
gameplayBackground.destroy();
gameplayBackground = null;
}
if (scoreTxt) {
scoreTxt.visible = true;
}
if (comboTxt) {
comboTxt.visible = true;
}
if (gameUIContainer) {
gameUIContainer.visible = false;
}
if (staticHitFrame) {
staticHitFrame.visible = false;
}
if (staticPerfectLine) {
staticPerfectLine.visible = false;
}
showMainMenu();
}
// Game State & Rhythm Logic Variables
var allSongData = {
"NoizboyTrack": {
musicAsset: 'Noizboy',
bossAssetKey: 'Boss3',
config: {
playerMaxHP: 20,
bossMaxHP: 220
},
rawRhythmMap: [{
time: 12000,
type: "tap",
columnIndex: 0
}, {
time: 12613,
type: "tap",
columnIndex: 1
}, {
time: 13148,
type: "tap",
columnIndex: 0
}, {
time: 13759,
type: "tap",
columnIndex: 1
}, {
time: 14293,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 14860,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 15437,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 15960,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 16561,
type: "tap",
columnIndex: 2
}, {
time: 17133,
type: "tap",
columnIndex: 1
}, {
time: 17647,
type: "tap",
columnIndex: 0
}, {
time: 18180,
type: "tap",
columnIndex: 0
}, {
time: 18859,
type: "tap",
columnIndex: 1
}, {
time: 19422,
type: "tap",
columnIndex: 0
}, {
time: 20010,
type: "tap",
columnIndex: 1
}, {
time: 20272,
type: "tap",
columnIndex: 2
}, {
time: 20609,
type: "tap",
columnIndex: 2
}, {
time: 20840,
type: "tap",
columnIndex: 2
}, {
time: 21186,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 21829,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 22364,
type: "swipe",
columnIndex: 1,
swipeDir: "left"
}, {
time: 22935,
type: "swipe",
columnIndex: 1,
swipeDir: "left"
}, {
time: 23517,
type: "tap",
columnIndex: 1
}, {
time: 23812,
type: "tap",
columnIndex: 1
}, {
time: 24063,
type: "tap",
columnIndex: 2
}, {
time: 24415,
type: "tap",
columnIndex: 2
}, {
time: 24678,
type: "tap",
columnIndex: 0
}, {
time: 24965,
type: "tap",
columnIndex: 0
}, {
time: 25234,
type: "tap",
columnIndex: 1
}, {
time: 25846,
type: "tap",
columnIndex: 2
}, {
time: 26440,
type: "tap",
columnIndex: 2
}, {
time: 27003,
type: "tap",
columnIndex: 1
}, {
time: 27535,
type: "tap",
columnIndex: 1
}, {
time: 28133,
type: "tap",
columnIndex: 0
}, {
time: 28680,
type: "tap",
columnIndex: 0
}, {
time: 29225,
type: "tap",
columnIndex: 0
}, {
time: 29846,
type: "tap",
columnIndex: 0
}, {
time: 30459,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 31100,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 31660,
type: "swipe",
columnIndex: 2,
swipeDir: "left"
}, {
time: 32775,
type: "swipe",
columnIndex: 2,
swipeDir: "down"
}, {
time: 33347,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 33930,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 35058,
type: "tap",
columnIndex: 2
}, {
time: 35640,
type: "tap",
columnIndex: 1
}, {
time: 36187,
type: "tap",
columnIndex: 2
}, {
time: 36722,
type: "tap",
columnIndex: 1
}, {
time: 37385,
type: "tap",
columnIndex: 0
}, {
time: 37928,
type: "tap",
columnIndex: 0
}, {
time: 38148,
type: "tap",
columnIndex: 0
}, {
time: 38502,
type: "tap",
columnIndex: 0
}, {
time: 39022,
type: "tap",
columnIndex: 1
}, {
time: 39657,
type: "tap",
columnIndex: 2
}, {
time: 40209,
type: "tap",
columnIndex: 2
}, {
time: 40800,
type: "tap",
columnIndex: 0
}, {
time: 41347,
type: "tap",
columnIndex: 0
}, {
time: 41963,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 42496,
type: "tap",
columnIndex: 0
}, {
time: 43113,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 43723,
type: "tap",
columnIndex: 0
}, {
time: 44318,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 44871,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 45456,
type: "tap",
columnIndex: 1
}, {
time: 45996,
type: "tap",
columnIndex: 1
}, {
time: 46548,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 47158,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 47720,
type: "tap",
columnIndex: 2
}, {
time: 48324,
type: "tap",
columnIndex: 2
}, {
time: 48833,
type: "swipe",
columnIndex: 2,
swipeDir: "down"
}, {
time: 49449,
type: "swipe",
columnIndex: 2,
swipeDir: "down"
}, {
time: 50039,
type: "tap",
columnIndex: 0
}, {
time: 50616,
type: "tap",
columnIndex: 0
}, {
time: 51149,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 51781,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 52401,
type: "tap",
columnIndex: 2
}, {
time: 52729,
type: "tap",
columnIndex: 2
}, {
time: 53030,
type: "tap",
columnIndex: 2
}, {
time: 53306,
type: "tap",
columnIndex: 2
}, {
time: 53560,
type: "tap",
columnIndex: 1
}, {
time: 54118,
type: "tap",
columnIndex: 2
}, {
time: 54687,
type: "tap",
columnIndex: 1
}, {
time: 55274,
type: "tap",
columnIndex: 2
}, {
time: 55842,
type: "tap",
columnIndex: 1
}, {
time: 56416,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 57066,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 57597,
type: "tap",
columnIndex: 2
}, {
time: 58182,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 58773,
type: "tap",
columnIndex: 2
}, {
time: 59339,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 59894,
type: "tap",
columnIndex: 1
}, {
time: 60459,
type: "tap",
columnIndex: 2
}, {
time: 61083,
type: "tap",
columnIndex: 1
}, {
time: 61659,
type: "tap",
columnIndex: 2
}, {
time: 62221,
type: "tap",
columnIndex: 0
}, {
time: 62754,
type: "tap",
columnIndex: 1
}, {
time: 68064,
type: "hold",
columnIndex: 1,
duration: 1227
}, {
time: 69302,
type: "hold",
columnIndex: 2,
duration: 1134
}, {
time: 70476,
type: "hold",
columnIndex: 0,
duration: 1249
}, {
time: 71721,
type: "hold",
columnIndex: 1,
duration: 1188
}, {
time: 72898,
type: "hold",
columnIndex: 2,
duration: 1232
}, {
time: 74104,
type: "hold",
columnIndex: 0,
duration: 1277
}, {
time: 75409,
type: "hold",
columnIndex: 1,
duration: 965
}, {
time: 76370,
type: "hold",
columnIndex: 2,
duration: 1539
}, {
time: 78101,
type: "hold",
columnIndex: 1,
duration: 1002
}, {
time: 79259,
type: "hold",
columnIndex: 0,
duration: 1222
}, {
time: 80575,
type: "hold",
columnIndex: 1,
duration: 1071
}, {
time: 81723,
type: "hold",
columnIndex: 2,
duration: 884
}, {
time: 82719,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 83490,
type: "hold",
columnIndex: 2,
duration: 1150
}, {
time: 84679,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 85134,
type: "hold",
columnIndex: 1,
duration: 1173
}, {
time: 86436,
type: "tap",
columnIndex: 0
}, {
time: 86983,
type: "tap",
columnIndex: 1
}, {
time: 87567,
type: "tap",
columnIndex: 0
}, {
time: 88162,
type: "tap",
columnIndex: 0
}, {
time: 88727,
type: "tap",
columnIndex: 1
}, {
time: 89296,
type: "tap",
columnIndex: 1
}, {
time: 89880,
type: "tap",
columnIndex: 2
}, {
time: 90438,
type: "tap",
columnIndex: 2
}, {
time: 90998,
type: "tap",
columnIndex: 1
}, {
time: 91591,
type: "tap",
columnIndex: 1
}, {
time: 92159,
type: "tap",
columnIndex: 1
}, {
time: 92717,
type: "tap",
columnIndex: 1
}, {
time: 93030,
type: "tap",
columnIndex: 2
}, {
time: 93403,
type: "tap",
columnIndex: 0
}, {
time: 93950,
type: "tap",
columnIndex: 1
}, {
time: 94528,
type: "tap",
columnIndex: 0
}, {
time: 95074,
type: "tap",
columnIndex: 1
}, {
time: 95304,
type: "tap",
columnIndex: 2
}, {
time: 95642,
type: "tap",
columnIndex: 0
}, {
time: 96220,
type: "tap",
columnIndex: 1
}, {
time: 96811,
type: "tap",
columnIndex: 2
}, {
time: 97429,
type: "tap",
columnIndex: 1
}, {
time: 97926,
type: "tap",
columnIndex: 2
}]
},
"GoblopBossTrack": {
musicAsset: "Goblop",
bossAssetKey: 'Boss2_Asset',
config: {
playerMaxHP: 15,
bossMaxHP: 200
},
rawRhythmMap: [{
time: 7000,
type: "tap",
columnIndex: 0
}, {
time: 7637,
type: "tap",
columnIndex: 1
}, {
time: 8205,
type: "tap",
columnIndex: 2
}, {
time: 8783,
type: "tap",
columnIndex: 2
}, {
time: 9355,
type: "tap",
columnIndex: 0
}, {
time: 9966,
type: "tap",
columnIndex: 1
}, {
time: 10584,
type: "tap",
columnIndex: 0
}, {
time: 11124,
type: "tap",
columnIndex: 0
}, {
time: 11668,
type: "tap",
columnIndex: 0
}, {
time: 12254,
type: "tap",
columnIndex: 1
}, {
time: 12833,
type: "tap",
columnIndex: 2
}, {
time: 13428,
type: "tap",
columnIndex: 1
}, {
time: 14026,
type: "hold",
columnIndex: 1,
duration: 1205
}, {
time: 15270,
type: "hold",
columnIndex: 2,
duration: 1028
}, {
time: 16918,
type: "tap",
columnIndex: 0
}, {
time: 17481,
type: "tap",
columnIndex: 1
}, {
time: 18120,
type: "tap",
columnIndex: 0
}, {
time: 18697,
type: "tap",
columnIndex: 1
}, {
time: 19238,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 19853,
type: "tap",
columnIndex: 1
}, {
time: 20442,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 21008,
type: "tap",
columnIndex: 2
}, {
time: 21561,
type: "swipe",
columnIndex: 2,
swipeDir: "left"
}, {
time: 22225,
type: "tap",
columnIndex: 2
}, {
time: 22794,
type: "swipe",
columnIndex: 2,
swipeDir: "up"
}, {
time: 23316,
type: "tap",
columnIndex: 2
}, {
time: 23933,
type: "swipe",
columnIndex: 1,
swipeDir: "left"
}, {
time: 24538,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 25132,
type: "tap",
columnIndex: 1
}, {
time: 25655,
type: "tap",
columnIndex: 2
}, {
time: 26261,
type: "tap",
columnIndex: 0
}, {
time: 26840,
type: "tap",
columnIndex: 1
}, {
time: 27382,
type: "tap",
columnIndex: 2
}, {
time: 28000,
type: "tap",
columnIndex: 1
}, {
time: 28617,
type: "tap",
columnIndex: 0
}, {
time: 29194,
type: "tap",
columnIndex: 1
}, {
time: 29777,
type: "tap",
columnIndex: 2
}, {
time: 30341,
type: "tap",
columnIndex: 0
}, {
time: 30816,
type: "tap",
columnIndex: 1
}, {
time: 31506,
type: "tap",
columnIndex: 2
}, {
time: 32106,
type: "tap",
columnIndex: 0
}, {
time: 32693,
type: "hold",
columnIndex: 0,
duration: 1057
}, {
time: 33803,
type: "hold",
columnIndex: 1,
duration: 1052
}, {
time: 35102,
type: "tap",
columnIndex: 0
}, {
time: 37350,
type: "hold",
columnIndex: 1,
duration: 1851
}, {
time: 39629,
type: "hold",
columnIndex: 2,
duration: 2237
}, {
time: 42031,
type: "hold",
columnIndex: 0,
duration: 2178
}, {
time: 44365,
type: "tap",
columnIndex: 0
}, {
time: 44996,
type: "tap",
columnIndex: 0
}, {
time: 45618,
type: "tap",
columnIndex: 0
}, {
time: 46143,
type: "tap",
columnIndex: 0
}, {
time: 46708,
type: "tap",
columnIndex: 0
}, {
time: 47258,
type: "tap",
columnIndex: 0
}, {
time: 47812,
type: "tap",
columnIndex: 0
}, {
time: 48333,
type: "tap",
columnIndex: 0
}, {
time: 48601,
type: "tap",
columnIndex: 0
}, {
time: 48988,
type: "swipe",
columnIndex: 0,
swipeDir: "right"
}, {
time: 49568,
type: "swipe",
columnIndex: 2,
swipeDir: "up"
}, {
time: 50154,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 50768,
type: "swipe",
columnIndex: 1,
swipeDir: "down"
}, {
time: 51337,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 51939,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 52497,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 53086,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 53638,
type: "tap",
columnIndex: 2
}, {
time: 54286,
type: "tap",
columnIndex: 1
}, {
time: 54830,
type: "tap",
columnIndex: 2
}, {
time: 55440,
type: "tap",
columnIndex: 1
}, {
time: 55971,
type: "tap",
columnIndex: 2
}, {
time: 56523,
type: "tap",
columnIndex: 0
}, {
time: 57124,
type: "tap",
columnIndex: 1
}, {
time: 57742,
type: "tap",
columnIndex: 2
}, {
time: 58339,
type: "tap",
columnIndex: 0
}, {
time: 59372,
type: "hold",
columnIndex: 0,
duration: 1269
}, {
time: 60694,
type: "hold",
columnIndex: 1,
duration: 2119
}, {
time: 62848,
type: "hold",
columnIndex: 2,
duration: 2364
}, {
time: 65253,
type: "hold",
columnIndex: 0,
duration: 2294
}, {
time: 67709,
type: "tap",
columnIndex: 0
}, {
time: 68257,
type: "tap",
columnIndex: 0
}, {
time: 68812,
type: "tap",
columnIndex: 0
}, {
time: 69407,
type: "tap",
columnIndex: 0
}, {
time: 69707,
type: "tap",
columnIndex: 0
}, {
time: 69989,
type: "tap",
columnIndex: 0
}, {
time: 70554,
type: "tap",
columnIndex: 1
}, {
time: 71147,
type: "tap",
columnIndex: 0
}, {
time: 71721,
type: "tap",
columnIndex: 1
}, {
time: 72304,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 72909,
type: "swipe",
columnIndex: 1,
swipeDir: "down"
}, {
time: 73509,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 74070,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 74655,
type: "tap",
columnIndex: 0
}, {
time: 75270,
type: "swipe",
columnIndex: 0,
swipeDir: "left"
}, {
time: 75835,
type: "tap",
columnIndex: 0
}, {
time: 76391,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 76968,
type: "tap",
columnIndex: 0
}, {
time: 77527,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 78153,
type: "tap",
columnIndex: 1
}, {
time: 78701,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 79300,
type: "tap",
columnIndex: 2
}, {
time: 79856,
type: "swipe",
columnIndex: 1,
swipeDir: "down"
}, {
time: 80433,
type: "tap",
columnIndex: 2
}, {
time: 81041,
type: "tap",
columnIndex: 1
}, {
time: 81632,
type: "tap",
columnIndex: 2
}, {
time: 82232,
type: "tap",
columnIndex: 1
}, {
time: 82769,
type: "tap",
columnIndex: 2
}, {
time: 83391,
type: "tap",
columnIndex: 2
}, {
time: 83960,
type: "tap",
columnIndex: 1
}, {
time: 84554,
type: "tap",
columnIndex: 2
}, {
time: 85139,
type: "tap",
columnIndex: 0
}, {
time: 85715,
type: "tap",
columnIndex: 1
}, {
time: 86261,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 86858,
type: "swipe",
columnIndex: 0,
swipeDir: "up"
}, {
time: 87427,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 88060,
type: "swipe",
columnIndex: 1,
swipeDir: "right"
}, {
time: 88630,
type: "tap",
columnIndex: 1
}, {
time: 89198,
type: "swipe",
columnIndex: 1,
swipeDir: "down"
}, {
time: 89777,
type: "tap",
columnIndex: 1
}, {
time: 90334,
type: "swipe",
columnIndex: 2,
swipeDir: "up"
}, {
time: 90976,
type: "tap",
columnIndex: 2
}, {
time: 91533,
type: "swipe",
columnIndex: 2,
swipeDir: "left"
}, {
time: 92125,
type: "tap",
columnIndex: 2
}, {
time: 92691,
type: "swipe",
columnIndex: 2,
swipeDir: "right"
}, {
time: 93264,
type: "tap",
columnIndex: 0
}, {
time: 93848,
type: "swipe",
columnIndex: 0,
swipeDir: "down"
}, {
time: 94458,
type: "tap",
columnIndex: 1
}, {
time: 95026,
type: "swipe",
columnIndex: 1,
swipeDir: "up"
}, {
time: 95599,
type: "tap",
columnIndex: 2
}, {
time: 96194,
type: "tap",
columnIndex: 1
}, {
time: 96765,
type: "tap",
columnIndex: 0
}, {
time: 97338,
type: "tap",
columnIndex: 1
}, {
time: 97640,
type: "tap",
columnIndex: 2
}, {
time: 97979,
type: "tap",
columnIndex: 0
}]
},
"OrctaveBossTrack": {
musicAsset: "Orctave",
// Upewnij się, że masz asset muzyczny o tym kluczu
bossAssetKey: 'Boss1_Asset',
// Asset dla pierwszego bossa
config: {
playerMaxHP: 10,
bossMaxHP: 200
},
rawRhythmMap: [{
time: 8596,
type: 'tap',
columnIndex: 0
}, {
time: 8795,
type: 'tap',
columnIndex: 1
}, {
time: 9117,
type: 'tap',
columnIndex: 2
}, {
time: 9832,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 10536,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 11245,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 11888,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 12628,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 13308,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 13986,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 14696,
type: 'tap',
columnIndex: 2
}, {
time: 15456,
type: 'tap',
columnIndex: 2
}, {
time: 16140,
type: 'tap',
columnIndex: 1
}, {
time: 16863,
type: 'tap',
columnIndex: 1
}, {
time: 17547,
type: 'tap',
columnIndex: 0
}, {
time: 18275,
type: 'tap',
columnIndex: 0
}, {
time: 18955,
type: 'tap',
columnIndex: 0
}, {
time: 19670,
type: 'tap',
columnIndex: 0
}, {
time: 20333,
type: 'tap',
columnIndex: 1
}, {
time: 20740,
type: 'tap',
columnIndex: 2
}, {
time: 21063,
type: 'tap',
columnIndex: 1
}, {
time: 21411,
type: 'tap',
columnIndex: 0
}, {
time: 21742,
type: 'tap',
columnIndex: 1
}, {
time: 22110,
type: 'tap',
columnIndex: 2
}, {
time: 22463,
type: 'tap',
columnIndex: 1
}, {
time: 22797,
type: 'tap',
columnIndex: 0
}, {
time: 23336,
type: 'tap',
columnIndex: 2
}, {
time: 26163,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 26737,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 27351,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 27764,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 28116,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 28827,
type: 'swipe',
columnIndex: 1,
swipeDir: 'right'
}, {
time: 29546,
type: 'swipe',
columnIndex: 0,
swipeDir: 'left'
}, {
time: 30102,
type: 'swipe',
columnIndex: 1,
swipeDir: 'right'
}, {
time: 30534,
type: 'swipe',
columnIndex: 1,
swipeDir: 'right'
}, {
time: 30931,
type: 'swipe',
columnIndex: 0,
swipeDir: 'left'
}, {
time: 31677,
type: 'tap',
columnIndex: 2
}, {
time: 32392,
type: 'tap',
columnIndex: 1
}, {
time: 32989,
type: 'tap',
columnIndex: 2
}, {
time: 33386,
type: 'tap',
columnIndex: 2
}, {
time: 33781,
type: 'tap',
columnIndex: 1
}, {
time: 34568,
type: 'tap',
columnIndex: 2
}, {
time: 35234,
type: 'tap',
columnIndex: 1
}, {
time: 35749,
type: 'tap',
columnIndex: 2
}, {
time: 36182,
type: 'tap',
columnIndex: 2
}, {
time: 36583,
type: 'tap',
columnIndex: 0
}, {
time: 37302,
type: 'tap',
columnIndex: 0
}, {
time: 37681,
type: 'tap',
columnIndex: 1
}, {
time: 38033,
type: 'tap',
columnIndex: 2
}, {
time: 38354,
type: 'tap',
columnIndex: 2
}, {
time: 38721,
type: 'tap',
columnIndex: 1
}, {
time: 39067,
type: 'tap',
columnIndex: 0
}, {
time: 39471,
type: 'tap',
columnIndex: 1
}, {
time: 39821,
type: 'tap',
columnIndex: 2
}, {
time: 40164,
type: 'tap',
columnIndex: 1
}, {
time: 40488,
type: 'tap',
columnIndex: 0
}, {
time: 40861,
type: 'tap',
columnIndex: 0
}, {
time: 41250,
type: 'tap',
columnIndex: 1
}, {
time: 41609,
type: 'tap',
columnIndex: 2
}, {
time: 41946,
type: 'tap',
columnIndex: 1
}, {
time: 42290,
type: 'tap',
columnIndex: 0
}, {
time: 42643,
type: 'tap',
columnIndex: 2
}, {
time: 43068,
type: 'tap',
columnIndex: 1
}, {
time: 43379,
type: 'tap',
columnIndex: 2
}, {
time: 43726,
type: 'tap',
columnIndex: 1
}, {
time: 44078,
type: 'tap',
columnIndex: 2
}, {
time: 44414,
type: 'tap',
columnIndex: 1
}, {
time: 44728,
type: 'tap',
columnIndex: 2
}, {
time: 45115,
type: 'tap',
columnIndex: 1
}, {
time: 45475,
type: 'tap',
columnIndex: 2
}, {
time: 45809,
type: 'tap',
columnIndex: 0
}, {
time: 46199,
type: 'tap',
columnIndex: 1
}, {
time: 46521,
type: 'tap',
columnIndex: 2
}, {
time: 46855,
type: 'tap',
columnIndex: 1
}, {
time: 47190,
type: 'tap',
columnIndex: 0
}, {
time: 47535,
type: 'tap',
columnIndex: 2
}, {
time: 47874,
type: 'tap',
columnIndex: 1
}, {
time: 48252,
type: 'tap',
columnIndex: 2
}, {
time: 51448,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 52112,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 52853,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 53536,
type: 'swipe',
columnIndex: 2,
swipeDir: 'left'
}, {
time: 54251,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 54964,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 55618,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 56339,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 57058,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 57799,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 58512,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 59170,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 59911,
type: 'swipe',
columnIndex: 2,
swipeDir: 'right'
}, {
time: 60668,
type: 'tap',
columnIndex: 2
}, {
time: 61334,
type: 'swipe',
columnIndex: 2,
swipeDir: 'right'
}, {
time: 62084,
type: 'tap',
columnIndex: 2
}, {
time: 62744,
type: 'swipe',
columnIndex: 2,
swipeDir: 'right'
}, {
time: 63445,
type: 'tap',
columnIndex: 2
}, {
time: 64134,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 64827,
type: 'tap',
columnIndex: 1
}, {
time: 65532,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 66199,
type: 'tap',
columnIndex: 1
}, {
time: 66921,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 67679,
type: 'tap',
columnIndex: 1
}, {
time: 68353,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 69005,
type: 'tap',
columnIndex: 0
}, {
time: 69772,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 70457,
type: 'tap',
columnIndex: 0
}, {
time: 71178,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 71892,
type: 'swipe',
columnIndex: 2,
swipeDir: 'right'
}, {
time: 72585,
type: 'swipe',
columnIndex: 1,
swipeDir: 'left'
}, {
time: 73287,
type: 'swipe',
columnIndex: 0,
swipeDir: 'right'
}, {
time: 74094,
type: 'tap',
columnIndex: 2
}, {
time: 75031,
type: 'tap',
columnIndex: 1
}, {
time: 75469,
type: 'tap',
columnIndex: 2
}, {
time: 75831,
type: 'tap',
columnIndex: 2
}, {
time: 76181,
type: 'tap',
columnIndex: 1
}, {
time: 76909,
type: 'tap',
columnIndex: 0
}, {
time: 77641,
type: 'tap',
columnIndex: 1
}, {
time: 78208,
type: 'tap',
columnIndex: 2
}, {
time: 78675,
type: 'tap',
columnIndex: 2
}, {
time: 79001,
type: 'tap',
columnIndex: 1
}, {
time: 79743,
type: 'tap',
columnIndex: 0
}, {
time: 80401,
type: 'tap',
columnIndex: 1
}, {
time: 80982,
type: 'tap',
columnIndex: 0
}, {
time: 81387,
type: 'tap',
columnIndex: 0
}, {
time: 81769,
type: 'tap',
columnIndex: 1
}, {
time: 82537,
type: 'tap',
columnIndex: 2
}, {
time: 83216,
type: 'tap',
columnIndex: 1
}, {
time: 83789,
type: 'tap',
columnIndex: 0
}, {
time: 84229,
type: 'tap',
columnIndex: 0
}, {
time: 84566,
type: 'tap',
columnIndex: 0
}, {
time: 84923,
type: 'tap',
columnIndex: 0
}, {
time: 85105,
type: 'tap',
columnIndex: 0
}, {
time: 85305,
type: 'tap',
columnIndex: 1
}]
}
};
// Initialize and add gameUIContainer to the game scene
gameUIContainer = new Container();
game.addChild(gameUIContainer);
// Function to process raw rhythm map data (remains unchanged, ensure it's here)
function processRawRhythmMap(rawMapData, songKeyForLogging) {
console.log("Processing raw map for: " + songKeyForLogging + " with " + rawMapData.length + " initial notes.");
var processedMap = [];
var tempMap = [];
for (var k = 0; k < rawMapData.length; k++) {
var originalNote = rawMapData[k];
var copiedNote = {};
for (var key in originalNote) {
if (originalNote.hasOwnProperty(key)) {
copiedNote[key] = originalNote[key];
}
}
tempMap.push(copiedNote);
}
for (var i = 0; i < tempMap.length; i++) {
var note = tempMap[i];
if (note.type === 'swipe' && note.swipeDir) {
var dir = note.swipeDir.toLowerCase();
if (dir.includes('right')) {
note.swipeDir = 'right';
} else if (dir.includes('left')) {
note.swipeDir = 'left';
} else if (dir.includes('up')) {
note.swipeDir = 'up';
} else if (dir.includes('down')) {
note.swipeDir = 'down';
}
}
}
var timeGroupedNotes = {};
tempMap.forEach(function (note) {
if (!timeGroupedNotes[note.time]) {
timeGroupedNotes[note.time] = [];
}
timeGroupedNotes[note.time].push(note);
});
var finalMapNotes = [];
var sortedTimes = Object.keys(timeGroupedNotes).map(Number).sort(function (a, b) {
return a - b;
});
for (var tIdx = 0; tIdx < sortedTimes.length; tIdx++) {
var time = sortedTimes[tIdx];
var notesAtThisTime = timeGroupedNotes[time];
var notesToKeepAtThisTime = [];
var processedForWiderSwipeConversion = [];
var colsWithVerticalSwipes = [null, null, null, null];
notesAtThisTime.forEach(function (note) {
if (note.type === 'swipe' && (note.swipeDir === 'up' || note.swipeDir === 'down')) {
if (note.columnIndex >= 0 && note.columnIndex < NUM_COLUMNS) {
var alreadyConverted = false;
for (var convIdx = 0; convIdx < processedForWiderSwipeConversion.length; convIdx++) {
if (processedForWiderSwipeConversion[convIdx].originalTime === note.time && processedForWiderSwipeConversion[convIdx].originalColumn === note.columnIndex) {
alreadyConverted = true;
break;
}
}
if (!alreadyConverted) {
colsWithVerticalSwipes[note.columnIndex] = note.swipeDir;
}
}
}
});
for (var c = 0; c < NUM_COLUMNS - 1; c++) {
if (colsWithVerticalSwipes[c] && colsWithVerticalSwipes[c + 1] && colsWithVerticalSwipes[c] === colsWithVerticalSwipes[c + 1]) {
var randomHorizontalDir = Math.random() < 0.5 ? 'left' : 'right';
var pairCenterX = (columnCenterXs[c] + columnCenterXs[c + 1]) / 2;
notesToKeepAtThisTime.push({
time: time,
type: 'swipe',
swipeDir: randomHorizontalDir,
partOfWiderSwipe: 'leftHalf',
widerSwipePairCenterX: pairCenterX,
originalColumnHint: c
});
notesToKeepAtThisTime.push({
time: time,
type: 'swipe',
swipeDir: randomHorizontalDir,
partOfWiderSwipe: 'rightHalf',
widerSwipePairCenterX: pairCenterX,
originalColumnHint: c + 1
});
processedForWiderSwipeConversion.push({
originalTime: time,
originalColumn: c
});
processedForWiderSwipeConversion.push({
originalTime: time,
originalColumn: c + 1
});
colsWithVerticalSwipes[c] = null;
colsWithVerticalSwipes[c + 1] = null;
c++;
}
}
notesAtThisTime.forEach(function (note) {
var wasConverted = false;
for (var convIdx = 0; convIdx < processedForWiderSwipeConversion.length; convIdx++) {
if (processedForWiderSwipeConversion[convIdx].originalTime === note.time && processedForWiderSwipeConversion[convIdx].originalColumn === note.columnIndex && (note.swipeDir === 'up' || note.swipeDir === 'down')) {
wasConverted = true;
break;
}
}
if (!wasConverted) {
notesToKeepAtThisTime.push(note);
}
});
var horizontalWiderSwipePairs = {};
var notesForFinalProcessing = [];
var uniqueNotesAtThisTime = [];
var seenNotesKeysAtThisTime = {};
notesToKeepAtThisTime.forEach(function (note) {
var key = "" + note.type + "_" + (note.columnIndex !== undefined ? note.columnIndex : note.partOfWiderSwipe ? note.widerSwipePairCenterX + note.partOfWiderSwipe : '') + "_" + (note.swipeDir || '');
if (!seenNotesKeysAtThisTime[key]) {
uniqueNotesAtThisTime.push(note);
seenNotesKeysAtThisTime[key] = true;
}
});
uniqueNotesAtThisTime.sort(function (a, b) {
var valA = a.originalColumnHint !== undefined ? a.originalColumnHint : a.columnIndex !== undefined ? a.columnIndex : a.widerSwipePairCenterX || 0;
var valB = b.originalColumnHint !== undefined ? b.originalColumnHint : b.columnIndex !== undefined ? b.columnIndex : b.widerSwipePairCenterX || 0;
return valA - valB;
});
for (var nIdx = 0; nIdx < uniqueNotesAtThisTime.length; nIdx++) {
var note = uniqueNotesAtThisTime[nIdx];
if (note.partOfWiderSwipe) {
notesForFinalProcessing.push(note);
continue;
}
var potentialPartner = null;
if (nIdx + 1 < uniqueNotesAtThisTime.length) {
potentialPartner = uniqueNotesAtThisTime[nIdx + 1];
}
if (note.type === 'swipe' && (note.swipeDir === 'left' || note.swipeDir === 'right') && potentialPartner && potentialPartner.type === 'swipe' && potentialPartner.time === note.time && potentialPartner.swipeDir === note.swipeDir && potentialPartner.columnIndex === note.columnIndex + 1) {
var pairCenterX = (columnCenterXs[note.columnIndex] + columnCenterXs[potentialPartner.columnIndex]) / 2;
notesForFinalProcessing.push({
time: note.time,
type: 'swipe',
swipeDir: note.swipeDir,
partOfWiderSwipe: 'leftHalf',
widerSwipePairCenterX: pairCenterX,
originalColumnHint: note.columnIndex
});
notesForFinalProcessing.push({
time: potentialPartner.time,
type: 'swipe',
swipeDir: potentialPartner.swipeDir,
partOfWiderSwipe: 'rightHalf',
widerSwipePairCenterX: pairCenterX,
originalColumnHint: potentialPartner.columnIndex
});
nIdx++;
} else {
notesForFinalProcessing.push(note);
}
}
finalMapNotes.push.apply(finalMapNotes, notesForFinalProcessing);
}
var uniqueNotesOverall = [];
var seenNotesOverall = {};
finalMapNotes.sort(function (a, b) {
return a.time - b.time;
});
finalMapNotes.forEach(function (note) {
var cX;
var keyPartForColumn;
if (note.partOfWiderSwipe) {
cX = note.widerSwipePairCenterX + (note.partOfWiderSwipe === 'leftHalf' ? -(SWIPE_NOTE_WIDTH / 2) : SWIPE_NOTE_WIDTH / 2);
keyPartForColumn = "pC" + note.widerSwipePairCenterX + "h" + (note.partOfWiderSwipe === 'leftHalf' ? 'L' : 'R');
} else if (note.columnIndex !== undefined) {
cX = columnCenterXs[note.columnIndex];
keyPartForColumn = "c" + note.columnIndex;
} else {
cX = gameScreenWidth / 2;
keyPartForColumn = "cX" + cX;
}
var key = "" + note.time + "_" + note.type + "_" + keyPartForColumn + "_" + (note.swipeDir || '');
if (!seenNotesOverall[key]) {
uniqueNotesOverall.push(note);
seenNotesOverall[key] = true;
} else {
// console.log("Filtered final duplicate note: " + key);
}
});
console.log("Processed map for: " + songKeyForLogging + " FINALLY contains " + uniqueNotesOverall.length + " notes.");
return uniqueNotesOverall;
}
var hpBarsInitialized = false;
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF,
alpha: 1
});
scoreTxt.anchor.set(1, 0); // Anchor center-top
scoreTxt.x = gameScreenWidth / 1;
scoreTxt.y = 20; // Position from the top of its container (gameUIContainer)
gameUIContainer.addChild(scoreTxt);
console.log("Restored scoreTxt: X=" + scoreTxt.x + " Y=" + scoreTxt.y + " Visible:" + scoreTxt.visible + " Parent: gameUIContainer");
var comboTxt = new Text2('Combo: 0', {
size: 50,
// Możesz dostosować rozmiar tekstu combo
fill: 0xFFFF00,
// Żółty kolor
alpha: 0.5
});
comboTxt.anchor.set(0, 0.5);
comboTxt.x = 100;
comboTxt.y = 1000;
comboTxt.rotation = -0.26;
gameUIContainer.addChild(comboTxt);
console.log("ComboTxt positioned: X=" + comboTxt.x + " Y=" + comboTxt.y + " Visible:" + comboTxt.visible + " Parent: gameUIContainer");
var hitZoneY = 1800;
var hitZoneVisualWidth = playfieldWidth;
function rectsIntersect(r1, r2) {
return !(r2.x > r1.x + r1.width || r2.x + r2.width < r1.x || r2.y > r1.y + r1.height || r2.y + r2.height < r1.y);
}
function resetGameState() {
notes.forEach(function (n) {
if (n && n.parent) {
n.destroy();
}
});
notes = [];
nextNoteIdx = 0;
score = 0;
combo = 0;
maxCombo = 0;
swipeStart = null;
inputLocked = false;
scoreTxt.setText('Score: 0');
comboTxt.setText('Combo: 0');
gameOverFlag = false;
playerCurrentHP = playerMaxHP;
bossCurrentHP = bossMaxHP;
hpBarsInitialized = false;
if (isShieldActive) {
isShieldActive = false;
}
if (shieldTimerDisplayContainer) {
shieldTimerDisplayContainer.visible = false;
}
if (isPrecisionBuffActive) {
isPrecisionBuffActive = false;
if (originalHitWindowPerfect > 0) {
hitWindowPerfect = originalHitWindowPerfect;
}
if (originalHitWindowGood > 0) {
hitWindowGood = originalHitWindowGood;
}
// Reset rozmiaru ramki, jeśli była powiększona
}
if (precisionBuffTimerDisplayContainer) {
precisionBuffTimerDisplayContainer.visible = false;
}
if (hpBarsInitialized && playerHpBarFill && bossHpBarFill) {
updatePlayerHpDisplay();
updateBossHpDisplay();
}
}
function loadSong(songKey) {
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
songSummaryContainer = null;
}
if (gameUIContainer) {
gameUIContainer.visible = true;
}
setupGameplayElements();
lastPlayedSongKeyForRestart = songKey;
bossWasDefeatedThisSong = false;
var songData;
if (isTutorialMode && songKey === "TutorialTrack") {
songData = tutorialSongData;
} else {
songData = allSongData[songKey];
}
if (!songData) {
console.log("Error: Song data not found for key: " + songKey);
if (allSongData["defaultTestTrack"]) {
songData = allSongData["defaultTestTrack"];
console.log("Fallback to defaultTestTrack");
} else {
currentActiveRhythmMap = [];
console.log("No fallback song data found.");
return;
}
}
currentFightingBossId = null;
if (!isTutorialMode) {
for (var i = 0; i < allBossData.length; i++) {
if (allBossData[i].songMapKey === songKey) {
currentFightingBossId = allBossData[i].id;
break;
}
}
}
if (songData.config) {
playerMaxHP = songData.config.playerMaxHP || 10;
bossMaxHP = songData.config.bossMaxHP || 50;
} else {
playerMaxHP = 10;
bossMaxHP = 50;
}
resetGameState();
createPlayerHUD();
createBossHUD();
if (gameplayBackground && gameplayBackground.parent) {
gameplayBackground.destroy();
gameplayBackground = null;
}
gameplayBackground = LK.getAsset('gameplayBg', {
x: 0,
y: 0,
width: gameScreenWidth,
height: gameScreenHeight,
alpha: 0.8
});
game.addChildAt(gameplayBackground, 0);
if (staticHitFrame) {
staticHitFrame.visible = true;
}
if (staticPerfectLine) {
staticPerfectLine.visible = true;
}
if (gameUIContainer) {
gameUIContainer.visible = true;
}
if (isTutorialMode) {
if (scoreTxt) {
scoreTxt.visible = false;
}
if (comboTxt) {
comboTxt.visible = false;
}
} else {
if (scoreTxt) {
scoreTxt.visible = true;
}
if (comboTxt) {
comboTxt.visible = true;
}
}
hpBarsInitialized = false;
nextNoteIdx = 0;
if (currentBossSprite && currentBossSprite.parent) {
currentBossSprite.destroy();
currentBossSprite = null;
} else if (isTutorialMode) {
if (currentBossSprite && currentBossSprite.parent) {
currentBossSprite.destroy();
currentBossSprite = null;
}
}
if (songData.rawRhythmMap) {
currentActiveRhythmMap = processRawRhythmMap(songData.rawRhythmMap, songKey);
} else {
currentActiveRhythmMap = [];
}
gameStartTime = Date.now();
setMusic(songData.musicAsset);
currentScreenState = 'gameplay';
if (!isTutorialMode) {
playerHUD.visible = true;
bossHUD.visible = true;
tween(playerHUD, {
alpha: 1
}, {
duration: 500
});
tween(bossHUD, {
alpha: 1
}, {
duration: 500
});
} else {
playerHUD.visible = false;
bossHUD.visible = false;
}
}
function setupPowerUpDisplay() {
var smallIconSize = 110;
if (shieldTimerDisplayContainer && shieldTimerDisplayContainer.parent) {
shieldTimerDisplayContainer.destroy();
}
shieldTimerDisplayContainer = new Container();
shieldTimerDisplayContainer.x = gameScreenWidth - 120;
shieldTimerDisplayContainer.y = 180;
if (gameUIContainer) {
gameUIContainer.addChild(shieldTimerDisplayContainer);
}
smallShieldIconDisplay = LK.getAsset('shieldAsset', {
anchorX: 0.5,
anchorY: 0.5,
width: smallIconSize,
height: smallIconSize
});
shieldTimerDisplayContainer.addChild(smallShieldIconDisplay);
shieldTimerTextDisplay = new Text2("", {
size: 50,
fill: 0xFFFFFF,
anchorX: 0.5,
anchorY: 0
});
shieldTimerTextDisplay.y = smallIconSize / 2 + 5;
shieldTimerDisplayContainer.addChild(shieldTimerTextDisplay);
shieldTimerDisplayContainer.visible = false;
if (precisionBuffTimerDisplayContainer && precisionBuffTimerDisplayContainer.parent) {
precisionBuffTimerDisplayContainer.destroy();
}
precisionBuffTimerDisplayContainer = new Container();
precisionBuffTimerDisplayContainer.x = gameScreenWidth - 120;
// Umieść poniżej timera tarczy lub w innym odpowiednim miejscu
precisionBuffTimerDisplayContainer.y = shieldTimerDisplayContainer.y + smallIconSize + 40 + 10;
if (gameUIContainer) {
gameUIContainer.addChild(precisionBuffTimerDisplayContainer);
}
smallPrecisionIconDisplay = LK.getAsset('shieldAsset', {
anchorX: 0.5,
anchorY: 0.5,
width: smallIconSize,
height: smallIconSize
});
precisionBuffTimerDisplayContainer.addChild(smallPrecisionIconDisplay);
precisionBuffTimerTextDisplay = new Text2("", {
size: 35,
fill: 0xFFFFFF,
anchorX: 0.5,
anchorY: 0
});
precisionBuffTimerTextDisplay.y = smallIconSize / 2 + 5;
precisionBuffTimerDisplayContainer.addChild(precisionBuffTimerTextDisplay);
precisionBuffTimerDisplayContainer.visible = false;
console.log("Timer UIs for Shield & Precision Buff created.");
}
function updatePowerUpDisplayCounts() {
if (hpPotionCountText) {
hpPotionCountText.setText("x" + collectedPowerUps.potion);
shieldCountText.setText("x" + collectedPowerUps.shield);
swipeToTapCountText.setText("x" + collectedPowerUps.swipeToTap);
}
}
function updatePlayerHpDisplay() {
if (playerHpBarFill) {
var healthPercent = playerCurrentHP / playerMaxHP;
playerHpBarFill.width = hpBarWidth * Math.max(0, healthPercent);
}
}
function updateBossHpDisplay() {
if (bossHpBarFill) {
var healthPercent = bossCurrentHP / bossMaxHP;
bossHpBarFill.width = hpBarWidth * Math.max(0, healthPercent);
}
}
function spawnNotes() {
if (!currentActiveRhythmMap || currentActiveRhythmMap.length === 0) {
return;
}
var now = Date.now();
if (!currentActiveRhythmMap) {
return;
}
while (nextNoteIdx < currentActiveRhythmMap.length) {
var noteData = currentActiveRhythmMap[nextNoteIdx];
var noteTargetHitTime = gameStartTime + noteData.time;
if (noteTargetHitTime - noteTravelTime <= now) {
var targetCenterX;
if (noteData.partOfWiderSwipe && noteData.widerSwipePairCenterX !== undefined) {
if (noteData.partOfWiderSwipe === 'leftHalf') {
targetCenterX = noteData.widerSwipePairCenterX - SWIPE_NOTE_WIDTH / 2;
} else if (noteData.partOfWiderSwipe === 'rightHalf') {
targetCenterX = noteData.widerSwipePairCenterX + SWIPE_NOTE_WIDTH / 2;
} else {
targetCenterX = columnCenterXs[noteData.originalColumnHint !== undefined ? noteData.originalColumnHint : Math.floor(NUM_COLUMNS / 2)];
}
} else if (noteData.columnIndex !== undefined && noteData.columnIndex >= 0 && noteData.columnIndex < NUM_COLUMNS) {
targetCenterX = columnCenterXs[noteData.columnIndex];
} else {
targetCenterX = playfieldWidth / 2;
console.warn("spawnNotes - Note spawned without proper columnIndex or widerSwipe info:", noteData);
}
var isBuffNoteFromGenerator = noteData.isBuffNote || false;
var buffTypeFromGenerator = noteData.buffType || null;
var n = new Note(noteData.type, noteData.swipeDir, noteTargetHitTime, targetCenterX, noteData.columnIndex, isBuffNoteFromGenerator, buffTypeFromGenerator, noteData.duration);
n.mapData = noteData;
if (noteData.partOfWiderSwipe) {
n.isWiderSwipePart = true;
}
notes.push(n);
game.addChild(n);
nextNoteIdx++;
} else {
break;
}
}
}
function removeOldNotes() {
var now = Date.now();
for (var i = notes.length - 1; i >= 0; i--) {
var n = notes[i];
var timeToRemoveAfterJudged = 700; // ms po targetHitTime dla ocenionych notatek
var timeToRemoveIfNotJudged = noteTravelTime / 2 + hitWindowGood + 500; // Dłuższy czas, jeśli nieoceniona, liczony od targetHitTime
if (n.judged && now > n.targetHitTime + timeToRemoveAfterJudged) {
if (n.parent) {
n.destroy();
}
notes.splice(i, 1);
} else if (!n.judged && now > n.targetHitTime + timeToRemoveIfNotJudged) {
if (n.noteType !== 'trap') {}
if (n.parent) {
n.destroy();
}
notes.splice(i, 1);
}
}
}
function findNoteAt(x, y, typeToFind) {
var now = Date.now();
var bestNote = null;
var smallestTimeDiff = hitWindowGood + 1;
for (var i = 0; i < notes.length; i++) {
var n = notes[i];
if (n.judged || n.noteType !== typeToFind && !(typeToFind === 'tap' && n.isHoldNote && !n.isBeingHeld)) {
continue;
}
var compensatedTargetTime = n.targetHitTime;
var timeDiffWithCompensation = Math.abs(now - compensatedTargetTime);
if (timeDiffWithCompensation > hitWindowGood) {
continue;
}
var originalTimeDiff = Math.abs(now - n.targetHitTime);
var targetYCenter, hitRadiusX, hitRadiusY;
var spatialBuffMultiplier = isPrecisionBuffActive ? 1.5 : 1.0;
if (n.isHoldNote) {
targetYCenter = n.y + n.yOffset - HOLD_HITBOX_HEIGHT / 2;
hitRadiusX = HOLD_HITBOX_WIDTH / 2 * spatialBuffMultiplier;
hitRadiusY = HOLD_HITBOX_HEIGHT / 2 * spatialBuffMultiplier;
} else if (n.noteAsset) {
targetYCenter = n.y;
hitRadiusX = n.noteAsset.width * n.scale.x / 2 * spatialBuffMultiplier * SPATIAL_HITBOX_MULTIPLIER;
hitRadiusY = n.noteAsset.height * n.scale.y / 2 * spatialBuffMultiplier * SPATIAL_HITBOX_MULTIPLIER;
} else {
continue;
}
var dx = x - n.x;
var dy = y - targetYCenter;
if (Math.abs(dx) <= hitRadiusX && Math.abs(dy) <= hitRadiusY) {
if (originalTimeDiff < smallestTimeDiff) {
bestNote = n;
smallestTimeDiff = originalTimeDiff;
}
}
}
return bestNote;
}
function addScore(result) {
if (isTutorialMode) {
return;
}
if (result === 'perfect') {
score += 100;
} else if (result === 'good') {
score += 50;
}
scoreTxt.setText('Score: ' + score);
}
function addCombo() {
if (isTutorialMode) {
return;
}
combo += 1;
if (combo > maxCombo) {
maxCombo = combo;
}
comboTxt.setText('Combo: ' + combo);
if (combo > 1) {
var originalScale = comboTxt.scale.x;
tween(comboTxt.scale, {
x: originalScale * 1.3,
y: originalScale * 1.3
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(comboTxt.scale, {
x: originalScale,
y: originalScale
}, {
duration: 100,
easing: tween.easeIn
});
}
});
}
}
function resetCombo() {
combo = 0;
comboTxt.setText('Combo: 0');
}
function checkGameEnd() {
if (isTutorialMode || gameOverFlag) {
return;
}
var summaryData = {
score: score,
maxCombo: maxCombo,
bossWasActuallyDefeated: bossWasDefeatedThisSong,
statusMessage: ""
};
if (playerCurrentHP <= 0) {
gameOverFlag = true;
console.log("GAME OVER - Player HP depleted");
setMusic(null);
summaryData.statusMessage = "GAME OVER";
summaryData.bossWasActuallyDefeated = false;
displayEndOfSongScreen(summaryData);
return;
}
if (bossCurrentHP <= 0 && !bossWasDefeatedThisSong) {
bossWasDefeatedThisSong = true;
console.log("Boss HP depleted during song! Player continues playing.");
if (currentFightingBossId && bossUnlockProgress.hasOwnProperty(currentFightingBossId)) {
bossUnlockProgress[currentFightingBossId] = true;
console.log("Boss " + currentFightingBossId + " marked as defeated in progress.");
storage[BOSS_UNLOCK_KEY] = bossUnlockProgress;
console.log("Boss unlock progress saved to storage.");
}
}
if (currentScreenState !== 'endlessLoopActive') {
if (currentActiveRhythmMap && nextNoteIdx >= currentActiveRhythmMap.length && notes.length === 0) {
gameOverFlag = true;
console.log("SONG ENDED");
setMusic(null);
if (bossWasDefeatedThisSong) {
summaryData.statusMessage = "VICTORY!";
} else {
summaryData.statusMessage = "SONG COMPLETED";
}
summaryData.bossWasActuallyDefeated = bossWasDefeatedThisSong;
displayEndOfSongScreen(summaryData);
return;
}
}
}
function getSongStats(songMapKey) {
console.log("getSongStats called for songMapKey:", songMapKey);
if (!songMapKey) {
console.warn("getSongStats: No songMapKey provided, returning default stats.");
return {
bestScore: 0,
bestCombo: 0
};
}
var individualSongStorageKey = 'wf_stats_' + songMapKey;
console.log("getSongStats: Attempting to read from storage key:", individualSongStorageKey);
var songStats = storage[individualSongStorageKey];
// ZMIENIONA LINIA DEBUGOWANIA:
console.log("getSongStats: Raw data from storage for " + individualSongStorageKey + ":", songStats);
// Po prostu logujemy surowy obiekt songStats, bez JSON.parse(JSON.stringify(...))
if (songStats) {
var statsToReturn = {
bestScore: parseInt(songStats.bestScore, 10) || 0,
bestCombo: parseInt(songStats.bestCombo, 10) || 0
};
console.log("getSongStats: Parsed and returning stats:", statsToReturn);
return statsToReturn;
}
console.log("getSongStats: No stats found in storage for " + individualSongStorageKey + ", returning default stats.");
return {
bestScore: 0,
bestCombo: 0
};
}
function saveSongStats(songMapKey, currentScore, currentCombo) {
if (!songMapKey) {
return;
}
var individualSongStorageKey = 'wf_stats_' + songMapKey; // Unikalny klucz dla piosenki
// Odczytaj istniejące statystyki dla tej konkretnej piosenki lub utwórz nowy obiekt
var storedData = storage[individualSongStorageKey];
var songStats;
if (storedData) {
songStats = {
bestScore: storedData.bestScore,
bestCombo: storedData.bestCombo
};
} else {
songStats = {
bestScore: 0,
bestCombo: 0
};
}
var updated = false;
var numericCurrentScore = parseInt(currentScore, 10) || 0;
var numericCurrentCombo = parseInt(currentCombo, 10) || 0;
if (numericCurrentScore > (parseInt(songStats.bestScore, 10) || 0)) {
songStats.bestScore = numericCurrentScore;
updated = true;
console.log("New best score for " + songMapKey + " (" + individualSongStorageKey + "): " + numericCurrentScore);
}
if (numericCurrentCombo > (parseInt(songStats.bestCombo, 10) || 0)) {
songStats.bestCombo = numericCurrentCombo;
updated = true;
console.log("New best combo for " + songMapKey + " (" + individualSongStorageKey + "): " + numericCurrentCombo);
}
if (updated) {
storage[individualSongStorageKey] = songStats; // Zapisz obiekt statystyk dla tej piosenki
console.log("Song stats saved to storage for key: " + individualSongStorageKey);
}
}
function startEndlessMode() {
// Ta funkcja teraz tylko uruchamia dedykowane intro dla nowego trybu.
showEndlessIntro();
}
function displayEndOfSongScreen(summaryData) {
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
}
songSummaryContainer = new Container();
songSummaryContainer.x = 0;
songSummaryContainer.y = 0;
game.addChild(songSummaryContainer);
currentScreenState = 'songSummary';
if (lastPlayedSongKeyForRestart) {
saveSongStats(lastPlayedSongKeyForRestart, summaryData.score, summaryData.maxCombo);
}
var bestStats = getSongStats(lastPlayedSongKeyForRestart || summaryData.songMapKey);
var overlay = LK.getAsset('summaryOverlayAsset', {
width: gameScreenWidth,
height: gameScreenHeight,
alpha: 0.7,
interactive: true
});
songSummaryContainer.addChild(overlay);
var popupWidth = gameScreenWidth * 0.6;
var popupHeight = 1720;
var popupX = (gameScreenWidth - popupWidth) / 2;
var popupY = (gameScreenHeight - popupHeight) / 2;
var popupBackground = LK.getAsset('summaryPopupBackgroundAsset', {
x: popupX,
y: popupY,
width: popupWidth,
height: popupHeight
});
songSummaryContainer.addChild(popupBackground);
// --- Sekcja Layoutu ---
// DŹWIGNIE DO STEROWANIA ODSTĘPAMI (możesz je zmieniać)
var v_gap_title = 80;
var v_gap_stats = 55;
var v_gap_bests = 55;
var v_gap_buttons = 90;
// 1. Stwórz wszystkie elementy, ale jeszcze ich nie pozycjonuj
var titleText = new Text2(summaryData.statusMessage || "SONG ENDED", {
size: 70,
fill: 0xFFFFFF,
align: 'center'
});
var bossDefeatedContainer = new Container();
var bossDefeatedStatusText = new Text2("Boss Defeated: ", {
size: 60,
fill: 0xFFFFFF
});
var bossDefeatedValueText = new Text2(summaryData.bossWasActuallyDefeated ? "YES" : "NO", {
size: 60,
fill: summaryData.bossWasActuallyDefeated ? 0x00FF00 : 0xFF0000
});
bossDefeatedValueText.x = bossDefeatedStatusText.width + 10;
bossDefeatedContainer.addChild(bossDefeatedStatusText);
bossDefeatedContainer.addChild(bossDefeatedValueText);
var scoreTextSummary = new Text2("Score: " + summaryData.score, {
size: 50,
fill: 0xFFFFFF,
align: 'center'
});
var comboTextSummary = new Text2("Max Combo: " + summaryData.maxCombo, {
size: 50,
fill: 0xFFFFFF,
align: 'center'
});
var bestScoreText = new Text2("Best Score: " + bestStats.bestScore, {
size: 50,
fill: 0xFFFF00,
align: 'center'
});
var bestComboText = new Text2("Best Combo: " + bestStats.bestCombo, {
size: 50,
fill: 0xFFFF00,
align: 'center'
});
var allElements = [titleText, bossDefeatedContainer, scoreTextSummary, comboTextSummary, bestScoreText, bestComboText];
var gaps = [v_gap_title, v_gap_stats, v_gap_stats, v_gap_bests, v_gap_bests, v_gap_buttons];
// 2. Oblicz całkowitą wysokość bloku zawartości
var totalContentHeight = 0;
for (var i = 0; i < allElements.length; i++) {
totalContentHeight += allElements[i].height;
if (gaps[i]) {
totalContentHeight += gaps[i];
}
}
var buttonHeight = 70; // Wysokość przycisków
totalContentHeight += buttonHeight;
// 3. Oblicz pozycję startową Y, aby wyśrodkować cały blok
var currentY = popupY + (popupHeight - totalContentHeight) / 2;
// 4. Rozmieść wszystkie elementy jeden pod drugim
allElements.forEach(function (element, index) {
element.y = currentY + element.height / 2;
element.x = popupX + popupWidth / 2;
if (element.anchor) {
element.anchor.set(0.5, 0.5);
} else {
// dla kontenera
element.pivot.x = element.width / 2;
element.pivot.y = element.height / 2;
}
songSummaryContainer.addChild(element);
currentY += element.height + gaps[index];
});
// 5. Umieść przyciski na samym dole bloku
var buttonWidth = popupWidth * 0.4;
var buttonY = currentY + buttonHeight / 2;
var backButtonBg = LK.getAsset('summaryButtonBackgroundAsset', {
x: popupX + (popupWidth / 2 - buttonWidth - 15),
y: buttonY,
width: buttonWidth,
height: buttonHeight,
interactive: true,
cursor: "pointer"
});
songSummaryContainer.addChild(backButtonBg);
var backToMenuButton = new Text2("Back to Menu", {
size: 40,
fill: 0xFFD700,
stroke: 0x000000,
strokeThickness: 2
});
backToMenuButton.anchor.set(0.5, 0.5);
backToMenuButton.x = backButtonBg.x + buttonWidth / 2;
backToMenuButton.y = backButtonBg.y + buttonHeight / 2;
songSummaryContainer.addChild(backToMenuButton);
backButtonBg.down = function () {
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
songSummaryContainer = null;
}
if (gameplayBackground && gameplayBackground.parent) {
gameplayBackground.destroy();
gameplayBackground = null;
}
showBossSelectionScreen();
};
var restartButtonBg = LK.getAsset('summaryButtonBackgroundAsset', {
x: popupX + (popupWidth / 2 + 15),
y: buttonY,
width: buttonWidth,
height: buttonHeight,
interactive: true,
cursor: "pointer"
});
songSummaryContainer.addChild(restartButtonBg);
var restartButton = new Text2("Restart Battle", {
size: 40,
fill: 0xFFD700,
stroke: 0x000000,
strokeThickness: 2
});
restartButton.anchor.set(0.5, 0.5);
restartButton.x = restartButtonBg.x + buttonWidth / 2;
restartButton.y = restartButtonBg.y + buttonHeight / 2;
songSummaryContainer.addChild(restartButton);
restartButtonBg.down = function () {
if (songSummaryContainer && songSummaryContainer.parent) {
songSummaryContainer.destroy();
songSummaryContainer = null;
}
if (lastPlayedSongKeyForRestart) {
loadSong(lastPlayedSongKeyForRestart);
} else {
showMainMenu();
}
};
if (gameUIContainer) {
gameUIContainer.visible = false;
}
if (staticHitFrame) {
staticHitFrame.visible = false;
}
if (staticPerfectLine) {
staticPerfectLine.visible = false;
}
}
game.onNoteMiss = function (note) {
if (!note) {
return;
}
note.showHitFeedback('miss');
if (!isTutorialMode) {
if (isShieldActive) {
console.log("Gracz ominął nutę, ale tarcza jest aktywna! Brak utraty HP i combo NIE zresetowane.");
} else {
resetCombo();
if (!gameOverFlag) {
playerCurrentHP = Math.max(0, playerCurrentHP - 1);
updatePlayerHpDisplay();
console.log("Player HP after miss: " + playerCurrentHP);
}
}
}
if (note.parent) {
LK.effects.flashObject(note, 0xff0000, 300);
}
};
game.down = function (x, y, obj) {
if (currentScreenState === 'gameplay' || currentScreenState === 'endlessLoopActive') {
if (inputLocked) {
return;
}
swipeStart = {
x: x,
y: y,
time: Date.now()
};
var now = Date.now();
for (var i_gp_pu = activePowerUpItems.length - 1; i_gp_pu >= 0; i_gp_pu--) {
var pItem_gp = activePowerUpItems[i_gp_pu];
if (pItem_gp && !pItem_gp.collected && pItem_gp.visualAsset && pItem_gp.parent) {
var pWidth_gp = pItem_gp.visualAsset.width * pItem_gp.scale.x;
var pHeight_gp = pItem_gp.visualAsset.height * pItem_gp.scale.y;
if (x >= pItem_gp.x - pWidth_gp / 2 && x <= pItem_gp.x + pWidth_gp / 2 && y >= pItem_gp.y - pHeight_gp / 2 && y <= pItem_gp.y + pHeight_gp / 2) {
if (Math.abs(pItem_gp.y - hitZoneY) < pHeight_gp * 1.5) {
pItem_gp.collect();
return;
}
}
}
}
var noteUnderCursorTrap = findNoteAt(x, y, 'trap');
if (noteUnderCursorTrap && !noteUnderCursorTrap.judged && noteUnderCursorTrap.isInHitWindow()) {
noteUnderCursorTrap.judged = true;
noteUnderCursorTrap.showHitFeedback('miss');
if (!isTutorialMode) {
if (isShieldActive) {
console.log("Gracz trafił w TRAP NOTE, ale tarcza jest aktywna! Brak utraty HP i combo NIE zresetowane.");
} else {
resetCombo();
LK.effects.flashScreen(0xff0000, 400);
if (!gameOverFlag) {
playerCurrentHP = Math.max(0, playerCurrentHP - 1);
updatePlayerHpDisplay();
}
}
}
if (noteUnderCursorTrap.alpha > 0) {
noteUnderCursorTrap.alpha = 0;
}
inputLocked = true;
LK.setTimeout(function () {
inputLocked = false;
}, 200);
return;
}
var noteUnderCursor = findNoteAt(x, y, 'tap');
if (noteUnderCursor && !noteUnderCursor.judged && !noteUnderCursor.isBeingHeld && noteUnderCursor.isInHitWindow()) {
var result = noteUnderCursor.getHitAccuracy();
noteUnderCursor.hit = true;
if (noteUnderCursor.isHoldNote) {
if (result !== 'miss') {
console.log("HOLD PRESSED: noteType=" + noteUnderCursor.noteType + ", y=" + noteUnderCursor.y.toFixed(2) + ", noteAsset.y=" + (noteUnderCursor.noteAsset ? noteUnderCursor.noteAsset.y.toFixed(2) : "N/A") + ", centerY=" + noteUnderCursor.centerY + ", now=" + now + ", targetHitTime=" + noteUnderCursor.targetHitTime + ", diffToTarget=" + (noteUnderCursor.targetHitTime - now) + ", result=" + result);
noteUnderCursor.isBeingHeld = true;
noteUnderCursor.holdPressTime = now;
noteUnderCursor.showHitFeedback(result);
if (noteUnderCursor.noteColumnIndex !== undefined) {
var overlay = columnFlashOverlays[noteUnderCursor.noteColumnIndex];
if (overlay) {
overlay.alpha = 0.5;
}
}
if (!isTutorialMode) {
addScore(result);
addCombo();
if (!gameOverFlag) {
if (result === 'perfect') {
bossCurrentHP = Math.max(0, bossCurrentHP - 2);
} else if (result === 'good') {
bossCurrentHP = Math.max(0, bossCurrentHP - 1);
}
updateBossHpDisplay();
}
}
if (noteUnderCursor.mapData && noteUnderCursor.mapData.columnIndex !== undefined) {
currentlyHeldNotes[noteUnderCursor.mapData.columnIndex] = noteUnderCursor;
} else if (noteUnderCursor.originalColumnHint !== undefined) {
currentlyHeldNotes[noteUnderCursor.originalColumnHint] = noteUnderCursor;
}
} else {
noteUnderCursor.judged = true;
noteUnderCursor.showHitFeedback('miss');
if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
if (noteUnderCursor.alpha > 0) {
noteUnderCursor.alpha = 0;
}
}
} else {
noteUnderCursor.judged = true;
noteUnderCursor.showHitFeedback(result);
if (noteUnderCursor.noteColumnIndex !== undefined) {
flashColumn(noteUnderCursor.noteColumnIndex);
}
if (noteUnderCursor.isBuffNote) {
if (result !== 'miss' && !isTutorialMode) {
var buffType = noteUnderCursor.buffType;
if (buffType === 'potion') {
playerCurrentHP = Math.min(playerMaxHP, playerCurrentHP + POTION_HEAL_AMOUNT);
updatePlayerHpDisplay();
} else if (buffType === 'shield') {
if (!isShieldActive) {
isShieldActive = true;
shieldEndTime = Date.now() + SHIELD_DURATION;
if (shieldTimerDisplayContainer) {
shieldTimerDisplayContainer.visible = true;
}
}
} else if (buffType === 'precision') {
if (!isPrecisionBuffActive) {
isPrecisionBuffActive = true;
precisionBuffEndTime = Date.now() + PRECISION_BUFF_DURATION;
originalHitWindowPerfect = hitWindowPerfect;
originalHitWindowGood = hitWindowGood;
hitWindowPerfect = Math.round(hitWindowPerfect * precisionBuffHitWindowMultiplier);
hitWindowGood = Math.round(hitWindowGood * precisionBuffHitWindowMultiplier);
if (precisionBuffTimerDisplayContainer) {
precisionBuffTimerDisplayContainer.visible = true;
}
if (staticHitFrame) {
tween(staticHitFrame, {
height: STATIC_HIT_FRAME_HEIGHT * 2
}, {
duration: 250,
easing: tween.easeOutQuad
});
}
}
}
} else if (result === 'miss' && !isTutorialMode && !isShieldActive) {
resetCombo();
}
} else {
if (result !== 'miss') {
addScore(result);
addCombo();
if (!isTutorialMode && !gameOverFlag) {
if (result === 'perfect') {
bossCurrentHP = Math.max(0, bossCurrentHP - 2);
} else if (result === 'good') {
bossCurrentHP = Math.max(0, bossCurrentHP - 1);
}
updateBossHpDisplay();
}
} else if (!isTutorialMode) {
if (!isShieldActive) {
resetCombo();
} else {
console.log("Tapnięcie nuty ocenione jako 'miss', ale tarcza jest aktywna! Combo NIE zresetowane.");
}
}
}
}
inputLocked = true;
LK.setTimeout(function () {
inputLocked = false;
}, 120);
return;
}
}
};
game.move = function (x, y, obj) {};
game.up = function (x, y, obj) {
if (currentScreenState === 'gameplay' || currentScreenState === 'endlessLoopActive') {
var holdReleasedThisUp = false;
for (var colIdx in currentlyHeldNotes) {
if (currentlyHeldNotes.hasOwnProperty(colIdx)) {
var heldNote = currentlyHeldNotes[colIdx];
if (heldNote && heldNote.isBeingHeld) {
console.log("Releasing hold note in column: " + (heldNote.noteColumnIndex !== undefined ? heldNote.noteColumnIndex : heldNote.mapData ? heldNote.mapData.columnIndex : 'unknown'));
heldNote.judgeHoldRelease();
delete currentlyHeldNotes[colIdx];
holdReleasedThisUp = true;
}
}
}
if (holdReleasedThisUp) {
swipeStart = null;
inputLocked = true;
LK.setTimeout(function () {
inputLocked = false;
}, 80);
return;
}
if (inputLocked || !swipeStart) {
swipeStart = null;
return;
}
var swipeEndX = x;
var swipeEndY = y;
var swipeEndTime = Date.now();
var dx = swipeEndX - swipeStart.x;
var dy = swipeEndY - swipeStart.y;
var dist = Math.sqrt(dx * dx + dy * dy);
var potentialSwipe = dist >= MIN_SWIPE_DISTANCE;
if (potentialSwipe) {
var detectedDir = null;
if (Math.abs(dx) > Math.abs(dy)) {
detectedDir = dx > 0 ? 'right' : 'left';
} else {
detectedDir = dy > 0 ? 'down' : 'up';
}
var swipeBoundingBox = {
x: Math.min(swipeStart.x, swipeEndX),
y: Math.min(swipeStart.y, swipeEndY),
width: Math.abs(dx),
height: Math.abs(dy)
};
var notesHitThisSwipe = [];
for (var i_swipe = 0; i_swipe < notes.length; i_swipe++) {
var n_swipe = notes[i_swipe];
if (n_swipe.judged || n_swipe.noteType !== 'swipe' || n_swipe.alpha === 0) {
continue;
}
var overallSwipeTimeMatchesNote = false;
if (n_swipe.targetHitTime >= swipeStart.time - hitWindowGood && n_swipe.targetHitTime <= swipeEndTime + hitWindowGood) {
overallSwipeTimeMatchesNote = true;
}
if (!overallSwipeTimeMatchesNote) {
if (swipeStart.time >= n_swipe.targetHitTime - hitWindowGood && swipeStart.time <= n_swipe.targetHitTime + hitWindowGood || swipeEndTime >= n_swipe.targetHitTime - hitWindowGood && swipeEndTime <= n_swipe.targetHitTime + hitWindowGood) {
overallSwipeTimeMatchesNote = true;
}
}
if (!overallSwipeTimeMatchesNote) {
continue;
}
var noteCurrentWidth_swipe = n_swipe.noteAsset ? n_swipe.noteAsset.width : SWIPE_NOTE_WIDTH;
var noteCurrentHeight_swipe = n_swipe.noteAsset ? n_swipe.noteAsset.height : SWIPE_NOTE_WIDTH;
var noteBoundingBox_swipe = {
x: n_swipe.x - noteCurrentWidth_swipe / 2,
y: n_swipe.y - noteCurrentHeight_swipe / 2,
width: noteCurrentWidth_swipe,
height: noteCurrentHeight_swipe
};
if (rectsIntersect(swipeBoundingBox, noteBoundingBox_swipe)) {
if (detectedDir === n_swipe.swipeDir) {
var verticalProximity = Math.abs(n_swipe.y - n_swipe.centerY);
var verticalTolerance = noteCurrentHeight_swipe / 1.5;
if (verticalProximity < verticalTolerance) {
notesHitThisSwipe.push(n_swipe);
}
}
}
}
if (notesHitThisSwipe.length > 0) {
notesHitThisSwipe.sort(function (a, b) {
var da = Math.abs(swipeEndTime - a.targetHitTime);
var db = Math.abs(swipeEndTime - b.targetHitTime);
return da - db;
});
var maxNotesToHitPerSwipe = 1;
var notesActuallyHitCount = 0;
for (var k_swipe = 0; k_swipe < notesHitThisSwipe.length && notesActuallyHitCount < maxNotesToHitPerSwipe; k_swipe++) {
var noteToJudge_swipe = notesHitThisSwipe[k_swipe];
if (noteToJudge_swipe.judged) {
continue;
}
var result_swipe = noteToJudge_swipe.getHitAccuracy();
noteToJudge_swipe.judged = true;
noteToJudge_swipe.showHitFeedback(result_swipe);
if (noteToJudge_swipe.noteColumnIndex !== undefined) {
flashColumn(noteToJudge_swipe.noteColumnIndex);
}
if (result_swipe !== 'miss') {
addScore(result_swipe);
addCombo();
if (!isTutorialMode && !gameOverFlag) {
if (result_swipe === 'perfect') {
bossCurrentHP = Math.max(0, bossCurrentHP - 2);
} else if (result_swipe === 'good') {
bossCurrentHP = Math.max(0, bossCurrentHP - 1);
}
updateBossHpDisplay();
}
} else if (!isTutorialMode && !isShieldActive) {
resetCombo();
}
notesActuallyHitCount++;
}
}
}
inputLocked = true;
LK.setTimeout(function () {
inputLocked = false;
}, 80);
swipeStart = null;
}
};
game.update = function () {
if (typeof notes === 'undefined' || !Array.isArray(notes)) {
notes = [];
}
var now = Date.now();
if (currentScreenState === 'miniGameActive' && !isMiniGameOver) {
miniGameTimeActive += 16;
if (miniGameTimeActive >= MINI_GAME_SPEED_INCREASE_INTERVAL) {
currentMiniGameObjectSpeed += MINI_GAME_SPEED_INCREMENT;
miniGameTimeActive = 0;
}
if (miniGamePlayer && miniGamePlayer.asset && typeof miniGamePlayer.asset.update === 'function') {
miniGamePlayer.asset.update();
}
for (var i = 0; i < miniGameObstacles.length; i++) {
var obs = miniGameObstacles[i];
if (obs && obs.asset && typeof obs.asset.update === 'function') {
obs.asset.update();
}
}
spawnMiniGameObstacle();
moveMiniGameObstacles();
checkMiniGameCollisions();
updateMiniGameScoreDisplay();
} else if (currentScreenState === 'miniGameActive' && isMiniGameOver) {
if (miniGameScreenElements.find(function (el) {
return el.isGameOverText;
}) === undefined) {
var gameOverText = new Text2("GAME OVER", {
size: 100,
fill: 0xFF0000,
align: 'center'
});
gameOverText.anchor.set(0.5, 0.5);
gameOverText.x = miniGameViewport.x + miniGameViewport.width / 2;
gameOverText.y = miniGameViewport.y + miniGameViewport.height / 2;
gameOverText.isGameOverText = true;
game.addChild(gameOverText);
miniGameScreenElements.push(gameOverText);
}
} else if (currentScreenState === 'gameplay') {
if (!isTutorialMode) {
if (isShieldActive) {
if (playerShieldAnimation) {
playerShieldAnimation.visible = true;
playerShieldAnimation.update();
}
if (now > shieldEndTime) {
isShieldActive = false;
if (shieldTimerDisplayContainer) {
shieldTimerDisplayContainer.visible = false;
}
if (playerShieldAnimation) {
playerShieldAnimation.visible = false;
}
console.log("Tarcza WYGASŁA.");
} else {
if (shieldTimerDisplayContainer && shieldTimerDisplayContainer.visible) {
var remainingSecondsShield = (shieldEndTime - now) / 1000;
if (shieldTimerTextDisplay) {
shieldTimerTextDisplay.setText(remainingSecondsShield.toFixed(1) + "s");
}
}
}
} else {
if (shieldTimerDisplayContainer && shieldTimerDisplayContainer.visible) {
shieldTimerDisplayContainer.visible = false;
}
if (playerShieldAnimation && playerShieldAnimation.visible) {
playerShieldAnimation.visible = false;
}
}
if (isPrecisionBuffActive) {
if (now > precisionBuffEndTime) {
isPrecisionBuffActive = false;
hitWindowPerfect = originalHitWindowPerfect;
hitWindowGood = originalHitWindowGood;
if (precisionBuffTimerDisplayContainer) {
precisionBuffTimerDisplayContainer.visible = false;
}
if (staticHitFrame) {
tween(staticHitFrame, {
height: STATIC_HIT_FRAME_HEIGHT
}, {
duration: 250,
easing: tween.easeInQuad
});
}
} else {
if (precisionBuffTimerDisplayContainer && precisionBuffTimerDisplayContainer.visible) {
var remainingSecondsBuff = (precisionBuffEndTime - now) / 1000;
if (precisionBuffTimerTextDisplay) {
precisionBuffTimerTextDisplay.setText(remainingSecondsBuff.toFixed(1) + "s");
}
}
}
} else {
if (precisionBuffTimerDisplayContainer && precisionBuffTimerDisplayContainer.visible) {
precisionBuffTimerDisplayContainer.visible = false;
}
}
}
spawnNotes();
for (var i_update_notes = 0; i_update_notes < notes.length; i_update_notes++) {
if (notes[i_update_notes] && notes[i_update_notes].update) {
notes[i_update_notes].update();
}
}
removeOldNotes();
if (isTutorialMode) {
var songHasEnded = activeMusicTrack && !activeMusicTrack.playing && now - gameStartTime > (activeMusicTrack.duration || 0) * 1000;
var noNotesLeftOnScreen = notes.length === 0;
var allNotesProcessed = nextNoteIdx >= (currentActiveRhythmMap ? currentActiveRhythmMap.length : 0);
if (songHasEnded && noNotesLeftOnScreen && allNotesProcessed && activeMusicTrack && now - gameStartTime > (activeMusicTrack.duration || 0) * 1000 + 500) {
exitTutorialGameplay();
return;
}
} else {
checkGameEnd();
}
} else if (currentScreenState === 'endlessLoopActive') {
if (currentEndlessDifficulty < MAX_ENDLESS_DIFFICULTY) {
currentEndlessDifficulty += ENDLESS_DIFFICULTY_INCREASE_RATE * (16 / 1000);
}
if (activeMusicTrack && !activeMusicTrack.playing && notes.length === 0) {
console.log("Utwór w pętli zakończony, przełączam na następny...");
playNextEndlessSong();
}
spawnNotes();
for (var i_update_notes_endless = 0; i_update_notes_endless < notes.length; i_update_notes_endless++) {
if (notes[i_update_notes_endless] && notes[i_update_notes_endless].update) {
notes[i_update_notes_endless].update();
}
}
removeOldNotes();
checkGameEnd();
} else {
if (notes.length > 0) {
for (var i_notes_clear = notes.length - 1; i_notes_clear >= 0; i_notes_clear--) {
var n_clear = notes[i_notes_clear];
if (n_clear && n_clear.parent) {
n_clear.destroy();
}
}
notes = [];
}
if (staticHitFrame && staticHitFrame.visible) {
staticHitFrame.visible = false;
}
if (staticPerfectLine && staticPerfectLine.visible) {
staticPerfectLine.visible = false;
}
}
};
// Load the specific song for testing
showStartScreen();