/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Class for Mom character var Mom = Container.expand(function () { var self = Container.call(this); var momGraphics = self.attachAsset('mom', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { // Update logic for Mom }; self.move = function (x, y) { self.x = x; self.y = y; }; }); // Class for Task (e.g., cooking, cleaning) var Task = Container.expand(function () { var self = Container.call(this); var taskGraphics = self.attachAsset('task', { anchorX: 0.5, anchorY: 0.5 }); self.completed = false; self.update = function () { // Update logic for Task }; self.complete = function () { self.completed = true; // Logic for completing the task }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize game variables var mom = game.addChild(new Mom()); mom.x = 1024; // Center horizontally mom.y = 1366; // Center vertically var tasks = []; var score = 0; var scoreTxt = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Function to create a new task function createTask() { var task = new Task(); task.x = Math.random() * 2048; task.y = Math.random() * 2732; tasks.push(task); game.addChild(task); } // Create initial tasks for (var i = 0; i < 5; i++) { createTask(); } // Handle game updates game.update = function () { // Update Mom mom.update(); // Update tasks for (var i = tasks.length - 1; i >= 0; i--) { var task = tasks[i]; task.update(); // Check if Mom completes a task if (!task.completed && mom.intersects(task)) { task.complete(); score += 10; scoreTxt.setText('Score: ' + score); tasks.splice(i, 1); createTask(); // Create a new task } } }; // Handle touch/mouse events game.down = function (x, y, obj) { mom.move(x, y); }; game.move = function (x, y, obj) { mom.move(x, y); }; game.up = function (x, y, obj) { // Logic for when touch/mouse is released };
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Class for Mom character
var Mom = Container.expand(function () {
var self = Container.call(this);
var momGraphics = self.attachAsset('mom', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
// Update logic for Mom
};
self.move = function (x, y) {
self.x = x;
self.y = y;
};
});
// Class for Task (e.g., cooking, cleaning)
var Task = Container.expand(function () {
var self = Container.call(this);
var taskGraphics = self.attachAsset('task', {
anchorX: 0.5,
anchorY: 0.5
});
self.completed = false;
self.update = function () {
// Update logic for Task
};
self.complete = function () {
self.completed = true;
// Logic for completing the task
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize game variables
var mom = game.addChild(new Mom());
mom.x = 1024; // Center horizontally
mom.y = 1366; // Center vertically
var tasks = [];
var score = 0;
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Function to create a new task
function createTask() {
var task = new Task();
task.x = Math.random() * 2048;
task.y = Math.random() * 2732;
tasks.push(task);
game.addChild(task);
}
// Create initial tasks
for (var i = 0; i < 5; i++) {
createTask();
}
// Handle game updates
game.update = function () {
// Update Mom
mom.update();
// Update tasks
for (var i = tasks.length - 1; i >= 0; i--) {
var task = tasks[i];
task.update();
// Check if Mom completes a task
if (!task.completed && mom.intersects(task)) {
task.complete();
score += 10;
scoreTxt.setText('Score: ' + score);
tasks.splice(i, 1);
createTask(); // Create a new task
}
}
};
// Handle touch/mouse events
game.down = function (x, y, obj) {
mom.move(x, y);
};
game.move = function (x, y, obj) {
mom.move(x, y);
};
game.up = function (x, y, obj) {
// Logic for when touch/mouse is released
};