/**** * Classes ****/ // Define a Decoration class for house decorations var Decoration = Container.expand(function (type) { var self = Container.call(this); var decoration = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5 }); // Update method for decoration, if needed self.update = function () { // Update logic for the decoration }; }); // Assets will be automatically created and loaded by the LK engine based on usage in the game code. // Define a House class for managing the dream house var House = Container.expand(function () { var self = Container.call(this); // Initialize the house with a basic shape var houseBase = self.attachAsset('houseBase', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); // Placeholder for decorations self.decorations = []; // Add decoration to the house self.addDecoration = function (decorationType) { var decoration = self.attachAsset(decorationType, { anchorX: 0.5, anchorY: 0.5 }); self.decorations.push(decoration); }; // Update method for house, if needed in the future self.update = function () { // Update logic for the house }; }); // Define a Pig class that moves within the red box var Pig = Container.expand(function () { var self = Container.call(this); var pig = self.attachAsset('pig', { anchorX: 0.5, anchorY: 0.5 }); // Set the pig's movement range self.range = { x: 0, y: 0, width: 0, height: 0 }; // Set the pig's speed self.speed = { x: 1, y: 1 }; // Update method for pig self.update = function () { // Move the pig self.x += self.speed.x; self.y += self.speed.y; // If the pig hits the edge of the range, reverse its direction if (self.x < self.range.x || self.x > self.range.x + self.range.width) { self.speed.x *= -1; } if (self.y < self.range.y || self.y > self.range.y + self.range.height) { self.speed.y *= -1; } }; }); // Define a PinkBox class for pink boxes var PinkBox = Container.expand(function () { var self = Container.call(this); var pinkBox = self.attachAsset('pinkBox', { anchorX: 0.5, anchorY: 0.5 }); }); // Define a RedBox class for red boxes var RedBox = Container.expand(function () { var self = Container.call(this); var redBox = self.attachAsset('redBox', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Light blue background to simulate sky }); /**** * Game Code ****/ // Initialize an array to store blue boxes var blueBoxes = []; var dreamHouse = game.addChild(new House()); dreamHouse.x = game.width / 2; dreamHouse.y = game.height / 2; // Initialize 5 pink boxes at random positions for (var i = 0; i < 5; i++) { var pinkBox = game.addChild(new PinkBox()); pinkBox.x = Math.random() * game.width; pinkBox.y = Math.random() * game.height; } // Sample decorations var decorationTypes = ['tree', 'flower', 'fence']; // Function to add random decoration function addRandomDecoration() { var randomDecorationType = decorationTypes[Math.floor(Math.random() * decorationTypes.length)]; dreamHouse.addDecoration(randomDecorationType); } // Add a simple GUI button for adding decorations var addButton = LK.gui.bottom.addChild(new Text2('Add Decoration', { size: 50, fill: "#ffffff" })); addButton.anchor.set(0.5, 1); // Center at bottom addButton.y = -20; // Slightly above the bottom edge // Handle touch on the add button game.down = function (x, y, obj) { // Define the size of the grid var gridSize = 100; // Calculate the grid position var gridX = Math.floor(x / gridSize) * gridSize; var gridY = Math.floor(y / gridSize) * gridSize; blueBoxes.forEach(function (blueBox) { var redBox = game.addChild(new RedBox()); redBox.x = blueBox.x; redBox.y = blueBox.y; // Generate a pig at the same location var pig = game.addChild(new Pig()); pig.x = redBox.x; pig.y = redBox.y; // Set the pig's movement range to the size of the red box pig.range = { x: redBox.x, y: redBox.y, width: redBox.width, height: redBox.height }; }); }; // Update the game state game.update = function () { // This could include logic for automatically adding decorations or other game mechanics }; // Handle mouseover on the game game.move = function (x, y, obj) { // Define the size of the grid var gridSize = 100; // Calculate the grid position var gridX = Math.floor(x / gridSize) * gridSize; var gridY = Math.floor(y / gridSize) * gridSize; var blueBox = game.addChild(LK.getAsset('blueBox', { anchorX: 0.5, anchorY: 0.5, x: gridX, y: gridY })); blueBoxes.push(blueBox); LK.setTimeout(function () { blueBox.destroy(); var index = blueBoxes.indexOf(blueBox); if (index > -1) { blueBoxes.splice(index, 1); } }, 1000); }; // Note: This is a simplified example. In a full game, you would likely have more complex logic for selecting and placing decorations, managing game state, and possibly saving/loading player progress.
/****
* Classes
****/
// Define a Decoration class for house decorations
var Decoration = Container.expand(function (type) {
var self = Container.call(this);
var decoration = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
// Update method for decoration, if needed
self.update = function () {
// Update logic for the decoration
};
});
// Assets will be automatically created and loaded by the LK engine based on usage in the game code.
// Define a House class for managing the dream house
var House = Container.expand(function () {
var self = Container.call(this);
// Initialize the house with a basic shape
var houseBase = self.attachAsset('houseBase', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
// Placeholder for decorations
self.decorations = [];
// Add decoration to the house
self.addDecoration = function (decorationType) {
var decoration = self.attachAsset(decorationType, {
anchorX: 0.5,
anchorY: 0.5
});
self.decorations.push(decoration);
};
// Update method for house, if needed in the future
self.update = function () {
// Update logic for the house
};
});
// Define a Pig class that moves within the red box
var Pig = Container.expand(function () {
var self = Container.call(this);
var pig = self.attachAsset('pig', {
anchorX: 0.5,
anchorY: 0.5
});
// Set the pig's movement range
self.range = {
x: 0,
y: 0,
width: 0,
height: 0
};
// Set the pig's speed
self.speed = {
x: 1,
y: 1
};
// Update method for pig
self.update = function () {
// Move the pig
self.x += self.speed.x;
self.y += self.speed.y;
// If the pig hits the edge of the range, reverse its direction
if (self.x < self.range.x || self.x > self.range.x + self.range.width) {
self.speed.x *= -1;
}
if (self.y < self.range.y || self.y > self.range.y + self.range.height) {
self.speed.y *= -1;
}
};
});
// Define a PinkBox class for pink boxes
var PinkBox = Container.expand(function () {
var self = Container.call(this);
var pinkBox = self.attachAsset('pinkBox', {
anchorX: 0.5,
anchorY: 0.5
});
});
// Define a RedBox class for red boxes
var RedBox = Container.expand(function () {
var self = Container.call(this);
var redBox = self.attachAsset('redBox', {
anchorX: 0.5,
anchorY: 0.5
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Light blue background to simulate sky
});
/****
* Game Code
****/
// Initialize an array to store blue boxes
var blueBoxes = [];
var dreamHouse = game.addChild(new House());
dreamHouse.x = game.width / 2;
dreamHouse.y = game.height / 2;
// Initialize 5 pink boxes at random positions
for (var i = 0; i < 5; i++) {
var pinkBox = game.addChild(new PinkBox());
pinkBox.x = Math.random() * game.width;
pinkBox.y = Math.random() * game.height;
}
// Sample decorations
var decorationTypes = ['tree', 'flower', 'fence'];
// Function to add random decoration
function addRandomDecoration() {
var randomDecorationType = decorationTypes[Math.floor(Math.random() * decorationTypes.length)];
dreamHouse.addDecoration(randomDecorationType);
}
// Add a simple GUI button for adding decorations
var addButton = LK.gui.bottom.addChild(new Text2('Add Decoration', {
size: 50,
fill: "#ffffff"
}));
addButton.anchor.set(0.5, 1); // Center at bottom
addButton.y = -20; // Slightly above the bottom edge
// Handle touch on the add button
game.down = function (x, y, obj) {
// Define the size of the grid
var gridSize = 100;
// Calculate the grid position
var gridX = Math.floor(x / gridSize) * gridSize;
var gridY = Math.floor(y / gridSize) * gridSize;
blueBoxes.forEach(function (blueBox) {
var redBox = game.addChild(new RedBox());
redBox.x = blueBox.x;
redBox.y = blueBox.y;
// Generate a pig at the same location
var pig = game.addChild(new Pig());
pig.x = redBox.x;
pig.y = redBox.y;
// Set the pig's movement range to the size of the red box
pig.range = {
x: redBox.x,
y: redBox.y,
width: redBox.width,
height: redBox.height
};
});
};
// Update the game state
game.update = function () {
// This could include logic for automatically adding decorations or other game mechanics
};
// Handle mouseover on the game
game.move = function (x, y, obj) {
// Define the size of the grid
var gridSize = 100;
// Calculate the grid position
var gridX = Math.floor(x / gridSize) * gridSize;
var gridY = Math.floor(y / gridSize) * gridSize;
var blueBox = game.addChild(LK.getAsset('blueBox', {
anchorX: 0.5,
anchorY: 0.5,
x: gridX,
y: gridY
}));
blueBoxes.push(blueBox);
LK.setTimeout(function () {
blueBox.destroy();
var index = blueBoxes.indexOf(blueBox);
if (index > -1) {
blueBoxes.splice(index, 1);
}
}, 1000);
};
// Note: This is a simplified example. In a full game, you would likely have more complex logic for selecting and placing decorations, managing game state, and possibly saving/loading player progress.
house,low geometry style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
realy
rabbit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
butterfly. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.