/**** * Classes ****/ //<Assets used in the game will automatically appear here> // AI class representing the player's character var AI = Container.expand(function () { var self = Container.call(this); var aiGraphics = self.attachAsset('ai', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { // AI movement logic can be added here }; }); // Document class representing the items AI can consume var Document = Container.expand(function () { var self = Container.call(this); var documentGraphics = self.attachAsset('document', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Document behavior logic can be added here }; }); // Drone class representing the enemies var Drone = Container.expand(function () { var self = Container.call(this); var droneGraphics = self.attachAsset('drone', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = -self.height; } }; }); // KillerSquare class representing deadly squares var KillerSquare = Container.expand(function () { var self = Container.call(this); var size = Math.random() > 0.5 ? { width: 100, height: 200 } : { width: 200, height: 100 }; var killerSquareGraphics = self.attachAsset('killerSquare', { anchorX: 0.5, anchorY: 0.5, width: size.width, height: size.height }); self.speed = 3; self.update = function () { self.x += self.speed; if (self.x > 2048 || self.x < 0) { self.speed *= -1; // Reverse direction when hitting screen edges } }; }); // LargeDrone class representing larger enemies var LargeDrone = Container.expand(function () { var self = Container.call(this); var largeDroneGraphics = self.attachAsset('drone', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 200 }); self.speed = 2; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = -self.height; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Add background image var background = LK.getAsset('Background1', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 2048 / 100, // Scale to fit the screen width scaleY: 2732 / 100 // Scale to fit the screen height }); game.addChild(background); var ai = game.addChild(new AI()); ai.x = 2048 / 2; ai.y = 2732 - 200; var documents = []; var drones = []; var killerSquares = []; // Delay the spawning of enemies and killer squares by one second after the game starts LK.setTimeout(function () { // Create initial documents and drones for (var i = 0; i < 10; i++) { var document = new Document(); document.x = Math.max(50, Math.min(1998, Math.random() * 2048)); document.y = Math.max(50, Math.min(2682, Math.random() * 2732)); documents.push(document); game.addChild(document); var drone; if (i % 10 === 0) { drone = new LargeDrone(); } else { drone = new Drone(); } if (Math.random() > 0.5) { // Spawn at the top drone.x = Math.random() * 2048; drone.y = -drone.height; } else { // Spawn at the sides drone.x = Math.random() > 0.5 ? -drone.width : 2048 + drone.width; drone.y = Math.random() * 2732; } drones.push(drone); game.addChild(drone); for (var j = 0; j < 5; j++) { var killerSquare = new KillerSquare(); if (Math.random() > 0.5) { // Spawn at the top killerSquare.x = Math.random() * 2048; killerSquare.y = -killerSquare.height; } else { // Spawn at the sides killerSquare.x = Math.random() > 0.5 ? -killerSquare.width : 2048 + killerSquare.width; killerSquare.y = Math.random() * 2732; } killerSquares.push(killerSquare); game.addChild(killerSquare); } } }, 1000); // Handle AI movement game.move = function (x, y, obj) { ai.x = x; ai.y = y; }; // Update game logic game.update = function () { // Check for collisions between AI and documents for (var i = documents.length - 1; i >= 0; i--) { if (ai.intersects(documents[i])) { documents[i].destroy(); documents.splice(i, 1); // Increase AI size or score if ((5 - documents.length) % 5 === 0) { for (var n = 0; n < 5; n++) { var newDocument = new Document(); newDocument.x = Math.random() * 2048; newDocument.y = Math.random() * 2732; documents.push(newDocument); game.addChild(newDocument); } } // 1/10 chance to spawn a 500x500 drone if (Math.random() < 0.1) { var largeKillerDrone = new Container(); var largeKillerDroneGraphics = largeKillerDrone.attachAsset('drone', { anchorX: 0.5, anchorY: 0.5, width: 500, height: 500 }); largeKillerDrone.speed = 2; largeKillerDrone.update = function () { this.y += this.speed; if (this.y > 2732) { this.y = -this.height; } }; largeKillerDrone.x = Math.random() * 2048; largeKillerDrone.y = -largeKillerDrone.height; drones.push(largeKillerDrone); game.addChild(largeKillerDrone); } // Start spawning larger drones and killer squares after collecting ten documents if (documents.length <= 0) { for (var m = 0; m < 5; m++) { var largeDrone = new LargeDrone(); if (Math.random() > 0.5) { // Spawn at the top largeDrone.x = Math.random() * 2048; largeDrone.y = -largeDrone.height; } else { // Spawn at the sides largeDrone.x = Math.random() > 0.5 ? -largeDrone.width : 2048 + largeDrone.width; largeDrone.y = Math.random() * 2732; } drones.push(largeDrone); game.addChild(largeDrone); } for (var j = 0; j < 5; j++) { var killerSquare = new KillerSquare(); if (Math.random() > 0.5) { // Spawn at the top killerSquare.x = Math.random() * 2048; killerSquare.y = -killerSquare.height; } else { // Spawn at the sides killerSquare.x = Math.random() > 0.5 ? -killerSquare.width : 2048 + killerSquare.width; killerSquare.y = Math.random() * 2732; } killerSquares.push(killerSquare); game.addChild(killerSquare); } } } } // Check for collisions between AI and drones for (var j = drones.length - 1; j >= 0; j--) { if (ai.intersects(drones[j])) { if (drones[j].width === 100 && drones[j].height === 100) { // AI can eat/delete 100x100 drones // Spawn two new drones when a 100x100 drone is eaten for (var n = 0; n < 2; n++) { var newDrone = new Drone(); if (Math.random() > 0.5) { // Spawn at the top newDrone.x = Math.random() * 2048; newDrone.y = -newDrone.height; } else { // Spawn at the sides newDrone.x = Math.random() > 0.5 ? -newDrone.width : 2048 + newDrone.width; newDrone.y = Math.random() * 2732; } drones.push(newDrone); game.addChild(newDrone); } drones[j].destroy(); drones.splice(j, 1); } else { // Handle collision with larger drone (e.g., game over) LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } } // Check for collisions between AI and killer squares for (var l = killerSquares.length - 1; l >= 0; l--) { if (ai.intersects(killerSquares[l])) { // Handle collision with killer square (e.g., game over) LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Update drones for (var k = 0; k < drones.length; k++) { drones[k].update(); } };
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// AI class representing the player's character
var AI = Container.expand(function () {
var self = Container.call(this);
var aiGraphics = self.attachAsset('ai', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
// AI movement logic can be added here
};
});
// Document class representing the items AI can consume
var Document = Container.expand(function () {
var self = Container.call(this);
var documentGraphics = self.attachAsset('document', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Document behavior logic can be added here
};
});
// Drone class representing the enemies
var Drone = Container.expand(function () {
var self = Container.call(this);
var droneGraphics = self.attachAsset('drone', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = -self.height;
}
};
});
// KillerSquare class representing deadly squares
var KillerSquare = Container.expand(function () {
var self = Container.call(this);
var size = Math.random() > 0.5 ? {
width: 100,
height: 200
} : {
width: 200,
height: 100
};
var killerSquareGraphics = self.attachAsset('killerSquare', {
anchorX: 0.5,
anchorY: 0.5,
width: size.width,
height: size.height
});
self.speed = 3;
self.update = function () {
self.x += self.speed;
if (self.x > 2048 || self.x < 0) {
self.speed *= -1; // Reverse direction when hitting screen edges
}
};
});
// LargeDrone class representing larger enemies
var LargeDrone = Container.expand(function () {
var self = Container.call(this);
var largeDroneGraphics = self.attachAsset('drone', {
anchorX: 0.5,
anchorY: 0.5,
width: 200,
height: 200
});
self.speed = 2;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = -self.height;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Add background image
var background = LK.getAsset('Background1', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 2048 / 100,
// Scale to fit the screen width
scaleY: 2732 / 100 // Scale to fit the screen height
});
game.addChild(background);
var ai = game.addChild(new AI());
ai.x = 2048 / 2;
ai.y = 2732 - 200;
var documents = [];
var drones = [];
var killerSquares = [];
// Delay the spawning of enemies and killer squares by one second after the game starts
LK.setTimeout(function () {
// Create initial documents and drones
for (var i = 0; i < 10; i++) {
var document = new Document();
document.x = Math.max(50, Math.min(1998, Math.random() * 2048));
document.y = Math.max(50, Math.min(2682, Math.random() * 2732));
documents.push(document);
game.addChild(document);
var drone;
if (i % 10 === 0) {
drone = new LargeDrone();
} else {
drone = new Drone();
}
if (Math.random() > 0.5) {
// Spawn at the top
drone.x = Math.random() * 2048;
drone.y = -drone.height;
} else {
// Spawn at the sides
drone.x = Math.random() > 0.5 ? -drone.width : 2048 + drone.width;
drone.y = Math.random() * 2732;
}
drones.push(drone);
game.addChild(drone);
for (var j = 0; j < 5; j++) {
var killerSquare = new KillerSquare();
if (Math.random() > 0.5) {
// Spawn at the top
killerSquare.x = Math.random() * 2048;
killerSquare.y = -killerSquare.height;
} else {
// Spawn at the sides
killerSquare.x = Math.random() > 0.5 ? -killerSquare.width : 2048 + killerSquare.width;
killerSquare.y = Math.random() * 2732;
}
killerSquares.push(killerSquare);
game.addChild(killerSquare);
}
}
}, 1000);
// Handle AI movement
game.move = function (x, y, obj) {
ai.x = x;
ai.y = y;
};
// Update game logic
game.update = function () {
// Check for collisions between AI and documents
for (var i = documents.length - 1; i >= 0; i--) {
if (ai.intersects(documents[i])) {
documents[i].destroy();
documents.splice(i, 1);
// Increase AI size or score
if ((5 - documents.length) % 5 === 0) {
for (var n = 0; n < 5; n++) {
var newDocument = new Document();
newDocument.x = Math.random() * 2048;
newDocument.y = Math.random() * 2732;
documents.push(newDocument);
game.addChild(newDocument);
}
}
// 1/10 chance to spawn a 500x500 drone
if (Math.random() < 0.1) {
var largeKillerDrone = new Container();
var largeKillerDroneGraphics = largeKillerDrone.attachAsset('drone', {
anchorX: 0.5,
anchorY: 0.5,
width: 500,
height: 500
});
largeKillerDrone.speed = 2;
largeKillerDrone.update = function () {
this.y += this.speed;
if (this.y > 2732) {
this.y = -this.height;
}
};
largeKillerDrone.x = Math.random() * 2048;
largeKillerDrone.y = -largeKillerDrone.height;
drones.push(largeKillerDrone);
game.addChild(largeKillerDrone);
}
// Start spawning larger drones and killer squares after collecting ten documents
if (documents.length <= 0) {
for (var m = 0; m < 5; m++) {
var largeDrone = new LargeDrone();
if (Math.random() > 0.5) {
// Spawn at the top
largeDrone.x = Math.random() * 2048;
largeDrone.y = -largeDrone.height;
} else {
// Spawn at the sides
largeDrone.x = Math.random() > 0.5 ? -largeDrone.width : 2048 + largeDrone.width;
largeDrone.y = Math.random() * 2732;
}
drones.push(largeDrone);
game.addChild(largeDrone);
}
for (var j = 0; j < 5; j++) {
var killerSquare = new KillerSquare();
if (Math.random() > 0.5) {
// Spawn at the top
killerSquare.x = Math.random() * 2048;
killerSquare.y = -killerSquare.height;
} else {
// Spawn at the sides
killerSquare.x = Math.random() > 0.5 ? -killerSquare.width : 2048 + killerSquare.width;
killerSquare.y = Math.random() * 2732;
}
killerSquares.push(killerSquare);
game.addChild(killerSquare);
}
}
}
}
// Check for collisions between AI and drones
for (var j = drones.length - 1; j >= 0; j--) {
if (ai.intersects(drones[j])) {
if (drones[j].width === 100 && drones[j].height === 100) {
// AI can eat/delete 100x100 drones
// Spawn two new drones when a 100x100 drone is eaten
for (var n = 0; n < 2; n++) {
var newDrone = new Drone();
if (Math.random() > 0.5) {
// Spawn at the top
newDrone.x = Math.random() * 2048;
newDrone.y = -newDrone.height;
} else {
// Spawn at the sides
newDrone.x = Math.random() > 0.5 ? -newDrone.width : 2048 + newDrone.width;
newDrone.y = Math.random() * 2732;
}
drones.push(newDrone);
game.addChild(newDrone);
}
drones[j].destroy();
drones.splice(j, 1);
} else {
// Handle collision with larger drone (e.g., game over)
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
}
// Check for collisions between AI and killer squares
for (var l = killerSquares.length - 1; l >= 0; l--) {
if (ai.intersects(killerSquares[l])) {
// Handle collision with killer square (e.g., game over)
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
// Update drones
for (var k = 0; k < drones.length; k++) {
drones[k].update();
}
};
A yellow folder document. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A evil cartoon drone. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A fun loving hungry cartoon drone with a giant mouth. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cartoon flying police car. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A top down view of a city. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.