/**** * Classes ****/ // Button class to represent the bake button var BakeButton = Container.expand(function () { var self = Container.call(this); var buttonGraphic = self.attachAsset('bakeButton', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { if (pizza) { pizza.cook(); } }; return self; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Fire class to represent the fire object var Fire = Container.expand(function () { var self = Container.call(this); var fireGraphic = self.attachAsset('fire', { anchorX: 0.5, anchorY: 0.5 }); self.visible = false; return self; }); // Pizza class to represent the pizza object var Pizza = Container.expand(function () { var self = Container.call(this); var rawPizza = self.attachAsset('rawPizza', { anchorX: 0.5, anchorY: 0.5 }); self.isCooked = false; self.isEaten = false; self.cook = function () { if (!self.isCooked) { // Start a timer for 15 seconds (15000ms) LK.setTimeout(function () { self.isCooked = true; rawPizza.visible = false; cookedPizza.visible = true; fire.visible = false; LK.getSound('fire').stop(); // Stop the fire sound when cooking is done }, 15000); fire.visible = true; LK.getSound('fire').play(); // Play the fire sound when cooking starts } }; self.eat = function () { if (self.isCooked && !self.isEaten) { self.isEaten = true; LK.setTimeout(function () { cookedPizza.visible = false; }, 3000); } }; var cookedPizza = self.attachAsset('cookedPizza', { anchorX: 0.5, anchorY: 0.5 }); cookedPizza.visible = false; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var background = game.addChild(LK.getAsset('background', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0 })); // Initialize pizza and button var pizza = game.addChild(new Pizza()); var fire = pizza.addChild(new Fire()); fire.x = 0; fire.y = 0; pizza.x = 2048 / 2; pizza.y = 2732 / 2; var bakeButton = game.addChild(new BakeButton()); bakeButton.x = 2048 - 100; // Position at top right bakeButton.y = 100; // Event listener for clicking on the pizza pizza.down = function (x, y, obj) { pizza.eat(); if (pizza.isEaten) { LK.getSound('eat').play(); LK.showGameOver(); } }; // Play the 'des' music at a low volume when the game starts LK.playMusic('des', { volume: 0.1 }); // Update function for game logic game.update = function () { // Game logic can be added here if needed };
/****
* Classes
****/
// Button class to represent the bake button
var BakeButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphic = self.attachAsset('bakeButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
if (pizza) {
pizza.cook();
}
};
return self;
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Fire class to represent the fire object
var Fire = Container.expand(function () {
var self = Container.call(this);
var fireGraphic = self.attachAsset('fire', {
anchorX: 0.5,
anchorY: 0.5
});
self.visible = false;
return self;
});
// Pizza class to represent the pizza object
var Pizza = Container.expand(function () {
var self = Container.call(this);
var rawPizza = self.attachAsset('rawPizza', {
anchorX: 0.5,
anchorY: 0.5
});
self.isCooked = false;
self.isEaten = false;
self.cook = function () {
if (!self.isCooked) {
// Start a timer for 15 seconds (15000ms)
LK.setTimeout(function () {
self.isCooked = true;
rawPizza.visible = false;
cookedPizza.visible = true;
fire.visible = false;
LK.getSound('fire').stop(); // Stop the fire sound when cooking is done
}, 15000);
fire.visible = true;
LK.getSound('fire').play(); // Play the fire sound when cooking starts
}
};
self.eat = function () {
if (self.isCooked && !self.isEaten) {
self.isEaten = true;
LK.setTimeout(function () {
cookedPizza.visible = false;
}, 3000);
}
};
var cookedPizza = self.attachAsset('cookedPizza', {
anchorX: 0.5,
anchorY: 0.5
});
cookedPizza.visible = false;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
var background = game.addChild(LK.getAsset('background', {
anchorX: 0.0,
anchorY: 0.0,
x: 0,
y: 0
}));
// Initialize pizza and button
var pizza = game.addChild(new Pizza());
var fire = pizza.addChild(new Fire());
fire.x = 0;
fire.y = 0;
pizza.x = 2048 / 2;
pizza.y = 2732 / 2;
var bakeButton = game.addChild(new BakeButton());
bakeButton.x = 2048 - 100; // Position at top right
bakeButton.y = 100;
// Event listener for clicking on the pizza
pizza.down = function (x, y, obj) {
pizza.eat();
if (pizza.isEaten) {
LK.getSound('eat').play();
LK.showGameOver();
}
};
// Play the 'des' music at a low volume when the game starts
LK.playMusic('des', {
volume: 0.1
});
// Update function for game logic
game.update = function () {
// Game logic can be added here if needed
};
çiğ pizza. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
fire. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
mutfak. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Fırın. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows