/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Character = Container.expand(function () {
var self = Container.call(this);
self.graphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
self.baseSize = 80;
self.growthMultiplier = 1;
self.updateSize = function () {
var newScale = self.growthMultiplier;
// Change to Fatmaximus asset when size exceeds 3.00
if (self.growthMultiplier > 3.00 && !self.isFatmaximus) {
self.removeChild(self.graphics);
self.graphics = self.attachAsset('Fatmaximus', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFatmaximus = true;
self.isFat3 = false;
self.isFat2 = false;
}
// Change to Fat3 asset when size is between 2.00 and 3.00
else if (self.growthMultiplier > 2.00 && self.growthMultiplier <= 3.00 && !self.isFat3) {
self.removeChild(self.graphics);
self.graphics = self.attachAsset('Fat3', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFat3 = true;
self.isFat2 = false;
self.isFatmaximus = false;
}
// Change to fat2 asset when size is between 1.50 and 2.00
else if (self.growthMultiplier > 1.50 && self.growthMultiplier <= 2.00 && !self.isFat2) {
self.removeChild(self.graphics);
self.graphics = self.attachAsset('fat2', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFat2 = true;
self.isFat3 = false;
self.isFatmaximus = false;
}
// Change back to character asset when size drops to 1.50 or below
else if (self.growthMultiplier <= 1.50 && (self.isFat2 || self.isFat3 || self.isFatmaximus)) {
self.removeChild(self.graphics);
self.graphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFat2 = false;
self.isFat3 = false;
self.isFatmaximus = false;
}
self.graphics.scaleX = newScale;
self.graphics.scaleY = newScale;
};
return self;
});
var FoodItem = Container.expand(function (foodType) {
var self = Container.call(this);
self.foodType = foodType || 'apple';
self.nutritionValue = 1;
self.requiredStomachSize = 1;
// Set properties based on food type
switch (self.foodType) {
case 'apple':
self.graphics = self.attachAsset('apple', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 1;
self.requiredStomachSize = 1;
break;
case 'burger':
self.graphics = self.attachAsset('burger', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 3;
self.requiredStomachSize = 2;
break;
case 'pizza':
self.graphics = self.attachAsset('pizza', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 5;
self.requiredStomachSize = 3;
break;
case 'cake':
self.graphics = self.attachAsset('cake', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 8;
self.requiredStomachSize = 4;
break;
case 'fish':
self.graphics = self.attachAsset('fish', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 0;
self.requiredStomachSize = 1;
break;
case 'ultraburgerpizzacafecake':
self.graphics = self.attachAsset('ultraburgerpizzacafecake', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 0; // Special item, handled differently
self.requiredStomachSize = 1;
break;
}
self.lifespan = 300; // 5 seconds at 60fps
self.update = function () {
self.lifespan--;
if (self.lifespan <= 60) {
self.alpha = self.lifespan / 60;
}
};
self.down = function (x, y, obj) {
if (stomachFood + self.nutritionValue <= maxFoodCapacity) {
eatFood(self);
}
};
return self;
});
var UpgradeButton = Container.expand(function (upgradeType, cost, description) {
var self = Container.call(this);
self.upgradeType = upgradeType;
self.cost = cost;
self.background = self.attachAsset('upgradeButton', {
anchorX: 0,
anchorY: 0
});
self.titleText = new Text2(description, {
size: 42,
fill: 0xFFFFFF
});
self.titleText.anchor.set(0, 0);
self.titleText.x = 10;
self.titleText.y = 10;
self.addChild(self.titleText);
self.costText = new Text2('Cost: ' + cost, {
size: 36,
fill: 0xFFFFFF
});
self.costText.anchor.set(0, 0);
self.costText.x = 10;
self.costText.y = 65;
self.addChild(self.costText);
self.updateCost = function (newCost) {
self.cost = newCost;
self.costText.setText('Cost: ' + newCost);
};
self.down = function (x, y, obj) {
if (currency >= self.cost) {
purchaseUpgrade(self.upgradeType, self.cost);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game variables
var currency = storage.currency || 0;
var totalEaten = storage.totalEaten || 0;
var stomachLevel = storage.stomachLevel || 1;
var stomachFood = storage.stomachFood || 0; // Track food in stomach
var maxFoodCapacity = storage.maxFoodCapacity || 5; // Maximum food that can be eaten
var foodSpawnRate = 120; // frames between spawns
var spawnTimer = 0;
var foods = [];
var showingUpgrades = false;
var lives = storage.lives || 3; // Player starts with 3 lives
var hearts = []; // Array to store heart UI elements
// Food costs and levels
var foodUpgradeCosts = {
burger: storage.burgerUnlocked || false,
pizza: storage.pizzaUnlocked || false,
cake: storage.cakeUnlocked || false
};
var stomachUpgradeCost = storage.stomachUpgradeCost || 10;
// Create character
var playerCharacter = game.addChild(new Character());
playerCharacter.x = 1024;
playerCharacter.y = 1366;
playerCharacter.growthMultiplier = 1 + totalEaten * 0.02;
playerCharacter.updateSize();
// Initialize heart display
updateHearts();
// UI Elements
var currencyText = new Text2('Coins: ' + currency, {
size: 40,
fill: 0xFFFFFF
});
currencyText.anchor.set(0, 0);
LK.gui.top.addChild(currencyText);
currencyText.x = 120;
currencyText.y = 20;
var sizeText = new Text2('Size: x' + playerCharacter.growthMultiplier.toFixed(2), {
size: 32,
fill: 0xFFFFFF
});
sizeText.anchor.set(0, 0);
LK.gui.top.addChild(sizeText);
sizeText.x = 120;
sizeText.y = 70;
var stomachText = new Text2('Stomach: ' + stomachLevel, {
size: 32,
fill: 0xFFFFFF
});
stomachText.anchor.set(0, 0);
stomachText.x = 120;
stomachText.y = 110;
LK.gui.top.addChild(stomachText);
// Create heart UI elements
for (var h = 0; h < 3; h++) {
var heart = LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
heart.x = 120 + h * 70;
heart.y = 190;
hearts.push(heart);
LK.gui.top.addChild(heart);
}
// Sell food button in top left
var sellButton = new Text2('SELL', {
size: 48,
fill: 0xFF6B35
});
sellButton.anchor.set(0, 0);
sellButton.x = 120;
sellButton.y = 150;
LK.gui.topLeft.addChild(sellButton);
// Upgrade shop button
var shopButton = new Text2('SHOP', {
size: 56,
fill: 0xFFD700
});
shopButton.anchor.set(1, 0);
LK.gui.topRight.addChild(shopButton);
shopButton.x = -20;
shopButton.y = 20;
// Upgrade panels
var upgradePanel = new Container();
upgradePanel.visible = false;
LK.gui.center.addChild(upgradePanel);
var panelBackground = LK.getAsset('upgradeButton', {
scaleX: 8,
scaleY: 10,
anchorX: 0.5,
anchorY: 0.5
});
panelBackground.tint = 0x333333;
upgradePanel.addChild(panelBackground);
var closeButton = new Text2('X', {
size: 68,
fill: 0xFF0000
});
closeButton.anchor.set(0.5, 0.5);
closeButton.x = 600;
closeButton.y = -350;
upgradePanel.addChild(closeButton);
// Create upgrade buttons
var stomachUpgradeBtn = upgradePanel.addChild(new UpgradeButton('stomach', stomachUpgradeCost, 'Upgrade Stomach'));
stomachUpgradeBtn.x = -200;
stomachUpgradeBtn.y = -250;
var burgerUpgradeBtn = upgradePanel.addChild(new UpgradeButton('burger', 15, 'Unlock Burgers'));
burgerUpgradeBtn.x = -200;
burgerUpgradeBtn.y = -120;
var pizzaUpgradeBtn = upgradePanel.addChild(new UpgradeButton('pizza', 50, 'Unlock Pizza'));
pizzaUpgradeBtn.x = -200;
pizzaUpgradeBtn.y = 10;
var cakeUpgradeBtn = upgradePanel.addChild(new UpgradeButton('cake', 110, 'Unlock Cake'));
cakeUpgradeBtn.x = -200;
cakeUpgradeBtn.y = 140;
var maxFoodUpgradeBtn = upgradePanel.addChild(new UpgradeButton('maxFood', 25, 'Increase Max Food'));
maxFoodUpgradeBtn.x = -200;
maxFoodUpgradeBtn.y = 270;
// Shop button functionality
shopButton.down = function (x, y, obj) {
showingUpgrades = !showingUpgrades;
upgradePanel.visible = showingUpgrades;
updateUpgradeButtons();
};
closeButton.down = function (x, y, obj) {
showingUpgrades = false;
upgradePanel.visible = false;
};
// Sell button functionality
sellButton.down = function (x, y, obj) {
if (stomachFood > 0) {
currency += stomachFood;
stomachFood = 0;
// Reset character size to original state
totalEaten = 0;
playerCharacter.growthMultiplier = 1;
playerCharacter.updateSize();
LK.getSound('purchase').play();
updateUI();
saveGame();
}
};
// Functions
function spawnFood() {
// 5% chance to spawn ultraburgerpizzacafecake
if (Math.random() < 0.05) {
var food = game.addChild(new FoodItem('ultraburgerpizzacafecake'));
food.x = Math.random() * (2048 - 100) + 50;
food.y = Math.random() * (2732 - 400) + 200;
foods.push(food);
return;
}
var availableFoods = ['apple'];
if (foodUpgradeCosts.burger) availableFoods.push('burger');
if (foodUpgradeCosts.pizza) availableFoods.push('pizza');
if (foodUpgradeCosts.cake) availableFoods.push('cake');
availableFoods.push('fish');
var randomType = availableFoods[Math.floor(Math.random() * availableFoods.length)];
var food = game.addChild(new FoodItem(randomType));
food.x = Math.random() * (2048 - 100) + 50;
food.y = Math.random() * (2732 - 400) + 200;
foods.push(food);
}
function eatFood(food) {
// Check if eating fish - lose a life
if (food.foodType === 'fish') {
lives--;
LK.effects.flashScreen(0xff0000, 500);
// Check for game over
if (lives <= 0) {
LK.showGameOver();
}
}
// Check if eating ultraburgerpizzacafecake - special effects
if (food.foodType === 'ultraburgerpizzacafecake') {
// Fill food capacity to max and add 8 more points
maxFoodCapacity += 8;
stomachFood = maxFoodCapacity;
LK.effects.flashScreen(0x00ff00, 800); // Green flash for positive effect
} else {
stomachFood += food.nutritionValue;
}
totalEaten += food.nutritionValue;
// Update character size
playerCharacter.growthMultiplier = 1 + totalEaten * 0.02;
playerCharacter.updateSize();
// Flash effect
LK.effects.flashObject(food, 0xFFFFFF, 200);
// Remove food
var index = foods.indexOf(food);
if (index > -1) {
foods.splice(index, 1);
}
food.destroy();
// Play sound
LK.getSound('eat').play();
// Update UI
updateUI();
// Save progress
saveGame();
}
function purchaseUpgrade(type, cost) {
if (currency >= cost) {
currency -= cost;
LK.getSound('purchase').play();
switch (type) {
case 'stomach':
stomachLevel++;
stomachUpgradeCost = Math.floor(stomachUpgradeCost * 1.5);
stomachUpgradeBtn.updateCost(stomachUpgradeCost);
break;
case 'maxFood':
maxFoodCapacity += 10;
var newCost = Math.floor(25 * Math.pow(1.8, (maxFoodCapacity - 10) / 10));
maxFoodUpgradeBtn.updateCost(newCost);
break;
case 'burger':
foodUpgradeCosts.burger = true;
burgerUpgradeBtn.titleText.setText('Burgers Unlocked!');
burgerUpgradeBtn.background.tint = 0x666666;
break;
case 'pizza':
foodUpgradeCosts.pizza = true;
pizzaUpgradeBtn.titleText.setText('Pizza Unlocked!');
pizzaUpgradeBtn.background.tint = 0x666666;
break;
case 'cake':
foodUpgradeCosts.cake = true;
cakeUpgradeBtn.titleText.setText('Cake Unlocked!');
cakeUpgradeBtn.background.tint = 0x666666;
break;
}
updateUI();
saveGame();
}
}
function updateUpgradeButtons() {
// Update button states based on currency and unlocks
stomachUpgradeBtn.background.tint = currency >= stomachUpgradeCost ? 0x4CAF50 : 0x666666;
var maxFoodCost = Math.floor(25 * Math.pow(1.8, (maxFoodCapacity - 10) / 10));
maxFoodUpgradeBtn.background.tint = currency >= maxFoodCost ? 0x4CAF50 : 0x666666;
burgerUpgradeBtn.background.tint = currency >= 15 && !foodUpgradeCosts.burger ? 0x4CAF50 : 0x666666;
pizzaUpgradeBtn.background.tint = currency >= 50 && !foodUpgradeCosts.pizza ? 0x4CAF50 : 0x666666;
cakeUpgradeBtn.background.tint = currency >= 110 && !foodUpgradeCosts.cake ? 0x4CAF50 : 0x666666;
}
function updateUI() {
currencyText.setText('Coins: ' + currency);
sizeText.setText('Size: x' + playerCharacter.growthMultiplier.toFixed(2));
stomachText.setText('Stomach: ' + stomachLevel + ' | Food: ' + stomachFood + '/' + maxFoodCapacity);
updateHearts();
}
function updateHearts() {
for (var h = 0; h < hearts.length; h++) {
hearts[h].alpha = h < lives ? 1.0 : 0.3;
}
}
function saveGame() {
storage.currency = currency;
storage.totalEaten = totalEaten;
storage.stomachLevel = stomachLevel;
storage.stomachFood = stomachFood;
storage.maxFoodCapacity = maxFoodCapacity;
storage.stomachUpgradeCost = stomachUpgradeCost;
storage.burgerUnlocked = foodUpgradeCosts.burger;
storage.pizzaUnlocked = foodUpgradeCosts.pizza;
storage.cakeUnlocked = foodUpgradeCosts.cake;
storage.lives = lives;
}
// Play background music
LK.playMusic('Silence');
// Game update loop
game.update = function () {
// Spawn food
spawnTimer++;
if (spawnTimer >= foodSpawnRate) {
spawnFood();
spawnTimer = 0;
}
// Update and remove expired foods
for (var i = foods.length - 1; i >= 0; i--) {
var food = foods[i];
if (food.lifespan <= 0) {
food.destroy();
foods.splice(i, 1);
}
}
// Update upgrade buttons if shop is open
if (showingUpgrades) {
updateUpgradeButtons();
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Character = Container.expand(function () {
var self = Container.call(this);
self.graphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
self.baseSize = 80;
self.growthMultiplier = 1;
self.updateSize = function () {
var newScale = self.growthMultiplier;
// Change to Fatmaximus asset when size exceeds 3.00
if (self.growthMultiplier > 3.00 && !self.isFatmaximus) {
self.removeChild(self.graphics);
self.graphics = self.attachAsset('Fatmaximus', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFatmaximus = true;
self.isFat3 = false;
self.isFat2 = false;
}
// Change to Fat3 asset when size is between 2.00 and 3.00
else if (self.growthMultiplier > 2.00 && self.growthMultiplier <= 3.00 && !self.isFat3) {
self.removeChild(self.graphics);
self.graphics = self.attachAsset('Fat3', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFat3 = true;
self.isFat2 = false;
self.isFatmaximus = false;
}
// Change to fat2 asset when size is between 1.50 and 2.00
else if (self.growthMultiplier > 1.50 && self.growthMultiplier <= 2.00 && !self.isFat2) {
self.removeChild(self.graphics);
self.graphics = self.attachAsset('fat2', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFat2 = true;
self.isFat3 = false;
self.isFatmaximus = false;
}
// Change back to character asset when size drops to 1.50 or below
else if (self.growthMultiplier <= 1.50 && (self.isFat2 || self.isFat3 || self.isFatmaximus)) {
self.removeChild(self.graphics);
self.graphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFat2 = false;
self.isFat3 = false;
self.isFatmaximus = false;
}
self.graphics.scaleX = newScale;
self.graphics.scaleY = newScale;
};
return self;
});
var FoodItem = Container.expand(function (foodType) {
var self = Container.call(this);
self.foodType = foodType || 'apple';
self.nutritionValue = 1;
self.requiredStomachSize = 1;
// Set properties based on food type
switch (self.foodType) {
case 'apple':
self.graphics = self.attachAsset('apple', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 1;
self.requiredStomachSize = 1;
break;
case 'burger':
self.graphics = self.attachAsset('burger', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 3;
self.requiredStomachSize = 2;
break;
case 'pizza':
self.graphics = self.attachAsset('pizza', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 5;
self.requiredStomachSize = 3;
break;
case 'cake':
self.graphics = self.attachAsset('cake', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 8;
self.requiredStomachSize = 4;
break;
case 'fish':
self.graphics = self.attachAsset('fish', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 0;
self.requiredStomachSize = 1;
break;
case 'ultraburgerpizzacafecake':
self.graphics = self.attachAsset('ultraburgerpizzacafecake', {
anchorX: 0.5,
anchorY: 0.5
});
self.nutritionValue = 0; // Special item, handled differently
self.requiredStomachSize = 1;
break;
}
self.lifespan = 300; // 5 seconds at 60fps
self.update = function () {
self.lifespan--;
if (self.lifespan <= 60) {
self.alpha = self.lifespan / 60;
}
};
self.down = function (x, y, obj) {
if (stomachFood + self.nutritionValue <= maxFoodCapacity) {
eatFood(self);
}
};
return self;
});
var UpgradeButton = Container.expand(function (upgradeType, cost, description) {
var self = Container.call(this);
self.upgradeType = upgradeType;
self.cost = cost;
self.background = self.attachAsset('upgradeButton', {
anchorX: 0,
anchorY: 0
});
self.titleText = new Text2(description, {
size: 42,
fill: 0xFFFFFF
});
self.titleText.anchor.set(0, 0);
self.titleText.x = 10;
self.titleText.y = 10;
self.addChild(self.titleText);
self.costText = new Text2('Cost: ' + cost, {
size: 36,
fill: 0xFFFFFF
});
self.costText.anchor.set(0, 0);
self.costText.x = 10;
self.costText.y = 65;
self.addChild(self.costText);
self.updateCost = function (newCost) {
self.cost = newCost;
self.costText.setText('Cost: ' + newCost);
};
self.down = function (x, y, obj) {
if (currency >= self.cost) {
purchaseUpgrade(self.upgradeType, self.cost);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game variables
var currency = storage.currency || 0;
var totalEaten = storage.totalEaten || 0;
var stomachLevel = storage.stomachLevel || 1;
var stomachFood = storage.stomachFood || 0; // Track food in stomach
var maxFoodCapacity = storage.maxFoodCapacity || 5; // Maximum food that can be eaten
var foodSpawnRate = 120; // frames between spawns
var spawnTimer = 0;
var foods = [];
var showingUpgrades = false;
var lives = storage.lives || 3; // Player starts with 3 lives
var hearts = []; // Array to store heart UI elements
// Food costs and levels
var foodUpgradeCosts = {
burger: storage.burgerUnlocked || false,
pizza: storage.pizzaUnlocked || false,
cake: storage.cakeUnlocked || false
};
var stomachUpgradeCost = storage.stomachUpgradeCost || 10;
// Create character
var playerCharacter = game.addChild(new Character());
playerCharacter.x = 1024;
playerCharacter.y = 1366;
playerCharacter.growthMultiplier = 1 + totalEaten * 0.02;
playerCharacter.updateSize();
// Initialize heart display
updateHearts();
// UI Elements
var currencyText = new Text2('Coins: ' + currency, {
size: 40,
fill: 0xFFFFFF
});
currencyText.anchor.set(0, 0);
LK.gui.top.addChild(currencyText);
currencyText.x = 120;
currencyText.y = 20;
var sizeText = new Text2('Size: x' + playerCharacter.growthMultiplier.toFixed(2), {
size: 32,
fill: 0xFFFFFF
});
sizeText.anchor.set(0, 0);
LK.gui.top.addChild(sizeText);
sizeText.x = 120;
sizeText.y = 70;
var stomachText = new Text2('Stomach: ' + stomachLevel, {
size: 32,
fill: 0xFFFFFF
});
stomachText.anchor.set(0, 0);
stomachText.x = 120;
stomachText.y = 110;
LK.gui.top.addChild(stomachText);
// Create heart UI elements
for (var h = 0; h < 3; h++) {
var heart = LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
heart.x = 120 + h * 70;
heart.y = 190;
hearts.push(heart);
LK.gui.top.addChild(heart);
}
// Sell food button in top left
var sellButton = new Text2('SELL', {
size: 48,
fill: 0xFF6B35
});
sellButton.anchor.set(0, 0);
sellButton.x = 120;
sellButton.y = 150;
LK.gui.topLeft.addChild(sellButton);
// Upgrade shop button
var shopButton = new Text2('SHOP', {
size: 56,
fill: 0xFFD700
});
shopButton.anchor.set(1, 0);
LK.gui.topRight.addChild(shopButton);
shopButton.x = -20;
shopButton.y = 20;
// Upgrade panels
var upgradePanel = new Container();
upgradePanel.visible = false;
LK.gui.center.addChild(upgradePanel);
var panelBackground = LK.getAsset('upgradeButton', {
scaleX: 8,
scaleY: 10,
anchorX: 0.5,
anchorY: 0.5
});
panelBackground.tint = 0x333333;
upgradePanel.addChild(panelBackground);
var closeButton = new Text2('X', {
size: 68,
fill: 0xFF0000
});
closeButton.anchor.set(0.5, 0.5);
closeButton.x = 600;
closeButton.y = -350;
upgradePanel.addChild(closeButton);
// Create upgrade buttons
var stomachUpgradeBtn = upgradePanel.addChild(new UpgradeButton('stomach', stomachUpgradeCost, 'Upgrade Stomach'));
stomachUpgradeBtn.x = -200;
stomachUpgradeBtn.y = -250;
var burgerUpgradeBtn = upgradePanel.addChild(new UpgradeButton('burger', 15, 'Unlock Burgers'));
burgerUpgradeBtn.x = -200;
burgerUpgradeBtn.y = -120;
var pizzaUpgradeBtn = upgradePanel.addChild(new UpgradeButton('pizza', 50, 'Unlock Pizza'));
pizzaUpgradeBtn.x = -200;
pizzaUpgradeBtn.y = 10;
var cakeUpgradeBtn = upgradePanel.addChild(new UpgradeButton('cake', 110, 'Unlock Cake'));
cakeUpgradeBtn.x = -200;
cakeUpgradeBtn.y = 140;
var maxFoodUpgradeBtn = upgradePanel.addChild(new UpgradeButton('maxFood', 25, 'Increase Max Food'));
maxFoodUpgradeBtn.x = -200;
maxFoodUpgradeBtn.y = 270;
// Shop button functionality
shopButton.down = function (x, y, obj) {
showingUpgrades = !showingUpgrades;
upgradePanel.visible = showingUpgrades;
updateUpgradeButtons();
};
closeButton.down = function (x, y, obj) {
showingUpgrades = false;
upgradePanel.visible = false;
};
// Sell button functionality
sellButton.down = function (x, y, obj) {
if (stomachFood > 0) {
currency += stomachFood;
stomachFood = 0;
// Reset character size to original state
totalEaten = 0;
playerCharacter.growthMultiplier = 1;
playerCharacter.updateSize();
LK.getSound('purchase').play();
updateUI();
saveGame();
}
};
// Functions
function spawnFood() {
// 5% chance to spawn ultraburgerpizzacafecake
if (Math.random() < 0.05) {
var food = game.addChild(new FoodItem('ultraburgerpizzacafecake'));
food.x = Math.random() * (2048 - 100) + 50;
food.y = Math.random() * (2732 - 400) + 200;
foods.push(food);
return;
}
var availableFoods = ['apple'];
if (foodUpgradeCosts.burger) availableFoods.push('burger');
if (foodUpgradeCosts.pizza) availableFoods.push('pizza');
if (foodUpgradeCosts.cake) availableFoods.push('cake');
availableFoods.push('fish');
var randomType = availableFoods[Math.floor(Math.random() * availableFoods.length)];
var food = game.addChild(new FoodItem(randomType));
food.x = Math.random() * (2048 - 100) + 50;
food.y = Math.random() * (2732 - 400) + 200;
foods.push(food);
}
function eatFood(food) {
// Check if eating fish - lose a life
if (food.foodType === 'fish') {
lives--;
LK.effects.flashScreen(0xff0000, 500);
// Check for game over
if (lives <= 0) {
LK.showGameOver();
}
}
// Check if eating ultraburgerpizzacafecake - special effects
if (food.foodType === 'ultraburgerpizzacafecake') {
// Fill food capacity to max and add 8 more points
maxFoodCapacity += 8;
stomachFood = maxFoodCapacity;
LK.effects.flashScreen(0x00ff00, 800); // Green flash for positive effect
} else {
stomachFood += food.nutritionValue;
}
totalEaten += food.nutritionValue;
// Update character size
playerCharacter.growthMultiplier = 1 + totalEaten * 0.02;
playerCharacter.updateSize();
// Flash effect
LK.effects.flashObject(food, 0xFFFFFF, 200);
// Remove food
var index = foods.indexOf(food);
if (index > -1) {
foods.splice(index, 1);
}
food.destroy();
// Play sound
LK.getSound('eat').play();
// Update UI
updateUI();
// Save progress
saveGame();
}
function purchaseUpgrade(type, cost) {
if (currency >= cost) {
currency -= cost;
LK.getSound('purchase').play();
switch (type) {
case 'stomach':
stomachLevel++;
stomachUpgradeCost = Math.floor(stomachUpgradeCost * 1.5);
stomachUpgradeBtn.updateCost(stomachUpgradeCost);
break;
case 'maxFood':
maxFoodCapacity += 10;
var newCost = Math.floor(25 * Math.pow(1.8, (maxFoodCapacity - 10) / 10));
maxFoodUpgradeBtn.updateCost(newCost);
break;
case 'burger':
foodUpgradeCosts.burger = true;
burgerUpgradeBtn.titleText.setText('Burgers Unlocked!');
burgerUpgradeBtn.background.tint = 0x666666;
break;
case 'pizza':
foodUpgradeCosts.pizza = true;
pizzaUpgradeBtn.titleText.setText('Pizza Unlocked!');
pizzaUpgradeBtn.background.tint = 0x666666;
break;
case 'cake':
foodUpgradeCosts.cake = true;
cakeUpgradeBtn.titleText.setText('Cake Unlocked!');
cakeUpgradeBtn.background.tint = 0x666666;
break;
}
updateUI();
saveGame();
}
}
function updateUpgradeButtons() {
// Update button states based on currency and unlocks
stomachUpgradeBtn.background.tint = currency >= stomachUpgradeCost ? 0x4CAF50 : 0x666666;
var maxFoodCost = Math.floor(25 * Math.pow(1.8, (maxFoodCapacity - 10) / 10));
maxFoodUpgradeBtn.background.tint = currency >= maxFoodCost ? 0x4CAF50 : 0x666666;
burgerUpgradeBtn.background.tint = currency >= 15 && !foodUpgradeCosts.burger ? 0x4CAF50 : 0x666666;
pizzaUpgradeBtn.background.tint = currency >= 50 && !foodUpgradeCosts.pizza ? 0x4CAF50 : 0x666666;
cakeUpgradeBtn.background.tint = currency >= 110 && !foodUpgradeCosts.cake ? 0x4CAF50 : 0x666666;
}
function updateUI() {
currencyText.setText('Coins: ' + currency);
sizeText.setText('Size: x' + playerCharacter.growthMultiplier.toFixed(2));
stomachText.setText('Stomach: ' + stomachLevel + ' | Food: ' + stomachFood + '/' + maxFoodCapacity);
updateHearts();
}
function updateHearts() {
for (var h = 0; h < hearts.length; h++) {
hearts[h].alpha = h < lives ? 1.0 : 0.3;
}
}
function saveGame() {
storage.currency = currency;
storage.totalEaten = totalEaten;
storage.stomachLevel = stomachLevel;
storage.stomachFood = stomachFood;
storage.maxFoodCapacity = maxFoodCapacity;
storage.stomachUpgradeCost = stomachUpgradeCost;
storage.burgerUnlocked = foodUpgradeCosts.burger;
storage.pizzaUnlocked = foodUpgradeCosts.pizza;
storage.cakeUnlocked = foodUpgradeCosts.cake;
storage.lives = lives;
}
// Play background music
LK.playMusic('Silence');
// Game update loop
game.update = function () {
// Spawn food
spawnTimer++;
if (spawnTimer >= foodSpawnRate) {
spawnFood();
spawnTimer = 0;
}
// Update and remove expired foods
for (var i = foods.length - 1; i >= 0; i--) {
var food = foods[i];
if (food.lifespan <= 0) {
food.destroy();
foods.splice(i, 1);
}
}
// Update upgrade buttons if shop is open
if (showingUpgrades) {
updateUpgradeButtons();
}
};
fat. In-Game asset. 2d. High contrast. No shadows
apple. In-Game asset. 2d. High contrast. No shadows
burger. In-Game asset. 2d. High contrast. No shadows
cake. In-Game asset. 2d. High contrast. No shadows
heart. In-Game asset. 2d. High contrast. No shadows
poison fish. In-Game asset. 2d. High contrast. No shadows
ultraburgerpizzacafecake. In-Game asset. 2d. High contrast. No shadows
a lot fat. In-Game asset. 2d. High contrast. No shadows
zombie fat. In-Game asset. 2d. High contrast. No shadows