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
User prompt
reduce the text size of the values under the units
Code edit (2 edits merged)
Please save this source code
User prompt
move the digestion system UI 200 pixels to the right
Code edit (3 edits merged)
Please save this source code
User prompt
reduce the gap between the units
User prompt
the Food item should add 2 units instead of one and it's score should also be 2 when collected and 2 when destroyed at the left
Code edit (1 edits merged)
Please save this source code
User prompt
attach the Mouth to the player when in the up position over the player_up asset, so it overlaps it. give it x and y coordinates so I can move it relative to player_up
User prompt
attach the Mouth to the player when in the up position
User prompt
place all 3 food items in the midground container
User prompt
place the player in the foreground container
Code edit (1 edits merged)
Please save this source code
User prompt
when collecting any food item, instead of just playing the Eat sound effect, pick between Eat or Eat_2 or Eat_3, each time at random
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
start all 3 foods from a slower speed
Code edit (6 edits merged)
Please save this source code
User prompt
Food_2 should actually increase by 3 units and award 3 points when collected and deduct 3 when destroyed, while Food_3 should actually increase by 5 units and award 5 points and deduct 5 when destroyed
Code edit (2 edits merged)
Please save this source code
User prompt
only show the UI_Crappy asset if the player goes to the up state while there are still filled units when he rose, otherwise dont show it
Code edit (1 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: 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 (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 - 400 - 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(); } } };
===================================================================
--- original.js
+++ change.js
@@ -12,9 +12,9 @@
self.units = [];
self.maxUnits = 10;
self.unitWidth = 100;
self.unitHeight = 100;
- self.unitSpacing = 100;
+ self.unitSpacing = 50;
self.unitFullAlpha = 1;
self.unitEmptyAlpha = 0.5;
// Initialize with 10 empty units
for (var i = 0; i < self.maxUnits; i++) {
@@ -314,9 +314,9 @@
if (LK.ticks % (60 - foodSpawnTimeDecrement) == 0) {
// every second
var foodBucket = [];
for (var i = 0; i < 100; i++) {
- foodBucket.push(new Food('Food', 2));
+ foodBucket.push(new Food('Food', 1));
}
for (var i = 0; i < 40; i++) {
foodBucket.push(new Food('Food_2', 3));
}
@@ -373,9 +373,9 @@
return unit.alpha === digestionSystem.unitFullAlpha;
}).length;
if (fullUnits === 0) {
// Decrease the score based on the points the food was supposed to increase
- score -= 2;
+ score -= food.points;
scoreTxt.setText(score);
if (score <= 0) {
LK.showGameOver();
return;
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.