User prompt
when displaying the game over screen, also display the Busted asset in the center of the screen. It needs to start very small from the size of a pixel up to it's original size over the course of 200 miliseconds.once it reaches it's full size freeze it in place. this animation should only play just once!
User prompt
ensure the busted animation is not referenced twice in the code as I believe that's why it plays twice. remove any duplicate code
User prompt
the Busted animation playes twice, it should only play just once! after it reaches it's original size, mark it's animation as complete so it doesnt run a second time
User prompt
the Busted animation playes twice, it should only play just once!
User prompt
the Busted animation playes twice, it should only play just once!
User prompt
when displaying the Busted asset, once it increases to it's original size, it shouldn't repeat the animation, instead freeze the asset to it's original size. that animation needs to only play once
User prompt
when displaying the game over screen, also display the Busted asset in the center of the screen. It needs to start very small from the size of a pixel up to it's original size over the course of 200 miliseconds
User prompt
increase the time of the game over screen from 2 to 3 seconds
User prompt
during the game over screen state, change the game's default background color to this edf5f9
User prompt
as soon as the game goes to the game over screen, also stop the spawner from generating foods, and freeze any foods in place that have been generated already
User prompt
now create a Game Over screen. after the amount of Units go above 10, instead fo going directly to Game over, display the Game_Over asset inside the Foreground container, and remove all other visual assets from the screen. anchor the image to the bottom of the screen and maintain it's asset size. Display this asset for 2 seconds before going to the game actual game over state
User prompt
now create a Game Over screen and add it in its own class. after the amount of Units go above 10, instead fo going directly to Game over, display the Game_Over asset inside the Foreground container, and remove all other visual assets from the screen. anchor the image to the bottom of the screen and maintain it's asset size. Display this asset for 2 seconds before going to the game actual game over state
Code edit (4 edits merged)
Please save this source code
User prompt
when the game goes to the game over state for the 3 econds, also change the default game's background color to white. this white color is only changed during this game over screen, it should revert to the existign color upon restarting the game
Code edit (1 edits merged)
Please save this source code
User prompt
after the game is over and the game_over asset is displayed, you also need to hide the game's score and the digestive system so they're not shown on the screen as well.
User prompt
the game over state broke after the last game update. not only the Game_Over asset is not displayed, but the game also continues going for an extra turn after the 11th unit has been filled which would suppose to trigger this game over state
User prompt
now create a Game Over screen. after the amount of Units go above 10, instead fo going directly to Game over, display the Game_Over asset inside the Foreground container, and remove all other visual assets from the screen. anchor the image to the bottom of the screen and maintain it's asset size. Display this asset for 2 seconds before going to the game actual game over state
User prompt
now create a Game Over screen. after the amount of Units go above 10, instead fo going directly to Game over, display the Game Over asset inside the Foreground container, and remove all other visual assets from the screen. anchor the image to the bottom of the screen and maintain it's asset size. Display this asset for 2 seconds before going to the game actual game over state
Code edit (1 edits merged)
Please save this source code
User prompt
when displaying any of the assets between UI_1 and 5, play the Splash sound
Code edit (2 edits merged)
Please save this source code
User prompt
when the player changes state from the down to the up state play the Flush sound
User prompt
when the player moves to the up state play the Flush sound
Code edit (4 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 = 50;
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: 60,
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 (assetId, points) {
var self = Container.call(this);
// Attach Food asset to the food
self.foodAsset = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
// Set food speed
self.speed = -3;
// Points awarded by this food item
self.points = points;
// This is automatically called every game tick, if the food is attached!
self.update = function () {
self.speed -= 0.3 + foodAccelerationIncrement; // acceleration with increment
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();
// 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;
} else {
// Only display UI_Crappy asset if there are still filled units
if (remainingUnits > 0) {
// Display UI_Crappy asset in the center of the screen
var uiCrappy = foregroundContainer.attachAsset('UI_Crappy', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 700
});
foregroundContainer.addChild(uiCrappy);
// Set a timeout to remove the UI_Crappy asset after 1 second
LK.setTimeout(function () {
foregroundContainer.removeChild(uiCrappy);
}, 2000);
}
}
// Display the appropriate UI element based on the number of units collected
if (filledUnits > 0 && digestionSystem.units.every(function (unit) {
return unit.alpha === digestionSystem.unitEmptyAlpha;
})) {
uiElementDisplay.displayUIElement(filledUnits);
filledUnits = 0; // Reset filledUnits to ensure UI elements are shown only once
}
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();
foodAccelerationIncrement += 0.1; // Increase the acceleration increment for food items
foodSpawnTimeDecrement += 1; // Decrease the spawn time for food items
}
};
// 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;
});
// Create UIElementDisplay class
var UIElementDisplay = Container.expand(function () {
var self = Container.call(this);
self.displayUIElement = function (unitsCollected) {
var uiElementId;
if (unitsCollected >= 1 && unitsCollected <= 2) {
uiElementId = 'UI_1';
} else if (unitsCollected >= 3 && unitsCollected <= 5) {
uiElementId = 'UI_2';
} else if (unitsCollected >= 6 && unitsCollected <= 7) {
uiElementId = 'UI_3';
} else if (unitsCollected >= 8 && unitsCollected <= 9) {
uiElementId = 'UI_4';
} else if (unitsCollected === 10) {
uiElementId = 'UI_5';
}
if (uiElementId) {
var uiElement = foregroundContainer.attachAsset(uiElementId, {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 700
});
foregroundContainer.addChild(uiElement);
// Animate the UI element to grow to its original size in less than a second
uiElement.scale.set(0.01, 0.01);
var growInterval = LK.setInterval(function () {
uiElement.scale.x += 0.1;
uiElement.scale.y += 0.1;
if (uiElement.scale.x >= 1 && uiElement.scale.y >= 1) {
LK.clearInterval(growInterval);
}
}, 10);
// Set a timeout to remove the UI element after 1 second
LK.setTimeout(function () {
foregroundContainer.removeChild(uiElement);
}, 2000);
}
};
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
****/
// Initialize the UIElementDisplay class
var uiElementDisplay = new UIElementDisplay();
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 - 180 - digestionSystem.unitWidth * digestionSystem.maxUnits / 2;
digestionSystem.y = 100;
var score = 0;
var scoreTxt;
var filledUnits = 0;
var foodSpawnTimeDecrement = 0; // Global variable to track spawn time decrement for food items
var foodAccelerationIncrement = 0; // Global variable to track acceleration increment for food items
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.x -= 10; // Move the score 10 pixels to the left
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 - foodSpawnTimeDecrement) == 0) {
// every second
var foodBucket = [];
for (var i = 0; i < 100; i++) {
foodBucket.push(new Food('Food', 1));
}
for (var i = 0; i < 40; i++) {
foodBucket.push(new Food('Food_2', 3));
}
for (var i = 0; i < 10; i++) {
foodBucket.push(new Food('Food_3', 5));
}
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 % 20 == 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;
}
// Display the appropriate UI element based on the number of units collected only once
if (filledUnits > 0 && digestionSystem.units.every(function (unit) {
return unit.alpha === digestionSystem.unitEmptyAlpha;
})) {
uiElementDisplay.displayUIElement(filledUnits);
filledUnits = 0; // Reset filledUnits to ensure UI elements are shown only once
}
} 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 (food && food.x <= 0) {
// Only decrease the score if the digestive system unit is 0
var fullUnits = digestionSystem.units.filter(function (unit) {
return unit.alpha === digestionSystem.unitFullAlpha;
}).length;
if (fullUnits === 0) {
// Decrease the score based on the points the food was supposed to increase
score -= food.points;
scoreTxt.setText(score);
if (score <= 0) {
LK.showGameOver();
return;
}
}
food.destroy();
} else if (food && (player.checkCollision(food) || player.checkCollision(food.foodAsset))) {
// Increment the score
score += food.points;
// Add units to the Digestion System based on the points of the food
for (var i = 0; i < food.points; 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('');
}
});
scoreTxt.setText(score);
// Play a random Eat sound
var eatSounds = ['Eat', 'Eat_2', 'Eat_3'];
var randomEatSound = eatSounds[Math.floor(Math.random() * eatSounds.length)];
LK.getSound(randomEatSound).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.