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 = 10;
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 = [];
// 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 a virus every 2 seconds
var virusTimer = LK.setInterval(function () {
spawnVirus();
}, 2000);
// 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);
// Increase score and update display
score += 1;
scoreTxt.setText(score);
continue;
}
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();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -62,9 +62,9 @@
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 = 6;
+ var speed = 10;
self.x += dx / len * speed;
self.y += dy / len * speed;
}
// Check for infection (collision)