User prompt
make background windows 10 background
User prompt
when game started, start music
User prompt
when we collect virus, start sound virus
User prompt
when we collect 20 virus, more virus come and speed up the virus
User prompt
when we collect 15 virus, more virus come and speed up the virus
User prompt
when we collect 10 virus, more virus come and speed up the virus
User prompt
when we collect 5 virus, more virus come
User prompt
speed up tthe virus
User prompt
Let the virus not come at the same time
User prompt
Let the virus come at the same time
User prompt
speed up the virus
User prompt
make score
User prompt
continue
User prompt
continue
User prompt
continue
User prompt
Computer Virus
Initial prompt
Computer Virus
/**** * Classes ****/ // AntivirusAgent class: player-controlled agent var AntivirusAgent = Container.expand(function () { var self = Container.call(this); // Attach agent asset (placeholder: 'antivirusAgent') var agentAsset = self.attachAsset('antivirusAgent', { anchorX: 0.5, anchorY: 0.5 }); // Track last position for event triggers self.lastX = 0; self.lastY = 0; // Update method stub self.update = function () { // To be implemented: movement, collision, etc. }; return self; }); // SystemFile class: files to protect from infection var SystemFile = Container.expand(function () { var self = Container.call(this); // Attach file asset (placeholder: 'systemFile') var fileAsset = self.attachAsset('systemFile', { anchorX: 0.5, anchorY: 0.5 }); // Infection state self.infected = false; return self; }); // Virus class: viruses that move toward system files var Virus = Container.expand(function () { var self = Container.call(this); // Attach virus asset (placeholder: 'virus') var virusAsset = self.attachAsset('virus', { anchorX: 0.5, anchorY: 0.5 }); // Track last position for event triggers self.lastX = 0; self.lastY = 0; // Update method: move toward nearest uninfected SystemFile and infect on contact self.update = function () { // Find nearest uninfected system file var nearestFile = null; var minDist = Infinity; for (var i = 0; i < systemFiles.length; i++) { var file = systemFiles[i]; if (file.infected) continue; var dx = file.x - self.x; var dy = file.y - self.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < minDist) { minDist = dist; nearestFile = file; } } // Move toward nearest file if found if (nearestFile) { var dx = nearestFile.x - self.x; var dy = nearestFile.y - self.y; var len = Math.sqrt(dx * dx + dy * dy); if (len > 0) { var speed = 16; // Speed up if this virus or all viruses are boosted if (self.speedBoost || Virus.prototype.speedBoosted) { speed = 28; } self.x += dx / len * speed; self.y += dy / len * speed; } // Check for infection (collision) if (!self.lastWasIntersecting && self.intersects(nearestFile)) { nearestFile.infected = true; // Optionally: visually indicate infection (e.g. alpha) if (nearestFile.children && nearestFile.children.length > 0) { nearestFile.children[0].alpha = 0.4; } } self.lastWasIntersecting = self.intersects(nearestFile); } // Track last position for event triggers self.lastX = self.x; self.lastY = self.y; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Global arrays to keep track of all viruses and system files var viruses = []; var systemFiles = []; // Start background music at game start LK.playMusic('music'); // Add Windows 10 background image, stretched to fill the game area var backgroundImg = LK.getAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: 2048, height: 2732 }); game.addChild(backgroundImg); // Create the antivirus agent and add to the game var antivirusAgent = new AntivirusAgent(); game.addChild(antivirusAgent); antivirusAgent.x = 2048 / 2; antivirusAgent.y = 2732 - 300; // Start near the bottom center // Add system files along the bottom of the screen var numFiles = 5; var spacing = 2048 / (numFiles + 1); for (var i = 0; i < numFiles; i++) { var file = new SystemFile(); file.x = spacing * (i + 1); file.y = 2732 - 100; game.addChild(file); systemFiles.push(file); } // Function to spawn a virus at a random X at the top function spawnVirus() { var virus = new Virus(); virus.x = 200 + Math.random() * (2048 - 400); virus.y = 100; game.addChild(virus); viruses.push(virus); } // Spawn viruses at intervals instead of all at once var numViruses = 5; var virusesSpawned = 0; var virusSpawnTimer = LK.setInterval(function () { if (virusesSpawned < numViruses) { spawnVirus(); virusesSpawned++; } else { LK.clearInterval(virusSpawnTimer); } }, 1200); // spawn every 1.2 seconds // Dragging logic for antivirus agent var draggingAgent = false; game.down = function (x, y, obj) { // Start dragging if touch/click is near the agent var dx = x - antivirusAgent.x; var dy = y - antivirusAgent.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < 120) { // touch radius draggingAgent = true; } }; game.move = function (x, y, obj) { if (draggingAgent) { antivirusAgent.x = x; antivirusAgent.y = y; } }; game.up = function (x, y, obj) { draggingAgent = false; }; // Score variable and display var score = 0; var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Main game update loop game.update = function () { // Update all viruses and check for collision with antivirus agent for (var i = viruses.length - 1; i >= 0; i--) { var virus = viruses[i]; if (virus.update) virus.update(); // Check for collision with antivirus agent (eliminate virus) if (!virus.lastAgentIntersect && virus.intersects(antivirusAgent)) { // Remove virus from game virus.destroy(); viruses.splice(i, 1); // Play virus sound LK.getSound('virus').play(); // Increase score and update display score += 1; scoreTxt.setText(score); // When score reaches 5, spawn 5 more viruses (if not already triggered) if (score === 5 && typeof moreVirusesSpawned === "undefined") { moreVirusesSpawned = true; var extraViruses = 5; var extraSpawned = 0; var extraVirusTimer = LK.setInterval(function () { if (extraSpawned < extraViruses) { spawnVirus(); extraSpawned++; } else { LK.clearInterval(extraVirusTimer); } }, 1000); } // When score reaches 10, spawn 8 more viruses and speed up all viruses (only once) if (score === 10 && typeof evenMoreVirusesSpawned === "undefined") { evenMoreVirusesSpawned = true; var moreViruses = 8; var moreSpawned = 0; var moreVirusTimer = LK.setInterval(function () { if (moreSpawned < moreViruses) { spawnVirus(); moreSpawned++; } else { LK.clearInterval(moreVirusTimer); } }, 600); // faster spawn interval // Speed up all existing viruses and future ones for (var v = 0; v < viruses.length; v++) { viruses[v].speedBoost = true; } Virus.prototype.speedBoosted = true; } continue; } // When score reaches 15, spawn 10 more viruses and speed up all viruses (only once) if (score === 15 && typeof maxVirusWaveSpawned === "undefined") { maxVirusWaveSpawned = true; var maxViruses = 10; var maxSpawned = 0; var maxVirusTimer = LK.setInterval(function () { if (maxSpawned < maxViruses) { spawnVirus(); maxSpawned++; } else { LK.clearInterval(maxVirusTimer); } }, 400); // even faster spawn interval // Speed up all existing viruses and future ones for (var v = 0; v < viruses.length; v++) { viruses[v].speedBoost = true; } Virus.prototype.speedBoosted = true; } // When score reaches 20, spawn 12 more viruses and speed up all viruses (only once) if (score === 20 && typeof ultraVirusWaveSpawned === "undefined") { ultraVirusWaveSpawned = true; var ultraViruses = 12; var ultraSpawned = 0; var ultraVirusTimer = LK.setInterval(function () { if (ultraSpawned < ultraViruses) { spawnVirus(); ultraSpawned++; } else { LK.clearInterval(ultraVirusTimer); } }, 250); // even faster spawn interval // Speed up all existing viruses and future ones for (var v = 0; v < viruses.length; v++) { viruses[v].speedBoost = true; } Virus.prototype.speedBoosted = true; } virus.lastAgentIntersect = virus.intersects(antivirusAgent); } // Update antivirus agent if (antivirusAgent.update) antivirusAgent.update(); // End game if too many files are infected var infectedCount = 0; for (var i = 0; i < systemFiles.length; i++) { if (systemFiles[i].infected) infectedCount++; } if (infectedCount >= 3) { LK.showGameOver(); } };
/****
* Classes
****/
// AntivirusAgent class: player-controlled agent
var AntivirusAgent = Container.expand(function () {
var self = Container.call(this);
// Attach agent asset (placeholder: 'antivirusAgent')
var agentAsset = self.attachAsset('antivirusAgent', {
anchorX: 0.5,
anchorY: 0.5
});
// Track last position for event triggers
self.lastX = 0;
self.lastY = 0;
// Update method stub
self.update = function () {
// To be implemented: movement, collision, etc.
};
return self;
});
// SystemFile class: files to protect from infection
var SystemFile = Container.expand(function () {
var self = Container.call(this);
// Attach file asset (placeholder: 'systemFile')
var fileAsset = self.attachAsset('systemFile', {
anchorX: 0.5,
anchorY: 0.5
});
// Infection state
self.infected = false;
return self;
});
// Virus class: viruses that move toward system files
var Virus = Container.expand(function () {
var self = Container.call(this);
// Attach virus asset (placeholder: 'virus')
var virusAsset = self.attachAsset('virus', {
anchorX: 0.5,
anchorY: 0.5
});
// Track last position for event triggers
self.lastX = 0;
self.lastY = 0;
// Update method: move toward nearest uninfected SystemFile and infect on contact
self.update = function () {
// Find nearest uninfected system file
var nearestFile = null;
var minDist = Infinity;
for (var i = 0; i < systemFiles.length; i++) {
var file = systemFiles[i];
if (file.infected) continue;
var dx = file.x - self.x;
var dy = file.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
nearestFile = file;
}
}
// Move toward nearest file if found
if (nearestFile) {
var dx = nearestFile.x - self.x;
var dy = nearestFile.y - self.y;
var len = Math.sqrt(dx * dx + dy * dy);
if (len > 0) {
var speed = 16;
// Speed up if this virus or all viruses are boosted
if (self.speedBoost || Virus.prototype.speedBoosted) {
speed = 28;
}
self.x += dx / len * speed;
self.y += dy / len * speed;
}
// Check for infection (collision)
if (!self.lastWasIntersecting && self.intersects(nearestFile)) {
nearestFile.infected = true;
// Optionally: visually indicate infection (e.g. alpha)
if (nearestFile.children && nearestFile.children.length > 0) {
nearestFile.children[0].alpha = 0.4;
}
}
self.lastWasIntersecting = self.intersects(nearestFile);
}
// Track last position for event triggers
self.lastX = self.x;
self.lastY = self.y;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Global arrays to keep track of all viruses and system files
var viruses = [];
var systemFiles = [];
// Start background music at game start
LK.playMusic('music');
// Add Windows 10 background image, stretched to fill the game area
var backgroundImg = LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: 2048,
height: 2732
});
game.addChild(backgroundImg);
// Create the antivirus agent and add to the game
var antivirusAgent = new AntivirusAgent();
game.addChild(antivirusAgent);
antivirusAgent.x = 2048 / 2;
antivirusAgent.y = 2732 - 300; // Start near the bottom center
// Add system files along the bottom of the screen
var numFiles = 5;
var spacing = 2048 / (numFiles + 1);
for (var i = 0; i < numFiles; i++) {
var file = new SystemFile();
file.x = spacing * (i + 1);
file.y = 2732 - 100;
game.addChild(file);
systemFiles.push(file);
}
// Function to spawn a virus at a random X at the top
function spawnVirus() {
var virus = new Virus();
virus.x = 200 + Math.random() * (2048 - 400);
virus.y = 100;
game.addChild(virus);
viruses.push(virus);
}
// Spawn viruses at intervals instead of all at once
var numViruses = 5;
var virusesSpawned = 0;
var virusSpawnTimer = LK.setInterval(function () {
if (virusesSpawned < numViruses) {
spawnVirus();
virusesSpawned++;
} else {
LK.clearInterval(virusSpawnTimer);
}
}, 1200); // spawn every 1.2 seconds
// Dragging logic for antivirus agent
var draggingAgent = false;
game.down = function (x, y, obj) {
// Start dragging if touch/click is near the agent
var dx = x - antivirusAgent.x;
var dy = y - antivirusAgent.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 120) {
// touch radius
draggingAgent = true;
}
};
game.move = function (x, y, obj) {
if (draggingAgent) {
antivirusAgent.x = x;
antivirusAgent.y = y;
}
};
game.up = function (x, y, obj) {
draggingAgent = false;
};
// Score variable and display
var score = 0;
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Main game update loop
game.update = function () {
// Update all viruses and check for collision with antivirus agent
for (var i = viruses.length - 1; i >= 0; i--) {
var virus = viruses[i];
if (virus.update) virus.update();
// Check for collision with antivirus agent (eliminate virus)
if (!virus.lastAgentIntersect && virus.intersects(antivirusAgent)) {
// Remove virus from game
virus.destroy();
viruses.splice(i, 1);
// Play virus sound
LK.getSound('virus').play();
// Increase score and update display
score += 1;
scoreTxt.setText(score);
// When score reaches 5, spawn 5 more viruses (if not already triggered)
if (score === 5 && typeof moreVirusesSpawned === "undefined") {
moreVirusesSpawned = true;
var extraViruses = 5;
var extraSpawned = 0;
var extraVirusTimer = LK.setInterval(function () {
if (extraSpawned < extraViruses) {
spawnVirus();
extraSpawned++;
} else {
LK.clearInterval(extraVirusTimer);
}
}, 1000);
}
// When score reaches 10, spawn 8 more viruses and speed up all viruses (only once)
if (score === 10 && typeof evenMoreVirusesSpawned === "undefined") {
evenMoreVirusesSpawned = true;
var moreViruses = 8;
var moreSpawned = 0;
var moreVirusTimer = LK.setInterval(function () {
if (moreSpawned < moreViruses) {
spawnVirus();
moreSpawned++;
} else {
LK.clearInterval(moreVirusTimer);
}
}, 600); // faster spawn interval
// Speed up all existing viruses and future ones
for (var v = 0; v < viruses.length; v++) {
viruses[v].speedBoost = true;
}
Virus.prototype.speedBoosted = true;
}
continue;
}
// When score reaches 15, spawn 10 more viruses and speed up all viruses (only once)
if (score === 15 && typeof maxVirusWaveSpawned === "undefined") {
maxVirusWaveSpawned = true;
var maxViruses = 10;
var maxSpawned = 0;
var maxVirusTimer = LK.setInterval(function () {
if (maxSpawned < maxViruses) {
spawnVirus();
maxSpawned++;
} else {
LK.clearInterval(maxVirusTimer);
}
}, 400); // even faster spawn interval
// Speed up all existing viruses and future ones
for (var v = 0; v < viruses.length; v++) {
viruses[v].speedBoost = true;
}
Virus.prototype.speedBoosted = true;
}
// When score reaches 20, spawn 12 more viruses and speed up all viruses (only once)
if (score === 20 && typeof ultraVirusWaveSpawned === "undefined") {
ultraVirusWaveSpawned = true;
var ultraViruses = 12;
var ultraSpawned = 0;
var ultraVirusTimer = LK.setInterval(function () {
if (ultraSpawned < ultraViruses) {
spawnVirus();
ultraSpawned++;
} else {
LK.clearInterval(ultraVirusTimer);
}
}, 250); // even faster spawn interval
// Speed up all existing viruses and future ones
for (var v = 0; v < viruses.length; v++) {
viruses[v].speedBoost = true;
}
Virus.prototype.speedBoosted = true;
}
virus.lastAgentIntersect = virus.intersects(antivirusAgent);
}
// Update antivirus agent
if (antivirusAgent.update) antivirusAgent.update();
// End game if too many files are infected
var infectedCount = 0;
for (var i = 0; i < systemFiles.length; i++) {
if (systemFiles[i].infected) infectedCount++;
}
if (infectedCount >= 3) {
LK.showGameOver();
}
};