User prompt
create tutorial section
Code edit (1 edits merged)
Please save this source code
User prompt
Chronos's Burden
Initial prompt
Stage 1: Initial Game Design (Psychologically Limiting Difficulty, High Goals) Game Title: Chronos's Burden Genre: 2D Time-Management Puzzle/Strategy with Roguelike Elements Core Concept: The player controls a lone Chronomancer tasked with preventing the complete collapse of a fractured timeline. The psychological burden comes from the constant, unavoidable loss and the impossibility of perfect success, forcing the player to make agonizing choices and live with their failures. Gameplay Loop (Basic): The Nexus: The central hub, representing the Chronomancer's current, relatively stable temporal position. From here, the player observes multiple "Temporal Anomalies" (levels) appearing simultaneously. Temporal Anomalies (Levels): Each anomaly is a small, self-contained puzzle. These could be: Resource Gathering: Collect 'Chronon Fragments' (currency/XP) before a timeline fully destabilizes. Event Correction: Prevent a catastrophic event (e.g., a city being destroyed, a key historical figure dying prematurely) by manipulating time within that anomaly. Entity Containment: Capture or neutralize rogue temporal entities. Time Limit: Each anomaly has a strict, visible, and unforgiving real-time countdown. When the timer hits zero, that anomaly fails. Simultaneous Appearance: Multiple anomalies (e.g., 3-5) appear at once. The player can only focus on one at a time. Switching between anomalies costs a small amount of "Temporal Cohesion" (a global resource, see below). Consequences of Failure: Minor Anomalies: Result in a visible "scar" on the timeline, a permanent negative debuff (e.g., -5% Chronon gain, +10% anomaly speed, a new type of hostile temporal entity appears more often). Major Anomalies (High Goals): These are rare but critical. Failure of a Major Anomaly results in a "Temporal Paradox" event, which can lead to: Immediate game over. A significant chunk of progress being reset. The introduction of new, more devastating types of anomalies or enemies. Crucially: A visual and auditory representation of the chosen path not taken and its positive outcome, rubbing salt in the wound. "Temporal Cohesion" (Global Resource): This represents the overall stability of reality. It slowly drains over time. Successfully completing anomalies replenishes a small amount. Failing anomalies, switching between them, or attempting advanced temporal manipulations drain it faster. When Temporal Cohesion hits zero, it's game over. Upgrades (Limited): Chronon Fragments can be used to purchase minor upgrades (e.g., slightly faster movement in anomalies, reduced Temporal Cohesion drain when switching). Upgrades are always a difficult choice, as Chronon is also needed to activate certain abilities within anomalies. High Goals: Survival: Last as many "temporal cycles" (rounds of anomalies) as possible. Minimizing Damage: The ultimate goal is not to "win" in the traditional sense, but to minimize the overall entropy and damage to the timeline. A score is presented based on successful anomalies vs. failed ones, temporal cohesion remaining, and accumulated debuffs. Specific "Mythic" Anomalies: Very rarely, an anomaly appears that, if completed, could permanently remove a significant debuff or grant a powerful, game-changing boon. These are incredibly difficult and demand all of the player's focus, guaranteeing other anomalies will fail. Psychological Limiting Factors: Constant Loss Aversion: The game forces the player to choose what to let fail. You cannot save everything. This is designed to be deeply frustrating and emotionally draining. Decision Paralysis: Multiple urgent timers counting down simultaneously, combined with limited resources, will create immense pressure. Regret and "What If?": The visual feedback of failed outcomes and the knowledge that a different choice could have saved something will foster strong feelings of regret. Hopelessness (Controlled): The underlying theme is that the universe is inherently chaotic, and the Chronomancer is fighting a losing battle. Success is temporary, and decline is inevitable. The "high goal" is to fight this decline for as long as possible, not to reverse it. Information Overload: Even simple anomalies will have multiple elements to manage, compounding the pressure. Uncertainty: While timers are visible, the exact consequence of a minor anomaly's failure might not be immediately apparent, leading to anxiety. Stage 2: Improving the Game and Fixing Bugs (Initial Pass) Improvements: More Dynamic Anomalies: Mini-Games: Instead of just simple timers, anomalies could involve very basic, quick mini-games: Rhythm Game: Tap in sync with a decaying timeline's pulse. Pattern Matching: Quickly identify and click on matching temporal distortions. Simple Traversal: Navigate a small maze to reach a goal before time runs out. Branching Choices within Anomalies: Sometimes, completing an anomaly presents a choice: save X, but slightly damage Y, or vice-versa. This further reinforces difficult decisions. Resource Scarcity and Feedback: "Chronon Burst" Ability: A very limited, high-cost ability to temporarily slow down all anomaly timers, giving a brief reprieve. Visual/Auditory Decline: As Temporal Cohesion drops, the Nexus environment visually degrades, and the background music becomes more dissonant. When debuffs accumulate, new visual glitches appear across the screen. Strategic Depth: Anomaly "Forecasting": A very expensive upgrade that allows the player to briefly see the type of anomaly that will appear next cycle, allowing for slight pre-planning. "Temporal Resonances": Certain successful anomaly combinations could yield minor, temporary buffs. (e.g., successful "Resource Gathering" + "Event Correction" gives a small boost to Chronon gain for the next 30 seconds). "Narrative Fragments": As major anomalies fail, small, cryptic text snippets appear, hinting at the grander narrative of timeline collapse, adding to the psychological weight. End-Game (No True Win): Instead of a sudden "Game Over" (unless Temporal Cohesion hits zero), the game could transition into an "Unraveling" state where new anomalies appear so rapidly and are so complex that failure becomes inevitable, leading to a slow, agonizing demise. The final score then truly reflects how long the Chronomancer fought. Bug Fixes (Conceptual, as it's a design document): Balancing Anomalies: Too Easy/Too Hard: Initial playtesting will reveal if anomaly timers are too generous or too punishing. Adjust durations, required interactions, and resource costs. Repetitive Anomalies: If mini-games are implemented, ensure enough variety so they don't become stale too quickly. Add more permutations. Resource Sinkholes: Chronon/Temporal Cohesion Economy: Ensure that gaining resources is challenging but not impossible, and that spending them feels meaningful without immediately crippling the player. Adjust upgrade costs and replenishment rates. UI Clarity: Timer Visibility: Ensure all timers are clearly visible, distinct, and easily identifiable. Use color coding (e.g., green for new, yellow for active, red for critical). Debuff Tracking: A clear, concise display of active debuffs and their effects. Feedback Loops: Ensure visual and auditory feedback is clear for success, failure, and critical events (e.g., low Temporal Cohesion alarm). Edge Cases for Failure: Simultaneous Failures: What happens if two anomalies hit zero at the exact same moment? Define the priority (e.g., Major always takes precedence in consequence). Game Over Conditions: Ensure all "Game Over" scenarios are robustly handled and provide appropriate feedback. Input Responsiveness: For mini-games, ensure controls are crisp and responsive to avoid frustration due to technical lag. Stage 3: Explaining this Game to Artificial Intelligence To explain Chronos's Burden to an AI, I'll focus on its rules, goals, state, actions, and the underlying logic of its difficulty. Explanation of "Chronos's Burden" to an Artificial Intelligence (AI) Game Name: Chronos's Burden 1. Game Type & Core Objective: This is a 2D, real-time strategy/puzzle game with time-management and resource-management elements. The primary objective for the player (the "Chronomancer") is not to "win" in a traditional sense, but to maximize the duration of survival by preventing the total collapse of a fractured timeline. Success is measured by how long the player can maintain "Temporal Cohesion" and how few "Temporal Scars" (permanent negative effects) are accumulated. The AI's goal, if it were to play this game, would be to optimize this survival duration and minimize negative outcomes. 2. Game State Representation: The game's state can be represented by a set of variables and objects: Global Variables: TemporalCohesion: Float (0.0 to 100.0). Represents the overall stability of reality. Drains over time. Game ends if TemporalCohesion <= 0.0. ChrononFragments: Integer. Currency/resource used for upgrades and certain anomaly interactions. CurrentCycle: Integer. Represents the number of anomaly waves survived. ActiveDebuffs: List of strings/enums. Each entry represents a permanent negative effect (e.g., "Chronon_Drain_Increased", "Anomaly_Speed_Increased"). TotalFailedAnomalies: Integer. Count of anomalies that timed out. TotalSuccessfulAnomalies: Integer. Count of anomalies completed. Anomaly Objects (Multiple, simultaneously active): AnomalyID: Unique identifier. AnomalyType: Enum (e.g., "ResourceGathering", "EventCorrection", "EntityContainment", "MajorCatastrophe"). Timer: Float (countdown in seconds). Decrements in real-time. If Timer <= 0.0, the anomaly fails. State: Enum (e.g., "Active", "Completed", "Failed"). RequiredInteraction: (Optional) Specifies what the player needs to do (e.g., "Click_Target", "Move_To_Point", "Solve_MiniGame_X"). Rewards: (Optional) What is gained upon success (e.g., +X Chronon, +Y TemporalCohesion). PenaltiesOnFailure: (Optional) What happens if this specific anomaly fails (e.g., +1 "Anomaly_Speed_Increased" debuff). Criticality: Enum (e.g., "Minor", "Major"). Major anomalies have more severe penalties for failure. 3. Player Actions (Discrete, but executed in real-time context): The AI can perform the following actions: FocusAnomaly(AnomalyID): Switches the player's active focus to a specific anomaly. Cost: Small reduction in TemporalCohesion. Effect: The specified anomaly's mini-game/interaction becomes active. Other anomalies continue to count down their timers in the background. PerformInteraction(InteractionType, Target): Executes the required action within the currently focused anomaly. Cost: Varies (e.g., consumes Chronon Fragments for certain abilities). Effect: Advances progress within the anomaly. If all RequiredInteractions are met, the anomaly is marked Completed. PurchaseUpgrade(UpgradeID): Spends ChrononFragments to unlock a permanent minor buff. Cost: ChrononFragments specified by UpgradeID. Effect: Applies the buff (e.g., reduces TemporalCohesion drain, increases movement speed in anomalies). ActivateChrononBurst(): (Limited use, high cost) Cost: Significant ChrononFragments. Effect: Temporarily slows down all active anomaly timers for a short duration. DoNothing(): No specific action is taken, but timers continue to count down. This is the implicit action when no other explicit action is chosen. 4. Game Loop & Progression: Initialization: Set TemporalCohesion to max, ChrononFragments to starting value, clear ActiveDebuffs. Cycle Start: A wave of N new AnomalyObjects (e.g., N=3 to 5) appears, each with its own Timer starting. Real-Time Tick: All AnomalyObjects.Timer decrement. TemporalCohesion decrements. If AnomalyObject.Timer <= 0.0: AnomalyObject.State set to "Failed". TotalFailedAnomalies increments. PenaltiesOnFailure for that anomaly are applied (e.g., add to ActiveDebuffs, apply immediate TemporalCohesion loss). If AnomalyType is "MajorCatastrophe", trigger a TemporalParadox event (potentially game over or major setback). If TemporalCohesion <= 0.0: Game Over. Player Input: AI chooses and executes actions (FocusAnomaly, PerformInteraction, PurchaseUpgrade, ActivateChrononBurst). Anomaly Completion: If PerformInteraction leads to an anomaly's completion: AnomalyObject.State set to "Completed". TotalSuccessfulAnomalies increments. Rewards for that anomaly are applied (e.g., gain ChrononFragments, restore TemporalCohesion). Cycle End: When all AnomalyObjects from the current wave are either Completed or Failed. Increment CurrentCycle. Go to "Cycle Start". Game Over: When TemporalCohesion reaches zero or a critical TemporalParadox occurs. A final score is calculated based on CurrentCycle, TotalSuccessfulAnomalies, TotalFailedAnomalies, and the number/severity of ActiveDebuffs. 5. Difficulty & Psychological Aspects (For AI to understand why it's "hard"): The difficulty stems from: Resource Scarcity: ChrononFragments and TemporalCohesion are always limited. Choices are always trade-offs. Parallelism (Simultaneous Timers): The AI cannot interact with multiple anomalies simultaneously. It must prioritize and consciously decide which anomalies to let fail. Irreversible Consequences: Failure is permanent. Debuffs accumulate, and past mistakes cannot be undone. This creates a "snowball effect" of increasing difficulty. Loss Aversion: The game design explicitly punishes failure with visible negative consequences, designed to evoke a strong "regret" response even in an AI if it were to model human emotional states or optimize for minimal negative feedback. Uncertainty (Initial): While timers are visible, the full long-term impact of a new debuff might not be immediately quantifiable by the AI without extensive simulation or pre-computation. High Goals: The goal isn't perfect success, but minimal failure. This means the AI must optimize for "least bad" outcomes rather than "best" outcomes, a fundamentally different optimization problem. It must understand that sometimes, the optimal move is to sacrifice an outcome to save another. 6. AI Decision-Making Challenges & Potential Approaches: An AI designed to play Chronos's Burden would face a complex optimization problem: Prioritization: Which anomaly to focus on? Factors: Time remaining (most urgent first?) Criticality (Major vs. Minor) Reward vs. Penalty (Which offers the best net gain/least severe loss?) Interaction difficulty/time cost. Resource Allocation: When to spend ChrononFragments on an upgrade vs. saving them for an in-anomaly ability? When to use ChrononBurst? Long-Term vs. Short-Term: Should the AI sacrifice a short-term gain to prevent a long-term debilitating debuff? This requires a robust predictive model. State-Space Search: The AI would need to explore possible action sequences. Given the real-time nature, a pure tree search would be infeasible. Heuristics: Develop powerful heuristics for anomaly prioritization (e.g., "weighted urgency" based on criticality and time remaining). Reinforcement Learning: Train an agent that learns optimal policies through trial and error, rewarding extended survival and penalizing quick failures and excessive debuffs. Monte Carlo Tree Search (MCTS): For limited look-aheads, MCTS could simulate short future sequences of actions to evaluate immediate choices. Multi-Objective Optimization: The AI needs to balance maximizing survival time while minimizing debuffs, potentially using a weighted sum or Pareto optimization.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Anomaly = Container.expand(function (type, difficulty) { var self = Container.call(this); self.type = type || 'minor'; self.difficulty = difficulty || 1; self.maxTime = self.type === 'major' ? 8000 : 5000; self.currentTime = self.maxTime; self.isActive = false; self.isCompleted = false; self.isFailed = false; // Visual elements var anomalyGraphic = self.attachAsset(self.type === 'major' ? 'anomalyMajor' : 'anomalyMinor', { anchorX: 0.5, anchorY: 0.5 }); var timerBg = self.attachAsset('timerBarBg', { anchorX: 0.5, anchorY: 0.5, y: 80 }); var timerBar = self.attachAsset('timerBar', { anchorX: 0.5, anchorY: 0.5, y: 80 }); self.timerBar = timerBar; // Timer text self.timerText = new Text2('5.0s', { size: 30, fill: 0xFFFFFF }); self.timerText.anchor.set(0.5, 0.5); self.timerText.y = 110; self.addChild(self.timerText); // Type label self.typeLabel = new Text2(self.type.toUpperCase(), { size: 25, fill: 0xFFFFFF }); self.typeLabel.anchor.set(0.5, 0.5); self.typeLabel.y = -60; self.addChild(self.typeLabel); self.updateTimer = function () { if (!self.isActive || self.isCompleted || self.isFailed) return; self.currentTime -= 16.67; // 60fps if (self.currentTime <= 0) { self.currentTime = 0; self.fail(); return; } var timePercent = self.currentTime / self.maxTime; self.timerBar.scaleX = timePercent; // Color timer based on remaining time if (timePercent > 0.5) { self.timerBar.tint = 0x27ae60; // green } else if (timePercent > 0.25) { self.timerBar.tint = 0xf39c12; // orange } else { self.timerBar.tint = 0xe74c3c; // red } self.timerText.setText((self.currentTime / 1000).toFixed(1) + 's'); }; self.activate = function () { self.isActive = true; anomalyGraphic.tint = 0xffffff; // Flash effect LK.effects.flashObject(anomalyGraphic, 0xffffff, 200); }; self.complete = function () { if (self.isCompleted || self.isFailed) return; self.isCompleted = true; self.isActive = false; anomalyGraphic.tint = 0x27ae60; LK.getSound('anomalySuccess').play(); // Award points var points = self.type === 'major' ? 50 : 25; LK.setScore(LK.getScore() + points); // Fade out tween(self, { alpha: 0 }, { duration: 1000, onFinish: function onFinish() { self.destroy(); } }); }; self.fail = function () { if (self.isCompleted || self.isFailed) return; self.isFailed = true; self.isActive = false; anomalyGraphic.tint = 0xe74c3c; LK.getSound('anomalyFail').play(); // Apply debuff if (self.type === 'major') { majorFailures++; temporalCohesion -= 25; } else { minorFailures++; temporalCohesion -= 10; } // Screen flash LK.effects.flashScreen(0xe74c3c, 500); // Fade out tween(self, { alpha: 0 }, { duration: 1000, onFinish: function onFinish() { self.destroy(); } }); }; self.down = function (x, y, obj) { if (!self.isActive || self.isCompleted || self.isFailed) return; // Start mini-game self.startMiniGame(); }; self.startMiniGame = function () { // Simple pattern matching mini-game var targetClicks = Math.floor(2 + self.difficulty); var clickCount = 0; var originalScale = anomalyGraphic.scaleX; var pulseInterval = LK.setInterval(function () { tween(anomalyGraphic, { scaleX: originalScale * 1.2, scaleY: originalScale * 1.2 }, { duration: 150, onFinish: function onFinish() { tween(anomalyGraphic, { scaleX: originalScale, scaleY: originalScale }, { duration: 150 }); } }); }, 300); var _clickHandler = function clickHandler(x, y, obj) { if (!self.isActive) return; clickCount++; if (clickCount >= targetClicks) { LK.clearInterval(pulseInterval); self.complete(); game.off('down', _clickHandler); } }; game.on('down', _clickHandler); // Auto-fail after remaining time LK.setTimeout(function () { if (self.isActive && !self.isCompleted) { LK.clearInterval(pulseInterval); game.off('down', _clickHandler); } }, self.currentTime); }; self.update = function () { self.updateTimer(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ var temporalCohesion = 100; var maxTemporalCohesion = 100; var minorFailures = 0; var majorFailures = 0; var activeAnomalies = []; var cyclesSurvived = 0; var anomalySpawnTimer = 0; var cohesionDrainTimer = 0; var gameActive = true; // Central nexus var nexus = game.addChild(LK.getAsset('nexus', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1200 })); // UI Elements var cohesionBarBg = LK.gui.top.addChild(LK.getAsset('cohesionBarBg', { anchorX: 0.5, anchorY: 0, x: LK.gui.top.width / 2, y: 120 })); var cohesionBar = LK.gui.top.addChild(LK.getAsset('cohesionBar', { anchorX: 0.5, anchorY: 0, x: LK.gui.top.width / 2, y: 120 })); var cohesionText = new Text2('Temporal Cohesion: 100%', { size: 40, fill: 0x3498DB }); cohesionText.anchor.set(0.5, 0); cohesionText.x = LK.gui.top.width / 2; cohesionText.y = 50; LK.gui.top.addChild(cohesionText); var cyclesText = new Text2('Cycles: 0', { size: 35, fill: 0xFFFFFF }); cyclesText.anchor.set(0, 0); cyclesText.x = 120; cyclesText.y = 50; LK.gui.top.addChild(cyclesText); var debuffText = new Text2('Debuffs: 0', { size: 35, fill: 0xE74C3C }); debuffText.anchor.set(1, 0); debuffText.x = LK.gui.top.width - 50; debuffText.y = 50; LK.gui.top.addChild(debuffText); function spawnAnomaly() { if (activeAnomalies.length >= 4) return; var type = Math.random() < 0.3 ? 'major' : 'minor'; var anomaly = new Anomaly(type, 1 + Math.floor(cyclesSurvived / 5)); // Position around the nexus var angle = Math.random() * Math.PI * 2; var distance = 400 + Math.random() * 300; anomaly.x = nexus.x + Math.cos(angle) * distance; anomaly.y = nexus.y + Math.sin(angle) * distance; // Ensure anomaly stays within bounds anomaly.x = Math.max(200, Math.min(1848, anomaly.x)); anomaly.y = Math.max(400, Math.min(2332, anomaly.y)); game.addChild(anomaly); activeAnomalies.push(anomaly); // Auto-activate after brief delay LK.setTimeout(function () { if (anomaly.parent) { anomaly.activate(); } }, 500); } function updateUI() { var cohesionPercent = temporalCohesion / maxTemporalCohesion; cohesionBar.scaleX = cohesionPercent; // Color cohesion bar if (cohesionPercent > 0.6) { cohesionBar.tint = 0x3498db; } else if (cohesionPercent > 0.3) { cohesionBar.tint = 0xf39c12; } else { cohesionBar.tint = 0xe74c3c; } cohesionText.setText('Temporal Cohesion: ' + Math.floor(temporalCohesion) + '%'); cyclesText.setText('Cycles: ' + cyclesSurvived); debuffText.setText('Debuffs: ' + (minorFailures + majorFailures)); } function checkGameOver() { if (temporalCohesion <= 0) { gameActive = false; LK.effects.flashScreen(0xe74c3c, 2000); LK.setTimeout(function () { LK.showGameOver(); }, 2000); } } function cleanupAnomalies() { for (var i = activeAnomalies.length - 1; i >= 0; i--) { var anomaly = activeAnomalies[i]; if (anomaly.isCompleted || anomaly.isFailed || !anomaly.parent) { activeAnomalies.splice(i, 1); } } } // Initial spawn spawnAnomaly(); spawnAnomaly(); game.update = function () { if (!gameActive) return; // Spawn anomalies anomalySpawnTimer += 16.67; if (anomalySpawnTimer >= 3000 - cyclesSurvived * 50) { anomalySpawnTimer = 0; spawnAnomaly(); } // Drain cohesion cohesionDrainTimer += 16.67; if (cohesionDrainTimer >= 2000) { cohesionDrainTimer = 0; temporalCohesion -= 1 + minorFailures * 0.5 + majorFailures * 1; if (temporalCohesion < 50 && LK.ticks % 120 === 0) { LK.getSound('cohesionDrain').play(); } } // Update cycle counter var newCycles = Math.floor(LK.ticks / 3600); // Every 60 seconds if (newCycles > cyclesSurvived) { cyclesSurvived = newCycles; LK.setScore(LK.getScore() + 100); } // Nexus pulse effect if (LK.ticks % 60 === 0) { var pulseIntensity = 1 - temporalCohesion / maxTemporalCohesion; if (pulseIntensity > 0.5) { tween(nexus, { scaleX: 1.1, scaleY: 1.1 }, { duration: 300, onFinish: function onFinish() { tween(nexus, { scaleX: 1, scaleY: 1 }, { duration: 300 }); } }); } } cleanupAnomalies(); updateUI(); checkGameOver(); };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,336 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Anomaly = Container.expand(function (type, difficulty) {
+ var self = Container.call(this);
+ self.type = type || 'minor';
+ self.difficulty = difficulty || 1;
+ self.maxTime = self.type === 'major' ? 8000 : 5000;
+ self.currentTime = self.maxTime;
+ self.isActive = false;
+ self.isCompleted = false;
+ self.isFailed = false;
+ // Visual elements
+ var anomalyGraphic = self.attachAsset(self.type === 'major' ? 'anomalyMajor' : 'anomalyMinor', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var timerBg = self.attachAsset('timerBarBg', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: 80
+ });
+ var timerBar = self.attachAsset('timerBar', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: 80
+ });
+ self.timerBar = timerBar;
+ // Timer text
+ self.timerText = new Text2('5.0s', {
+ size: 30,
+ fill: 0xFFFFFF
+ });
+ self.timerText.anchor.set(0.5, 0.5);
+ self.timerText.y = 110;
+ self.addChild(self.timerText);
+ // Type label
+ self.typeLabel = new Text2(self.type.toUpperCase(), {
+ size: 25,
+ fill: 0xFFFFFF
+ });
+ self.typeLabel.anchor.set(0.5, 0.5);
+ self.typeLabel.y = -60;
+ self.addChild(self.typeLabel);
+ self.updateTimer = function () {
+ if (!self.isActive || self.isCompleted || self.isFailed) return;
+ self.currentTime -= 16.67; // 60fps
+ if (self.currentTime <= 0) {
+ self.currentTime = 0;
+ self.fail();
+ return;
+ }
+ var timePercent = self.currentTime / self.maxTime;
+ self.timerBar.scaleX = timePercent;
+ // Color timer based on remaining time
+ if (timePercent > 0.5) {
+ self.timerBar.tint = 0x27ae60; // green
+ } else if (timePercent > 0.25) {
+ self.timerBar.tint = 0xf39c12; // orange
+ } else {
+ self.timerBar.tint = 0xe74c3c; // red
+ }
+ self.timerText.setText((self.currentTime / 1000).toFixed(1) + 's');
+ };
+ self.activate = function () {
+ self.isActive = true;
+ anomalyGraphic.tint = 0xffffff;
+ // Flash effect
+ LK.effects.flashObject(anomalyGraphic, 0xffffff, 200);
+ };
+ self.complete = function () {
+ if (self.isCompleted || self.isFailed) return;
+ self.isCompleted = true;
+ self.isActive = false;
+ anomalyGraphic.tint = 0x27ae60;
+ LK.getSound('anomalySuccess').play();
+ // Award points
+ var points = self.type === 'major' ? 50 : 25;
+ LK.setScore(LK.getScore() + points);
+ // Fade out
+ tween(self, {
+ alpha: 0
+ }, {
+ duration: 1000,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ };
+ self.fail = function () {
+ if (self.isCompleted || self.isFailed) return;
+ self.isFailed = true;
+ self.isActive = false;
+ anomalyGraphic.tint = 0xe74c3c;
+ LK.getSound('anomalyFail').play();
+ // Apply debuff
+ if (self.type === 'major') {
+ majorFailures++;
+ temporalCohesion -= 25;
+ } else {
+ minorFailures++;
+ temporalCohesion -= 10;
+ }
+ // Screen flash
+ LK.effects.flashScreen(0xe74c3c, 500);
+ // Fade out
+ tween(self, {
+ alpha: 0
+ }, {
+ duration: 1000,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ };
+ self.down = function (x, y, obj) {
+ if (!self.isActive || self.isCompleted || self.isFailed) return;
+ // Start mini-game
+ self.startMiniGame();
+ };
+ self.startMiniGame = function () {
+ // Simple pattern matching mini-game
+ var targetClicks = Math.floor(2 + self.difficulty);
+ var clickCount = 0;
+ var originalScale = anomalyGraphic.scaleX;
+ var pulseInterval = LK.setInterval(function () {
+ tween(anomalyGraphic, {
+ scaleX: originalScale * 1.2,
+ scaleY: originalScale * 1.2
+ }, {
+ duration: 150,
+ onFinish: function onFinish() {
+ tween(anomalyGraphic, {
+ scaleX: originalScale,
+ scaleY: originalScale
+ }, {
+ duration: 150
+ });
+ }
+ });
+ }, 300);
+ var _clickHandler = function clickHandler(x, y, obj) {
+ if (!self.isActive) return;
+ clickCount++;
+ if (clickCount >= targetClicks) {
+ LK.clearInterval(pulseInterval);
+ self.complete();
+ game.off('down', _clickHandler);
+ }
+ };
+ game.on('down', _clickHandler);
+ // Auto-fail after remaining time
+ LK.setTimeout(function () {
+ if (self.isActive && !self.isCompleted) {
+ LK.clearInterval(pulseInterval);
+ game.off('down', _clickHandler);
+ }
+ }, self.currentTime);
+ };
+ self.update = function () {
+ self.updateTimer();
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a1a1a
+});
+
+/****
+* Game Code
+****/
+var temporalCohesion = 100;
+var maxTemporalCohesion = 100;
+var minorFailures = 0;
+var majorFailures = 0;
+var activeAnomalies = [];
+var cyclesSurvived = 0;
+var anomalySpawnTimer = 0;
+var cohesionDrainTimer = 0;
+var gameActive = true;
+// Central nexus
+var nexus = game.addChild(LK.getAsset('nexus', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1200
+}));
+// UI Elements
+var cohesionBarBg = LK.gui.top.addChild(LK.getAsset('cohesionBarBg', {
+ anchorX: 0.5,
+ anchorY: 0,
+ x: LK.gui.top.width / 2,
+ y: 120
+}));
+var cohesionBar = LK.gui.top.addChild(LK.getAsset('cohesionBar', {
+ anchorX: 0.5,
+ anchorY: 0,
+ x: LK.gui.top.width / 2,
+ y: 120
+}));
+var cohesionText = new Text2('Temporal Cohesion: 100%', {
+ size: 40,
+ fill: 0x3498DB
+});
+cohesionText.anchor.set(0.5, 0);
+cohesionText.x = LK.gui.top.width / 2;
+cohesionText.y = 50;
+LK.gui.top.addChild(cohesionText);
+var cyclesText = new Text2('Cycles: 0', {
+ size: 35,
+ fill: 0xFFFFFF
+});
+cyclesText.anchor.set(0, 0);
+cyclesText.x = 120;
+cyclesText.y = 50;
+LK.gui.top.addChild(cyclesText);
+var debuffText = new Text2('Debuffs: 0', {
+ size: 35,
+ fill: 0xE74C3C
+});
+debuffText.anchor.set(1, 0);
+debuffText.x = LK.gui.top.width - 50;
+debuffText.y = 50;
+LK.gui.top.addChild(debuffText);
+function spawnAnomaly() {
+ if (activeAnomalies.length >= 4) return;
+ var type = Math.random() < 0.3 ? 'major' : 'minor';
+ var anomaly = new Anomaly(type, 1 + Math.floor(cyclesSurvived / 5));
+ // Position around the nexus
+ var angle = Math.random() * Math.PI * 2;
+ var distance = 400 + Math.random() * 300;
+ anomaly.x = nexus.x + Math.cos(angle) * distance;
+ anomaly.y = nexus.y + Math.sin(angle) * distance;
+ // Ensure anomaly stays within bounds
+ anomaly.x = Math.max(200, Math.min(1848, anomaly.x));
+ anomaly.y = Math.max(400, Math.min(2332, anomaly.y));
+ game.addChild(anomaly);
+ activeAnomalies.push(anomaly);
+ // Auto-activate after brief delay
+ LK.setTimeout(function () {
+ if (anomaly.parent) {
+ anomaly.activate();
+ }
+ }, 500);
+}
+function updateUI() {
+ var cohesionPercent = temporalCohesion / maxTemporalCohesion;
+ cohesionBar.scaleX = cohesionPercent;
+ // Color cohesion bar
+ if (cohesionPercent > 0.6) {
+ cohesionBar.tint = 0x3498db;
+ } else if (cohesionPercent > 0.3) {
+ cohesionBar.tint = 0xf39c12;
+ } else {
+ cohesionBar.tint = 0xe74c3c;
+ }
+ cohesionText.setText('Temporal Cohesion: ' + Math.floor(temporalCohesion) + '%');
+ cyclesText.setText('Cycles: ' + cyclesSurvived);
+ debuffText.setText('Debuffs: ' + (minorFailures + majorFailures));
+}
+function checkGameOver() {
+ if (temporalCohesion <= 0) {
+ gameActive = false;
+ LK.effects.flashScreen(0xe74c3c, 2000);
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 2000);
+ }
+}
+function cleanupAnomalies() {
+ for (var i = activeAnomalies.length - 1; i >= 0; i--) {
+ var anomaly = activeAnomalies[i];
+ if (anomaly.isCompleted || anomaly.isFailed || !anomaly.parent) {
+ activeAnomalies.splice(i, 1);
+ }
+ }
+}
+// Initial spawn
+spawnAnomaly();
+spawnAnomaly();
+game.update = function () {
+ if (!gameActive) return;
+ // Spawn anomalies
+ anomalySpawnTimer += 16.67;
+ if (anomalySpawnTimer >= 3000 - cyclesSurvived * 50) {
+ anomalySpawnTimer = 0;
+ spawnAnomaly();
+ }
+ // Drain cohesion
+ cohesionDrainTimer += 16.67;
+ if (cohesionDrainTimer >= 2000) {
+ cohesionDrainTimer = 0;
+ temporalCohesion -= 1 + minorFailures * 0.5 + majorFailures * 1;
+ if (temporalCohesion < 50 && LK.ticks % 120 === 0) {
+ LK.getSound('cohesionDrain').play();
+ }
+ }
+ // Update cycle counter
+ var newCycles = Math.floor(LK.ticks / 3600); // Every 60 seconds
+ if (newCycles > cyclesSurvived) {
+ cyclesSurvived = newCycles;
+ LK.setScore(LK.getScore() + 100);
+ }
+ // Nexus pulse effect
+ if (LK.ticks % 60 === 0) {
+ var pulseIntensity = 1 - temporalCohesion / maxTemporalCohesion;
+ if (pulseIntensity > 0.5) {
+ tween(nexus, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ tween(nexus, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300
+ });
+ }
+ });
+ }
+ }
+ cleanupAnomalies();
+ updateUI();
+ checkGameOver();
+};
\ No newline at end of file