Code edit (3 edits merged)
Please save this source code
User prompt
move the crappy asset higher
User prompt
if the units are reset to 0 upon the player prematurely goes to the up state, display the UI_Crappy asset in the center of the screen. this asset is placed in the foreground container
User prompt
fix it
User prompt
place the UI_Crappy asset in the foreground container and show it in the center of the screen
User prompt
show the UI_Crappy asset in the center of the screen
User prompt
create a system to display the player's performance, based on the digestive system. his system will be able to display multiple assets, depending on the performance of the units system. All images have the same display animation method, as they start from a very small 1 pixel point and over the course of a second are expanded to their original asset size. they remain on the screen for 1 second they they fade out to become fully invisible. the first asset we show is the asset UI_Crappy which shows when the player moves from down to up while there are still undepleted units. so if the player has 1 or more units filled up, and he transitions to the up position while there are still undepleted units, display the UI_Crappy
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'var uiCrappy = foregroundContainer.attachAsset('UI_Crappy', {' Line Number: 242
User prompt
place the UI_Crappy asset in the foreground container
User prompt
the UI_Crappy asset is not displayed in the center of the screen as per the rules of the system
User prompt
create a system to display the player's performance, based on the digestive system. his system will be able to display multiple assets, depending on the performance of the units system. All images have the same display animation method, as they start from a very small 1 pixel point and over the course of a second are expanded to their original asset size. they remain on the screen for 1 second they they fade out to become fully invisible. the first asset we show is the asset UI_Crappy which shows when the player moves from down to up while there are still undepleted units. so if the player has 1 or more units filled up, and he transitions to the up position while there are still undepleted units, display the UI_Crappy
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'if (food.x <= 0) {' Line Number: 342
User prompt
move the score 10 pixels to the left
Code edit (1 edits merged)
Please save this source code
User prompt
the spawn time increase for every player down change is too large, make it less
User prompt
on top of increasing the foods acceleration when the player moves down, similarly, also decrease the spawn time of all 3 foods
User prompt
when units are removed, instead of simply making the value under it disappear, add an animation tothem. this animation is defined by 2 factors. the value doubles in size and also becomes transparent to alpha 0 before being destroyed. the size increase and alpha transparency must happen at the same time so it takes 1 second for both of these changes to occur
User prompt
when units are removed, instead of simply making the value under it disappear, make that value travel towards the score with a speed of 20. ensure they travel exactly to the center of the score's location
User prompt
when units are removed, instead of simply making the value under it disappear, make that value travel towards the score with a speed of 20
User prompt
the food decreaseing the score when the hit the elft screen edge should only decerase the points if the digestive system unit is 0, while the units are still depleating, don't remove those points
User prompt
if a food reaches the left edge of the screen before the player manages to collect it, instead of increasing the score, decrease it based on the points they were supposed to increase
Code edit (1 edits merged)
Please save this source code
User prompt
decrease the acceleration increase after player moving to the down state from 1 to 0.1
User prompt
after each time the player moves to the down state, permanently increase the acceleration of all 3 food items by 1 for all future spawned food items
Code edit (10 edits merged)
Please save this source code
/**** * Classes ****/ // Create BackgroundContainer class var BackgroundContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create DigestionSystem class var DigestionSystem = Container.expand(function () { var self = Container.call(this); self.units = []; self.maxUnits = 10; self.unitWidth = 100; self.unitHeight = 100; self.unitSpacing = 100; self.unitFullAlpha = 1; self.unitEmptyAlpha = 0.5; // Initialize with 10 empty units for (var i = 0; i < self.maxUnits; i++) { var unit = self.attachAsset('Unit', { anchorX: 0.5, anchorY: 0.5, x: i * (self.unitWidth + self.unitSpacing), alpha: self.unitEmptyAlpha }); self.units.push(unit); } // Add text display for points under each unit self.unitTexts = []; for (var i = 0; i < self.maxUnits; i++) { var unitText = new Text2('', { size: 80, fill: "#ffffff", stroke: "#000000", strokeThickness: 10 }); unitText.anchor.set(0.5, 0.5); unitText.x = i * (self.unitWidth + self.unitSpacing); unitText.y = +120; self.addChild(unitText); self.unitTexts.push(unitText); } return self; }); // Create Food class var Food = Container.expand(function () { var self = Container.call(this); // Attach Food asset to the food self.foodAsset = self.attachAsset('Food', { anchorX: 0.5, anchorY: 0.5 }); // Set food speed self.speed = -5; // This is automatically called every game tick, if the food is attached! self.update = function () { self.speed -= 0.3; // acceleration self.x += self.speed; }; return self; }); // Create Food_2 class var Food_2 = Container.expand(function () { var self = Container.call(this); // Attach Food_2 asset to the food self.foodAsset = self.attachAsset('Food_2', { anchorX: 0.5, anchorY: 0.5 }); // Set food speed self.speed = -5; // This is automatically called every game tick, if the food is attached! self.update = function () { self.speed -= 0.3; // acceleration self.x += self.speed; }; return self; }); // Create Food_3 class var Food_3 = Container.expand(function () { var self = Container.call(this); // Attach Food_3 asset to the food self.foodAsset = self.attachAsset('Food_3', { anchorX: 0.5, anchorY: 0.5 }); // Set food speed self.speed = -5; // This is automatically called every game tick, if the food is attached! self.update = function () { self.speed -= 0.3; // acceleration self.x += self.speed; }; return self; }); // Create ForegroundContainer class var ForegroundContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create MidgroundContainer class var MidgroundContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create Player class var Player = Container.expand(function () { var self = Container.call(this); // Attach Player_Up asset to the player self.playerUp = self.attachAsset('Player_Up', { anchorX: 0.5, anchorY: 1.0, scaleX: 1.5, scaleY: 1.5 }); // Attach Player_Down asset to the player self.playerDown = self.attachAsset('Player_Down', { anchorX: 0.5, anchorY: 1.0, x: -120, scaleX: 1.5, scaleY: 1.5 }); // Initially, Player_Down is not visible self.playerDown.visible = false; // Method to switch between Player_Up and Player_Down self.switchFrame = function () { self.playerUp.visible = !self.playerUp.visible; self.playerDown.visible = !self.playerDown.visible; if (self.playerDown.visible) { LK.getSound('Pooping').play(); // Increase the acceleration of all 3 food items by 0.1 Food.prototype.speed -= 1; Food_2.prototype.speed -= 1; Food_3.prototype.speed -= 1; // Store the number of filled units when transitioning to the down state filledUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }).length; } else { // Decrease the score for each remaining unit when the player prematurely moves back up var remainingUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }).length; score -= remainingUnits * filledUnits; scoreTxt.setText(score); if (score <= 0) { LK.showGameOver(); return; } filledUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }).length; // Update points display under each unit digestionSystem.units.forEach(function (unit, index) { if (unit.alpha === digestionSystem.unitFullAlpha) { digestionSystem.unitTexts[index].setText(filledUnits); } else { digestionSystem.unitTexts[index].setText(''); } }); digestionSystem.units.forEach(function (unit, index) { unit.alpha = digestionSystem.unitEmptyAlpha; digestionSystem.unitTexts[index].setText(''); // Clear points display under each unit }); filledUnits = 0; LK.getSound('Pooping').stop(); } }; // Method to check if the player collides with a food object self.checkCollision = function (food) { // Only player_up can collect food if (self.playerUp.visible) { var playerBounds = self.playerUp.getBounds(); if (food) { var foodBounds = food.getBounds(); var foodCenter = { x: foodBounds.x + foodBounds.width / 2, y: foodBounds.y + foodBounds.height / 2 }; } var playerCenter = { x: playerBounds.x + playerBounds.width / 2, y: playerBounds.y + playerBounds.height / 2 }; // Check if the center of the food is within the bounds of the player if (foodCenter && playerBounds.contains(foodCenter.x, foodCenter.y)) { // Do not add a unit to the Digestion System here return true; } if (food) { var foodBounds = food.getBounds(); var foodCenter = { x: foodBounds.x + foodBounds.width / 2, y: foodBounds.y + foodBounds.height / 2 }; if (playerBounds.contains(foodCenter.x, foodCenter.y)) { return true; } if (food && food.foodAsset && food.foodAsset.getBounds) { var foodAssetBounds = food.foodAsset.getBounds(); var foodAssetCenter = { x: foodAssetBounds.x + foodAssetBounds.width / 2, y: foodAssetBounds.y + foodAssetBounds.height / 2 }; if (playerBounds.contains(foodAssetCenter.x, foodAssetCenter.y)) { return true; } } } return false; } return false; }; return self; }); /**** * Initialize Game ****/ //<Assets used in the game will automatically appear here> var game = new LK.Game({ backgroundColor: 0xfdfff4 // Init game with white background }); /**** * Game Code ****/ var backgroundContainer = game.addChild(new BackgroundContainer()); var background = backgroundContainer.attachAsset('background', { anchorX: 0.5, anchorY: 1.0, x: 2048 / 2, y: 2732 }); var midgroundContainer = game.addChild(new MidgroundContainer()); var foregroundContainer = game.addChild(new ForegroundContainer()); // Add the Digestion System to the game var digestionSystem = game.addChild(new DigestionSystem()); digestionSystem.x = 2048 / 2 - 400 - digestionSystem.unitWidth * digestionSystem.maxUnits / 2; digestionSystem.y = 100; var score = 0; var scoreTxt; var filledUnits = 0; var filledUnits = 0; scoreTxt = new Text2('0', { size: 150, fill: "#ffffff", stroke: "#000000", strokeThickness: 15 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.y += 920; // Add the Player in the center of the screen var player = midgroundContainer.addChild(new Player()); player.x = 2048 / 2 - 500; player.y = 2732 + 30; // Switch the player's frame on tap game.down = function (x, y, obj) { player.switchFrame(); }; // Spawn food from the right edge of the screen at y position of 500 game.update = function () { if (LK.ticks == 0) { score = 0; scoreTxt.setText(score); filledUnits = 0; // Reset the Digestion System digestionSystem.units.forEach(function (unit) { unit.alpha = digestionSystem.unitEmptyAlpha; }); // Clear points display under each unit digestionSystem.unitTexts.forEach(function (unitText) { unitText.setText(''); }); } if (LK.ticks % 60 == 0) { // every second var foodBucket = []; for (var i = 0; i < 90; i++) { foodBucket.push(new Food()); } for (var i = 0; i < 60; i++) { foodBucket.push(new Food_2()); } for (var i = 0; i < 30; i++) { foodBucket.push(new Food_3()); } var newFood = foodBucket[Math.floor(Math.random() * foodBucket.length)]; newFood.x = 2048; // right edge of the screen newFood.y = 1900; foregroundContainer.addChild(newFood); } // Check for collision between the player and the food // Remove a unit from the Digestion System when the player is in the Down state if (!player.playerUp.visible) { if (LK.ticks % 30 == 0) { var fullUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }); if (fullUnits.length > 0) { fullUnits[fullUnits.length - 1].alpha = digestionSystem.unitEmptyAlpha; score += filledUnits; // Add points based on the fixed number of filled units // Update points display under each unit digestionSystem.units.forEach(function (unit, index) { if (unit.alpha === digestionSystem.unitFullAlpha) { digestionSystem.unitTexts[index].setText(filledUnits); } else { digestionSystem.unitTexts[index].setText(''); } }); scoreTxt.setText(score); if (score <= 0) { LK.showGameOver(); return; } } else { LK.getSound('Pooping').stop(); } } } else { LK.getSound('Pooping').stop(); } for (var i = foregroundContainer.children.length - 1; i >= 0; i--) { var food = foregroundContainer.children[i]; if (player.checkCollision(food) || player.checkCollision(food.foodAsset)) { // Increment the score if (food instanceof Food_2) { score += 2; // Add two units to the Digestion System for (var i = 0; i < 2; i++) { var fullUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }); if (fullUnits.length < digestionSystem.maxUnits) { digestionSystem.units[fullUnits.length].alpha = digestionSystem.unitFullAlpha; filledUnits = fullUnits.length + 1; // Update filledUnits } else { LK.showGameOver(); return; } } // Update points display under each unit digestionSystem.units.forEach(function (unit, index) { if (unit.alpha === digestionSystem.unitFullAlpha) { digestionSystem.unitTexts[index].setText(filledUnits); } else { digestionSystem.unitTexts[index].setText(''); } }); } else if (food instanceof Food_3) { score += 3; // Add three units to the Digestion System for (var i = 0; i < 3; i++) { var fullUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }); if (fullUnits.length < digestionSystem.maxUnits) { digestionSystem.units[fullUnits.length].alpha = digestionSystem.unitFullAlpha; filledUnits = fullUnits.length + 1; // Update filledUnits } else { LK.showGameOver(); return; } } // Update points display under each unit digestionSystem.units.forEach(function (unit, index) { if (unit.alpha === digestionSystem.unitFullAlpha) { digestionSystem.unitTexts[index].setText(filledUnits); } else { digestionSystem.unitTexts[index].setText(''); } }); } else { score++; // Add a unit to the Digestion System var fullUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }); if (fullUnits.length < digestionSystem.maxUnits) { digestionSystem.units[fullUnits.length].alpha = digestionSystem.unitFullAlpha; filledUnits = fullUnits.length + 1; // Update filledUnits // Update points display under each unit digestionSystem.units.forEach(function (unit, index) { if (unit.alpha === digestionSystem.unitFullAlpha) { digestionSystem.unitTexts[index].setText(filledUnits); } else { digestionSystem.unitTexts[index].setText(''); } }); } else { LK.showGameOver(); return; } } scoreTxt.setText(score); // Play the Eat sound LK.getSound('Eat').play(); // Remove the food from the game food.destroy(); } } };
/****
* Classes
****/
// Create BackgroundContainer class
var BackgroundContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Create DigestionSystem class
var DigestionSystem = Container.expand(function () {
var self = Container.call(this);
self.units = [];
self.maxUnits = 10;
self.unitWidth = 100;
self.unitHeight = 100;
self.unitSpacing = 100;
self.unitFullAlpha = 1;
self.unitEmptyAlpha = 0.5;
// Initialize with 10 empty units
for (var i = 0; i < self.maxUnits; i++) {
var unit = self.attachAsset('Unit', {
anchorX: 0.5,
anchorY: 0.5,
x: i * (self.unitWidth + self.unitSpacing),
alpha: self.unitEmptyAlpha
});
self.units.push(unit);
}
// Add text display for points under each unit
self.unitTexts = [];
for (var i = 0; i < self.maxUnits; i++) {
var unitText = new Text2('', {
size: 80,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 10
});
unitText.anchor.set(0.5, 0.5);
unitText.x = i * (self.unitWidth + self.unitSpacing);
unitText.y = +120;
self.addChild(unitText);
self.unitTexts.push(unitText);
}
return self;
});
// Create Food class
var Food = Container.expand(function () {
var self = Container.call(this);
// Attach Food asset to the food
self.foodAsset = self.attachAsset('Food', {
anchorX: 0.5,
anchorY: 0.5
});
// Set food speed
self.speed = -5;
// This is automatically called every game tick, if the food is attached!
self.update = function () {
self.speed -= 0.3; // acceleration
self.x += self.speed;
};
return self;
});
// Create Food_2 class
var Food_2 = Container.expand(function () {
var self = Container.call(this);
// Attach Food_2 asset to the food
self.foodAsset = self.attachAsset('Food_2', {
anchorX: 0.5,
anchorY: 0.5
});
// Set food speed
self.speed = -5;
// This is automatically called every game tick, if the food is attached!
self.update = function () {
self.speed -= 0.3; // acceleration
self.x += self.speed;
};
return self;
});
// Create Food_3 class
var Food_3 = Container.expand(function () {
var self = Container.call(this);
// Attach Food_3 asset to the food
self.foodAsset = self.attachAsset('Food_3', {
anchorX: 0.5,
anchorY: 0.5
});
// Set food speed
self.speed = -5;
// This is automatically called every game tick, if the food is attached!
self.update = function () {
self.speed -= 0.3; // acceleration
self.x += self.speed;
};
return self;
});
// Create ForegroundContainer class
var ForegroundContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Create MidgroundContainer class
var MidgroundContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Create Player class
var Player = Container.expand(function () {
var self = Container.call(this);
// Attach Player_Up asset to the player
self.playerUp = self.attachAsset('Player_Up', {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 1.5,
scaleY: 1.5
});
// Attach Player_Down asset to the player
self.playerDown = self.attachAsset('Player_Down', {
anchorX: 0.5,
anchorY: 1.0,
x: -120,
scaleX: 1.5,
scaleY: 1.5
});
// Initially, Player_Down is not visible
self.playerDown.visible = false;
// Method to switch between Player_Up and Player_Down
self.switchFrame = function () {
self.playerUp.visible = !self.playerUp.visible;
self.playerDown.visible = !self.playerDown.visible;
if (self.playerDown.visible) {
LK.getSound('Pooping').play();
// Increase the acceleration of all 3 food items by 0.1
Food.prototype.speed -= 1;
Food_2.prototype.speed -= 1;
Food_3.prototype.speed -= 1;
// Store the number of filled units when transitioning to the down state
filledUnits = digestionSystem.units.filter(function (unit) {
return unit.alpha === digestionSystem.unitFullAlpha;
}).length;
} else {
// Decrease the score for each remaining unit when the player prematurely moves back up
var remainingUnits = digestionSystem.units.filter(function (unit) {
return unit.alpha === digestionSystem.unitFullAlpha;
}).length;
score -= remainingUnits * filledUnits;
scoreTxt.setText(score);
if (score <= 0) {
LK.showGameOver();
return;
}
filledUnits = digestionSystem.units.filter(function (unit) {
return unit.alpha === digestionSystem.unitFullAlpha;
}).length;
// Update points display under each unit
digestionSystem.units.forEach(function (unit, index) {
if (unit.alpha === digestionSystem.unitFullAlpha) {
digestionSystem.unitTexts[index].setText(filledUnits);
} else {
digestionSystem.unitTexts[index].setText('');
}
});
digestionSystem.units.forEach(function (unit, index) {
unit.alpha = digestionSystem.unitEmptyAlpha;
digestionSystem.unitTexts[index].setText(''); // Clear points display under each unit
});
filledUnits = 0;
LK.getSound('Pooping').stop();
}
};
// Method to check if the player collides with a food object
self.checkCollision = function (food) {
// Only player_up can collect food
if (self.playerUp.visible) {
var playerBounds = self.playerUp.getBounds();
if (food) {
var foodBounds = food.getBounds();
var foodCenter = {
x: foodBounds.x + foodBounds.width / 2,
y: foodBounds.y + foodBounds.height / 2
};
}
var playerCenter = {
x: playerBounds.x + playerBounds.width / 2,
y: playerBounds.y + playerBounds.height / 2
};
// Check if the center of the food is within the bounds of the player
if (foodCenter && playerBounds.contains(foodCenter.x, foodCenter.y)) {
// Do not add a unit to the Digestion System here
return true;
}
if (food) {
var foodBounds = food.getBounds();
var foodCenter = {
x: foodBounds.x + foodBounds.width / 2,
y: foodBounds.y + foodBounds.height / 2
};
if (playerBounds.contains(foodCenter.x, foodCenter.y)) {
return true;
}
if (food && food.foodAsset && food.foodAsset.getBounds) {
var foodAssetBounds = food.foodAsset.getBounds();
var foodAssetCenter = {
x: foodAssetBounds.x + foodAssetBounds.width / 2,
y: foodAssetBounds.y + foodAssetBounds.height / 2
};
if (playerBounds.contains(foodAssetCenter.x, foodAssetCenter.y)) {
return true;
}
}
}
return false;
}
return false;
};
return self;
});
/****
* Initialize Game
****/
//<Assets used in the game will automatically appear here>
var game = new LK.Game({
backgroundColor: 0xfdfff4 // Init game with white background
});
/****
* Game Code
****/
var backgroundContainer = game.addChild(new BackgroundContainer());
var background = backgroundContainer.attachAsset('background', {
anchorX: 0.5,
anchorY: 1.0,
x: 2048 / 2,
y: 2732
});
var midgroundContainer = game.addChild(new MidgroundContainer());
var foregroundContainer = game.addChild(new ForegroundContainer());
// Add the Digestion System to the game
var digestionSystem = game.addChild(new DigestionSystem());
digestionSystem.x = 2048 / 2 - 400 - digestionSystem.unitWidth * digestionSystem.maxUnits / 2;
digestionSystem.y = 100;
var score = 0;
var scoreTxt;
var filledUnits = 0;
var filledUnits = 0;
scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 15
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y += 920;
// Add the Player in the center of the screen
var player = midgroundContainer.addChild(new Player());
player.x = 2048 / 2 - 500;
player.y = 2732 + 30;
// Switch the player's frame on tap
game.down = function (x, y, obj) {
player.switchFrame();
};
// Spawn food from the right edge of the screen at y position of 500
game.update = function () {
if (LK.ticks == 0) {
score = 0;
scoreTxt.setText(score);
filledUnits = 0;
// Reset the Digestion System
digestionSystem.units.forEach(function (unit) {
unit.alpha = digestionSystem.unitEmptyAlpha;
});
// Clear points display under each unit
digestionSystem.unitTexts.forEach(function (unitText) {
unitText.setText('');
});
}
if (LK.ticks % 60 == 0) {
// every second
var foodBucket = [];
for (var i = 0; i < 90; i++) {
foodBucket.push(new Food());
}
for (var i = 0; i < 60; i++) {
foodBucket.push(new Food_2());
}
for (var i = 0; i < 30; i++) {
foodBucket.push(new Food_3());
}
var newFood = foodBucket[Math.floor(Math.random() * foodBucket.length)];
newFood.x = 2048; // right edge of the screen
newFood.y = 1900;
foregroundContainer.addChild(newFood);
}
// Check for collision between the player and the food
// Remove a unit from the Digestion System when the player is in the Down state
if (!player.playerUp.visible) {
if (LK.ticks % 30 == 0) {
var fullUnits = digestionSystem.units.filter(function (unit) {
return unit.alpha === digestionSystem.unitFullAlpha;
});
if (fullUnits.length > 0) {
fullUnits[fullUnits.length - 1].alpha = digestionSystem.unitEmptyAlpha;
score += filledUnits; // Add points based on the fixed number of filled units
// Update points display under each unit
digestionSystem.units.forEach(function (unit, index) {
if (unit.alpha === digestionSystem.unitFullAlpha) {
digestionSystem.unitTexts[index].setText(filledUnits);
} else {
digestionSystem.unitTexts[index].setText('');
}
});
scoreTxt.setText(score);
if (score <= 0) {
LK.showGameOver();
return;
}
} else {
LK.getSound('Pooping').stop();
}
}
} else {
LK.getSound('Pooping').stop();
}
for (var i = foregroundContainer.children.length - 1; i >= 0; i--) {
var food = foregroundContainer.children[i];
if (player.checkCollision(food) || player.checkCollision(food.foodAsset)) {
// Increment the score
if (food instanceof Food_2) {
score += 2;
// Add two units to the Digestion System
for (var i = 0; i < 2; i++) {
var fullUnits = digestionSystem.units.filter(function (unit) {
return unit.alpha === digestionSystem.unitFullAlpha;
});
if (fullUnits.length < digestionSystem.maxUnits) {
digestionSystem.units[fullUnits.length].alpha = digestionSystem.unitFullAlpha;
filledUnits = fullUnits.length + 1; // Update filledUnits
} else {
LK.showGameOver();
return;
}
}
// Update points display under each unit
digestionSystem.units.forEach(function (unit, index) {
if (unit.alpha === digestionSystem.unitFullAlpha) {
digestionSystem.unitTexts[index].setText(filledUnits);
} else {
digestionSystem.unitTexts[index].setText('');
}
});
} else if (food instanceof Food_3) {
score += 3;
// Add three units to the Digestion System
for (var i = 0; i < 3; i++) {
var fullUnits = digestionSystem.units.filter(function (unit) {
return unit.alpha === digestionSystem.unitFullAlpha;
});
if (fullUnits.length < digestionSystem.maxUnits) {
digestionSystem.units[fullUnits.length].alpha = digestionSystem.unitFullAlpha;
filledUnits = fullUnits.length + 1; // Update filledUnits
} else {
LK.showGameOver();
return;
}
}
// Update points display under each unit
digestionSystem.units.forEach(function (unit, index) {
if (unit.alpha === digestionSystem.unitFullAlpha) {
digestionSystem.unitTexts[index].setText(filledUnits);
} else {
digestionSystem.unitTexts[index].setText('');
}
});
} else {
score++;
// Add a unit to the Digestion System
var fullUnits = digestionSystem.units.filter(function (unit) {
return unit.alpha === digestionSystem.unitFullAlpha;
});
if (fullUnits.length < digestionSystem.maxUnits) {
digestionSystem.units[fullUnits.length].alpha = digestionSystem.unitFullAlpha;
filledUnits = fullUnits.length + 1; // Update filledUnits
// Update points display under each unit
digestionSystem.units.forEach(function (unit, index) {
if (unit.alpha === digestionSystem.unitFullAlpha) {
digestionSystem.unitTexts[index].setText(filledUnits);
} else {
digestionSystem.unitTexts[index].setText('');
}
});
} else {
LK.showGameOver();
return;
}
}
scoreTxt.setText(score);
// Play the Eat sound
LK.getSound('Eat').play();
// Remove the food from the game
food.destroy();
}
}
};
hamburger. pixelated. 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
poop UI element . pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
text saying "Constipated" against a poop banner. pixelated. 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
text saying "You’re on a roll!" against a toilet paper banner. pixelated. 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
text saying "Holy Crap!" against a divine angelic poop banner. pixelated. 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelated text saying "Shit Yeah!" as a shitty newspaper headline. pixelated. 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
macdonalds fries but with the M letter rotated so it looks like a 3. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
large KFC bucket with the digit 5 on it. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit pixelated image of a video game character sitting with hands on a large belly, wearing a white shirt and brown pants. The setting is a simple bathroom, with the character as the main focus. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.