/****
* Classes
****/
// Define a class for the Box Lid
var BoxLid = Container.expand(function () {
var self = Container.call(this);
var boxLidGraphics = self.attachAsset('boxLid', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2; // Center the box lid horizontally
self.y = 2732 / 2 + 720 - 350 - 300; // Move the box lid up by 300 units
});
// Assets will be automatically created and loaded by the LK engine based on their usage in the code.
// Define a class for the Cat
var Cat = Container.expand(function () {
var self = Container.call(this);
// Method to animate the cat paw stretching towards the toggle switch
self.stretchPaw = function () {
var targetX = toggleSwitch.x;
var targetY = toggleSwitch.y;
var stretchInterval = LK.setInterval(function () {
if (catPaw.x < targetX) {
catPaw.x += 5; // Move the paw towards the toggle switch
}
if (catPaw.y > targetY) {
catPaw.y -= 5; // Move the paw upwards towards the toggle switch
}
if (Math.abs(catPaw.x - targetX) < 5 && Math.abs(catPaw.y - targetY) < 5) {
LK.clearInterval(stretchInterval); // Stop the interval when the paw reaches the toggle switch
catPaw.visible = false; // Hide the cat paw
toggleSwitch.isTouched = true; // Set toggle switch as touched
LK.getSound('ts').play(); // Play 'ts' sound when the cat paw touches the toggle switch
}
}, 16); // Approximately 60 FPS
};
var catGraphics = self.attachAsset('cat', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2;
self.y = 2732 / 2 + 1050; // Move the cat down by 1050 units to ensure it does not cover the cat paw
});
// Define a class for the Cat Paw
var CatPaw = Container.expand(function () {
var self = Container.call(this);
var pawGraphics = self.attachAsset('catPaw', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2 + 110 - 50 + 10 + 45 - 20 - 20 + 70;
self.y = 2732 / 2 + 550; // Move the cat arm up by 10 units
pawGraphics.rotation = Math.PI / 4 - Math.PI / 18; // Rotate the cat paw 35 degrees to the right (10 degrees left from original)
});
// Define a class for the Ceiling Light
var CeilingLight = Container.expand(function () {
var self = Container.call(this);
var lightGraphics = self.attachAsset('ceilingLight', {
anchorX: 0.5,
anchorY: 0.0
});
self.x = 2048 / 2; // Center the ceiling light horizontally
self.y = 2732 / 2 - 1400; // Move the ceiling light up by 300 units
// Initialize swaying properties
self.swaySpeed = 0.005;
self.swayDirection = 1;
self.swaying = false;
self.swayCount = 0;
// Method to start swaying
self.startSwaying = function () {
if (!self.swaying) {
self.swaying = true;
self.swayCount = 0;
self.swaySpeed = 0.01; // Reset sway speed to default
}
};
// Method to update swaying
self.updateSwaying = function () {
if (self.swaying) {
self.rotation += self.swaySpeed * self.swayDirection;
if (self.rotation > 0.349 || self.rotation < -0.349) {
// 20 degrees in radians
self.swayDirection *= -1;
}
self.swayCount++;
if (self.swayCount > 120) {
// 2 seconds at 60 FPS
self.swaySpeed *= 0.99; // Gradually slow down
if (Math.abs(self.rotation) < 0.01) {
self.rotation = 0; // Reset to original position
self.swaying = false; // Stop swaying
}
}
}
};
// Event handler for when the ceiling light is touched
self.down = function (x, y, obj) {
self.startSwaying();
self.clickCount = (self.clickCount || 0) + 1; // Increment click count
if (self.clickCount >= 10) {
self.fallToGround(); // Trigger the fall to ground method
self.clickCount = 0; // Reset click count
}
self.swaySpeed *= 1.2; // Increase swaying speed
self.swayCount = 0; // Reset sway count
};
// Method to make the ceiling light fall to the ground
self.fallToGround = function () {
darkOverlay.toggle(); // Turn on the dark overlay
var fallInterval = LK.setInterval(function () {
if (self.y < 2732 / 2 + 1100) {
self.y += 64; // Move the ceiling light down at double the previous speed
} else {
LK.clearInterval(fallInterval); // Stop the interval when it reaches the ground
self.visible = false; // Hide the ceiling light
}
}, 16); // Approximately 60 FPS
};
});
// Define a class for Cookies
var Cookies = Container.expand(function () {
var self = Container.call(this);
var cookiesGraphics = self.attachAsset('cookies', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2 + 500; // Position the cookies to the right side of the table
self.y = 2732 / 2 + 1200; // Position the cookies below the mug
});
// Define a class for the DarkOverlay
var DarkOverlay = Container.expand(function () {
var self = Container.call(this);
var overlayGraphics = LK.getAsset('darkOverlay', {
anchorX: 0.0,
anchorY: 0.0,
width: 2048,
height: 2732,
alpha: 0.95
});
self.addChild(overlayGraphics);
self.visible = false; // Initially hidden
// Method to toggle visibility
self.toggle = function () {
self.visible = !self.visible;
};
});
// Define a class for the Mug
var Mug = Container.expand(function () {
var self = Container.call(this);
var mugGraphics = self.attachAsset('hotChocolate', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2 + 800; // Position the mug to the right side of the table
self.y = 2732 / 2 + 1000; // Move the mug up by 200 units
// Create steam effect
var steam = new Container();
var steamGraphics = LK.getAsset('steam', {
anchorX: 0.5,
anchorY: 1.0,
alpha: 0.5
});
steam.addChild(steamGraphics);
steam.y = -100; // Position steam above the mug
self.addChild(steam);
// Animate steam rising
steam.update = function () {
steam.y -= 0.5; // Move steam upwards at half speed
if (steam.y < -150) {
steam.y = -100; // Reset steam position
}
};
self.update = function () {
steam.update();
};
});
// Define a class for the Remote
var Remote = Container.expand(function () {
var self = Container.call(this);
// Event handler for when the remote is touched
self.down = function (x, y, obj) {
if (self.soundPlaying) {
LK.getSound('Christmassound').stop(); // Stop sound if it's playing
self.soundPlaying = false;
} else {
LK.getSound('Christmassound').play(); // Play sound if it's not playing
self.soundPlaying = true;
}
};
var remoteGraphics = self.attachAsset('remote', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2 - 300; // Position the remote on the left side of the table
self.y = 2732 / 2 + 1200; // Position the remote on the table
});
// Define a class for Snowflake
var Snowflake = Container.expand(function () {
var self = Container.call(this);
var snowflakeGraphics = self.attachAsset('snowflake', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = Math.random() * 2048; // Random horizontal position
self.y = -50; // Start above the screen
self.speedY = 1 + Math.random() * 2; // Random falling speed
self.update = function () {
self.y += self.speedY;
if (self.y > 2732) {
self.y = -50; // Reset to top
self.x = Math.random() * 2048; // Random horizontal position
}
};
});
// Define a class for the StickyNote
var StickyNote = Container.expand(function () {
var self = Container.call(this);
var stickyNoteGraphics = self.attachAsset('stickyNote', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2 - 750; // Move the sticky note to the left side of the box
self.y = 2732 / 2 + 1020; // Move the sticky note down by 300 units
self.touchCount = 0; // Initialize touch counter
// Method to handle touch events
self.down = function (x, y, obj) {
self.touchCount++;
if (self.touchCount >= 3) {
self.fallToBottom();
self.touchCount = 0; // Reset touch counter
}
};
// Method to animate falling to the bottom
self.fallToBottom = function () {
var fallInterval = LK.setInterval(function () {
if (self.y < 2732 / 2 + 1100) {
self.y += 5; // Move the sticky note down
} else {
LK.clearInterval(fallInterval); // Stop the interval when it reaches the bottom
}
}, 16); // Approximately 60 FPS
};
});
// Define a class for the Table
var Table = Container.expand(function () {
var self = Container.call(this);
var tableGraphics = self.attachAsset('table', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2; // Center the table horizontally
self.y = 2732 / 2 + 1700; // Move the table up by 500 units
});
// Define a class for the Toggle Switch
var ToggleSwitch = Container.expand(function () {
var self = Container.call(this);
var switchGraphics = self.attachAsset('toggleSwitch', {
anchorX: 0.5,
anchorY: 0.33
});
self.x = 2048 / 2;
self.y = 2732 / 2 + 750; // Move the toggle switch down by 50 units
self.isTouched = false;
// Event handler for when the switch is touched
self.down = function (x, y, obj) {
self.isTouched = true;
LK.getSound('ts').play();
boxLid.visible = !boxLid.visible; // Toggle the visibility of the box lid
if (boxLid.visible) {
LK.setTimeout(function () {
cat.visible = boxLid.visible; // Make the cat visible only if the box lid is visible
var targetY = 2732 / 2 + 100; // Target position for the cat
var moveInterval = LK.setInterval(function () {
if (cat.y > targetY) {
cat.y -= 10; // Move the cat upwards at double speed
} else {
LK.clearInterval(moveInterval); // Stop the interval when the cat reaches the target position
cat.stretchPaw(); // Trigger the paw stretch animation
catPaw.visible = true; // Show the cat paw when the toggle switch is open
switchGraphics.scale.y *= -1; // Flip the toggle switch vertically
LK.setTimeout(function () {
catPaw.visible = false; // Hide the cat paw when the toggle switch is closed
boxLid.visible = false; // Hide the box lid when the cat and paw are hidden
cat.y = 2732 / 2 + 950; // Move the cat back behind the box
}, 500);
}
}, 16); // Approximately 60 FPS
}, 500);
} else {
cat.visible = false; // Hide the cat when the box lid is not visible
catPaw.visible = false; // Hide the cat paw when the toggle switch is closed
}
// Mirror the toggle switch vertically
switchGraphics.scale.y *= -1;
};
});
// Define a class for the Wall
var Wall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2; // Center the wall horizontally
self.y = 2732 / 2 - 100; // Move the wall up by 100 units
});
// Define a class for the Wallpaper
var Wallpaper = Container.expand(function () {
var self = Container.call(this);
var wallpaperGraphics = self.attachAsset('wallpaper', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2 - 10; // Move the wallpaper left by 10 units
self.y = 2732 / 2 - 300; // Move the wallpaper up by 300 units
});
// Define a class for the Wooden Box
var WoodenBox = Container.expand(function () {
var self = Container.call(this);
var boxGraphics = self.attachAsset('woodenBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2; // Center the wooden box horizontally
self.y = 2732 / 2 + 720; // Move the wooden box down by 220 units
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize snowflakes
var snowflakes = [];
for (var i = 0; i < 100; i++) {
var snowflake = new Snowflake();
game.addChild(snowflake);
snowflakes.push(snowflake);
}
// Add the wall to the game
var wall = game.addChild(new Wall());
// Add the ceiling light to the game, ensuring it is in front of the wallpaper
var wallpaper = game.addChildAt(new Wallpaper(), 0); // Ensure wallpaper is rendered behind other elements
// Add the ceiling light to the game, ensuring it is in front of the wallpaper
ceilingLight = game.addChild(new CeilingLight());
game.setChildIndex(ceilingLight, game.children.length - 1);
// Add the dark overlay to the game
var darkOverlay = game.addChild(new DarkOverlay());
game.setChildIndex(darkOverlay, game.children.length - 1); // Ensure darkOverlay is rendered above wallpaper
// Add the box lid to the game
var boxLid = game.addChild(new BoxLid());
boxLid.visible = false; // Ensure the box lid is initially invisible when the game starts
// Initialize game elements
var cat = game.addChild(new Cat());
cat.visible = true; // Ensure the cat is visible when the game starts
// Add the table to the game
var table = game.addChild(new Table());
// Add the wooden box to the game
var woodenBox = game.addChild(new WoodenBox());
// Add the remote to the game
var remote = game.addChild(new Remote());
// Add the mug to the game
var mug = game.addChild(new Mug());
var cookies = game.addChild(new Cookies());
var toggleSwitch = game.addChild(new ToggleSwitch());
toggleSwitch.isTouched = false; // Ensure toggle switch is in close state when the game starts
// Removed the LightSwitch instance creation as the class is not defined
var catPaw = game.addChild(new CatPaw());
catPaw.visible = false; // Ensure the cat's paw is initially invisible when the game starts
game.setChildIndex(catPaw, game.children.length - 1);
// Add the sticky note to the game
var stickyNote = game.addChild(new StickyNote());
// Add the dark overlay to the game
var darkOverlay = game.addChild(new DarkOverlay());
game.setChildIndex(darkOverlay, game.children.length - 1); // Ensure darkOverlay is rendered above wallpaper
// Game update loop
game.update = function () {
ceilingLight.updateSwaying(); // Update swaying effect for ceiling light
// Update snowflakes
for (var i = 0; i < snowflakes.length; i++) {
snowflakes[i].update();
}
// Move the cat down by 600 units
if (toggleSwitch.isTouched) {
if (!boxLid.visible) {
cat.y = 2732 / 2 + 790; // Ensure the cat's position is set correctly when visible
}
LK.getSound('ts').play(); // Play 'ts' sound when the player reaches the toggleSwitch
toggleSwitch.isTouched = false; // Reset the switch state
}
};
// Handle touch events on the game
game.down = function (x, y, obj) {
// Convert global coordinates to local game coordinates
var localPos = game.toLocal(obj.global);
// Check if the touch is on the sticky note
if (stickyNote.intersects({
x: localPos.x,
y: localPos.y,
width: 1,
height: 1
})) {
stickyNote.down(x, y, obj);
}
};
fehér fényű mennyezeti lámpa.
Photorealistic ginger cat face, front view..
Photorealistic wonderfull Snowy winter garden at night
Photorealistic snowflakes. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Photorealistic gold-colored, silver snowflakes Christmas tablecloth, front view.
photorealistic red and gold standing and opened postcard with Merry Christmas text
photorealistic red mug of hot chocolate. ows.
multimedia remote switch
photorealistic red plate of cookies, profile view.